From 8b4a2fa41ae97080b9c5ec2bb566bd0ec3f89d4e Mon Sep 17 00:00:00 2001 From: TinyAnts Date: Tue, 13 Sep 2022 16:47:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=85=AC=E4=BC=97=E5=8F=B7?= =?UTF-8?q?=E5=9B=9E=E5=A4=8D=E8=AF=A6=E6=83=85=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/channel/OaReplyController.java | 15 +- .../channel/IChannelOaReplyService.java | 22 ++- .../impl/ChannelOaReplyServiceImpl.java | 135 ++++++++++++++++-- 3 files changed, 157 insertions(+), 15 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 3c9bbacb..57919d77 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 @@ -2,12 +2,14 @@ package com.mdd.admin.controller.channel; import com.baomidou.mybatisplus.core.toolkit.Assert; import com.mdd.admin.service.channel.IChannelOaReplyService; +import com.mdd.admin.validate.common.PageParam; import com.mdd.common.core.AjaxResult; -import com.mdd.common.validator.IDMustValidator; +import com.mdd.common.validator.annotation.IDMust; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +import java.util.List; import java.util.Map; /** @@ -27,8 +29,10 @@ public class OaReplyController { * @return Object */ @GetMapping("/list") - public Object list() { - return AjaxResult.success(); + public Object list(@Validated PageParam pageParam, + @RequestParam Map params) { + List> list = iChannelOaReplyService.list(pageParam, params); + return AjaxResult.success(list); } /** @@ -38,8 +42,9 @@ public class OaReplyController { * @return Object */ @GetMapping("/detail") - public Object detail() { - return AjaxResult.success(); + public Object detail(@Validated @IDMust() @RequestParam("id") Integer id) { + Map map = iChannelOaReplyService.detail(id); + return AjaxResult.success(map); } /** 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 bfd4db65..58740eae 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 @@ -1,12 +1,30 @@ package com.mdd.admin.service.channel; +import com.mdd.admin.validate.common.PageParam; + +import java.util.List; import java.util.Map; public interface IChannelOaReplyService { - Object list(); + /** + * 回复列表 + * + * @author fzr + * @param pageParam 分页参数 + * @param params 参数 + * @return List> + */ + List> list(PageParam pageParam, Map params); - Object detail(); + /** + * 回复详情 + * + * @author fzr + * @param id 主键 + * @return Map + */ + Map detail(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 72417d83..02214595 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,17 +1,18 @@ package com.mdd.admin.service.channel.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.Assert; +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 javax.annotation.Resource; -import java.util.Arrays; -import java.util.Map; +import java.util.*; @Service public class ChannelOaReplyServiceImpl implements IChannelOaReplyService { @@ -19,15 +20,133 @@ public class ChannelOaReplyServiceImpl implements IChannelOaReplyService { @Resource OfficialReplyMapper officialReplyMapper; - + /** + * 回复列表 + * + * @author fzr + * @param pageParam 分页参数 + * @param params 参数 + * @return List> + */ @Override - public Object list() { - return null; + public List> list(PageParam pageParam, Map params) { + Integer pageNo = pageParam.getPageNo(); + Integer pageSize = pageParam.getPageSize(); + + Assert.notNull(params.get("type"), "type参数缺失"); + int type; + switch (params.get("type")) { + case "follow": + type = 1; + break; + case "keyword": + type = 2; + break; + case "default": + type = 3; + break; + default: + throw new OperateException("不被支持的类型!"); + } + + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("is_delete", 0); + queryWrapper.orderByDesc(Arrays.asList("sort", "id")); + queryWrapper.eq("reply_type", type); + IPage iPage = officialReplyMapper.selectPage(new Page<>(pageNo, pageSize), queryWrapper); + + List> list = new LinkedList<>(); + for (OfficialReply officialReply : iPage.getRecords()) { + Map map = new LinkedHashMap<>(); + switch (params.get("type")) { + case "follow": + map.put("id", officialReply.getId()); + map.put("name", officialReply.getName()); + map.put("replyType", officialReply.getReplyType()); + map.put("contentType", officialReply.getContentType()); + map.put("content", officialReply.getContent()); + map.put("sort", officialReply.getSort()); + map.put("status", officialReply.getStatus()); + break; + case "keyword": + map.put("id", officialReply.getId()); + map.put("name", officialReply.getName()); + map.put("keyword", officialReply.getKeyword()); + map.put("matchingType", officialReply.getMatchingType()); + map.put("replyType", officialReply.getReplyType()); + map.put("contentType", officialReply.getContentType()); + map.put("content", officialReply.getContent()); + map.put("sort", officialReply.getSort()); + map.put("status", officialReply.getStatus()); + break; + case "default": + map.put("id", officialReply.getId()); + map.put("name", officialReply.getName()); + map.put("replyType", officialReply.getReplyType()); + map.put("content", officialReply.getContent()); + map.put("sort", officialReply.getSort()); + map.put("status", officialReply.getStatus()); + break; + default: + throw new OperateException("不被支持的类型!"); + } + list.add(map); + } + + return list; } + /** + * 回复详情 + * + * @author fzr + * @param id 主键 + * @return Map + */ @Override - public Object detail() { - return null; + public Map detail(Integer id) { + OfficialReply officialReply = officialReplyMapper.selectOne(new QueryWrapper() + .eq("id", id) + .eq("is_delete", 0) + .last("limit 1")); + + Assert.notNull(officialReply, "数据不存在!"); + + Map map = new LinkedHashMap<>(); + switch (officialReply.getReplyType()) { + case 1: + map.put("id", officialReply.getId()); + map.put("name", officialReply.getName()); + map.put("replyType", officialReply.getReplyType()); + map.put("contentType", officialReply.getContentType()); + map.put("content", officialReply.getContent()); + map.put("sort", officialReply.getSort()); + map.put("status", officialReply.getStatus()); + break; + case 2: + map.put("id", officialReply.getId()); + map.put("name", officialReply.getName()); + map.put("keyword", officialReply.getKeyword()); + map.put("replyType", officialReply.getReplyType()); + map.put("matchingType", officialReply.getMatchingType()); + map.put("contentType", officialReply.getContentType()); + map.put("content", officialReply.getContent()); + map.put("sort", officialReply.getSort()); + map.put("status", officialReply.getStatus()); + break; + case 3: + map.put("id", officialReply.getId()); + map.put("name", officialReply.getName()); + map.put("replyType", officialReply.getReplyType()); + map.put("content", officialReply.getContent()); + map.put("sort", officialReply.getSort()); + map.put("status", officialReply.getStatus()); + break; + default: + throw new OperateException("不被支持的类型!"); + } + + return map; } /**