From 04bdc9b6589b6a1137117724ca22c865bd3ed77e Mon Sep 17 00:00:00 2001 From: zhaoqifeng Date: Thu, 9 Sep 2021 10:41:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8C=87=E5=8D=97=E6=94=B6=E8=97=8F=E5=92=8C?= =?UTF-8?q?=E6=88=91=E7=9A=84=E6=94=B6=E8=97=8F=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/epmet/dto/form/GuideListFormDTO.java | 1 + .../controller/GuideCollectionController.java | 18 ++++++++++ .../com/epmet/controller/GuideController.java | 8 +++++ .../src/main/java/com/epmet/dao/GuideDao.java | 11 ++++++ .../epmet/service/GuideCollectionService.java | 12 +++++++ .../java/com/epmet/service/GuideService.java | 11 ++++++ .../impl/GuideCollectionServiceImpl.java | 35 +++++++++++++++++++ .../epmet/service/impl/GuideServiceImpl.java | 27 ++++++++++++++ .../src/main/resources/mapper/GuideDao.xml | 18 +++++++++- 9 files changed, 140 insertions(+), 1 deletion(-) diff --git a/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/GuideListFormDTO.java b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/GuideListFormDTO.java index d4ff3bdfcb..2e36d7c517 100644 --- a/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/GuideListFormDTO.java +++ b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/GuideListFormDTO.java @@ -16,6 +16,7 @@ import java.io.Serializable; public class GuideListFormDTO extends PageFormDTO implements Serializable { private static final long serialVersionUID = -4471422632936288213L; + private String customerId; /** * 组织ID */ diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/GuideCollectionController.java b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/GuideCollectionController.java index 08f94a4126..5c6ffe5019 100644 --- a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/GuideCollectionController.java +++ b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/GuideCollectionController.java @@ -17,7 +17,9 @@ package com.epmet.controller; +import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.AssertUtils; import com.epmet.commons.tools.validator.ValidatorUtils; @@ -25,6 +27,7 @@ import com.epmet.commons.tools.validator.group.AddGroup; import com.epmet.commons.tools.validator.group.DefaultGroup; import com.epmet.commons.tools.validator.group.UpdateGroup; import com.epmet.dto.GuideCollectionDTO; +import com.epmet.dto.form.GuideFormDTO; import com.epmet.service.GuideCollectionService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -81,4 +84,19 @@ public class GuideCollectionController { return new Result(); } + /** + * @Description 收藏指南 + * @Param tokenDto + * @Param formDTO + * @Return {@link Result} + * @Author zhaoqifeng + * @Date 2021/9/9 9:46 + */ + @PostMapping("collection") + public Result collection(@LoginUser TokenDto tokenDto, @RequestBody GuideFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO); + guideCollectionService.collection(tokenDto, formDTO); + return new Result(); + } + } \ No newline at end of file diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/GuideController.java b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/GuideController.java index 602916807e..c9b9ccfead 100644 --- a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/GuideController.java +++ b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/GuideController.java @@ -169,4 +169,12 @@ public class GuideController { } + @PostMapping("collectionlist") + public Result> collectionList(@LoginUser TokenDto tokenDto, @RequestBody PageFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO, PageFormDTO.AddUserInternalGroup.class); + PageData page = guideService.collectionList(tokenDto, formDTO); + return new Result>().ok(page); + } + + } \ No newline at end of file diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/GuideDao.java b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/GuideDao.java index ec78fb5803..77d3f6e805 100644 --- a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/GuideDao.java +++ b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/GuideDao.java @@ -18,6 +18,7 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.dto.form.GuideListFormDTO; import com.epmet.dto.result.GuideDetailResultDTO; import com.epmet.dto.result.GuideListResultDTO; @@ -56,4 +57,14 @@ public interface GuideDao extends BaseDao { */ GuideDetailResultDTO getGuideDetail(@Param("guideId") String guideId); + /** + * 收藏列表 + * + * @Param tokenDto + * @Return {@link List< GuideListResultDTO>} + * @Author zhaoqifeng + * @Date 2021/9/9 10:09 + */ + List getCollectionList(TokenDto tokenDto); + } \ No newline at end of file diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/GuideCollectionService.java b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/GuideCollectionService.java index 6e8266c556..a4acb0b6e4 100644 --- a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/GuideCollectionService.java +++ b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/GuideCollectionService.java @@ -19,7 +19,9 @@ package com.epmet.service; import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.dto.GuideCollectionDTO; +import com.epmet.dto.form.GuideFormDTO; import com.epmet.entity.GuideCollectionEntity; import java.util.List; @@ -92,4 +94,14 @@ public interface GuideCollectionService extends BaseService { * @Date 2021/9/7 14:12 */ GuideDetailResultDTO guideDetail(GuideFormDTO formDTO); + + /** + * @Description 收藏列表 + * @Param tokenDto + * @Param formDTO + * @Return {@link PageData< GuideListResultDTO>} + * @Author zhaoqifeng + * @Date 2021/9/9 10:07 + */ + PageData collectionList(TokenDto tokenDto, PageFormDTO formDTO); } \ No newline at end of file diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/GuideCollectionServiceImpl.java b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/GuideCollectionServiceImpl.java index a73d8228ee..382a9db1ce 100644 --- a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/GuideCollectionServiceImpl.java +++ b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/GuideCollectionServiceImpl.java @@ -17,14 +17,17 @@ package com.epmet.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.dao.GuideCollectionDao; import com.epmet.dto.GuideCollectionDTO; +import com.epmet.dto.form.GuideFormDTO; import com.epmet.entity.GuideCollectionEntity; import com.epmet.service.GuideCollectionService; import org.apache.commons.lang3.StringUtils; @@ -97,4 +100,36 @@ public class GuideCollectionServiceImpl extends BaseServiceImpl wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(GuideCollectionEntity::getGuideId, formDTO.getGuideId()); + wrapper.eq(GuideCollectionEntity::getUserId, tokenDto.getUserId()); + wrapper.eq(GuideCollectionEntity::getApp, tokenDto.getApp()); + wrapper.eq(GuideCollectionEntity::getCustomerId, tokenDto.getCustomerId()); + GuideCollectionEntity entity = baseDao.selectOne(wrapper); + //如果没有收藏记录,则添加收藏,有就删除收藏 + if (null == entity) { + entity = new GuideCollectionEntity(); + entity.setCustomerId(tokenDto.getCustomerId()); + entity.setUserId(tokenDto.getUserId()); + entity.setGuideId(formDTO.getGuideId()); + entity.setApp(tokenDto.getApp()); + insert(entity); + } else { + deleteById(entity.getId()); + } + } + } \ No newline at end of file diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/GuideServiceImpl.java b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/GuideServiceImpl.java index ac643590eb..abd1116256 100644 --- a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/GuideServiceImpl.java +++ b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/GuideServiceImpl.java @@ -21,6 +21,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.commons.tools.dto.form.PageFormDTO; import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.RenException; @@ -142,6 +143,7 @@ public class GuideServiceImpl extends BaseServiceImpl imp @Override public PageData guideList(TokenDto tokenDto, GuideListFormDTO formDTO) { PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize()); + formDTO.setCustomerId(tokenDto.getCustomerId()); List list = baseDao.getGuideList(formDTO); list.forEach(item -> { CustomerStaffInfoCacheResult staffInfoCache = CustomerStaffRedis.getStaffInfo(tokenDto.getCustomerId(), item.getCreatedId()); @@ -382,4 +384,29 @@ public class GuideServiceImpl extends BaseServiceImpl imp return result; } + /** + * @param tokenDto + * @Description 收藏列表 + * @Param tokenDto + * @Param formDTO + * @Return {@link PageData< GuideListResultDTO>} + * @Author zhaoqifeng + * @Date 2021/9/9 10:03 + */ + @Override + public PageData collectionList(TokenDto tokenDto, PageFormDTO formDTO) { + PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize()); + List list = baseDao.getCollectionList(tokenDto); + list.forEach(item -> { + CustomerStaffInfoCacheResult staffInfoCache = CustomerStaffRedis.getStaffInfo(tokenDto.getCustomerId(), item.getCreatedId()); + if (null == staffInfoCache) { + item.setCategoryName(""); + } else { + item.setCreatedName(staffInfoCache.getRealName()); + } + }); + PageInfo pageInfo = new PageInfo<>(list); + return new PageData<>(list, pageInfo.getTotal()); + } + } \ No newline at end of file diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/GuideDao.xml b/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/GuideDao.xml index 82a784dbe9..c557360208 100644 --- a/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/GuideDao.xml +++ b/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/GuideDao.xml @@ -29,8 +29,9 @@ g.UPDATED_TIME AS updatedTime, FROM guide g - INNER JOIN guide_category gc ON g.CATEGORY_ID = gc.ID + INNER JOIN guide_category gc ON g.CATEGORY_ID = gc.ID AND gc.DEL_FLAG = 0 AND gc.CUSTOMER_ID = #{customerId} WHERE g.DEL_FLAG = 0 + AND g.CUSTOMER_ID = #{customerId} AND g.PIDS LIKE CONCAT( '%', #{agencyId}, '%' ) @@ -56,6 +57,21 @@ WHERE g.ID = #{guideId} + \ No newline at end of file