From 71998ed2f17eb91156b09be91c55a11f802561c8 Mon Sep 17 00:00:00 2001 From: TinyAnts Date: Tue, 13 Sep 2022 16:06:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=AC=E4=BC=97=E5=8F=B7=E5=9B=9E=E5=A4=8D?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/channel/OaReplyController.java | 33 +++++++- .../channel/IChannelOaReplyService.java | 14 +++- .../impl/ChannelOaReplyServiceImpl.java | 83 ++++++++++++++++++- .../com/mdd/common/entity/OfficialReply.java | 1 + 4 files changed, 125 insertions(+), 6 deletions(-) diff --git a/server/like-admin/src/main/java/com/mdd/admin/controller/channel/OaReplyController.java b/server/like-admin/src/main/java/com/mdd/admin/controller/channel/OaReplyController.java index 208ac173..890831ee 100644 --- a/server/like-admin/src/main/java/com/mdd/admin/controller/channel/OaReplyController.java +++ b/server/like-admin/src/main/java/com/mdd/admin/controller/channel/OaReplyController.java @@ -11,33 +11,64 @@ import java.util.Map; * 公众号回复管理 */ @RestController -@RequestMapping("api/channel/OaReply") +@RequestMapping("api/channel/oaReply") public class OaReplyController { @Resource IChannelOaReplyService iChannelOaReplyService; + /** + * 回复列表 + * + * @author fzr + * @return Object + */ @GetMapping("/list") public Object list() { return AjaxResult.success(); } + /** + * 回复详情 + * + * @author fzr + * @return Object + */ @GetMapping("/detail") public Object detail() { return AjaxResult.success(); } + /** + * 回复新增 + * + * @author fzr + * @param params 参数 + * @return Object + */ @PostMapping("/add") public Object add(@RequestBody Map params) { iChannelOaReplyService.add(params); return AjaxResult.success(); } + /** + * 回复编辑 + * + * @author fzr + * @return Object + */ @PostMapping("/edit") public Object edit() { return AjaxResult.success(); } + /** + * 回复删除 + * + * @author fzr + * @return Object + */ @PostMapping("/del") public Object del() { return AjaxResult.success(); diff --git a/server/like-admin/src/main/java/com/mdd/admin/service/channel/IChannelOaReplyService.java b/server/like-admin/src/main/java/com/mdd/admin/service/channel/IChannelOaReplyService.java index 975d7812..24220dbe 100644 --- a/server/like-admin/src/main/java/com/mdd/admin/service/channel/IChannelOaReplyService.java +++ b/server/like-admin/src/main/java/com/mdd/admin/service/channel/IChannelOaReplyService.java @@ -8,9 +8,21 @@ public interface IChannelOaReplyService { Object detail(); + /** + * 回复新增 + * + * @author fzr + * @param params 参数 + */ void add(Map params); - void edit(); + /** + * 回复编辑 + * + * @author fzr + * @param params 参数 + */ + void edit(Map params); void del(); diff --git a/server/like-admin/src/main/java/com/mdd/admin/service/channel/impl/ChannelOaReplyServiceImpl.java b/server/like-admin/src/main/java/com/mdd/admin/service/channel/impl/ChannelOaReplyServiceImpl.java index 72c055e4..44362c5d 100644 --- a/server/like-admin/src/main/java/com/mdd/admin/service/channel/impl/ChannelOaReplyServiceImpl.java +++ b/server/like-admin/src/main/java/com/mdd/admin/service/channel/impl/ChannelOaReplyServiceImpl.java @@ -1,5 +1,6 @@ package com.mdd.admin.service.channel.impl; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Assert; import com.mdd.admin.service.channel.IChannelOaReplyService; import com.mdd.common.entity.OfficialReply; @@ -29,6 +30,12 @@ public class ChannelOaReplyServiceImpl implements IChannelOaReplyService { return null; } + /** + * 回复新增 + * + * @author fzr + * @param params 参数 + */ @Override public void add(Map params) { String type = params.getOrDefault("type", ""); @@ -41,7 +48,7 @@ public class ChannelOaReplyServiceImpl implements IChannelOaReplyService { Assert.notNull(params.get("status"), "请正确选择状态"); officialReply.setName(params.get("name")); officialReply.setReplyType(1); - officialReply.setContentType(Integer.parseInt(params.get("replyType"))); + officialReply.setContentType(Integer.parseInt(params.get("contentType"))); officialReply.setContent(params.get("content")); officialReply.setStatus(Integer.parseInt(params.get("status"))); officialReply.setCreateTime(System.currentTimeMillis() / 1000); @@ -73,7 +80,8 @@ public class ChannelOaReplyServiceImpl implements IChannelOaReplyService { Assert.notNull(params.get("status"), "请正确选择状态"); officialReply.setName(params.get("name")); officialReply.setReplyType(3); - officialReply.setMatchingType(Integer.parseInt(params.get("matchingType"))); + officialReply.setContent(params.get("content")); + officialReply.setContentType(Integer.parseInt(params.get("contentType"))); officialReply.setStatus(Integer.parseInt(params.get("status"))); officialReply.setCreateTime(System.currentTimeMillis() / 1000); officialReply.setUpdateTime(System.currentTimeMillis() / 1000); @@ -82,12 +90,79 @@ public class ChannelOaReplyServiceImpl implements IChannelOaReplyService { default: throw new OperateException("不被支持的类型"); } - } + /** + * 回复编辑 + * + * @author fzr + * @param params 参数 + */ @Override - public void edit() { + public void edit(Map params) { + Assert.notNull(params.get("id"), "id参数缺失"); + Integer id = Integer.parseInt(params.get("id")); + OfficialReply officialReply = officialReplyMapper.selectOne(new QueryWrapper() + .eq("id", id) + .eq("is_delete", 0) + .last("limit 1")); + + Assert.notNull(officialReply, "数据不存在!"); + + switch (officialReply.getReplyType()) { + case 1: + Assert.notNull(params.get("name"), "规则名称不能为空"); + Assert.notNull(params.get("contentType"), "请正确选择回复类型"); + Assert.notNull(params.get("content"), "回复内容不能为空"); + Assert.notNull(params.get("status"), "请正确选择状态"); + officialReply.setId(id); + officialReply.setName(params.get("name")); + officialReply.setReplyType(1); + officialReply.setContentType(Integer.parseInt(params.get("contentType"))); + officialReply.setContent(params.get("content")); + officialReply.setStatus(Integer.parseInt(params.get("status"))); + officialReply.setCreateTime(System.currentTimeMillis() / 1000); + officialReply.setUpdateTime(System.currentTimeMillis() / 1000); + officialReplyMapper.insert(officialReply); + break; + case 2: + Assert.notNull(params.get("name"), "规则名称不能为空"); + Assert.notNull(params.get("keyword"), "关键词不能为空"); + Assert.notNull(params.get("matchingType"), "请正确选择匹配模式"); + Assert.notNull(params.get("contentType"), "请正确选择回复类型"); + Assert.notNull(params.get("content"), "回复内容不能为空"); + Assert.notNull(params.get("status"), "请正确选择状态"); + officialReply.setId(id); + officialReply.setName(params.get("name")); + officialReply.setKeyword(params.get("keyword")); + officialReply.setMatchingType(Integer.parseInt(params.get("matchingType"))); + officialReply.setReplyType(2); + officialReply.setContent(params.get("content")); + officialReply.setContentType(Integer.parseInt(params.get("contentType"))); + officialReply.setStatus(Integer.parseInt(params.get("status"))); + officialReply.setCreateTime(System.currentTimeMillis() / 1000); + officialReply.setUpdateTime(System.currentTimeMillis() / 1000); + officialReplyMapper.insert(officialReply); + break; + case 3: + Assert.notNull(params.get("name"), "规则名称不能为空"); + Assert.notNull(params.get("contentType"), "请正确选择回复类型"); + Assert.notNull(params.get("content"), "回复内容不能为空"); + Assert.notNull(params.get("status"), "请正确选择状态"); + officialReply.setId(id); + officialReply.setName(params.get("name")); + officialReply.setReplyType(3); + officialReply.setContent(params.get("content")); + officialReply.setContentType(Integer.parseInt(params.get("contentType"))); + officialReply.setStatus(Integer.parseInt(params.get("status"))); + officialReply.setCreateTime(System.currentTimeMillis() / 1000); + officialReply.setUpdateTime(System.currentTimeMillis() / 1000); + officialReplyMapper.insert(officialReply); + break; + default: + throw new OperateException("不被支持的类型"); + } } @Override diff --git a/server/like-common/src/main/java/com/mdd/common/entity/OfficialReply.java b/server/like-common/src/main/java/com/mdd/common/entity/OfficialReply.java index f21f83de..4ce93542 100644 --- a/server/like-common/src/main/java/com/mdd/common/entity/OfficialReply.java +++ b/server/like-common/src/main/java/com/mdd/common/entity/OfficialReply.java @@ -24,6 +24,7 @@ public class OfficialReply implements Serializable { private Integer status; // 启动状态: [1=启动, 0=关闭] private String content; // 回复内容 private Integer sort; // 排序编号 + private Integer isDelete; // 是否删除 private Long createTime; // 创建时间 private Long updateTime; // 更新时间 private Long deleteTime; // 删除时间