Forráskód Böngészése

用户反馈模块 查看、已读、删除接口

ZhangManMan 2 éve
szülő
commit
89c307f13a

+ 36 - 0
src/main/java/com/sky/ioc/entity/domain/notice/FeedBack.java

@@ -0,0 +1,36 @@
+package com.sky.ioc.entity.domain.notice;
+
+import lombok.Data;
+
+@Data
+public class FeedBack {
+    private Integer id;
+    private String title;
+    private String content;
+    /**
+     * 类型
+     * */
+    private Integer type;
+
+
+    /**
+     * 发送人
+     * */
+    private String creator;
+    /**
+     * 状态
+     * 0未读
+     * 1已读
+     * */
+    private Integer status;
+
+    /**
+     * 0 未删除
+     * 1 已删除
+     * */
+    private Integer is_del;
+
+    private String createTime;
+
+    private String updateTime;
+}

+ 57 - 0
src/main/java/com/sky/ioc/mapper/notice/FeedBackMapper.java

@@ -0,0 +1,57 @@
+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.NoticeParam;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+
+import java.util.List;
+import java.util.Map;
+
+@Mapper
+public interface FeedBackMapper extends BaseMapper<FeedBack> {
+
+    @Select("<script>" +
+            "select id,title,content 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>" +
+            "<if test='noticeParam!=null and noticeParam.type != null '>" +
+            " and type=#{noticeParam.type} " +
+            "</if>"+
+            "<if test='noticeParam!=null and noticeParam.status != null '>" +
+            " and status=#{noticeParam.status} " +
+            "</if>"+
+            " order by create_time desc limit #{noticeParam.pageSize} offset #{noticeParam.pageStart}" +
+            "</script>")
+    List<Map<String,Object>> listPage(@Param("noticeParam") NoticeParam noticeParam);
+
+
+    @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>" +
+            "<if test='noticeParam!=null and noticeParam.type != null '>" +
+            " and type=#{noticeParam.type} " +
+            "</if>"+
+            "<if test='noticeParam!=null and noticeParam.status != null '>" +
+            " and status=#{noticeParam.status} " +
+            "</if>"+
+            "</script>")
+    long  countPage(@Param("noticeParam")NoticeParam noticeParam);
+
+    @Select("<script>" +
+            " update feedback set status = 1,update_time = now()  " +
+            " where id in (<foreach collection='ids' item='id' index='no' separator=','>#{id}</foreach>) "
+            + "</script>")
+    Integer updateStatusByIds(@Param("ids") List<Integer> ids);
+
+    @Select("<script>" +
+            " update feedback set is_del = 1, update_time = now()  " +
+            " where id in (<foreach collection='ids' item='id' index='no' separator=','>#{id}</foreach>) "
+            + "</script>")
+    Integer delByIds(@Param("ids") List<Integer> ids);
+}

+ 18 - 0
src/main/java/com/sky/ioc/service/notice/FeedBackService.java

@@ -0,0 +1,18 @@
+package com.sky.ioc.service.notice;
+
+import com.sky.ioc.entity.params.notice.NoticeParam;
+import com.sky.ioc.tool.ReturnMsg;
+
+import java.util.List;
+
+public interface FeedBackService {
+
+    ReturnMsg listPage(NoticeParam noticeParam);
+
+
+    ReturnMsg readFeedBack(List<Integer> ids);
+
+    ReturnMsg delFeedBack(List<Integer> ids);
+
+    ReturnMsg getFeedBack(Integer id);
+}

+ 58 - 0
src/main/java/com/sky/ioc/service/notice/impl/FeedBackServiceImpl.java

@@ -0,0 +1,58 @@
+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.NoticeParam;
+import com.sky.ioc.mapper.notice.FeedBackMapper;
+import com.sky.ioc.service.notice.FeedBackService;
+import com.sky.ioc.tool.ReturnMsg;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+
+@Service
+public class FeedBackServiceImpl implements FeedBackService {
+
+    @Autowired
+    FeedBackMapper feedBackMapper;
+
+
+    @Override
+    public ReturnMsg listPage(NoticeParam noticeParam) {
+        long count = feedBackMapper.countPage(noticeParam);
+        List<Map<String, Object>> lists = feedBackMapper.listPage(noticeParam);
+        JSONObject jsonObject = new JSONObject();
+        jsonObject.put("total",count);
+        jsonObject.put("data",lists);
+        return ReturnMsg.ok(jsonObject);
+    }
+
+    @Override
+    public ReturnMsg readFeedBack(List<Integer> ids) {
+        if(ids.size()==0||ids==null){
+            return ReturnMsg.fail("参数错误");
+        }else{
+            feedBackMapper.updateStatusByIds(ids);
+            return ReturnMsg.ok();
+        }
+    }
+
+    @Override
+    public ReturnMsg delFeedBack(List<Integer> ids) {
+        if(ids.size()==0||ids==null){
+            return ReturnMsg.fail("参数错误");
+        }else{
+            feedBackMapper.updateStatusByIds(ids);
+            return ReturnMsg.ok();
+        }
+    }
+
+    @Override
+    public ReturnMsg getFeedBack(Integer id) {
+        FeedBack feedBack = feedBackMapper.selectById(id);
+        return ReturnMsg.ok(feedBack);
+    }
+}