Sfoglia il codice sorgente

纠错反馈接口

zuy 1 anno fa
parent
commit
69c7fe3fe1

+ 111 - 0
car-wash-admin/src/main/java/com/kym/admin/controller/FeedbackController.java

@@ -0,0 +1,111 @@
+package com.kym.admin.controller;
+
+import cn.dev33.satoken.annotation.SaCheckPermission;
+import com.kym.common.R;
+import com.kym.common.annotation.SysLog;
+import com.kym.common.controller.IController;
+import com.kym.entity.admin.Feedback;
+import com.kym.service.admin.FeedbackService;
+import jakarta.annotation.Resource;
+import jakarta.validation.Valid;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+
+/**
+ * 纠错反馈接口
+ *
+ * @date 2024-09-22T20:40:35.300431885
+ */
+@RestController
+@RequestMapping("feedback")
+public class FeedbackController extends IController {
+
+    @Resource
+    private FeedbackService feedbackService;
+
+
+    /**
+     * 纠错反馈新增接口
+     *
+     * @param feedback 新增纠错反馈
+     * @return Res
+     */
+    @SaCheckPermission(value = "feedback.add")
+    @PostMapping("add")
+    @SysLog(value = "纠错反馈新增接口")
+    public R<?> add(@Valid @RequestBody Feedback.FeedbackInfo feedback) {
+//other params checked
+        return resp(() -> feedbackService.add(feedback));
+    }
+
+    /**
+     * 纠错反馈编辑
+     *
+     * @return Res
+     */
+    @SaCheckPermission(value = "feedback.modify")
+    @PostMapping("modify")
+    @SysLog(value = "纠错反馈更新接口")
+    public R<?> reply(@Valid @RequestBody Feedback.FeedbackInfo feedback) {
+        return resp((t) -> feedbackService.reply(feedback));
+    }
+
+
+    /**
+     * 纠错反馈查询接口
+     *
+     * @return Res
+     */
+    @SaCheckPermission(value = "feedback.list")
+    @PostMapping("list")
+    @SysLog(value = "纠错反馈列表查询接口")
+    public R<?> list(@RequestBody Feedback.FeedbackBasicQuery query) {
+        return resp(() -> feedbackService.list(query));
+    }
+
+
+    /**
+     * 纠错反馈查询详情接口
+     *
+     * @return Res
+     */
+    @SaCheckPermission(value = "feedback.list")
+    @GetMapping("detail/{id}")
+    @SysLog(value = "纠错反馈详情查询接口")
+    public R<?> detail(@PathVariable long id) {
+        return resp(() -> feedbackService.detail(id));
+    }
+
+
+    /**
+     * 纠错反馈变更状态接口
+     *
+     * @return Res
+     */
+    @SaCheckPermission(value = "feedback.modify")
+    @GetMapping("status/{id}/{status}")
+    @SysLog(value = "纠错反馈变更状态")
+    public R<?> status(@PathVariable long id, @PathVariable int status) {
+        return resp((t) -> feedbackService.status(id, status));
+    }
+
+
+    /**
+     * 纠错反馈删除接口
+     *
+     * @return Res
+     */
+    @SaCheckPermission(value = "feedback.remove")
+    @GetMapping("remove/{id}")
+    @SysLog(value = "纠错反馈删除")
+    public R<?> remove(@PathVariable long id) {
+        return resp((t) -> feedbackService.remove(id));
+    }
+
+
+}

+ 1 - 0
car-wash-common/src/main/java/com/kym/common/constant/ResponseEnum.java

@@ -21,6 +21,7 @@ public enum ResponseEnum implements BusinessExceptionAssert {
     HTTP_STATUS_500(500, "server error"),
 
     DB_ERROR(999, "数据异常"),
+    PARAMS_ERROR(1000, "参数异常"),
 
 
     // 微信小程序

+ 26 - 2
car-wash-common/src/main/java/com/kym/common/utils/CommUtil.java

@@ -46,6 +46,19 @@ public class CommUtil {
         }
     }
 
+    /**
+     * 断言
+     *
+     * @param obj
+     * @param error
+     * @param code
+     */
+    public static void assertsNonNull(Object obj, String error, int code) {
+        if (isEmptyOrNull(obj)) {
+            throw new BusinessException(code, error);
+        }
+    }
+
     /**
      * 断言
      *
@@ -71,6 +84,18 @@ public class CommUtil {
         }
     }
 
+    /**
+     * 断言
+     *
+     * @param obj
+     * @param msgEnum
+     */
+    public static void assertsNonNull(Object obj, ResponseEnum msgEnum) {
+        if (isEmptyOrNull(obj)) {
+            throw new BusinessException(msgEnum);
+        }
+    }
+
     /**
      * privatmitive
      * 判断一个对象是否是基础数据类型或String
@@ -293,7 +318,6 @@ public class CommUtil {
     }
 
 
-
     public static String logNull2String(Object s) {
         if (isEmptyOrNull(s)) {
             return "";
@@ -302,7 +326,7 @@ public class CommUtil {
             return s.toString().trim();
         }
         if (s instanceof Date) {
-            Date d = DateUtil.date((Date)s);
+            Date d = DateUtil.date((Date) s);
             long time = d.getTime();
             if (time % (24 * 3600 * 1000) == 57600000) {
                 return DateUtil.format(d, "yyyy-MM-dd");

+ 124 - 0
car-wash-entity/src/main/java/com/kym/entity/admin/Feedback.java

@@ -0,0 +1,124 @@
+package com.kym.entity.admin;
+
+
+import com.kym.entity.miniapp.Attachment;
+import com.kym.entity.miniapp.User;
+import com.kym.jdbc.BasicQuery;
+import com.kym.jdbc.annotations.DBF;
+import com.kym.jdbc.annotations.Entity;
+import com.kym.jdbc.annotations.FK;
+import com.kym.jdbc.annotations.OP;
+import com.kym.jdbc.annotations.One;
+import com.kym.jdbc.annotations.QE;
+import com.kym.jdbc.annotations.QF;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.List;
+
+
+/**
+ * 纠错反馈
+ *
+ * @date 2024-09-22T20:40:35.300431885
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Entity(clz = Feedback.class, comment = "纠错反馈")
+public class Feedback implements Serializable {
+
+    public static final int TYPE_ERROR = 1; //纠错
+    public static final int TYPE_SUGGEST = 2; //建议
+    public static final int TYPE_OTHER = 3; //其他
+
+    public static final int STATUS_UNREPLY = 1; //未回复
+    public static final int STATUS_REPLIED = 2; //已回复
+
+    @DBF(comment = "ID")
+    private long id;
+    @DBF(comment = "反馈标题", max = 128)
+    private String title;
+    @DBF(comment = "纠错类型", dict = "Feedback.type")
+    private int type;
+    @DBF(comment = "详情描述", max = 512)
+    private String content;
+    @DBF(comment = "附件清单")
+    private List<Attachment> attachList;
+    @DBF(comment = "状态", dict = "Feedback.status")
+    private int status;
+
+    @DBF(comment = "提交时间")
+    private Date submitTime;
+    @FK(clz = User.class)
+    @DBF(comment = "提交人")
+    private long submitUserId;
+
+    @DBF(comment = "回复内容", max = 512)
+    private String replyContent;
+    @DBF(comment = "回复时间")
+    private Date replyTime;
+    @FK(clz = AdminUser.class)
+    @DBF(comment = "提交人")
+    private long replyUserId;
+
+    @DBF(comment = "创建时间")
+    private Date createTime;
+    @DBF(comment = "更新时间")
+    private Date updateTime;
+
+    @Data
+    @EqualsAndHashCode(callSuper = true)
+    public static class FeedbackInfo extends Feedback {
+        @One(mkf = "submitUserId", tf = "name", comment = "创建人")
+        private String submitUserName;
+
+        // @One(mkf = "updateBy", tf = "name", comment = "更新人")
+        // private String updateName;
+    }
+
+    @Data
+    @EqualsAndHashCode(callSuper = true)
+    @QE(clz = FeedbackInfo.class)
+    public static class FeedbackBasicQuery extends BasicQuery {
+        private String content;
+        private Long id;
+        private long submitUserId;
+        private String replyContent;
+        private Integer status;
+        private String title;
+        private Integer type;
+        private long replyUserId;
+
+        //region date query
+        @QF(op = OP.GTE, tf = "createTime")
+        private Date createTimeStart;
+        @QF(op = OP.LTE, tf = "createTime")
+        private Date createTimeEnd;
+        @QF(op = OP.GTE, tf = "replyTime")
+        private Date replyTimeStart;
+        @QF(op = OP.LTE, tf = "replyTime")
+        private Date replyTimeEnd;
+        @QF(op = OP.GTE, tf = "submitTime")
+        private Date submitTimeStart;
+        @QF(op = OP.LTE, tf = "submitTime")
+        private Date submitTimeEnd;
+        @QF(op = OP.GTE, tf = "updateTime")
+        private Date updateTimeStart;
+        @QF(op = OP.LTE, tf = "updateTime")
+        private Date updateTimeEnd;
+        //endregion
+
+
+        //region sort query
+        private Integer createTimeSort;
+        private Integer idSort;
+        private Integer replyTimeSort;
+        private Integer statusSort;
+        private Integer submitTimeSort;
+        private Integer typeSort;
+        private Integer updateTimeSort;
+        //endregion
+    }
+}

+ 48 - 0
car-wash-service/src/main/java/com/kym/service/admin/FeedbackService.java

@@ -0,0 +1,48 @@
+package com.kym.service.admin;
+
+import com.kym.common.R;
+import com.kym.jdbc.Bean;
+
+import com.kym.entity.admin.Feedback.FeedbackInfo;
+import com.kym.entity.admin.Feedback.FeedbackBasicQuery;
+
+
+/**
+ * 纠错反馈业务类
+ * @date 2024-09-22T20:40:35.300431885
+ */
+public interface  FeedbackService {
+
+    /**
+     * 纠错反馈分页查询
+     */
+     Bean<FeedbackInfo> list(FeedbackBasicQuery query);
+
+    /**
+     * 查询纠错反馈详情
+     */
+     FeedbackInfo detail(long id);
+
+
+    /**
+     * 纠错反馈状态变更
+     */
+     void status(long id, int status);
+
+
+    /**
+     * 新增纠错反馈
+     */
+     long add(FeedbackInfo feedback);
+
+    /**
+     * 物理删除纠错反馈
+     */
+      R<?> remove(long id);
+
+    /**
+     * 编辑纠错反馈
+     */
+     void reply(FeedbackInfo feedback);
+
+}

+ 98 - 0
car-wash-service/src/main/java/com/kym/service/admin/impl/FeedbackServiceImpl.java

@@ -0,0 +1,98 @@
+package com.kym.service.admin.impl;
+
+import com.kym.common.R;
+import com.kym.common.constant.ResponseEnum;
+import com.kym.common.utils.CommUtil;
+import com.kym.dao.admin.FeedbackDAO;
+import com.kym.entity.admin.Feedback;
+import com.kym.entity.admin.Feedback.FeedbackBasicQuery;
+import com.kym.entity.admin.Feedback.FeedbackInfo;
+import com.kym.jdbc.Bean;
+import com.kym.service.IService;
+import com.kym.service.admin.FeedbackService;
+import jakarta.annotation.Resource;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.Date;
+
+
+/**
+ * 纠错反馈业务类
+ *
+ * @date 2024-09-22T20:40:35.300431885
+ */
+@Service("feedbackService")
+public class FeedbackServiceImpl extends IService implements FeedbackService {
+
+    @Resource
+    private FeedbackDAO feedbackDAO;
+
+    /**
+     * 纠错反馈分页查询
+     */
+    public Bean<FeedbackInfo> list(FeedbackBasicQuery query) {
+        setupQuery(query);
+        return feedbackDAO.selectPageBean(query);
+    }
+
+    /**
+     * 查询纠错反馈详情
+     */
+    public FeedbackInfo detail(long id) {
+        return feedbackDAO.selectOneExist(FeedbackInfo.class, id);
+    }
+
+
+    /**
+     * 纠错反馈状态变更
+     */
+    @Transactional(rollbackFor = Exception.class)
+    public void status(long id, int status) {
+        Feedback old = feedbackDAO.selectOneExist(Feedback.class, id);
+        Feedback bean = new Feedback();
+//    bean.setId(id);
+        bean.setStatus(status);
+        feedbackDAO.updateSelective(bean, "status");
+        super.afterModify(old, bean);
+    }
+
+
+    /**
+     * 新增纠错反馈
+     */
+    @Transactional(rollbackFor = Exception.class)
+    public long add(FeedbackInfo feedback) {
+        long ret = feedbackDAO.insert(feedback);
+        CommUtil.asserts(ret > 0, ResponseEnum.DB_ERROR);
+
+        super.afterAdd(ret);
+        return ret;
+    }
+
+    /**
+     * 物理删除纠错反馈
+     */
+    @Transactional(rollbackFor = Exception.class)
+    public R<?> remove(long id) {
+        feedbackDAO.delete(Feedback.class, id);
+        super.afterRemove(id);
+        return R.success();
+    }
+
+    /**
+     * 编辑纠错反馈
+     */
+    @Transactional(rollbackFor = Exception.class)
+    public void reply(FeedbackInfo feedback) {
+        FeedbackInfo oldBean = feedbackDAO.selectOneExist(FeedbackInfo.class, feedback.getId());
+        CommUtil.assertsNonNull(feedback.getReplyContent(),ResponseEnum.PARAMS_ERROR);
+        feedback.setReplyUserId(getUserId());
+        feedback.setReplyTime(new Date());
+        int ret = feedbackDAO.updateSelective(feedback,Feedback::getReplyContent,Feedback::getReplyTime,Feedback::getStatus,Feedback::getReplyContent);
+        CommUtil.asserts(ret > 0, ResponseEnum.DB_ERROR);
+        super.afterModify(oldBean, feedback);
+    }
+
+
+}