Parcourir la source

用户反馈接口修改

ZhangManMan il y a 2 ans
Parent
commit
df1ce8d0bc

+ 3 - 2
src/main/java/com/sky/ioc/controller/notice/FeedBackController.java

@@ -1,6 +1,7 @@
 package com.sky.ioc.controller.notice;
 
 import com.sky.ioc.entity.domain.notice.Feedback;
+import com.sky.ioc.entity.params.notice.FeedBackParam;
 import com.sky.ioc.entity.params.notice.NoticeParam;
 import com.sky.ioc.service.notice.FeedBackService;
 import com.sky.ioc.tool.ReturnMsg;
@@ -26,8 +27,8 @@ public class FeedBackController {
 
     @ApiOperation("分页列表")
     @PostMapping("/getFeedBackList")
-    public ReturnMsg getFeedBackList(@RequestBody NoticeParam noticeParam){
-        return feedBackService.listPage(noticeParam);
+    public ReturnMsg getFeedBackList(@RequestBody FeedBackParam feedBackParam){
+        return feedBackService.listPage(feedBackParam);
     }
 
     @ApiOperation("用户反馈设为已读")

+ 58 - 18
src/main/java/com/sky/ioc/controller/scene/QuartzJobController.java

@@ -7,6 +7,7 @@ import com.sky.ioc.tool.ReturnMsg;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
+import org.quartz.SchedulerException;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
@@ -32,24 +33,6 @@ public class QuartzJobController {
         return ReturnMsg.ok("创建定时任务成功");
     }
 
-    /**
-     * 通过id删除
-     *
-     * @param id
-     * @return
-     */
-    @ApiOperation("删除定时任务")
-    @PostMapping(value = "/deljob")
-    public ReturnMsg<?> delete(@RequestParam(name = "id", required = true) String id) {
-        QuartzJob quartzJob = quartzJobService.getById(id);
-        if (quartzJob == null) {
-            return ReturnMsg.fail("未找到对应实体");
-        }
-        quartzJobService.deleteAndStopJob(quartzJob);
-        return ReturnMsg.ok("删除成功!");
-    }
-
-
 
     @ApiOperation("定时任务列表")
     @GetMapping(value = "/getJobList")
@@ -61,4 +44,61 @@ public class QuartzJobController {
         return  quartzJobService.pageList(name,groupName,status,pageStart,pageSize);
     }
 
+
+    @ApiOperation("编辑定时任务")
+    @PostMapping(value = "/editJob")
+    public ReturnMsg<?> editJob(@RequestBody QuartzJob quartzJob) {
+        //  QuartzJob quartzJob = quartzJobService.getById(id);
+        if (quartzJob == null) {
+            return ReturnMsg.fail("未找到对应实体");
+        }else {
+            try {
+                quartzJobService.editAndScheduleJob(quartzJob);
+                return ReturnMsg.ok("操作成功!");
+            } catch (SchedulerException e) {
+               // throw new RuntimeException(e);
+                return ReturnMsg.ok("失败!"+e.getMessage());
+            }
+
+        }
+    }
+
+    @ApiOperation("删除定时任务")
+    @PostMapping(value = "/deleteJob")
+    public ReturnMsg<?> deleteJob(@RequestParam(name = "id", required = true) Integer id) {
+        QuartzJob quartzJob = quartzJobService.getById(id);
+        if (quartzJob == null) {
+            return ReturnMsg.fail("未找到对应实体");
+        }else {
+            quartzJobService.deleteAndStopJob(quartzJob);
+            return ReturnMsg.ok("操作成功!");
+        }
+    }
+
+    @ApiOperation("启动/停止定时任务")
+    @PostMapping(value = "/stopAndScheduleJob")
+    public ReturnMsg<?> stopAndScheduleJob(@RequestParam(name = "id", required = true) Integer id,
+                                           @RequestParam(name = "status", required = true) Integer status) {
+        QuartzJob quartzJob = quartzJobService.getById(id);
+        quartzJob.setStatus(status);
+        if (quartzJob == null) {
+            return ReturnMsg.fail("未找到对应实体");
+        }else {
+            if (status==0){
+                //启动
+                quartzJobService.resumeJob(quartzJob);
+                return ReturnMsg.ok("操作成功!");
+            }else{
+                //暂停
+                try {
+                    quartzJobService.editAndScheduleJob(quartzJob);
+                    return ReturnMsg.ok("操作成功!");
+                } catch (SchedulerException e) {
+                    // throw new RuntimeException(e);
+                    return ReturnMsg.ok("失败!"+e.getMessage());
+                }
+            }
+        }
+    }
+
 }

+ 10 - 2
src/main/java/com/sky/ioc/entity/domain/notice/Feedback.java

@@ -10,10 +10,18 @@ public class Feedback {
     @TableId(type = IdType.AUTO)
     private Integer id;
 
-    private String title;
+    /**
+     * 反馈模块
+     * 1 能源模块
+     * 2 生活模块
+     * 3 办公模块
+     * */
+    private Integer module;
+
     private String content;
     /**
-     * 类型
+     * 反馈来源
+     * 1 app
      * */
     private Integer type;
 

+ 44 - 0
src/main/java/com/sky/ioc/entity/params/notice/FeedBackParam.java

@@ -0,0 +1,44 @@
+package com.sky.ioc.entity.params.notice;
+
+import lombok.Data;
+
+@Data
+public class FeedBackParam {
+
+    /**
+     * 反馈来源
+     * 1 app
+     * 2 其他
+     * */
+    private Integer type;
+
+    /**
+     * 0未读
+     * 1 已读
+     * */
+    private Integer status;
+
+    /**
+     * 反馈模块
+     * 1 能源模块
+     * 2 生活模块
+     * 3 办公模块
+     * */
+    private Integer module;
+
+    /**
+     * 分页数
+     */
+    private Integer pageSize =10;
+
+    /**
+     * 分页数
+     */
+    private Integer pageStart =0;
+
+    /** 开始时间 */
+    private String startTime;
+
+    /** 结束时间 */
+    private String endTime;
+}

+ 23 - 16
src/main/java/com/sky/ioc/mapper/notice/FeedBackMapper.java

@@ -2,6 +2,7 @@ package com.sky.ioc.mapper.notice;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.sky.ioc.entity.domain.notice.Feedback;
+import com.sky.ioc.entity.params.notice.FeedBackParam;
 import com.sky.ioc.entity.params.notice.NoticeParam;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
@@ -14,34 +15,40 @@ import java.util.Map;
 public interface FeedBackMapper extends BaseMapper<Feedback> {
 
     @Select("<script>" +
-            "select id,title,content,create_time,status from feedback where is_del=0 " +
-            "<if test='noticeParam!=null and noticeParam.startTime != null '>" +
-            "<![CDATA[ and create_time >= #{noticeParam.startTime} AND create_time <= #{noticeParam.endTime} ]]> " +
+            "select id,module,content,create_time,status,type from feedback where is_del=0 " +
+            "<if test='feedBackParam!=null and feedBackParam.startTime != null '>" +
+            "<![CDATA[ and create_time >= #{feedBackParam.startTime} AND create_time <= #{feedBackParam.endTime} ]]> " +
             "</if>" +
-            "<if test='noticeParam!=null and noticeParam.type != null '>" +
-            " and type=#{noticeParam.type} " +
+            "<if test='feedBackParam!=null and feedBackParam.type != null '>" +
+            " and type=#{feedBackParam.type} " +
             "</if>"+
-            "<if test='noticeParam!=null and noticeParam.status != null '>" +
-            " and status=#{noticeParam.status} " +
+            "<if test='feedBackParam!=null and feedBackParam.status != null '>" +
+            " and status=#{feedBackParam.status} " +
             "</if>"+
-            " order by create_time desc limit #{noticeParam.pageSize} offset #{noticeParam.pageStart}" +
+            "<if test='feedBackParam!=null and feedBackParam.module != null '>" +
+            " and module=#{feedBackParam.module} " +
+            "</if>"+
+            " order by create_time desc limit #{feedBackParam.pageSize} offset #{feedBackParam.pageStart}" +
             "</script>")
-    List<Map<String,Object>> listPage(@Param("noticeParam") NoticeParam noticeParam);
+    List<Map<String,Object>> listPage(@Param("feedBackParam") FeedBackParam feedBackParam);
 
 
     @Select("<script>" +
             "select count(1) from feedback where is_del=0 " +
-            "<if test='noticeParam!=null and noticeParam.startTime != null '>" +
-            "<![CDATA[ and create_time >= #{noticeParam.startTime} AND create_time <= #{noticeParam.endTime} ]]> " +
+            "<if test='feedBackParam!=null and feedBackParam.startTime != null '>" +
+            "<![CDATA[ and create_time >= #{feedBackParam.startTime} AND create_time <= #{feedBackParam.endTime} ]]> " +
             "</if>" +
-            "<if test='noticeParam!=null and noticeParam.type != null '>" +
-            " and type=#{noticeParam.type} " +
+            "<if test='feedBackParam!=null and feedBackParam.type != null '>" +
+            " and type=#{feedBackParam.type} " +
+            "</if>"+
+            "<if test='feedBackParam!=null and feedBackParam.status != null '>" +
+            " and status=#{feedBackParam.status} " +
             "</if>"+
-            "<if test='noticeParam!=null and noticeParam.status != null '>" +
-            " and status=#{noticeParam.status} " +
+            "<if test='feedBackParam!=null and feedBackParam.module != null '>" +
+            " and module=#{feedBackParam.module} " +
             "</if>"+
             "</script>")
-    long  countPage(@Param("noticeParam")NoticeParam noticeParam);
+    long  countPage(@Param("feedBackParam")FeedBackParam feedBackParam);
 
     @Select("<script>" +
             " update feedback set status = 1,update_time = now()  " +

+ 7 - 1
src/main/java/com/sky/ioc/service/job/impl/QuartzJobServiceImpl.java

@@ -7,6 +7,7 @@ import com.sky.ioc.mapper.job.QuartzJobMapper;
 import com.sky.ioc.service.job.IQuartzJobService;
 import com.sky.ioc.tool.ReturnMsg;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
 import org.quartz.*;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -55,7 +56,12 @@ public class QuartzJobServiceImpl extends ServiceImpl<QuartzJobMapper, QuartzJob
 
     @Override
     public ReturnMsg pageList(String name, String groupName, Integer status, Integer pageStart, Integer pageSize) {
-
+        if(StringUtils.isNotBlank(name)){
+            name = "%"+name+"%";
+        }
+        if(StringUtils.isNotBlank(groupName)){
+            groupName = "%"+groupName+"%";
+        }
         List<QuartzJob> lists = quartzJobMapper.pageList(name,groupName,status,pageStart,pageSize);
         return ReturnMsg.ok(lists);
     }

+ 2 - 1
src/main/java/com/sky/ioc/service/notice/FeedBackService.java

@@ -1,6 +1,7 @@
 package com.sky.ioc.service.notice;
 
 import com.sky.ioc.entity.domain.notice.Feedback;
+import com.sky.ioc.entity.params.notice.FeedBackParam;
 import com.sky.ioc.entity.params.notice.NoticeParam;
 import com.sky.ioc.tool.ReturnMsg;
 
@@ -8,7 +9,7 @@ import java.util.List;
 
 public interface FeedBackService {
 
-    ReturnMsg listPage(NoticeParam noticeParam);
+    ReturnMsg listPage(FeedBackParam feedBackParam);
 
 
     ReturnMsg readFeedBack(List<Integer> ids);

+ 4 - 3
src/main/java/com/sky/ioc/service/notice/impl/FeedBackServiceImpl.java

@@ -2,6 +2,7 @@ package com.sky.ioc.service.notice.impl;
 
 import com.alibaba.fastjson.JSONObject;
 import com.sky.ioc.entity.domain.notice.Feedback;
+import com.sky.ioc.entity.params.notice.FeedBackParam;
 import com.sky.ioc.entity.params.notice.NoticeParam;
 import com.sky.ioc.entity.result.system.LoginUserVo;
 import com.sky.ioc.mapper.notice.FeedBackMapper;
@@ -29,9 +30,9 @@ public class FeedBackServiceImpl implements FeedBackService {
 
 
     @Override
-    public ReturnMsg listPage(NoticeParam noticeParam) {
-        long count = feedBackMapper.countPage(noticeParam);
-        List<Map<String, Object>> lists = feedBackMapper.listPage(noticeParam);
+    public ReturnMsg listPage(FeedBackParam feedBackParam) {
+        long count = feedBackMapper.countPage(feedBackParam);
+        List<Map<String, Object>> lists = feedBackMapper.listPage(feedBackParam);
         JSONObject jsonObject = new JSONObject();
         jsonObject.put("total",count);
         jsonObject.put("data",lists);

+ 1 - 1
src/main/resources/application.yml

@@ -12,7 +12,7 @@ server:
 spring:
   # 环境设置
   profiles:
-    active: publish
+    active: dev
   # 数据源配置
   datasource:
     type: com.alibaba.druid.pool.DruidDataSource