From f4eca5bc1356f0589dd40417022ffd11ce63b53c Mon Sep 17 00:00:00 2001 From: TinyAnts Date: Tue, 13 Sep 2022 17:14:07 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=9E=E5=A4=8D=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/channel/OaReplyController.java | 14 +++++ .../channel/IChannelOaReplyService.java | 11 ++++ .../impl/ChannelOaReplyServiceImpl.java | 56 +++++++++++++++++++ .../front/service/impl/LoginServiceImpl.java | 1 - 4 files changed, 81 insertions(+), 1 deletion(-) 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 57919d77..e98debd5 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 @@ -85,4 +85,18 @@ public class OaReplyController { return AjaxResult.success(); } + /** + * 回复状态 + * + * @author fzr + * @return Object + */ + @PostMapping("/status") + public Object status(@RequestBody Map params) { + Assert.notNull(params.get("id"), "id参数缺失"); + iChannelOaReplyService.status(Integer.parseInt(params.get("id"))); + 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 58740eae..5d347dcd 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 @@ -5,6 +5,9 @@ import com.mdd.admin.validate.common.PageParam; import java.util.List; import java.util.Map; +/** + * 公众号回复服务接口类 + */ public interface IChannelOaReplyService { /** @@ -50,4 +53,12 @@ public interface IChannelOaReplyService { */ void del(Integer id); + /** + * 回复状态 + * + * @author fzr + * @param id 主键 + */ + void status(Integer id); + } 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 02214595..34f595d0 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 @@ -7,13 +7,18 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.mdd.admin.service.channel.IChannelOaReplyService; import com.mdd.admin.validate.common.PageParam; import com.mdd.common.entity.OfficialReply; +import com.mdd.common.entity.server.Sys; import com.mdd.common.exception.OperateException; import com.mdd.common.mapper.OfficialReplyMapper; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.util.*; +/** + * 公众号回复服务实现类 + */ @Service public class ChannelOaReplyServiceImpl implements IChannelOaReplyService { @@ -155,18 +160,30 @@ public class ChannelOaReplyServiceImpl implements IChannelOaReplyService { * @author fzr * @param params 参数 */ + @Transactional @Override public void add(Map params) { String type = params.getOrDefault("type", ""); + + if (!type.equals("keyword")) { + OfficialReply reply = new OfficialReply(); + reply.setStatus(0); + Integer t = type.equals("follow") ? 1 : 3; + officialReplyMapper.update(reply, new QueryWrapper() + .eq("reply_type", t)); + } + OfficialReply officialReply = new OfficialReply(); switch (type) { case "follow": Assert.notNull(params.get("name"), "规则名称不能为空"); Assert.notNull(params.get("contentType"), "请正确选择回复类型"); Assert.notNull(params.get("content"), "回复内容不能为空"); + Assert.notNull(params.get("sort"), "排序号不能为空"); Assert.notNull(params.get("status"), "请正确选择状态"); officialReply.setName(params.get("name")); officialReply.setReplyType(1); + officialReply.setSort(Integer.parseInt(params.get("sort"))); officialReply.setContentType(Integer.parseInt(params.get("contentType"))); officialReply.setContent(params.get("content")); officialReply.setStatus(Integer.parseInt(params.get("status"))); @@ -217,6 +234,7 @@ public class ChannelOaReplyServiceImpl implements IChannelOaReplyService { * @author fzr * @param params 参数 */ + @Transactional @Override public void edit(Map params) { Assert.notNull(params.get("id"), "id参数缺失"); @@ -229,15 +247,24 @@ public class ChannelOaReplyServiceImpl implements IChannelOaReplyService { Assert.notNull(officialReply, "数据不存在!"); + if (officialReply.getReplyType() != 2) { + OfficialReply reply = new OfficialReply(); + reply.setStatus(0); + officialReplyMapper.update(reply, new QueryWrapper() + .eq("reply_type", officialReply.getReplyType() )); + } + switch (officialReply.getReplyType()) { case 1: Assert.notNull(params.get("name"), "规则名称不能为空"); Assert.notNull(params.get("contentType"), "请正确选择回复类型"); Assert.notNull(params.get("content"), "回复内容不能为空"); + Assert.notNull(params.get("sort"), "排序号不能为空"); Assert.notNull(params.get("status"), "请正确选择状态"); officialReply.setId(id); officialReply.setName(params.get("name")); officialReply.setReplyType(1); + officialReply.setSort(Integer.parseInt(params.get("sort"))); officialReply.setContentType(Integer.parseInt(params.get("contentType"))); officialReply.setContent(params.get("content")); officialReply.setStatus(Integer.parseInt(params.get("status"))); @@ -304,4 +331,33 @@ public class ChannelOaReplyServiceImpl implements IChannelOaReplyService { officialReplyMapper.updateById(officialReply); } + /** + * 回复状态 + * + * @author fzr + * @param id 主键 + */ + @Override + public void status(Integer id) { + OfficialReply officialReply = officialReplyMapper.selectOne(new QueryWrapper() + .eq("is_delete", 0) + .eq("id", id) + .last("limit 1")); + + Assert.notNull(officialReply, "数据不存在!"); + + if (officialReply.getReplyType() != 2 && officialReply.getStatus() == 1) { + OfficialReply reply = new OfficialReply(); + reply.setStatus(0); + officialReplyMapper.update(reply, new QueryWrapper() + .eq("reply_type", officialReply.getReplyType())); + } + + officialReply.setId(id); + officialReply.setStatus(officialReply.getStatus() == 1 ? 0 : 1); + officialReply.setUpdateTime(System.currentTimeMillis() / 1000); + officialReplyMapper.updateById(officialReply); + } + + } diff --git a/server/like-front/src/main/java/com/mdd/front/service/impl/LoginServiceImpl.java b/server/like-front/src/main/java/com/mdd/front/service/impl/LoginServiceImpl.java index c7ddef9f..f4272219 100644 --- a/server/like-front/src/main/java/com/mdd/front/service/impl/LoginServiceImpl.java +++ b/server/like-front/src/main/java/com/mdd/front/service/impl/LoginServiceImpl.java @@ -9,7 +9,6 @@ import com.baomidou.mybatisplus.core.toolkit.Assert; import com.mdd.common.config.GlobalConfig; import com.mdd.common.entity.user.User; import com.mdd.common.entity.user.UserAuth; -import com.mdd.common.enums.ClientEnum; import com.mdd.common.enums.NoticeEnum; import com.mdd.common.exception.OperateException; import com.mdd.common.mapper.user.UserAuthMapper;