From 1bdfbf6acd9e275414f47792993a0b796089e25e Mon Sep 17 00:00:00 2001 From: zhaoqifeng Date: Mon, 28 Mar 2022 16:48:04 +0800 Subject: [PATCH] =?UTF-8?q?=E9=98=B2=E7=96=AB=E9=80=9A=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../commons/tools/enums/ChannelEnum.java | 57 +++++++++++++++++++ .../main/java/com/epmet/dto/IcNoticeDTO.java | 12 ++++ .../com/epmet/dto/form/IcNoticeFormDTO.java | 21 +++++++ .../epmet/controller/IcNoticeController.java | 8 +-- .../com/epmet/service/IcNoticeService.java | 5 +- .../service/impl/IcNoticeServiceImpl.java | 36 +++++++++--- 6 files changed, 124 insertions(+), 15 deletions(-) create mode 100644 epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/ChannelEnum.java create mode 100644 epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/IcNoticeFormDTO.java diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/ChannelEnum.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/ChannelEnum.java new file mode 100644 index 0000000000..389338f717 --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/ChannelEnum.java @@ -0,0 +1,57 @@ +package com.epmet.commons.tools.enums; + +import com.epmet.commons.tools.exception.EpmetErrorCode; + +/** + * @author Administrator + */ +public enum ChannelEnum { + //通知渠道 0小程序通知,1短信通知 + APP("0", "小程序通知"), + MESSAGE("1", "短信通知"), + ALL("2", "小程序通知,短信通知"); + private String code; + private String name; + + + ChannelEnum(String code, String name) { + this.code = code; + this.name = name; + } + + public static String getName(String code) { + ChannelEnum[] houseTypeEnums = values(); + for (ChannelEnum houseTypeEnum : houseTypeEnums) { + if (houseTypeEnum.getCode() == code) { + return houseTypeEnum.getName(); + } + } + return EpmetErrorCode.SERVER_ERROR.getMsg(); + } + + public static String getCode(String name) { + ChannelEnum[] houseTypeEnums = values(); + for (ChannelEnum houseTypeEnum : houseTypeEnums) { + if (houseTypeEnum.getName().equals(name)) { + return houseTypeEnum.getCode(); + } + } + return null; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcNoticeDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcNoticeDTO.java index 0a67cd4875..72520ef800 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcNoticeDTO.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcNoticeDTO.java @@ -1,6 +1,7 @@ package com.epmet.dto; import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Data; import java.io.Serializable; @@ -22,11 +23,13 @@ public class IcNoticeDTO implements Serializable { /** * 唯一标识 */ + @JsonIgnore private String id; /** * 客户Id customer.id */ + @JsonIgnore private String customerId; /** @@ -37,20 +40,24 @@ public class IcNoticeDTO implements Serializable { /** * 通知来源 0行程上报,1疫苗接种,2核酸检测 */ + @JsonIgnore private String origin; /** * 用户ID */ + @JsonIgnore private String userId; /** * 手机号 */ + @JsonIgnore private String mobile; /** * 被通知人身份证号 */ + @JsonIgnore private String idCard; /** @@ -66,16 +73,19 @@ public class IcNoticeDTO implements Serializable { /** * 删除标识:0.未删除 1.已删除 */ + @JsonIgnore private Integer delFlag; /** * 乐观锁 */ + @JsonIgnore private Integer revision; /** * 创建人 */ + @JsonIgnore private String createdBy; /** @@ -87,11 +97,13 @@ public class IcNoticeDTO implements Serializable { /** * 更新人 */ + @JsonIgnore private String updatedBy; /** * 更新时间 */ + @JsonIgnore private Date updatedTime; } \ No newline at end of file diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/IcNoticeFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/IcNoticeFormDTO.java new file mode 100644 index 0000000000..057ee17921 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/IcNoticeFormDTO.java @@ -0,0 +1,21 @@ +package com.epmet.dto.form; + +import com.epmet.commons.tools.dto.form.PageFormDTO; +import com.epmet.commons.tools.validator.group.DefaultGroup; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Description + * @Author zhaoqifeng + * @Date 2022/3/28 16:13 + */ +@Data +public class IcNoticeFormDTO extends PageFormDTO implements Serializable { + private static final long serialVersionUID = 7392894573654015338L; + private String customerId; + @NotBlank(message = "身份证号不能为空", groups = DefaultGroup.class) + private String idCard; +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcNoticeController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcNoticeController.java index 644c768530..f7cb128fc4 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcNoticeController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcNoticeController.java @@ -11,13 +11,12 @@ 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.IcNoticeDTO; +import com.epmet.dto.form.IcNoticeFormDTO; import com.epmet.dto.form.SendNoticeFormDTO; import com.epmet.service.IcNoticeService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; -import java.util.Map; - /** * 防疫通知 @@ -33,8 +32,9 @@ public class IcNoticeController { private IcNoticeService icNoticeService; @RequestMapping("page") - public Result> page(@RequestParam Map params){ - PageData page = icNoticeService.page(params); + public Result> page(@LoginUser TokenDto tokenDto, @RequestBody IcNoticeFormDTO formDTO){ + formDTO.setCustomerId(tokenDto.getCustomerId()); + PageData page = icNoticeService.page(formDTO); return new Result>().ok(page); } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcNoticeService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcNoticeService.java index 9bbcd2428e..937cca916a 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcNoticeService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcNoticeService.java @@ -3,6 +3,7 @@ package com.epmet.service; import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.tools.page.PageData; import com.epmet.dto.IcNoticeDTO; +import com.epmet.dto.form.IcNoticeFormDTO; import com.epmet.dto.form.SendNoticeFormDTO; import com.epmet.entity.IcNoticeEntity; @@ -20,12 +21,12 @@ public interface IcNoticeService extends BaseService { /** * 默认分页 * - * @param params + * @param dto * @return PageData * @author generator * @date 2022-03-28 */ - PageData page(Map params); + PageData page(IcNoticeFormDTO formDTO); /** * 默认查询 diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcNoticeServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcNoticeServiceImpl.java index ddd101c46b..64fe1016c2 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcNoticeServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcNoticeServiceImpl.java @@ -3,9 +3,9 @@ package com.epmet.service.impl; import com.alibaba.fastjson.JSON; 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.*; +import com.epmet.commons.tools.enums.ChannelEnum; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.Result; @@ -13,12 +13,15 @@ import com.epmet.constant.SmsTemplateConstant; import com.epmet.constant.UserMessageTypeConstant; import com.epmet.dao.IcNoticeDao; import com.epmet.dto.IcNoticeDTO; +import com.epmet.dto.form.IcNoticeFormDTO; import com.epmet.dto.form.ProjectSendMsgFormDTO; import com.epmet.dto.form.SendNoticeFormDTO; import com.epmet.dto.form.UserMessageFormDTO; import com.epmet.entity.IcNoticeEntity; import com.epmet.feign.MessageFeignClient; import com.epmet.service.IcNoticeService; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; @@ -46,12 +49,27 @@ public class IcNoticeServiceImpl extends BaseServiceImpl page(Map params) { - IPage page = baseDao.selectPage( - getPage(params, FieldConstant.CREATED_TIME, false), - getWrapper(params) - ); - return getPageData(page, IcNoticeDTO.class); + public PageData page(IcNoticeFormDTO formDTO) { + PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize()); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(IcNoticeEntity::getCustomerId, formDTO.getCustomerId()); + wrapper.eq(IcNoticeEntity::getIdCard, formDTO.getIdCard()); + wrapper.orderByDesc(IcNoticeEntity::getCreatedTime); + List list = baseDao.selectList(wrapper); + PageInfo pageInfo = new PageInfo<>(list); + List dtoList = ConvertUtils.sourceToTarget(list, IcNoticeDTO.class); + + if (CollectionUtils.isNotEmpty(dtoList)) { + dtoList.forEach(item -> { + List channelList = Arrays.asList(item.getChannel().split(StrConstant.COMMA)); + if (channelList.size() == NumConstant.ONE) { + item.setChannel(ChannelEnum.getName(channelList.get(0))); + } else { + item.setChannel(ChannelEnum.getName(NumConstant.TWO_STR)); + } + }); + } + return new PageData<>(dtoList, pageInfo.getTotal()); } @Override @@ -115,9 +133,9 @@ public class IcNoticeServiceImpl extends BaseServiceImpl