From fe1977419d9f9ab3871f047674bc6f059406ccb6 Mon Sep 17 00:00:00 2001 From: zhaoqifeng Date: Mon, 2 Nov 2020 10:48:24 +0800 Subject: [PATCH 01/16] =?UTF-8?q?=E8=AE=A2=E9=98=85=E7=9B=B8=E5=90=8C?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E6=97=B6=E6=B7=BB=E5=8A=A0=E5=85=B3=E9=94=AE?= =?UTF-8?q?=E5=AD=97=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/epmet/dao/PersonalTemplateDao.java | 11 +++++++++++ .../epmet/service/PersonalTemplateService.java | 11 +++++++++++ .../service/impl/PersonalTemplateServiceImpl.java | 15 +++++++++++++++ .../epmet/service/impl/SubscribeServiceImpl.java | 5 +++++ .../main/resources/mapper/PersonalTemplateDao.xml | 8 ++++++++ 5 files changed, 50 insertions(+) diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PersonalTemplateDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PersonalTemplateDao.java index 6e229dc052..c89ed2aeba 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PersonalTemplateDao.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PersonalTemplateDao.java @@ -94,4 +94,15 @@ public interface PersonalTemplateDao extends BaseDao { * @author sun */ List selectCustomerTemplateList(CustomerTemplateListFormDTO formDTO); + + /** + * 根据tid和keyIds查询是否已存在该模板类型数据 + * @author zhaoqifeng + * @date 2020/11/2 10:31 + * @param appId + * @param tid + * @param keyIds + * @return java.util.List + */ + List selectListByKey(@Param("appId") String appId, @Param("tid") String tid, @Param("keyIds") String keyIds); } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PersonalTemplateService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PersonalTemplateService.java index f3f0da9b49..1d69a7b16a 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PersonalTemplateService.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PersonalTemplateService.java @@ -141,4 +141,15 @@ public interface PersonalTemplateService extends BaseService customerTemplateList(CustomerTemplateListFormDTO formDTO); + + /** + * 根据tid和keyIds查询是否已存在该模板类型数据 + * @author zhaoqifeng + * @date 2020/11/2 10:29 + * @param appId + * @param tid + * @param keyIds + * @return java.util.List + */ + List getListByKey(String appId, String tid, String keyIds); } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PersonalTemplateServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PersonalTemplateServiceImpl.java index 154cca9082..bdc7b6bf1d 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PersonalTemplateServiceImpl.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PersonalTemplateServiceImpl.java @@ -141,4 +141,19 @@ public class PersonalTemplateServiceImpl extends BaseServiceImpl + * @author zhaoqifeng + * @date 2020/11/2 10:29 + */ + @Override + public List getListByKey(String appId, String tid, String keyIds) { + return baseDao.selectListByKey(appId, tid, keyIds); + } + } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/SubscribeServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/SubscribeServiceImpl.java index 1521aa508a..4596bcf589 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/SubscribeServiceImpl.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/SubscribeServiceImpl.java @@ -180,6 +180,11 @@ public class SubscribeServiceImpl implements SubscribeService { String keywords = String.join(",", formDTO.getNameList()); List keyIdList = formDTO.getKidList().stream().map(Object::toString).collect(Collectors.toList()); String keyIds = String.join(",", keyIdList); + //根据tid和keyIds查询是否已存在该模板类型数据 + List list = personalTemplateService.getListByKey(formDTO.getAppId(), formDTO.getTid(), keyIds); + if (null != list && list.size() > NumConstant.ZERO) { + throw new RenException(formDTO.getTitle() + "已存在所选关键词[" + keywords + "]的模板"); + } //将公共模板存入数据库 PersonalTemplateDTO personalTemplateDTO = new PersonalTemplateDTO(); personalTemplateDTO.setCustomerId(authInfo.getCustomerId()); diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PersonalTemplateDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PersonalTemplateDao.xml index 7eab9a2e63..c6d4f4eecb 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PersonalTemplateDao.xml +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PersonalTemplateDao.xml @@ -103,5 +103,13 @@ AND pt.customer_id = #{customerId} AND pt.tid = #{publicId} + \ No newline at end of file From 82c11e230fca5f0328a7d009ae32367cc8a1deb1 Mon Sep 17 00:00:00 2001 From: sunyuchao Date: Mon, 2 Nov 2020 11:00:15 +0800 Subject: [PATCH 02/16] =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E6=A8=A1=E6=9D=BFId=20?= =?UTF-8?q?sql=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/epmet/dto/form/CustomerTemplateListFormDTO.java | 4 ++++ .../main/java/com/epmet/dto/form/GetTemplateListFormDTO.java | 4 ++++ .../com/epmet/service/impl/PersonalTemplateServiceImpl.java | 2 ++ .../src/main/resources/mapper/PersonalTemplateDao.xml | 5 ++++- 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/CustomerTemplateListFormDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/CustomerTemplateListFormDTO.java index 9dbabbfdbe..2fb11064f0 100644 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/CustomerTemplateListFormDTO.java +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/CustomerTemplateListFormDTO.java @@ -22,6 +22,10 @@ public class CustomerTemplateListFormDTO implements Serializable { */ @NotBlank(message="公共模板Id不能为空", groups = {AddUserInternalGroup.class}) private String publicId; + /** + * 模板关键词Id + */ + private String keyIds; public interface AddUserInternalGroup {} } diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/GetTemplateListFormDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/GetTemplateListFormDTO.java index 09fb259376..8bde81adf2 100644 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/GetTemplateListFormDTO.java +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/GetTemplateListFormDTO.java @@ -26,6 +26,10 @@ public class GetTemplateListFormDTO implements Serializable { * 模板类型(站内信提醒) */ private String templateType; + /** + * 模板关键词Id + */ + private String keyIds; public interface AddUserInternalGroup {} } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PersonalTemplateServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PersonalTemplateServiceImpl.java index bdc7b6bf1d..6aac8fdc8f 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PersonalTemplateServiceImpl.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PersonalTemplateServiceImpl.java @@ -127,6 +127,7 @@ public class PersonalTemplateServiceImpl extends BaseServiceImpl templateList(GetTemplateListFormDTO formDTO) { + formDTO.setKeyIds("5,4,2"); //根据客户Id、appId、模板类型查询小程序订阅消息模板列表 return baseDao.selectTemplateList(formDTO); } @@ -138,6 +139,7 @@ public class PersonalTemplateServiceImpl extends BaseServiceImpl customerTemplateList(CustomerTemplateListFormDTO formDTO) { + formDTO.setKeyIds("5,4,2"); return baseDao.selectCustomerTemplateList(formDTO); } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PersonalTemplateDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PersonalTemplateDao.xml index c6d4f4eecb..97452fa3b9 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PersonalTemplateDao.xml +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PersonalTemplateDao.xml @@ -86,7 +86,8 @@ AND customer_id = #{customerId} AND app_id = #{appId} AND title = #{templateType} - ORDER BY CREATED_TIME DESC + AND key_ids = '5,4,2' + ORDER BY created_time ASC Date: Tue, 3 Nov 2020 15:55:52 +0800 Subject: [PATCH 06/16] =?UTF-8?q?=E5=BE=BD=E7=AB=A0=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resi/mine/dto/from/BadgeListFormDTO.java | 30 +++++++ .../mine/dto/result/BadgeListResultDTO.java | 30 +++++++ .../badege/controller/BadgeController.java | 20 +++++ .../modules/badege/service/BadgeService.java | 8 ++ .../badege/service/impl/BadgeServiceImpl.java | 14 ++++ .../com/epmet/constant/BadgeConstant.java | 15 ++++ .../epmet/dto/form/UserBadgeListFormDTO.java | 26 ++++++ .../dto/result/UserBadgeListResultDTO.java | 46 +++++++++++ .../epmet/controller/UserBadgeController.java | 37 +++++++++ .../main/java/com/epmet/dao/UserBadgeDao.java | 32 ++++++++ .../java/com/epmet/redis/UserBadgeRedis.java | 50 ++++++++++++ .../com/epmet/service/UserBadgeService.java | 22 ++++++ .../service/impl/UserBadgeServiceImpl.java | 79 +++++++++++++++++++ .../main/resources/mapper/UserBadgeDao.xml | 37 +++++++++ 14 files changed, 446 insertions(+) create mode 100644 epmet-module/resi-mine/resi-mine-client/src/main/java/com/epmet/resi/mine/dto/from/BadgeListFormDTO.java create mode 100644 epmet-module/resi-mine/resi-mine-client/src/main/java/com/epmet/resi/mine/dto/result/BadgeListResultDTO.java create mode 100644 epmet-user/epmet-user-client/src/main/java/com/epmet/constant/BadgeConstant.java create mode 100644 epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/UserBadgeListFormDTO.java create mode 100644 epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/UserBadgeListResultDTO.java create mode 100644 epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserBadgeController.java create mode 100644 epmet-user/epmet-user-server/src/main/java/com/epmet/dao/UserBadgeDao.java create mode 100644 epmet-user/epmet-user-server/src/main/java/com/epmet/redis/UserBadgeRedis.java create mode 100644 epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserBadgeService.java create mode 100644 epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBadgeServiceImpl.java create mode 100644 epmet-user/epmet-user-server/src/main/resources/mapper/UserBadgeDao.xml diff --git a/epmet-module/resi-mine/resi-mine-client/src/main/java/com/epmet/resi/mine/dto/from/BadgeListFormDTO.java b/epmet-module/resi-mine/resi-mine-client/src/main/java/com/epmet/resi/mine/dto/from/BadgeListFormDTO.java new file mode 100644 index 0000000000..ef8ef67308 --- /dev/null +++ b/epmet-module/resi-mine/resi-mine-client/src/main/java/com/epmet/resi/mine/dto/from/BadgeListFormDTO.java @@ -0,0 +1,30 @@ +package com.epmet.resi.mine.dto.from; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Author zxc + * @DateTime 2020/11/3 11:07 上午 + */ +@Data +public class BadgeListFormDTO implements Serializable { + + private static final long serialVersionUID = 9082922684993474574L; + + public interface BadgeList{} + + /** + * 用户ID + */ + @NotBlank(message = "用户ID不能为空",groups = {BadgeList.class}) + private String userId; + + /** + * 客户ID + */ + @NotBlank(message = "客户ID不能为空",groups = {BadgeList.class}) + private String customerId; +} diff --git a/epmet-module/resi-mine/resi-mine-client/src/main/java/com/epmet/resi/mine/dto/result/BadgeListResultDTO.java b/epmet-module/resi-mine/resi-mine-client/src/main/java/com/epmet/resi/mine/dto/result/BadgeListResultDTO.java new file mode 100644 index 0000000000..41f82feed4 --- /dev/null +++ b/epmet-module/resi-mine/resi-mine-client/src/main/java/com/epmet/resi/mine/dto/result/BadgeListResultDTO.java @@ -0,0 +1,30 @@ +package com.epmet.resi.mine.dto.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author zxc + * @DateTime 2020/11/3 11:08 上午 + */ +@Data +public class BadgeListResultDTO implements Serializable { + + private static final long serialVersionUID = -6542233940679158922L; + + /** + * 徽章ID + */ + private String badgeId; + + /** + * 徽章图片地址 + */ + private String badgeIcon; + + /** + * 徽章是否点亮 + */ + private String isOpened; +} diff --git a/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/controller/BadgeController.java b/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/controller/BadgeController.java index 9d98bfa74a..059f37972f 100644 --- a/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/controller/BadgeController.java +++ b/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/controller/BadgeController.java @@ -1,8 +1,18 @@ package com.epmet.modules.badege.controller; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.modules.badege.service.BadgeService; +import com.epmet.resi.mine.dto.from.BadgeListFormDTO; +import com.epmet.resi.mine.dto.result.BadgeListResultDTO; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.util.List; + /** * @Author zxc * @DateTime 2020/11/3 10:42 上午 @@ -10,4 +20,14 @@ import org.springframework.web.bind.annotation.RestController; @RestController @RequestMapping("badge") public class BadgeController { + + @Autowired + private BadgeService badgeService; + + @PostMapping("list") + public Result> getBadgeList(@RequestBody BadgeListFormDTO badgeListFormDTO){ + ValidatorUtils.validateEntity(badgeListFormDTO, BadgeListFormDTO.BadgeList.class); + return new Result>().ok(badgeService.getBadgeList(badgeListFormDTO)); + } + } diff --git a/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/service/BadgeService.java b/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/service/BadgeService.java index 18c5f38926..1aa44135c9 100644 --- a/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/service/BadgeService.java +++ b/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/service/BadgeService.java @@ -1,8 +1,16 @@ package com.epmet.modules.badege.service; +import com.epmet.resi.mine.dto.from.BadgeListFormDTO; +import com.epmet.resi.mine.dto.result.BadgeListResultDTO; + +import java.util.List; + /** * @Author zxc * @DateTime 2020/11/3 10:52 上午 */ public interface BadgeService { + + List getBadgeList(BadgeListFormDTO badgeListFormDTO); + } diff --git a/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/service/impl/BadgeServiceImpl.java b/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/service/impl/BadgeServiceImpl.java index 6a848eb868..3d6c5f02d2 100644 --- a/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/service/impl/BadgeServiceImpl.java +++ b/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/service/impl/BadgeServiceImpl.java @@ -1,9 +1,15 @@ package com.epmet.modules.badege.service.impl; +import com.epmet.feign.EpmetUserOpenFeignClient; import com.epmet.modules.badege.service.BadgeService; +import com.epmet.resi.mine.dto.from.BadgeListFormDTO; +import com.epmet.resi.mine.dto.result.BadgeListResultDTO; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.List; + /** * @Author zxc * @DateTime 2020/11/3 10:53 上午 @@ -11,4 +17,12 @@ import org.springframework.stereotype.Service; @Service @Slf4j public class BadgeServiceImpl implements BadgeService { + + @Autowired + private EpmetUserOpenFeignClient epmetUserOpenFeignClient; + + @Override + public List getBadgeList(BadgeListFormDTO badgeListFormDTO) { + return null; + } } diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/constant/BadgeConstant.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/constant/BadgeConstant.java new file mode 100644 index 0000000000..e95fc2a5c0 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/constant/BadgeConstant.java @@ -0,0 +1,15 @@ +package com.epmet.constant; + +/** + * @Author zxc + * @DateTime 2020/11/3 2:45 下午 + */ +public interface BadgeConstant { + + String BADGE_KEY = "epmet:badge:"; + + String BADGE = "badge"; + + String DEFAULT_CUSTOMER = "default"; + +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/UserBadgeListFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/UserBadgeListFormDTO.java new file mode 100644 index 0000000000..c77cee2d1f --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/UserBadgeListFormDTO.java @@ -0,0 +1,26 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Author zxc + * @DateTime 2020/11/3 11:07 上午 + */ +@Data +public class UserBadgeListFormDTO implements Serializable { + + private static final long serialVersionUID = 9082922684993474574L; + + /** + * 用户ID + */ + private String userId; + + /** + * 客户ID + */ + private String customerId; +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/UserBadgeListResultDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/UserBadgeListResultDTO.java new file mode 100644 index 0000000000..a9db8612a2 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/UserBadgeListResultDTO.java @@ -0,0 +1,46 @@ +package com.epmet.dto.result; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author zxc + * @DateTime 2020/11/3 11:08 上午 + */ +@Data +public class UserBadgeListResultDTO implements Serializable { + + private static final long serialVersionUID = -6542233940679158922L; + + /** + * 徽章ID + */ + private String badgeId; + + /** + * 徽章图片地址 + */ + private String badgeIcon; + + /** + * 徽章是否点亮 + */ + private String isOpened; + @JsonIgnore + private String customerId; + @JsonIgnore + private String badgeName; + @JsonIgnore + private String fixationBadgeType; + @JsonIgnore + private Boolean status; + + public UserBadgeListResultDTO() { + this.badgeId = ""; + this.badgeIcon = ""; + this.isOpened = "0"; + this.status = false; + } +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserBadgeController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserBadgeController.java new file mode 100644 index 0000000000..a11fc74409 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserBadgeController.java @@ -0,0 +1,37 @@ +package com.epmet.controller; + +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.form.UserBadgeListFormDTO; +import com.epmet.dto.result.UserBadgeListResultDTO; +import com.epmet.service.UserBadgeService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +/** + * @Author zxc + * @DateTime 2020/11/3 11:16 上午 + */ +@RestController +@RequestMapping("badge") +public class UserBadgeController { + + @Autowired + private UserBadgeService userBadgeService; + + /** + * @Description 查询已经点亮的徽章 + * @Param userBadgeListFormDTO + * @author zxc + * @date 2020/11/3 1:33 下午 + */ + @PostMapping("badgelist") + public Result> selectBadgeList(@RequestBody UserBadgeListFormDTO userBadgeListFormDTO){ + return new Result>().ok(userBadgeService.selectBadgeList(userBadgeListFormDTO)); + } + +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/UserBadgeDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/UserBadgeDao.java new file mode 100644 index 0000000000..d836a2e510 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/UserBadgeDao.java @@ -0,0 +1,32 @@ +package com.epmet.dao; + +import com.epmet.dto.form.UserBadgeListFormDTO; +import com.epmet.dto.result.UserBadgeListResultDTO; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * @Author zxc + * @DateTime 2020/11/3 1:22 下午 + */ +@Mapper +public interface UserBadgeDao { + + /** + * @Description 查询已经点亮的徽章 + * @Param userBadgeListFormDTO + * @author zxc + * @date 2020/11/3 1:33 下午 + */ + List selectBadgeList(UserBadgeListFormDTO userBadgeListFormDTO); + + /** + * @Description 查询默认徽章和改名后的徽章 + * @Param userBadgeListFormDTO + * @author zxc + * @date 2020/11/3 3:11 下午 + */ + List selectAllBadge(UserBadgeListFormDTO userBadgeListFormDTO); + +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/redis/UserBadgeRedis.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/redis/UserBadgeRedis.java new file mode 100644 index 0000000000..56492844b1 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/redis/UserBadgeRedis.java @@ -0,0 +1,50 @@ +package com.epmet.redis; + +import com.alibaba.fastjson.JSON; +import com.epmet.commons.tools.redis.RedisUtils; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.constant.BadgeConstant; +import com.epmet.dto.result.UserBadgeListResultDTO; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** + * @Author zxc + * @DateTime 2020/11/3 2:21 下午 + */ +@Component +public class UserBadgeRedis { + + @Autowired + private RedisUtils redisUtils; + + /** + * @Description 获取徽章信息 + * @Param customerId + * @author zxc + * @date 2020/11/3 2:50 下午 + */ + public List getUserBadge(String customerId){ + Object userBadge = redisUtils.hGet(BadgeConstant.BADGE_KEY + customerId, BadgeConstant.BADGE); + if (null == userBadge){ + return new ArrayList<>(); + } + return JSON.parseArray(userBadge.toString(), UserBadgeListResultDTO.class); + } + + /** + * @Description 存放徽章信息 + * @Param userBadge + * @Param customerId + * @author zxc + * @date 2020/11/3 2:51 下午 + */ + public void setUserBadge(List userBadge,String customerId){ + redisUtils.hSet(BadgeConstant.BADGE_KEY+customerId,BadgeConstant.BADGE, JSON.toJSON(userBadge).toString(),-1); + } + +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserBadgeService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserBadgeService.java new file mode 100644 index 0000000000..367f16993b --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserBadgeService.java @@ -0,0 +1,22 @@ +package com.epmet.service; + +import com.epmet.dto.form.UserBadgeListFormDTO; +import com.epmet.dto.result.UserBadgeListResultDTO; + +import java.util.List; + +/** + * @Author zxc + * @DateTime 2020/11/3 11:18 上午 + */ +public interface UserBadgeService { + + /** + * @Description 查询已经点亮的徽章 + * @Param userBadgeListFormDTO + * @author zxc + * @date 2020/11/3 1:33 下午 + */ + List selectBadgeList(UserBadgeListFormDTO userBadgeListFormDTO); + +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBadgeServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBadgeServiceImpl.java new file mode 100644 index 0000000000..7ee534b2f6 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBadgeServiceImpl.java @@ -0,0 +1,79 @@ +package com.epmet.service.impl; + +import com.epmet.constant.BadgeConstant; +import com.epmet.dao.UserBadgeDao; +import com.epmet.dto.form.UserBadgeListFormDTO; +import com.epmet.dto.result.UserBadgeListResultDTO; +import com.epmet.redis.UserBadgeRedis; +import com.epmet.service.UserBadgeService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * @Author zxc + * @DateTime 2020/11/3 11:18 上午 + */ +@Service +@Slf4j +public class UserBadgeServiceImpl implements UserBadgeService { + + @Autowired + private UserBadgeDao userBadgeDao; + @Autowired + private UserBadgeRedis userBadgeRedis; + + /** + * @Description 查询已经点亮的徽章 + * @Param userBadgeListFormDTO + * @author zxc + * @date 2020/11/3 1:33 下午 + */ + @Override + public List selectBadgeList(UserBadgeListFormDTO userBadgeListFormDTO) { + List userBadge = userBadgeRedis.getUserBadge(userBadgeListFormDTO.getCustomerId()); + if (CollectionUtils.isEmpty(userBadge)){ + List resultUserBadge = new ArrayList<>(); + List userBadgeListResultDTOS = userBadgeDao.selectAllBadge(userBadgeListFormDTO); + if (!CollectionUtils.isEmpty(userBadgeListResultDTOS)){ + Map> groupByCustomer = userBadgeListResultDTOS.stream().collect(Collectors.groupingBy(UserBadgeListResultDTO::getCustomerId)); + resultUserBadge.addAll(groupByCustomer.get(BadgeConstant.DEFAULT_CUSTOMER)); + List badgeByCustomer = groupByCustomer.get(userBadgeListFormDTO.getCustomerId()); + resultUserBadge.forEach(r -> { + badgeByCustomer.forEach(b -> { + if (r.getBadgeId().equals(b.getBadgeId())){ + BeanUtils.copyProperties(b,r); + } + }); + }); + userBadgeRedis.setUserBadge(resultUserBadge,userBadgeListFormDTO.getCustomerId()); + } + } + userBadge = userBadgeRedis.getUserBadge(userBadgeListFormDTO.getCustomerId()); + List userBadgeListResultDTOS = userBadgeDao.selectBadgeList(userBadgeListFormDTO); + if (CollectionUtils.isEmpty(userBadgeListResultDTOS)){ + return userBadge; + } + userBadge.forEach(u -> { + userBadgeListResultDTOS.forEach(badge -> { + if (u.getBadgeId().equals(badge.getBadgeId())){ + badge.setBadgeIcon(u.getBadgeIcon()); + u.setStatus(true); + } + }); + }); + userBadge.forEach(u -> { + if (!u.getStatus()){ + userBadgeListResultDTOS.add(u); + } + }); + return userBadgeListResultDTOS; + } +} diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/UserBadgeDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/UserBadgeDao.xml new file mode 100644 index 0000000000..b709353ce5 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/UserBadgeDao.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + From c5dadab50bfeace1bdde0e85601256d064f1b08e Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Tue, 3 Nov 2020 16:03:57 +0800 Subject: [PATCH 07/16] =?UTF-8?q?=E5=BE=BD=E7=AB=A0=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../badege/service/impl/BadgeServiceImpl.java | 17 ++++++++++++++++- .../epmet/feign/EpmetUserOpenFeignClient.java | 10 ++++++++++ .../EpmetUserOpenFeignClientFallback.java | 5 +++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/service/impl/BadgeServiceImpl.java b/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/service/impl/BadgeServiceImpl.java index 3d6c5f02d2..e78f745c40 100644 --- a/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/service/impl/BadgeServiceImpl.java +++ b/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/service/impl/BadgeServiceImpl.java @@ -1,5 +1,10 @@ package com.epmet.modules.badege.service.impl; +import com.epmet.commons.tools.exception.RenException; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.form.UserBadgeListFormDTO; +import com.epmet.dto.result.UserBadgeListResultDTO; import com.epmet.feign.EpmetUserOpenFeignClient; import com.epmet.modules.badege.service.BadgeService; import com.epmet.resi.mine.dto.from.BadgeListFormDTO; @@ -8,6 +13,7 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.ArrayList; import java.util.List; /** @@ -23,6 +29,15 @@ public class BadgeServiceImpl implements BadgeService { @Override public List getBadgeList(BadgeListFormDTO badgeListFormDTO) { - return null; + UserBadgeListFormDTO form = ConvertUtils.sourceToTarget(badgeListFormDTO, UserBadgeListFormDTO.class); + Result> listResult = epmetUserOpenFeignClient.selectBadgeList(form); + if (!listResult.success()){ + throw new RenException("获取徽章点亮列表失败......"); + } + if (null == listResult.getData()){ + return new ArrayList<>(); + } + List result = ConvertUtils.sourceToTarget(listResult.getData(), BadgeListResultDTO.class); + return result; } } diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java index 2c7d2555cd..e56d27287c 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java @@ -337,4 +337,14 @@ public interface EpmetUserOpenFeignClient { */ @PostMapping("/epmetuser/userresiinfo/edituserinfo") Result editUserInfo(@RequestBody EditInfoFormDTO formDTO); + + /** + * @Description 查询已经点亮的徽章 + * @Param userBadgeListFormDTO + * @author zxc + * @date 2020/11/3 1:33 下午 + */ + @PostMapping("/epmetuser/badge/badgelist") + Result> selectBadgeList(@RequestBody UserBadgeListFormDTO userBadgeListFormDTO); + } diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java index a2de76e587..46fad76aa3 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java @@ -225,4 +225,9 @@ public class EpmetUserOpenFeignClientFallback implements EpmetUserOpenFeignClien public Result editUserInfo(EditInfoFormDTO formDTO) { return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "editUserInfo", formDTO); } + + @Override + public Result> selectBadgeList(UserBadgeListFormDTO userBadgeListFormDTO) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "selectBadgeList", userBadgeListFormDTO); + } } From 54219febb49dcc0b219f68a4b51be7769e772323 Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Wed, 4 Nov 2020 11:02:10 +0800 Subject: [PATCH 08/16] =?UTF-8?q?=E5=BE=BD=E7=AB=A0=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resi/mine/dto/from/BadgeListFormDTO.java | 1 - .../resi/mine/dto/from/OperListFormDTO.java | 21 +++++++ .../mine/dto/result/BadgeListResultDTO.java | 2 + .../mine/dto/result/OperListResultDTO.java | 46 ++++++++++++++ .../badege/controller/BadgeController.java | 26 +++++++- .../modules/badege/service/BadgeService.java | 19 +++++- .../badege/service/impl/BadgeServiceImpl.java | 39 +++++++++++- .../com/epmet/constant/BadgeConstant.java | 8 +++ .../epmet/dto/form/UserBadgeListFormDTO.java | 11 +++- .../epmet/dto/form/UserOperListFormDTO.java | 28 +++++++++ .../dto/result/UserBadgeListResultDTO.java | 3 + .../dto/result/UserOperListResultDTO.java | 62 +++++++++++++++++++ .../epmet/feign/EpmetUserOpenFeignClient.java | 8 +++ .../EpmetUserOpenFeignClientFallback.java | 5 ++ .../epmet/controller/UserBadgeController.java | 13 ++++ .../main/java/com/epmet/dao/UserBadgeDao.java | 18 ++++++ .../java/com/epmet/redis/UserBadgeRedis.java | 7 +-- .../com/epmet/service/UserBadgeService.java | 10 +++ .../service/impl/UserBadgeServiceImpl.java | 59 ++++++++++++++++-- .../main/resources/mapper/UserBadgeDao.xml | 41 +++++++++--- 20 files changed, 400 insertions(+), 27 deletions(-) create mode 100644 epmet-module/resi-mine/resi-mine-client/src/main/java/com/epmet/resi/mine/dto/from/OperListFormDTO.java create mode 100644 epmet-module/resi-mine/resi-mine-client/src/main/java/com/epmet/resi/mine/dto/result/OperListResultDTO.java create mode 100644 epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/UserOperListFormDTO.java create mode 100644 epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/UserOperListResultDTO.java diff --git a/epmet-module/resi-mine/resi-mine-client/src/main/java/com/epmet/resi/mine/dto/from/BadgeListFormDTO.java b/epmet-module/resi-mine/resi-mine-client/src/main/java/com/epmet/resi/mine/dto/from/BadgeListFormDTO.java index ef8ef67308..c5ace2985f 100644 --- a/epmet-module/resi-mine/resi-mine-client/src/main/java/com/epmet/resi/mine/dto/from/BadgeListFormDTO.java +++ b/epmet-module/resi-mine/resi-mine-client/src/main/java/com/epmet/resi/mine/dto/from/BadgeListFormDTO.java @@ -19,7 +19,6 @@ public class BadgeListFormDTO implements Serializable { /** * 用户ID */ - @NotBlank(message = "用户ID不能为空",groups = {BadgeList.class}) private String userId; /** diff --git a/epmet-module/resi-mine/resi-mine-client/src/main/java/com/epmet/resi/mine/dto/from/OperListFormDTO.java b/epmet-module/resi-mine/resi-mine-client/src/main/java/com/epmet/resi/mine/dto/from/OperListFormDTO.java new file mode 100644 index 0000000000..a0f7b7f919 --- /dev/null +++ b/epmet-module/resi-mine/resi-mine-client/src/main/java/com/epmet/resi/mine/dto/from/OperListFormDTO.java @@ -0,0 +1,21 @@ +package com.epmet.resi.mine.dto.from; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Author zxc + * @DateTime 2020/11/3 4:18 下午 + */ +@Data +public class OperListFormDTO implements Serializable { + + private static final long serialVersionUID = -1872129597916414752L; + + public interface OperList{} + + @NotBlank(message = "客户ID不能为空",groups = {OperList.class}) + private String customerId; +} diff --git a/epmet-module/resi-mine/resi-mine-client/src/main/java/com/epmet/resi/mine/dto/result/BadgeListResultDTO.java b/epmet-module/resi-mine/resi-mine-client/src/main/java/com/epmet/resi/mine/dto/result/BadgeListResultDTO.java index 41f82feed4..d32230501e 100644 --- a/epmet-module/resi-mine/resi-mine-client/src/main/java/com/epmet/resi/mine/dto/result/BadgeListResultDTO.java +++ b/epmet-module/resi-mine/resi-mine-client/src/main/java/com/epmet/resi/mine/dto/result/BadgeListResultDTO.java @@ -27,4 +27,6 @@ public class BadgeListResultDTO implements Serializable { * 徽章是否点亮 */ private String isOpened; + + private String badgeType; } diff --git a/epmet-module/resi-mine/resi-mine-client/src/main/java/com/epmet/resi/mine/dto/result/OperListResultDTO.java b/epmet-module/resi-mine/resi-mine-client/src/main/java/com/epmet/resi/mine/dto/result/OperListResultDTO.java new file mode 100644 index 0000000000..044d118a0f --- /dev/null +++ b/epmet-module/resi-mine/resi-mine-client/src/main/java/com/epmet/resi/mine/dto/result/OperListResultDTO.java @@ -0,0 +1,46 @@ +package com.epmet.resi.mine.dto.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author zxc + * @DateTime 2020/11/3 4:20 下午 + */ +@Data +public class OperListResultDTO implements Serializable { + + private static final long serialVersionUID = -6185696177370545937L; + + /** + * 徽章ID + */ + private String badgeId; + + /** + * 徽章名字 + */ + private String badgeName; + + /** + * 点亮状态 yes:已点亮,no:未点亮 + */ + private String isLighted; + + /** + * 是否认证 yes 认证 no 已认证 + */ + private String isCertificated; + + /** + * 徽章图片地址 + */ + private String badgeIcon; + + /** + * 是否被驳回 true:已驳回,false:未驳回 + */ + private Boolean isReject; + +} diff --git a/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/controller/BadgeController.java b/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/controller/BadgeController.java index 059f37972f..fe519e7cbb 100644 --- a/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/controller/BadgeController.java +++ b/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/controller/BadgeController.java @@ -1,10 +1,14 @@ package com.epmet.modules.badege.controller; +import com.epmet.commons.tools.annotation.LoginUser; +import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.modules.badege.service.BadgeService; import com.epmet.resi.mine.dto.from.BadgeListFormDTO; +import com.epmet.resi.mine.dto.from.OperListFormDTO; import com.epmet.resi.mine.dto.result.BadgeListResultDTO; +import com.epmet.resi.mine.dto.result.OperListResultDTO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -24,10 +28,28 @@ public class BadgeController { @Autowired private BadgeService badgeService; + /** + * @Description 个人中心-获取个人徽章点亮列表 + * @Param badgeListFormDTO + * @author zxc + * @date 2020/11/3 4:11 下午 + */ @PostMapping("list") - public Result> getBadgeList(@RequestBody BadgeListFormDTO badgeListFormDTO){ + public Result> getBadgeList(@LoginUser TokenDto tokenDto,@RequestBody BadgeListFormDTO badgeListFormDTO){ ValidatorUtils.validateEntity(badgeListFormDTO, BadgeListFormDTO.BadgeList.class); - return new Result>().ok(badgeService.getBadgeList(badgeListFormDTO)); + return new Result>().ok(badgeService.getBadgeList(tokenDto,badgeListFormDTO)); + } + + /** + * @Description 个人中心-获取徽章可操作列表(点亮,取消,认证) + * @Param operListFormDTO + * @author zxc + * @date 2020/11/3 4:28 下午 + */ + @PostMapping("operlist") + public Result> getOperList(@LoginUser TokenDto tokenDto,@RequestBody OperListFormDTO operListFormDTO){ + ValidatorUtils.validateEntity(operListFormDTO, OperListFormDTO.OperList.class); + return new Result>().ok(badgeService.getOperList(tokenDto,operListFormDTO)); } } diff --git a/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/service/BadgeService.java b/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/service/BadgeService.java index 1aa44135c9..fe1d1c140e 100644 --- a/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/service/BadgeService.java +++ b/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/service/BadgeService.java @@ -1,7 +1,10 @@ package com.epmet.modules.badege.service; +import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.resi.mine.dto.from.BadgeListFormDTO; +import com.epmet.resi.mine.dto.from.OperListFormDTO; import com.epmet.resi.mine.dto.result.BadgeListResultDTO; +import com.epmet.resi.mine.dto.result.OperListResultDTO; import java.util.List; @@ -11,6 +14,20 @@ import java.util.List; */ public interface BadgeService { - List getBadgeList(BadgeListFormDTO badgeListFormDTO); + /** + * @Description 个人中心-获取个人徽章点亮列表 + * @Param badgeListFormDTO + * @author zxc + * @date 2020/11/3 4:11 下午 + */ + List getBadgeList(TokenDto tokenDto,BadgeListFormDTO badgeListFormDTO); + + /** + * @Description 个人中心-获取徽章可操作列表(点亮,取消,认证) + * @Param operListFormDTO + * @author zxc + * @date 2020/11/3 4:28 下午 + */ + List getOperList(TokenDto tokenDto,OperListFormDTO operListFormDTO); } diff --git a/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/service/impl/BadgeServiceImpl.java b/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/service/impl/BadgeServiceImpl.java index e78f745c40..6e1d3ae1e9 100644 --- a/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/service/impl/BadgeServiceImpl.java +++ b/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/service/impl/BadgeServiceImpl.java @@ -1,14 +1,19 @@ package com.epmet.modules.badege.service.impl; import com.epmet.commons.tools.exception.RenException; +import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.form.UserBadgeListFormDTO; +import com.epmet.dto.form.UserOperListFormDTO; import com.epmet.dto.result.UserBadgeListResultDTO; +import com.epmet.dto.result.UserOperListResultDTO; import com.epmet.feign.EpmetUserOpenFeignClient; import com.epmet.modules.badege.service.BadgeService; import com.epmet.resi.mine.dto.from.BadgeListFormDTO; +import com.epmet.resi.mine.dto.from.OperListFormDTO; import com.epmet.resi.mine.dto.result.BadgeListResultDTO; +import com.epmet.resi.mine.dto.result.OperListResultDTO; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -27,9 +32,17 @@ public class BadgeServiceImpl implements BadgeService { @Autowired private EpmetUserOpenFeignClient epmetUserOpenFeignClient; + /** + * @Description 个人中心-获取个人徽章点亮列表 + * @Param badgeListFormDTO + * @author zxc + * @date 2020/11/3 4:11 下午 + */ @Override - public List getBadgeList(BadgeListFormDTO badgeListFormDTO) { - UserBadgeListFormDTO form = ConvertUtils.sourceToTarget(badgeListFormDTO, UserBadgeListFormDTO.class); + public List getBadgeList(TokenDto tokenDto,BadgeListFormDTO badgeListFormDTO) { + UserBadgeListFormDTO form = new UserBadgeListFormDTO(); + form.setCustomerId(badgeListFormDTO.getCustomerId()); + form.setUserId(tokenDto.getUserId()); Result> listResult = epmetUserOpenFeignClient.selectBadgeList(form); if (!listResult.success()){ throw new RenException("获取徽章点亮列表失败......"); @@ -40,4 +53,26 @@ public class BadgeServiceImpl implements BadgeService { List result = ConvertUtils.sourceToTarget(listResult.getData(), BadgeListResultDTO.class); return result; } + + /** + * @Description 个人中心-获取徽章可操作列表(点亮,取消,认证) + * @Param operListFormDTO + * @author zxc + * @date 2020/11/3 4:28 下午 + */ + @Override + public List getOperList(TokenDto tokenDto,OperListFormDTO operListFormDTO) { + UserOperListFormDTO userOperListFormDTO = new UserOperListFormDTO(); + userOperListFormDTO.setCustomerId(operListFormDTO.getCustomerId()); + userOperListFormDTO.setUserId(tokenDto.getUserId()); + Result> listResult = epmetUserOpenFeignClient.selectOperList(userOperListFormDTO); + if (!listResult.success()){ + throw new RenException("获取徽章列表失败......"); + } + if (null == listResult.getData()){ + return new ArrayList<>(); + } + List result = ConvertUtils.sourceToTarget(listResult.getData(), OperListResultDTO.class); + return result; + } } diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/constant/BadgeConstant.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/constant/BadgeConstant.java index e95fc2a5c0..7c2a6313c2 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/constant/BadgeConstant.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/constant/BadgeConstant.java @@ -12,4 +12,12 @@ public interface BadgeConstant { String DEFAULT_CUSTOMER = "default"; + String YES = "yes"; + + String NO = "no"; + + String REJECTED = "rejected"; + + String APPROVED = "approved"; + } diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/UserBadgeListFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/UserBadgeListFormDTO.java index c77cee2d1f..2cb7f728dc 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/UserBadgeListFormDTO.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/UserBadgeListFormDTO.java @@ -2,7 +2,6 @@ package com.epmet.dto.form; import lombok.Data; -import javax.validation.constraints.NotBlank; import java.io.Serializable; /** @@ -12,7 +11,7 @@ import java.io.Serializable; @Data public class UserBadgeListFormDTO implements Serializable { - private static final long serialVersionUID = 9082922684993474574L; + private static final long serialVersionUID = 9002922684993474574L; /** * 用户ID @@ -23,4 +22,12 @@ public class UserBadgeListFormDTO implements Serializable { * 客户ID */ private String customerId; + + public UserBadgeListFormDTO(String userId, String customerId) { + this.userId = userId; + this.customerId = customerId; + } + + public UserBadgeListFormDTO() { + } } diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/UserOperListFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/UserOperListFormDTO.java new file mode 100644 index 0000000000..84578f7abb --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/UserOperListFormDTO.java @@ -0,0 +1,28 @@ +package com.epmet.dto.form; + +import lombok.AllArgsConstructor; +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author zxc + * @DateTime 2020/11/3 4:18 下午 + */ +@Data +public class UserOperListFormDTO implements Serializable { + + private static final long serialVersionUID = -1872129597916414712L; + + private String userId; + + private String customerId; + + public UserOperListFormDTO(String userId, String customerId) { + this.userId = userId; + this.customerId = customerId; + } + + public UserOperListFormDTO() { + } +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/UserBadgeListResultDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/UserBadgeListResultDTO.java index a9db8612a2..19fce3bb3c 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/UserBadgeListResultDTO.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/UserBadgeListResultDTO.java @@ -28,6 +28,9 @@ public class UserBadgeListResultDTO implements Serializable { * 徽章是否点亮 */ private String isOpened; + + private String badgeType; + @JsonIgnore private String customerId; @JsonIgnore diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/UserOperListResultDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/UserOperListResultDTO.java new file mode 100644 index 0000000000..4e587fa5cd --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/UserOperListResultDTO.java @@ -0,0 +1,62 @@ +package com.epmet.dto.result; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author zxc + * @DateTime 2020/11/3 4:20 下午 + */ +@Data +public class UserOperListResultDTO implements Serializable { + + private static final long serialVersionUID = -6185696177370545937L; + + /** + * 徽章ID + */ + private String badgeId; + + /** + * 徽章名字 + */ + private String badgeName; + + /** + * 点亮状态 yes:已点亮,no:未点亮 + */ + private String isLighted; + + /** + * 是否认证 yes 认证 no 已认证 + */ + private String isCertificated; + + /** + * 徽章图片地址 + */ + private String badgeIcon; + + /** + * 是否被驳回 true:已驳回,false:未驳回 + */ + private Boolean isReject; + + @JsonIgnore + private String customerId; + @JsonIgnore + private String isOpened; + @JsonIgnore + private String auditStatus; + + public UserOperListResultDTO() { + this.badgeId = ""; + this.badgeName = ""; + this.isLighted = "no"; + this.isCertificated = "no"; + this.badgeIcon = ""; + this.isReject = false; + } +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java index e56d27287c..8ab0fd12b2 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java @@ -347,4 +347,12 @@ public interface EpmetUserOpenFeignClient { @PostMapping("/epmetuser/badge/badgelist") Result> selectBadgeList(@RequestBody UserBadgeListFormDTO userBadgeListFormDTO); + /** + * @Description 个人中心-获取徽章可操作列表(点亮,取消,认证) + * @Param operListFormDTO + * @author zxc + * @date 2020/11/3 4:28 下午 + */ + @PostMapping("/epmetuser/badge/badgeoperlist") + Result> selectOperList(@RequestBody UserOperListFormDTO userOperListFormDTO); } diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java index 46fad76aa3..aa5db5968a 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java @@ -230,4 +230,9 @@ public class EpmetUserOpenFeignClientFallback implements EpmetUserOpenFeignClien public Result> selectBadgeList(UserBadgeListFormDTO userBadgeListFormDTO) { return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "selectBadgeList", userBadgeListFormDTO); } + + @Override + public Result> selectOperList(UserOperListFormDTO userOperListFormDTO) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "selectOperList", userOperListFormDTO); + } } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserBadgeController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserBadgeController.java index a11fc74409..5b8f9d46e6 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserBadgeController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserBadgeController.java @@ -2,7 +2,9 @@ package com.epmet.controller; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.form.UserBadgeListFormDTO; +import com.epmet.dto.form.UserOperListFormDTO; import com.epmet.dto.result.UserBadgeListResultDTO; +import com.epmet.dto.result.UserOperListResultDTO; import com.epmet.service.UserBadgeService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; @@ -34,4 +36,15 @@ public class UserBadgeController { return new Result>().ok(userBadgeService.selectBadgeList(userBadgeListFormDTO)); } + /** + * @Description 个人中心-获取徽章可操作列表(点亮,取消,认证) + * @Param userOperListFormDTO + * @author zxc + * @date 2020/11/3 4:42 下午 + */ + @PostMapping("badgeoperlist") + public Result> selectOperList(@RequestBody UserOperListFormDTO userOperListFormDTO){ + return new Result>().ok(userBadgeService.selectOperList(userOperListFormDTO)); + } + } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/UserBadgeDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/UserBadgeDao.java index d836a2e510..65eec9d1ac 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/UserBadgeDao.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/UserBadgeDao.java @@ -2,7 +2,9 @@ package com.epmet.dao; import com.epmet.dto.form.UserBadgeListFormDTO; import com.epmet.dto.result.UserBadgeListResultDTO; +import com.epmet.dto.result.UserOperListResultDTO; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; import java.util.List; @@ -29,4 +31,20 @@ public interface UserBadgeDao { */ List selectAllBadge(UserBadgeListFormDTO userBadgeListFormDTO); + /** + * @Description 查询徽章认证记录 + * @Param userId + * @author zxc + * @date 2020/11/3 5:25 下午 + */ + List selectAuthRecord(@Param("userId")String userId); + + /** + * @Description 根据UserId查询个人徽章点亮信息 + * @Param userId + * @author zxc + * @date 2020/11/4 9:32 上午 + */ + List selectBadgeByUserId(@Param("userId")String userId); + } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/redis/UserBadgeRedis.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/redis/UserBadgeRedis.java index 56492844b1..727c467e12 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/redis/UserBadgeRedis.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/redis/UserBadgeRedis.java @@ -28,12 +28,9 @@ public class UserBadgeRedis { * @author zxc * @date 2020/11/3 2:50 下午 */ - public List getUserBadge(String customerId){ + public Object getUserBadge(String customerId){ Object userBadge = redisUtils.hGet(BadgeConstant.BADGE_KEY + customerId, BadgeConstant.BADGE); - if (null == userBadge){ - return new ArrayList<>(); - } - return JSON.parseArray(userBadge.toString(), UserBadgeListResultDTO.class); + return userBadge; } /** diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserBadgeService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserBadgeService.java index 367f16993b..fe5737a2d3 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserBadgeService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserBadgeService.java @@ -1,7 +1,9 @@ package com.epmet.service; import com.epmet.dto.form.UserBadgeListFormDTO; +import com.epmet.dto.form.UserOperListFormDTO; import com.epmet.dto.result.UserBadgeListResultDTO; +import com.epmet.dto.result.UserOperListResultDTO; import java.util.List; @@ -19,4 +21,12 @@ public interface UserBadgeService { */ List selectBadgeList(UserBadgeListFormDTO userBadgeListFormDTO); + /** + * @Description 个人中心-获取徽章可操作列表(点亮,取消,认证) + * @Param userOperListFormDTO + * @author zxc + * @date 2020/11/3 4:42 下午 + */ + List selectOperList(UserOperListFormDTO userOperListFormDTO); + } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBadgeServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBadgeServiceImpl.java index 7ee534b2f6..261f7e7bdc 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBadgeServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBadgeServiceImpl.java @@ -1,9 +1,14 @@ package com.epmet.service.impl; +import com.alibaba.fastjson.JSON; +import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.constant.BadgeConstant; import com.epmet.dao.UserBadgeDao; import com.epmet.dto.form.UserBadgeListFormDTO; +import com.epmet.dto.form.UserOperListFormDTO; import com.epmet.dto.result.UserBadgeListResultDTO; +import com.epmet.dto.result.UserOperListResultDTO; import com.epmet.redis.UserBadgeRedis; import com.epmet.service.UserBadgeService; import lombok.extern.slf4j.Slf4j; @@ -38,8 +43,8 @@ public class UserBadgeServiceImpl implements UserBadgeService { */ @Override public List selectBadgeList(UserBadgeListFormDTO userBadgeListFormDTO) { - List userBadge = userBadgeRedis.getUserBadge(userBadgeListFormDTO.getCustomerId()); - if (CollectionUtils.isEmpty(userBadge)){ + Object userBadge = userBadgeRedis.getUserBadge(userBadgeListFormDTO.getCustomerId()); + if (null == userBadge){ List resultUserBadge = new ArrayList<>(); List userBadgeListResultDTOS = userBadgeDao.selectAllBadge(userBadgeListFormDTO); if (!CollectionUtils.isEmpty(userBadgeListResultDTOS)){ @@ -54,14 +59,15 @@ public class UserBadgeServiceImpl implements UserBadgeService { }); }); userBadgeRedis.setUserBadge(resultUserBadge,userBadgeListFormDTO.getCustomerId()); + userBadge = userBadgeRedis.getUserBadge(userBadgeListFormDTO.getCustomerId()); } } - userBadge = userBadgeRedis.getUserBadge(userBadgeListFormDTO.getCustomerId()); + List redisUserBadgeList = JSON.parseArray(userBadge.toString(), UserBadgeListResultDTO.class); List userBadgeListResultDTOS = userBadgeDao.selectBadgeList(userBadgeListFormDTO); if (CollectionUtils.isEmpty(userBadgeListResultDTOS)){ - return userBadge; + return redisUserBadgeList; } - userBadge.forEach(u -> { + redisUserBadgeList.forEach(u -> { userBadgeListResultDTOS.forEach(badge -> { if (u.getBadgeId().equals(badge.getBadgeId())){ badge.setBadgeIcon(u.getBadgeIcon()); @@ -69,11 +75,52 @@ public class UserBadgeServiceImpl implements UserBadgeService { } }); }); - userBadge.forEach(u -> { + redisUserBadgeList.forEach(u -> { if (!u.getStatus()){ userBadgeListResultDTOS.add(u); } }); return userBadgeListResultDTOS; } + + /** + * @Description 个人中心-获取徽章可操作列表(点亮,取消,认证) + * @Param userOperListFormDTO + * @author zxc + * @date 2020/11/3 4:42 下午 + */ + @Override + public List selectOperList(UserOperListFormDTO userOperListFormDTO) { + List userAuthBadgeList = userBadgeDao.selectAuthRecord(userOperListFormDTO.getUserId()); + Object userBadge = userBadgeRedis.getUserBadge(userOperListFormDTO.getCustomerId()); + List userOperListResultDTOS = JSON.parseArray(userBadge.toString(), UserOperListResultDTO.class); + // 没有任何记录 + if (CollectionUtils.isEmpty(userAuthBadgeList)){ + userOperListResultDTOS.forEach(u -> { + u.setIsLighted(u.getIsOpened().equals(NumConstant.ZERO_STR) ? BadgeConstant.NO : BadgeConstant.YES); + u.setIsCertificated(BadgeConstant.NO); + u.setIsReject(false); + }); + return userOperListResultDTOS; + } + List badgeIsOpenedList = userBadgeDao.selectBadgeByUserId(userOperListFormDTO.getUserId()); + userOperListResultDTOS.forEach(ub -> { + userAuthBadgeList.forEach(u -> { + if (ub.getBadgeId().equals(u.getBadgeId())){ + ub.setIsReject(u.getAuditStatus().equals(BadgeConstant.REJECTED) ? true : false); + ub.setIsCertificated(u.getAuditStatus().equals(BadgeConstant.APPROVED) ? BadgeConstant.YES : BadgeConstant.NO); + } + }); + if (CollectionUtils.isEmpty(badgeIsOpenedList)){ + ub.setIsLighted(BadgeConstant.NO); + }else { + badgeIsOpenedList.forEach(b -> { + if (ub.getBadgeId().equals(b.getBadgeId())){ + ub.setIsLighted(b.getIsOpened().equals(NumConstant.ZERO_STR) ? BadgeConstant.NO : BadgeConstant.YES); + } + }); + } + }); + return userOperListResultDTOS; + } } diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/UserBadgeDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/UserBadgeDao.xml index b709353ce5..b9bcbad998 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/UserBadgeDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/UserBadgeDao.xml @@ -7,14 +7,14 @@ @@ -26,12 +26,37 @@ CUSTOMER_ID, BADGE_NAME, BADGE_ICON, - FIXATION_BADGE_TYPE + FIXATION_BADGE_TYPE AS badgeType FROM badge WHERE DEL_FLAG = '0' AND (CUSTOMER_ID = 'default' OR CUSTOMER_ID = 'zxc') + + + + + + From 1c8eca02dd3f6e46526beb03abfaa827077f16b0 Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Wed, 4 Nov 2020 15:38:45 +0800 Subject: [PATCH 09/16] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E5=BE=BD=E7=AB=A0?= =?UTF-8?q?=E8=AE=A4=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../badege/controller/BadgeController.java | 16 ++++ .../modules/badege/service/BadgeService.java | 10 +++ .../badege/service/impl/BadgeServiceImpl.java | 17 ++++ .../dto/UserBadgeCertificateRecordDTO.java | 44 +++++++++++ .../epmet/dto/form/BadgeSendCodeFormDTO.java | 22 ++++++ .../dto/form/CertificationAddFormDTO.java | 67 ++++++++++++++++ .../epmet/feign/EpmetUserOpenFeignClient.java | 3 + .../EpmetUserOpenFeignClientFallback.java | 5 ++ .../epmet/controller/UserBadgeController.java | 28 +++++++ .../main/java/com/epmet/dao/UserBadgeDao.java | 18 +++++ .../java/com/epmet/redis/UserBadgeRedis.java | 15 ++++ .../com/epmet/service/UserBadgeService.java | 20 +++++ .../service/impl/UserBadgeServiceImpl.java | 79 ++++++++++++++++++- .../main/resources/mapper/UserBadgeDao.xml | 59 ++++++++++++++ 14 files changed, 401 insertions(+), 2 deletions(-) create mode 100644 epmet-user/epmet-user-client/src/main/java/com/epmet/dto/UserBadgeCertificateRecordDTO.java create mode 100644 epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/BadgeSendCodeFormDTO.java create mode 100644 epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/CertificationAddFormDTO.java diff --git a/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/controller/BadgeController.java b/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/controller/BadgeController.java index fe519e7cbb..8d70e5d097 100644 --- a/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/controller/BadgeController.java +++ b/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/controller/BadgeController.java @@ -6,6 +6,7 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.modules.badege.service.BadgeService; import com.epmet.resi.mine.dto.from.BadgeListFormDTO; +import com.epmet.dto.form.CertificationAddFormDTO; import com.epmet.resi.mine.dto.from.OperListFormDTO; import com.epmet.resi.mine.dto.result.BadgeListResultDTO; import com.epmet.resi.mine.dto.result.OperListResultDTO; @@ -52,4 +53,19 @@ public class BadgeController { return new Result>().ok(badgeService.getOperList(tokenDto,operListFormDTO)); } + /** + * @Description 个人中心-提交徽章认证 + * @Param tokenDto + * @Param certificationAddFormDTO + * @author zxc + * @date 2020/11/4 11:16 上午 + */ + @PostMapping("certification/add") + public Result certificationAdd(@LoginUser TokenDto tokenDto,@RequestBody CertificationAddFormDTO certificationAddFormDTO){ + ValidatorUtils.validateEntity(certificationAddFormDTO, CertificationAddFormDTO.CertificationAdd.class); + badgeService.certificationAdd(tokenDto,certificationAddFormDTO); + return new Result(); + } + + } diff --git a/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/service/BadgeService.java b/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/service/BadgeService.java index fe1d1c140e..6d020bc286 100644 --- a/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/service/BadgeService.java +++ b/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/service/BadgeService.java @@ -2,6 +2,7 @@ package com.epmet.modules.badege.service; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.resi.mine.dto.from.BadgeListFormDTO; +import com.epmet.dto.form.CertificationAddFormDTO; import com.epmet.resi.mine.dto.from.OperListFormDTO; import com.epmet.resi.mine.dto.result.BadgeListResultDTO; import com.epmet.resi.mine.dto.result.OperListResultDTO; @@ -30,4 +31,13 @@ public interface BadgeService { */ List getOperList(TokenDto tokenDto,OperListFormDTO operListFormDTO); + /** + * @Description 个人中心-提交徽章认证 + * @Param tokenDto + * @Param certificationAddFormDTO + * @author zxc + * @date 2020/11/4 11:16 上午 + */ + void certificationAdd(TokenDto tokenDto, CertificationAddFormDTO certificationAddFormDTO); + } diff --git a/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/service/impl/BadgeServiceImpl.java b/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/service/impl/BadgeServiceImpl.java index 6e1d3ae1e9..259ffc23ae 100644 --- a/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/service/impl/BadgeServiceImpl.java +++ b/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/service/impl/BadgeServiceImpl.java @@ -11,6 +11,7 @@ import com.epmet.dto.result.UserOperListResultDTO; import com.epmet.feign.EpmetUserOpenFeignClient; import com.epmet.modules.badege.service.BadgeService; import com.epmet.resi.mine.dto.from.BadgeListFormDTO; +import com.epmet.dto.form.CertificationAddFormDTO; import com.epmet.resi.mine.dto.from.OperListFormDTO; import com.epmet.resi.mine.dto.result.BadgeListResultDTO; import com.epmet.resi.mine.dto.result.OperListResultDTO; @@ -75,4 +76,20 @@ public class BadgeServiceImpl implements BadgeService { List result = ConvertUtils.sourceToTarget(listResult.getData(), OperListResultDTO.class); return result; } + + /** + * @Description 个人中心-提交徽章认证 + * @Param tokenDto + * @Param certificationAddFormDTO + * @author zxc + * @date 2020/11/4 11:16 上午 + */ + @Override + public void certificationAdd(TokenDto tokenDto, CertificationAddFormDTO certificationAddFormDTO) { + certificationAddFormDTO.setUserId(tokenDto.getUserId()); + Result result = epmetUserOpenFeignClient.authBadgeRecord(certificationAddFormDTO); + if (!result.success()){ + throw new RenException("提交徽章认证失败......"); + } + } } diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/UserBadgeCertificateRecordDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/UserBadgeCertificateRecordDTO.java new file mode 100644 index 0000000000..a398d6f2cc --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/UserBadgeCertificateRecordDTO.java @@ -0,0 +1,44 @@ +package com.epmet.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * @Author zxc + * @DateTime 2020/11/4 1:46 下午 + */ +@Data +public class UserBadgeCertificateRecordDTO implements Serializable { + + private static final long serialVersionUID = 3207509834642386145L; + + private String customerId; + private String gridId; + private String userId; + private String badgeId; + private String surname; + private String name; + private String idNum; + private String certificationImg; + private String remark; + private String auditStatus; + private String auditRemark; + private String staffId; + private Date auditTime; + private String isLast; + private String delFlag; + private Integer revision; + private String createdBy; + private String updatedBy; + + public UserBadgeCertificateRecordDTO() { + this.auditStatus = "auditing"; + this.isLast = "yes"; + this.delFlag = "0"; + this.revision = 0; + this.createdBy = "APP_USER"; + this.updatedBy = "APP_USER"; + } +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/BadgeSendCodeFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/BadgeSendCodeFormDTO.java new file mode 100644 index 0000000000..14cb3c3333 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/BadgeSendCodeFormDTO.java @@ -0,0 +1,22 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Author zxc + * @DateTime 2020/11/4 3:11 下午 + */ +@Data +public class BadgeSendCodeFormDTO implements Serializable { + + private static final long serialVersionUID = -3926070129364657241L; + + public interface BadgeSendCode{} + + @NotBlank(message = "手机号不能为空", groups = {BadgeSendCode.class}) + private String mobile; + +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/CertificationAddFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/CertificationAddFormDTO.java new file mode 100644 index 0000000000..76583e9559 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/CertificationAddFormDTO.java @@ -0,0 +1,67 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Author zxc + * @DateTime 2020/11/4 11:05 上午 + */ +@Data +public class CertificationAddFormDTO implements Serializable { + + private static final long serialVersionUID = 1330773325803513330L; + + public interface CertificationAdd{} + + private String userId; + + /** + * 客户ID + */ + @NotBlank(message = "客户ID不能为空",groups = {CertificationAdd.class}) + private String customerId; + + /** + * 徽章ID + */ + private String badgeId; + + /** + * 手机号 + */ + private String mobile; + + /** + * 姓 + */ + private String subName; + + /** + * 名 + */ + private String name; + + /** + * 身份证号 + */ + private String idCard; + + /** + * 认证证件图片url + */ + private String certificate; + + /** + * 认证说明 + */ + private String remark; + + /** + * 验证码 + */ + private String code; + +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java index 8ab0fd12b2..f356eb8b1a 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java @@ -355,4 +355,7 @@ public interface EpmetUserOpenFeignClient { */ @PostMapping("/epmetuser/badge/badgeoperlist") Result> selectOperList(@RequestBody UserOperListFormDTO userOperListFormDTO); + + @PostMapping("/epmetuser/badge/authbadgerecord") + Result authBadgeRecord(@RequestBody CertificationAddFormDTO certificationAddFormDTO); } diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java index aa5db5968a..789acb75f4 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java @@ -235,4 +235,9 @@ public class EpmetUserOpenFeignClientFallback implements EpmetUserOpenFeignClien public Result> selectOperList(UserOperListFormDTO userOperListFormDTO) { return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "selectOperList", userOperListFormDTO); } + + @Override + public Result authBadgeRecord(CertificationAddFormDTO certificationAddFormDTO) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "authBadgeRecord", certificationAddFormDTO); + } } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserBadgeController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserBadgeController.java index 5b8f9d46e6..f29179b551 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserBadgeController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserBadgeController.java @@ -1,6 +1,9 @@ package com.epmet.controller; import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.dto.form.BadgeSendCodeFormDTO; +import com.epmet.dto.form.CertificationAddFormDTO; import com.epmet.dto.form.UserBadgeListFormDTO; import com.epmet.dto.form.UserOperListFormDTO; import com.epmet.dto.result.UserBadgeListResultDTO; @@ -47,4 +50,29 @@ public class UserBadgeController { return new Result>().ok(userBadgeService.selectOperList(userOperListFormDTO)); } + /** + * @Description 个人中心-提交徽章认证 + * @Param certificationAddFormDTO + * @author zxc + * @date 2020/11/4 1:36 下午 + */ + @PostMapping("authbadgerecord") + public Result authBadgeRecord(@RequestBody CertificationAddFormDTO certificationAddFormDTO){ + userBadgeService.authBadgeRecord(certificationAddFormDTO); + return new Result(); + } + + /** + * @Description 发送验证码 + * @Param badgeSendCodeFormDTO + * @author zxc + * @date 2020/11/4 3:14 下午 + */ + @PostMapping("badgesendcode") + public Result badgeSendCode(@RequestBody BadgeSendCodeFormDTO badgeSendCodeFormDTO){ + ValidatorUtils.validateEntity(badgeSendCodeFormDTO, BadgeSendCodeFormDTO.BadgeSendCode.class); + userBadgeService.badgeSendCode(badgeSendCodeFormDTO); + return new Result(); + } + } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/UserBadgeDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/UserBadgeDao.java index 65eec9d1ac..fececff9d8 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/UserBadgeDao.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/UserBadgeDao.java @@ -1,5 +1,6 @@ package com.epmet.dao; +import com.epmet.dto.UserBadgeCertificateRecordDTO; import com.epmet.dto.form.UserBadgeListFormDTO; import com.epmet.dto.result.UserBadgeListResultDTO; import com.epmet.dto.result.UserOperListResultDTO; @@ -47,4 +48,21 @@ public interface UserBadgeDao { */ List selectBadgeByUserId(@Param("userId")String userId); + /** + * @Description 用户认证徽章记录表插入 + * @Param userBadgeCertificateRecordDTO + * @author zxc + * @date 2020/11/4 2:13 下午 + */ + void insertUserBadgeCertificateRecord(UserBadgeCertificateRecordDTO userBadgeCertificateRecordDTO); + + /** + * @Description 更新认证徽章记录最新 + * @Param badgeId + * @Param userId + * @author zxc + * @date 2020/11/4 2:16 下午 + */ + void updateCertificateRecordIsLast(@Param("badgeId")String badgeId,@Param("userId")String userId); + } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/redis/UserBadgeRedis.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/redis/UserBadgeRedis.java index 727c467e12..1b209e7dee 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/redis/UserBadgeRedis.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/redis/UserBadgeRedis.java @@ -1,6 +1,8 @@ package com.epmet.redis; import com.alibaba.fastjson.JSON; +import com.epmet.common.token.constant.LoginConstant; +import com.epmet.commons.tools.redis.RedisKeys; import com.epmet.commons.tools.redis.RedisUtils; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.constant.BadgeConstant; @@ -12,6 +14,8 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import static com.epmet.commons.tools.redis.RedisUtils.MINUTE_THIRTY_EXPIRE; + /** * @Author zxc * @DateTime 2020/11/3 2:21 下午 @@ -44,4 +48,15 @@ public class UserBadgeRedis { redisUtils.hSet(BadgeConstant.BADGE_KEY+customerId,BadgeConstant.BADGE, JSON.toJSON(userBadge).toString(),-1); } + public void saveBadgeSmsCode(String mobile, String smsCode) { + String smsCodeKey = "epmet:smsCode:badge:" + mobile; + redisUtils.set(smsCodeKey, smsCode, MINUTE_THIRTY_EXPIRE); + } + + public String getBadgeSmsCode(String mobile) { + String smsCodeKey = "epmet:smsCode:badge:" + mobile; + String smsCode = (String) redisUtils.get(smsCodeKey); + return smsCode; + } + } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserBadgeService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserBadgeService.java index fe5737a2d3..79334d2960 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserBadgeService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserBadgeService.java @@ -1,9 +1,13 @@ package com.epmet.service; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.form.BadgeSendCodeFormDTO; +import com.epmet.dto.form.CertificationAddFormDTO; import com.epmet.dto.form.UserBadgeListFormDTO; import com.epmet.dto.form.UserOperListFormDTO; import com.epmet.dto.result.UserBadgeListResultDTO; import com.epmet.dto.result.UserOperListResultDTO; +import org.springframework.web.bind.annotation.RequestBody; import java.util.List; @@ -29,4 +33,20 @@ public interface UserBadgeService { */ List selectOperList(UserOperListFormDTO userOperListFormDTO); + /** + * @Description 个人中心-提交徽章认证 + * @Param certificationAddFormDTO + * @author zxc + * @date 2020/11/4 1:36 下午 + */ + Result authBadgeRecord(CertificationAddFormDTO certificationAddFormDTO); + + /** + * @Description 发送验证码 + * @Param badgeSendCodeFormDTO + * @author zxc + * @date 2020/11/4 3:14 下午 + */ + void badgeSendCode(BadgeSendCodeFormDTO badgeSendCodeFormDTO); + } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBadgeServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBadgeServiceImpl.java index 261f7e7bdc..33ddb19b00 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBadgeServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBadgeServiceImpl.java @@ -2,16 +2,27 @@ package com.epmet.service.impl; import com.alibaba.fastjson.JSON; import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.PhoneValidatorUtils; import com.epmet.constant.BadgeConstant; +import com.epmet.constant.SmsTemplateConstant; import com.epmet.dao.UserBadgeDao; -import com.epmet.dto.form.UserBadgeListFormDTO; -import com.epmet.dto.form.UserOperListFormDTO; +import com.epmet.dto.UserBadgeCertificateRecordDTO; +import com.epmet.dto.form.*; +import com.epmet.dto.result.SendVerificationCodeResultDTO; import com.epmet.dto.result.UserBadgeListResultDTO; +import com.epmet.dto.result.UserBaseInfoResultDTO; import com.epmet.dto.result.UserOperListResultDTO; +import com.epmet.feign.EpmetMessageOpenFeignClient; import com.epmet.redis.UserBadgeRedis; +import com.epmet.service.CustomerStaffService; import com.epmet.service.UserBadgeService; +import com.epmet.service.UserBaseInfoService; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -34,6 +45,12 @@ public class UserBadgeServiceImpl implements UserBadgeService { private UserBadgeDao userBadgeDao; @Autowired private UserBadgeRedis userBadgeRedis; + @Autowired + private UserBaseInfoService userBaseInfoService; + @Autowired + private CustomerStaffService customerStaffService; + @Autowired + private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient; /** * @Description 查询已经点亮的徽章 @@ -123,4 +140,62 @@ public class UserBadgeServiceImpl implements UserBadgeService { }); return userOperListResultDTOS; } + + /** + * @Description 个人中心-提交徽章认证 + * @Param certificationAddFormDTO + * @author zxc + * @date 2020/11/4 1:36 下午 + */ + @Override + public Result authBadgeRecord(CertificationAddFormDTO certificationAddFormDTO) { + if (StringUtils.isNotBlank(certificationAddFormDTO.getMobile())){ + String smsCode = userBadgeRedis.getBadgeSmsCode(certificationAddFormDTO.getMobile()); + if (!StringUtils.isNotBlank(smsCode)){ + return new Result().error(EpmetErrorCode.MOBILE_CODE_ERROR.getCode()); + } + } + UserBadgeCertificateRecordDTO form = ConvertUtils.sourceToTarget(certificationAddFormDTO, UserBadgeCertificateRecordDTO.class); + List userIds = new ArrayList<>(); + userIds.add(certificationAddFormDTO.getUserId()); + List userBaseInfoResultDTOS = userBaseInfoService.queryUserBaseInfo(userIds); + if (CollectionUtils.isEmpty(userBaseInfoResultDTOS)){ + throw new RenException("查询用户基本信息集合为空......"); + } + userBadgeDao.updateCertificateRecordIsLast(form.getBadgeId(),form.getUserId()); + form.setGridId(userBaseInfoResultDTOS.get(NumConstant.ZERO).getRegisteredGridId()); + form.setIdNum(certificationAddFormDTO.getIdCard()); + form.setCertificationImg(certificationAddFormDTO.getCertificate()); + form.setSurname(certificationAddFormDTO.getSubName()); + userBadgeDao.insertUserBadgeCertificateRecord(form); + return new Result(); + } + + /** + * @Description 发送验证码 + * @Param badgeSendCodeFormDTO + * @author zxc + * @date 2020/11/4 3:14 下午 + */ + @Override + public void badgeSendCode(BadgeSendCodeFormDTO badgeSendCodeFormDTO) { + //1、校验手机号是否符合规范 + if (!PhoneValidatorUtils.isMobile(badgeSendCodeFormDTO.getMobile())) { + log.error(String.format("发送短信验证码异常,手机号[%s],code[%s],msg[%s]", badgeSendCodeFormDTO.getMobile(), EpmetErrorCode.ERROR_PHONE.getCode(), EpmetErrorCode.ERROR_PHONE.getMsg())); + throw new RenException(EpmetErrorCode.ERROR_PHONE.getCode()); + } + //3、发送短信验证码 + SendVerificationCodeFormDTO sendVerificationCodeFormDTO=new SendVerificationCodeFormDTO(); + sendVerificationCodeFormDTO.setMobile(badgeSendCodeFormDTO.getMobile()); + sendVerificationCodeFormDTO.setAliyunTemplateCode(SmsTemplateConstant.LGOIN_CONFIRM); + Result smsCodeResult=epmetMessageOpenFeignClient.sendVerificationCode(sendVerificationCodeFormDTO); + if (!smsCodeResult.success()) { + log.error(String.format("发送短信验证码异常,手机号[%s],code[%s],msg[%s]", badgeSendCodeFormDTO.getMobile(), smsCodeResult.getCode(), smsCodeResult.getMsg())); + throw new RenException(smsCodeResult.getCode()); + } + //4、保存短信验证码(删除现有短信验证码、将新的短信验证码存入Redis) + userBadgeRedis.saveBadgeSmsCode(badgeSendCodeFormDTO.getMobile(),smsCodeResult.getData().getCode()); + log.info(String.format("发送短信验证码成功,手机号[%s]", badgeSendCodeFormDTO.getMobile())); + } + } diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/UserBadgeDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/UserBadgeDao.xml index b9bcbad998..b6c688b331 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/UserBadgeDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/UserBadgeDao.xml @@ -3,6 +3,15 @@ + + + UPDATE user_badge_certificate_record + SET is_last = 'no' + WHERE DEL_FLAG = '0' + AND BADGE_ID = #{badgeId} + AND USER_ID = #{userId} + + + + + INSERT INTO user_badge_certificate_record ( + ID, + CUSTOMER_ID, + GRID_ID, + USER_ID, + BADGE_ID, + SURNAME, + NAME, + ID_NUM, + CERTIFICATION_IMG, + REMAEK, + AUDIT_STATUS, + AUDIT_REMARK, + STAFF_ID, + AUDIT_TIME, + IS_LAST, + DEL_FLAG, + REVISION, + CREATED_BY, + CREATED_TIME, + UPDATED_BY, + UPDATED_TIME + ) + VALUES + ( + REPLACE ( UUID(), '-', '' ), + #{customerId}, + #{gridId}, + #{userId}, + #{badgeId}, + #{surname}, + #{name}, + #{idNum}, + #{certificationImg}, + #{remark}, + #{auditStatus}, + #{auditRemark}, + #{staffId}, + #{auditTime}, + #{isLast}, + #{delFlag}, + #{revision}, + #{createdBy}, + NOW(), + #{updatedBy}, + NOW() + ) + From 67baaefff06e77e86fbbdee1ae15791441155177 Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Wed, 4 Nov 2020 16:50:40 +0800 Subject: [PATCH 10/16] =?UTF-8?q?=E5=BE=BD=E7=AB=A0=E8=AE=A4=E8=AF=81?= =?UTF-8?q?=E8=AF=A6=E6=83=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/UserBadgeCertificateRecordDTO.java | 1 + .../dto/form/CertificationDetailFormDTO.java | 29 +++++++++ .../result/CertificationDetailResultDTO.java | 60 +++++++++++++++++++ .../epmet/feign/EpmetUserOpenFeignClient.java | 12 +++- .../epmet/controller/UserBadgeController.java | 23 +++++-- .../main/java/com/epmet/dao/UserBadgeDao.java | 9 +++ .../com/epmet/service/UserBadgeService.java | 17 ++++-- .../service/impl/UserBadgeServiceImpl.java | 19 ++++-- .../main/resources/mapper/UserBadgeDao.xml | 27 +++++++++ 9 files changed, 181 insertions(+), 16 deletions(-) create mode 100644 epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/CertificationDetailFormDTO.java create mode 100644 epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/CertificationDetailResultDTO.java diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/UserBadgeCertificateRecordDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/UserBadgeCertificateRecordDTO.java index a398d6f2cc..ffa2be3013 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/UserBadgeCertificateRecordDTO.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/UserBadgeCertificateRecordDTO.java @@ -20,6 +20,7 @@ public class UserBadgeCertificateRecordDTO implements Serializable { private String badgeId; private String surname; private String name; + private String mobile; private String idNum; private String certificationImg; private String remark; diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/CertificationDetailFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/CertificationDetailFormDTO.java new file mode 100644 index 0000000000..1eea42f575 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/CertificationDetailFormDTO.java @@ -0,0 +1,29 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Author zxc + * @DateTime 2020/11/4 3:51 下午 + */ +@Data +public class CertificationDetailFormDTO implements Serializable { + + private static final long serialVersionUID = -398879254354767770L; + + public interface CertificationDetail{} + + @NotBlank(message = "客户ID不能为空",groups = {CertificationDetail.class}) + private String customerId; + + @NotBlank(message = "徽章ID不能为空",groups = {CertificationDetail.class}) + private String badgeId; + + /** + * 客户ID + */ + private String userId; +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/CertificationDetailResultDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/CertificationDetailResultDTO.java new file mode 100644 index 0000000000..4e7298c1b9 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/CertificationDetailResultDTO.java @@ -0,0 +1,60 @@ +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author zxc + * @DateTime 2020/11/4 3:51 下午 + */ +@Data +public class CertificationDetailResultDTO implements Serializable { + + private static final long serialVersionUID = 6538150132908927308L; + + /** + * 姓 + */ + private String surname; + + /** + * 名 + */ + private String name; + + /** + * 身份证号 + */ + private String idNum; + + /** + * 是否认证 yes 认证 no 已认证 + */ + private String isCertificated; + + /** + * 手机号 + */ + private String mobile; + + /** + * 认证图片地址 + */ + private String certificationImg; + + /** + * 备注 + */ + private String remark; + + /** + * 审核结果 + */ + private String authResult; + + /** + * 驳回原因 + */ + private String authReason; +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java index f356eb8b1a..f5f531b656 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java @@ -344,7 +344,7 @@ public interface EpmetUserOpenFeignClient { * @author zxc * @date 2020/11/3 1:33 下午 */ - @PostMapping("/epmetuser/badge/badgelist") + @PostMapping("/epmetuser/more/badge/badgelist") Result> selectBadgeList(@RequestBody UserBadgeListFormDTO userBadgeListFormDTO); /** @@ -353,9 +353,15 @@ public interface EpmetUserOpenFeignClient { * @author zxc * @date 2020/11/3 4:28 下午 */ - @PostMapping("/epmetuser/badge/badgeoperlist") + @PostMapping("/epmetuser/more/badge/badgeoperlist") Result> selectOperList(@RequestBody UserOperListFormDTO userOperListFormDTO); - @PostMapping("/epmetuser/badge/authbadgerecord") + /** + * @Description 徽章认证提交 + * @Param certificationAddFormDTO + * @author zxc + * @date 2020/11/4 4:30 下午 + */ + @PostMapping("/epmetuser/more/badge/authbadgerecord") Result authBadgeRecord(@RequestBody CertificationAddFormDTO certificationAddFormDTO); } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserBadgeController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserBadgeController.java index f29179b551..ff5767867e 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserBadgeController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserBadgeController.java @@ -1,11 +1,11 @@ package com.epmet.controller; +import com.epmet.commons.tools.annotation.LoginUser; +import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; -import com.epmet.dto.form.BadgeSendCodeFormDTO; -import com.epmet.dto.form.CertificationAddFormDTO; -import com.epmet.dto.form.UserBadgeListFormDTO; -import com.epmet.dto.form.UserOperListFormDTO; +import com.epmet.dto.form.*; +import com.epmet.dto.result.CertificationDetailResultDTO; import com.epmet.dto.result.UserBadgeListResultDTO; import com.epmet.dto.result.UserOperListResultDTO; import com.epmet.service.UserBadgeService; @@ -22,7 +22,7 @@ import java.util.List; * @DateTime 2020/11/3 11:16 上午 */ @RestController -@RequestMapping("badge") +@RequestMapping("more/badge") public class UserBadgeController { @Autowired @@ -75,4 +75,17 @@ public class UserBadgeController { return new Result(); } + /** + * @Description 个人中心-获取徽章认证页面详情 + * @Param tokenDto + * @Param certificationDetailFormDTO + * @author zxc + * @date 2020/11/4 4:03 下午 + */ + @PostMapping("certification/detail") + public Result certificationDetail(@LoginUser TokenDto tokenDto,@RequestBody CertificationDetailFormDTO certificationDetailFormDTO){ + ValidatorUtils.validateEntity(certificationDetailFormDTO); + return new Result().ok(userBadgeService.certificationDetail(tokenDto,certificationDetailFormDTO)); + } + } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/UserBadgeDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/UserBadgeDao.java index fececff9d8..7025c1870c 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/UserBadgeDao.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/UserBadgeDao.java @@ -2,6 +2,7 @@ package com.epmet.dao; import com.epmet.dto.UserBadgeCertificateRecordDTO; import com.epmet.dto.form.UserBadgeListFormDTO; +import com.epmet.dto.result.CertificationDetailResultDTO; import com.epmet.dto.result.UserBadgeListResultDTO; import com.epmet.dto.result.UserOperListResultDTO; import org.apache.ibatis.annotations.Mapper; @@ -65,4 +66,12 @@ public interface UserBadgeDao { */ void updateCertificateRecordIsLast(@Param("badgeId")String badgeId,@Param("userId")String userId); + /** + * @Description 查询单个徽章的认证记录 + * @Param userId + * @Param badgeId + * @author zxc + * @date 2020/11/4 4:09 下午 + */ + CertificationDetailResultDTO selectBadgeAuthRecord(@Param("userId")String userId, @Param("badgeId")String badgeId); } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserBadgeService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserBadgeService.java index 79334d2960..e9cc979c91 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserBadgeService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserBadgeService.java @@ -1,10 +1,10 @@ package com.epmet.service; +import com.epmet.commons.tools.annotation.LoginUser; +import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; -import com.epmet.dto.form.BadgeSendCodeFormDTO; -import com.epmet.dto.form.CertificationAddFormDTO; -import com.epmet.dto.form.UserBadgeListFormDTO; -import com.epmet.dto.form.UserOperListFormDTO; +import com.epmet.dto.form.*; +import com.epmet.dto.result.CertificationDetailResultDTO; import com.epmet.dto.result.UserBadgeListResultDTO; import com.epmet.dto.result.UserOperListResultDTO; import org.springframework.web.bind.annotation.RequestBody; @@ -49,4 +49,13 @@ public interface UserBadgeService { */ void badgeSendCode(BadgeSendCodeFormDTO badgeSendCodeFormDTO); + /** + * @Description 个人中心-获取徽章认证页面详情 + * @Param tokenDto + * @Param certificationDetailFormDTO + * @author zxc + * @date 2020/11/4 4:03 下午 + */ + CertificationDetailResultDTO certificationDetail(TokenDto tokenDto, CertificationDetailFormDTO certificationDetailFormDTO); + } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBadgeServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBadgeServiceImpl.java index 33ddb19b00..2d96216eaa 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBadgeServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBadgeServiceImpl.java @@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.RenException; +import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.PhoneValidatorUtils; @@ -12,10 +13,7 @@ import com.epmet.constant.SmsTemplateConstant; import com.epmet.dao.UserBadgeDao; import com.epmet.dto.UserBadgeCertificateRecordDTO; import com.epmet.dto.form.*; -import com.epmet.dto.result.SendVerificationCodeResultDTO; -import com.epmet.dto.result.UserBadgeListResultDTO; -import com.epmet.dto.result.UserBaseInfoResultDTO; -import com.epmet.dto.result.UserOperListResultDTO; +import com.epmet.dto.result.*; import com.epmet.feign.EpmetMessageOpenFeignClient; import com.epmet.redis.UserBadgeRedis; import com.epmet.service.CustomerStaffService; @@ -198,4 +196,17 @@ public class UserBadgeServiceImpl implements UserBadgeService { log.info(String.format("发送短信验证码成功,手机号[%s]", badgeSendCodeFormDTO.getMobile())); } + /** + * @Description 个人中心-获取徽章认证页面详情 + * @Param tokenDto + * @Param certificationDetailFormDTO + * @author zxc + * @date 2020/11/4 4:03 下午 + */ + @Override + public CertificationDetailResultDTO certificationDetail(TokenDto tokenDto, CertificationDetailFormDTO certificationDetailFormDTO) { + certificationDetailFormDTO.setUserId(tokenDto.getUserId()); + return userBadgeDao.selectBadgeAuthRecord(certificationDetailFormDTO.getUserId(), certificationDetailFormDTO.getBadgeId()); + } + } diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/UserBadgeDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/UserBadgeDao.xml index b6c688b331..5d46734499 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/UserBadgeDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/UserBadgeDao.xml @@ -67,6 +67,31 @@ AND USER_ID = #{userId} + + + INSERT INTO user_badge_certificate_record ( @@ -77,6 +102,7 @@ BADGE_ID, SURNAME, NAME, + MOBILE, ID_NUM, CERTIFICATION_IMG, REMAEK, @@ -101,6 +127,7 @@ #{badgeId}, #{surname}, #{name}, + #{mobile}, #{idNum}, #{certificationImg}, #{remark}, From 8084fce2b4695806f11e269314b70f3da2b8ae62 Mon Sep 17 00:00:00 2001 From: zhaoqifeng Date: Wed, 4 Nov 2020 17:03:20 +0800 Subject: [PATCH 11/16] =?UTF-8?q?=E5=B7=A5=E4=BD=9C=E7=AB=AF-=E5=BE=BD?= =?UTF-8?q?=E7=AB=A0=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tools/exception/EpmetErrorCode.java | 5 + .../com/epmet/controller/OssController.java | 34 +++ .../com/epmet/constant/BadgeConstant.java | 2 + .../dto/BadgeCertificationConfigDTO.java | 86 ++++++ .../src/main/java/com/epmet/dto/BadgeDTO.java | 96 +++++++ .../com/epmet/dto/form/AddBadgeFormDTO.java | 42 +++ .../java/com/epmet/dto/form/BadgeFormDTO.java | 16 ++ .../com/epmet/dto/form/EditBadgeFormDTO.java | 40 +++ .../dto/result/BadgeDetailResultDTO.java | 26 ++ .../epmet/dto/result/BadgeListResultDTO.java | 31 +++ .../com/epmet/controller/BadgeController.java | 104 ++++++++ .../dao/BadgeCertificationConfigDao.java | 54 ++++ .../src/main/java/com/epmet/dao/BadgeDao.java | 108 ++++++++ .../BadgeCertificationConfigEntity.java | 56 ++++ .../java/com/epmet/entity/BadgeEntity.java | 66 +++++ .../java/com/epmet/redis/UserBadgeRedis.java | 5 - .../BadgeCertificationConfigService.java | 127 +++++++++ .../java/com/epmet/service/BadgeService.java | 150 +++++++++++ .../BadgeCertificationConfigServiceImpl.java | 149 +++++++++++ .../epmet/service/impl/BadgeServiceImpl.java | 248 ++++++++++++++++++ .../mapper/BadgeCertificationConfigDao.xml | 42 +++ .../src/main/resources/mapper/BadgeDao.xml | 116 ++++++++ 22 files changed, 1598 insertions(+), 5 deletions(-) create mode 100644 epmet-user/epmet-user-client/src/main/java/com/epmet/dto/BadgeCertificationConfigDTO.java create mode 100644 epmet-user/epmet-user-client/src/main/java/com/epmet/dto/BadgeDTO.java create mode 100644 epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/AddBadgeFormDTO.java create mode 100644 epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/BadgeFormDTO.java create mode 100644 epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/EditBadgeFormDTO.java create mode 100644 epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/BadgeDetailResultDTO.java create mode 100644 epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/BadgeListResultDTO.java create mode 100644 epmet-user/epmet-user-server/src/main/java/com/epmet/controller/BadgeController.java create mode 100644 epmet-user/epmet-user-server/src/main/java/com/epmet/dao/BadgeCertificationConfigDao.java create mode 100644 epmet-user/epmet-user-server/src/main/java/com/epmet/dao/BadgeDao.java create mode 100644 epmet-user/epmet-user-server/src/main/java/com/epmet/entity/BadgeCertificationConfigEntity.java create mode 100644 epmet-user/epmet-user-server/src/main/java/com/epmet/entity/BadgeEntity.java create mode 100644 epmet-user/epmet-user-server/src/main/java/com/epmet/service/BadgeCertificationConfigService.java create mode 100644 epmet-user/epmet-user-server/src/main/java/com/epmet/service/BadgeService.java create mode 100644 epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/BadgeCertificationConfigServiceImpl.java create mode 100644 epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/BadgeServiceImpl.java create mode 100644 epmet-user/epmet-user-server/src/main/resources/mapper/BadgeCertificationConfigDao.xml create mode 100644 epmet-user/epmet-user-server/src/main/resources/mapper/BadgeDao.xml diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java index e4832a1c8b..2242a9ef9c 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java @@ -95,6 +95,9 @@ public enum EpmetErrorCode { SIGN_IN_TIME_NO(8513, "签到时间还未到~"), SIGN_IN_TIME_END(8514, "签到时间已结束~"), + //徽章管理 + DUPLICATE_BADGE_NAME(8515, "徽章名已存在"), + // 该错误不会提示给前端,只是后端传输错误信息用。 ACCESS_SQL_FILTER_MISSION_ARGS(8701, "缺少生成权限过滤SQL所需参数"), OPER_ADD_CUSTOMER_ROOT_AGENCY_ERROR(8702, "添加客户根级组织失败"), @@ -110,6 +113,8 @@ public enum EpmetErrorCode { OPER_CUSTOMER_FOOTBAR_EXISTS(8712, "footbar已存在"), OPER_CUSTOMER_FOOTBAR_NOT_FOUND(8713, "footbar不存在"), OPER_EXT_APP_SECRET_RESET_FAIL(8714, "秘钥更新失败"), + OPER_UPLOAD_IMG_TYPE_ERROR(8715, "请上传PNG格式的图片"), + OPER_UPLOAD_IMG_SIZE_ERROR(8716, "请上传200*200的图片"), // 党建声音 前端提示 88段 DRAFT_CONTENT_IS_NULL(8801, "至少需要添加一个段落"), diff --git a/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/controller/OssController.java b/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/controller/OssController.java index 5b3e3bee6b..a7f37ab6e9 100644 --- a/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/controller/OssController.java +++ b/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/controller/OssController.java @@ -10,6 +10,7 @@ package com.epmet.controller; import com.epmet.cloud.CloudStorageConfig; import com.epmet.cloud.OssFactory; +import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.page.PageData; @@ -37,6 +38,9 @@ import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import springfox.documentation.annotations.ApiIgnore; +import javax.imageio.ImageIO; +import java.awt.image.BufferedImage; +import java.io.IOException; import java.util.Arrays; import java.util.Map; @@ -218,4 +222,34 @@ public class OssController { return ossService.uploadImg(file); } + + @PostMapping("uploadimg/badgeicon") + public Result badgeIcon(@RequestParam("file") MultipartFile file) throws IOException { + + // 校验文件类型 + if (!MediaType.IMAGE_PNG_VALUE.equals(file.getContentType())) { + log.error("uploadArticleImg file type:{} is not support 2 upload", file.getContentType()); + throw new RenException(EpmetErrorCode.OPER_UPLOAD_IMG_TYPE_ERROR.getCode() + , EpmetErrorCode.OPER_UPLOAD_IMG_TYPE_ERROR.getMsg()); + } + + // 校验文件体积,不超过2m + long maxSize = 2 * 1024 * 1024; + long size = file.getSize(); + if (size > maxSize) { + throw new RenException(EpmetErrorCode.OPER_UPLOAD_FILE_OVER_SIZE.getCode() + , EpmetErrorCode.OPER_UPLOAD_FILE_OVER_SIZE.getMsg()); + } + + BufferedImage bufferedImage = ImageIO.read(file.getInputStream()); + int width = bufferedImage.getWidth(); + int height = bufferedImage.getHeight(); + if (width != 200 || height != 200) { + throw new RenException(EpmetErrorCode.OPER_UPLOAD_IMG_SIZE_ERROR.getCode() + , EpmetErrorCode.OPER_UPLOAD_IMG_SIZE_ERROR.getMsg()); + + } + return ossService.uploadImg(file); + } + } diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/constant/BadgeConstant.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/constant/BadgeConstant.java index 7c2a6313c2..57661b4871 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/constant/BadgeConstant.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/constant/BadgeConstant.java @@ -20,4 +20,6 @@ public interface BadgeConstant { String APPROVED = "approved"; + String NONE ="none"; + } diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/BadgeCertificationConfigDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/BadgeCertificationConfigDTO.java new file mode 100644 index 0000000000..5eb6e95749 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/BadgeCertificationConfigDTO.java @@ -0,0 +1,86 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto; + +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + + +/** + * 徽章认证配置 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-11-03 + */ +@Data +public class BadgeCertificationConfigDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键ID + */ + private String id; + + /** + * 客户Id 默认配置id:default + */ + private String customerId; + + /** + * 徽章ID + */ + private String badgeId; + + /** + * 认证信息类型 手机号:mobile;全名:fullname;身份证:idcard;认证证件: certificate;认证说明(备注):remark + */ + private String certificationType; + + /** + * 删除标识 1删除;0未删除 + */ + private String delFlag; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + +} \ No newline at end of file diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/BadgeDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/BadgeDTO.java new file mode 100644 index 0000000000..dfeb6f055b --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/BadgeDTO.java @@ -0,0 +1,96 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto; + +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + + +/** + * 徽章 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-11-03 + */ +@Data +public class BadgeDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键ID + */ + private String id; + + /** + * 客户Id 默认配置id:default + */ + private String customerId; + + /** + * 徽章名称 + */ + private String badgeName; + + /** + * 徽章图标url + */ + private String badgeIcon; + + /** + * 固有徽章类型 前端页面跳转标识,党员徽章:party;无:none + */ + private String fixationBadgeType; + + /** + * 状态 上线:online;下线:offline; + */ + private String badgeStatus; + + /** + * 删除标识 1删除;0未删除 + */ + private String delFlag; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + +} \ No newline at end of file diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/AddBadgeFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/AddBadgeFormDTO.java new file mode 100644 index 0000000000..ceb07d1651 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/AddBadgeFormDTO.java @@ -0,0 +1,42 @@ +package com.epmet.dto.form; + +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; +import java.io.Serializable; +import java.util.List; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/11/4 9:47 + */ +@NoArgsConstructor +@Data +public class AddBadgeFormDTO implements Serializable { + + private static final long serialVersionUID = -5220529162950147825L; + /** + * 徽章名称 + */ + @NotBlank(message = "徽章名称不能为空") + private String badgeName; + /** + * 徽章图标 + */ + @NotBlank(message = "徽章图标不能为空") + private String badgeIcon; + /** + * 徽章状态 上线:online;下线:offline; + */ + @NotBlank(message = "徽章状态不能为空") + private String badgeStatus; + /** + * 认证信息类型数组 手机号:mobile;姓名:fullname;身份证:idcard;认证证件: certificate;认证说明(备注):remark + */ + @NotEmpty(message = "认证信息类型不能为空") + private List certificationTypes; +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/BadgeFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/BadgeFormDTO.java new file mode 100644 index 0000000000..4b35497e8b --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/BadgeFormDTO.java @@ -0,0 +1,16 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/11/4 14:22 + */ +@Data +public class BadgeFormDTO implements Serializable { + private static final long serialVersionUID = 9156247659994638103L; + private String badgeId; +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/EditBadgeFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/EditBadgeFormDTO.java new file mode 100644 index 0000000000..e11d2e107c --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/EditBadgeFormDTO.java @@ -0,0 +1,40 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; +import java.io.Serializable; +import java.util.List; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/11/4 14:23 + */ +@Data +public class EditBadgeFormDTO implements Serializable { + private static final long serialVersionUID = 1578890423002035200L; + private String badgeId; + /** + * 徽章名称 + */ + @NotBlank(message = "徽章名称不能为空") + private String badgeName; + /** + * 徽章图标 + */ + @NotBlank(message = "徽章图标不能为空") + private String badgeIcon; + /** + * 徽章状态 上线:online;下线:offline; + */ + @NotBlank(message = "徽章状态不能为空") + private String badgeStatus; + /** + * 认证信息类型数组 手机号:mobile;姓名:fullname;身份证:idcard;认证证件: certificate;认证说明(备注):remark + */ + @NotEmpty(message = "认证信息类型不能为空") + private List certificationTypes; +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/BadgeDetailResultDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/BadgeDetailResultDTO.java new file mode 100644 index 0000000000..311c78f460 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/BadgeDetailResultDTO.java @@ -0,0 +1,26 @@ +package com.epmet.dto.result; + +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/11/4 14:17 + */ +@NoArgsConstructor +@Data +public class BadgeDetailResultDTO implements Serializable { + + private static final long serialVersionUID = 7698898330565297328L; + + private String badgeId; + private String badgeName; + private String badgeIcon; + private String badgeStatus; + private List certificationTypes; + +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/BadgeListResultDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/BadgeListResultDTO.java new file mode 100644 index 0000000000..8d5d7c28ec --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/BadgeListResultDTO.java @@ -0,0 +1,31 @@ +package com.epmet.dto.result; + +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/11/3 16:58 + */ +@NoArgsConstructor +@Data +public class BadgeListResultDTO { + + /** + * 徽章Id + */ + private String badgeId; + /** + * 徽章名称 + */ + private String badgeName; + /** + * 徽章图标url + */ + private String badgeIcon; + /** + * 徽章状态 上线:online;下线:offline; + */ + private String badgeStatus; +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/BadgeController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/BadgeController.java new file mode 100644 index 0000000000..92a2621013 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/BadgeController.java @@ -0,0 +1,104 @@ +package com.epmet.controller; + +import com.epmet.commons.tools.annotation.LoginUser; +import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.dto.form.AddBadgeFormDTO; +import com.epmet.dto.form.BadgeFormDTO; +import com.epmet.dto.form.EditBadgeFormDTO; +import com.epmet.dto.result.BadgeDetailResultDTO; +import com.epmet.dto.result.BadgeListResultDTO; +import com.epmet.service.BadgeService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/11/3 16:09 + */ +@RestController +@RequestMapping("badge") +public class BadgeController { + @Autowired + private BadgeService badgeService; + + /** + * 徽章列表 + * @author zhaoqifeng + * @date 2020/11/4 14:27 + * @param tokenDto + * @return com.epmet.commons.tools.utils.Result> + */ + @PostMapping("list") + public Result> list(@LoginUser TokenDto tokenDto) { + List result = badgeService.getList(tokenDto.getCustomerId()); + return new Result>().ok(result); + } + + /** + * 添加徽章 + * @author zhaoqifeng + * @date 2020/11/4 14:27 + * @param tokenDto + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + */ + @PostMapping("add") + public Result add(@LoginUser TokenDto tokenDto, @RequestBody AddBadgeFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO); + badgeService.add(tokenDto, formDTO); + return new Result(); + } + + /** + * 徽章详情 + * @author zhaoqifeng + * @date 2020/11/4 14:27 + * @param tokenDto + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + */ + @PostMapping("detail") + public Result detail(@LoginUser TokenDto tokenDto, @RequestBody BadgeFormDTO formDTO) { + BadgeDetailResultDTO result = badgeService.detail(tokenDto, formDTO); + return new Result().ok(result); + } + + /** + * 修改 + * @author zhaoqifeng + * @date 2020/11/4 15:32 + * @param tokenDto + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + */ + @PostMapping("edit") + public Result edit(@LoginUser TokenDto tokenDto, @RequestBody EditBadgeFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO); + badgeService.edit(tokenDto, formDTO); + return new Result(); + } + + /** + * 删除徽章 + * @author zhaoqifeng + * @date 2020/11/4 15:34 + * @param tokenDto + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + */ + @PostMapping("delete") + public Result delete(@LoginUser TokenDto tokenDto, @RequestBody BadgeFormDTO formDTO) { + badgeService.deleteBadge(tokenDto, formDTO); + return new Result(); + } + + +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/BadgeCertificationConfigDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/BadgeCertificationConfigDao.java new file mode 100644 index 0000000000..e60ac24fc5 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/BadgeCertificationConfigDao.java @@ -0,0 +1,54 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.entity.BadgeCertificationConfigEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 徽章认证配置 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-11-03 + */ +@Mapper +public interface BadgeCertificationConfigDao extends BaseDao { + /** + * 获取认证信息类型 + * @author zhaoqifeng + * @date 2020/11/4 14:42 + * @param customerId + * @param badgeId + * @return java.util.List + */ + List getCertificationType(@Param("customerId") String customerId, @Param("badgeId") String badgeId); + + /** + * 删除认证信息 + * @author zhaoqifeng + * @date 2020/11/4 14:43 + * @param customerId + * @param badgeId + * @return int + */ + int deleteConfig(@Param("customerId") String customerId, @Param("badgeId") String badgeId); +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/BadgeDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/BadgeDao.java new file mode 100644 index 0000000000..965f753b6e --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/BadgeDao.java @@ -0,0 +1,108 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.result.BadgeDetailResultDTO; +import com.epmet.dto.result.BadgeListResultDTO; +import com.epmet.entity.BadgeEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; +import org.omg.PortableInterceptor.ORBInitInfoPackage.DuplicateName; + +import java.util.List; + +/** + * 徽章 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-11-03 + */ +@Mapper +public interface BadgeDao extends BaseDao { + + /** + * 获取徽章列表 + * @author zhaoqifeng + * @date 2020/11/3 17:30 + * @param customerId + * @return java.util.List + */ + List selectList(@Param("customerId") String customerId); + + /** + * 重名校验 + * @author zhaoqifeng + * @date 2020/11/4 10:40 + * @param customerId + * @param badgeName + * @return java.util.List + */ + List getDuplicateName(@Param("customerId") String customerId, @Param("badgeName") String badgeName); + + /** + * 编辑重名校验 + * @author zhaoqifeng + * @date 2020/11/4 15:09 + * @param customerId + * @param badgeId + * @param badgeName + * @return java.util.List + */ + List getDuplicateNameForEdit(@Param("customerId") String customerId, @Param("badgeId") String badgeId, + @Param("badgeName") String badgeName); + + /** + * 获取徽章详情 + * @author zhaoqifeng + * @date 2020/11/4 14:30 + * @param customerId + * @param badgeId + * @return com.epmet.dto.result.BadgeDetailResultDTO + */ + BadgeDetailResultDTO selectDetail(@Param("customerId") String customerId, @Param("badgeId") String badgeId); + + /** + * 获取徽章信息 + * @author zhaoqifeng + * @date 2020/11/4 15:16 + * @param customerId + * @param badgeId + * @return com.epmet.entity.BadgeEntity + */ + BadgeEntity selectBadgeInfo(@Param("customerId") String customerId, @Param("badgeId") String badgeId); + + /** + * 更新徽章信息 + * @author zhaoqifeng + * @date 2020/11/4 15:38 + * @param entity + * @return void + */ + void updateBadge(BadgeEntity entity); + + /** + * 删除徽章信息 + * @author zhaoqifeng + * @date 2020/11/4 15:39 + * @param customerId + * @param badgeId + * @return void + */ + void deleteBadge(@Param("customerId") String customerId, @Param("badgeId") String badgeId); +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/BadgeCertificationConfigEntity.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/BadgeCertificationConfigEntity.java new file mode 100644 index 0000000000..90a6001940 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/BadgeCertificationConfigEntity.java @@ -0,0 +1,56 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.entity; + +import com.baomidou.mybatisplus.annotation.TableName; + +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * 徽章认证配置 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-11-03 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("badge_certification_config") +public class BadgeCertificationConfigEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户Id 默认配置id:default + */ + private String customerId; + + /** + * 徽章ID + */ + private String badgeId; + + /** + * 认证信息类型 手机号:mobile;全名:fullname;身份证:idcard;认证证件: certificate;认证说明(备注):remark + */ + private String certificationType; + +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/BadgeEntity.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/BadgeEntity.java new file mode 100644 index 0000000000..c6aec0b820 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/BadgeEntity.java @@ -0,0 +1,66 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.entity; + +import com.baomidou.mybatisplus.annotation.TableName; + +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * 徽章 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-11-03 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("badge") +public class BadgeEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户Id 默认配置id:default + */ + private String customerId; + + /** + * 徽章名称 + */ + private String badgeName; + + /** + * 徽章图标url + */ + private String badgeIcon; + + /** + * 固有徽章类型 前端页面跳转标识,党员徽章:party;无:none + */ + private String fixationBadgeType; + + /** + * 状态 上线:online;下线:offline; + */ + private String badgeStatus; + +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/redis/UserBadgeRedis.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/redis/UserBadgeRedis.java index 1b209e7dee..cf1a34f871 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/redis/UserBadgeRedis.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/redis/UserBadgeRedis.java @@ -1,18 +1,13 @@ package com.epmet.redis; import com.alibaba.fastjson.JSON; -import com.epmet.common.token.constant.LoginConstant; -import com.epmet.commons.tools.redis.RedisKeys; import com.epmet.commons.tools.redis.RedisUtils; -import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.constant.BadgeConstant; import com.epmet.dto.result.UserBadgeListResultDTO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import java.util.ArrayList; import java.util.List; -import java.util.Map; import static com.epmet.commons.tools.redis.RedisUtils.MINUTE_THIRTY_EXPIRE; diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/BadgeCertificationConfigService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/BadgeCertificationConfigService.java new file mode 100644 index 0000000000..5c14ca740a --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/BadgeCertificationConfigService.java @@ -0,0 +1,127 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.page.PageData; +import com.epmet.dto.BadgeCertificationConfigDTO; +import com.epmet.entity.BadgeCertificationConfigEntity; + +import java.util.List; +import java.util.Map; + +/** + * 徽章认证配置 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-11-03 + */ +public interface BadgeCertificationConfigService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2020-11-03 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2020-11-03 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return BadgeCertificationConfigDTO + * @author generator + * @date 2020-11-03 + */ + BadgeCertificationConfigDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2020-11-03 + */ + void save(BadgeCertificationConfigDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2020-11-03 + */ + void update(BadgeCertificationConfigDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2020-11-03 + */ + void delete(String[] ids); + + /** + * 获取认证信息类型 + * @author zhaoqifeng + * @date 2020/11/4 14:39 + * @param customerId + * @param badgeId + * @return java.util.List + */ + List getCertificationType(String customerId, String badgeId); + + /** + * 保存认证信息配置 + * @author zhaoqifeng + * @date 2020/11/4 15:29 + * @param customerId + * @param badgeId + * @param list + * @return void + */ + void saveConfig(String customerId, String badgeId, List list); + + /** + * 删除配置 + * @author zhaoqifeng + * @date 2020/11/4 15:41 + * @param customerId + * @param badgeId + * @return void + */ + void deleteConfig(String customerId, String badgeId); + +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/BadgeService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/BadgeService.java new file mode 100644 index 0000000000..7b73e28561 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/BadgeService.java @@ -0,0 +1,150 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +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.BadgeDTO; +import com.epmet.dto.form.AddBadgeFormDTO; +import com.epmet.dto.form.BadgeFormDTO; +import com.epmet.dto.form.EditBadgeFormDTO; +import com.epmet.dto.result.BadgeDetailResultDTO; +import com.epmet.dto.result.BadgeListResultDTO; +import com.epmet.entity.BadgeEntity; + +import java.util.List; +import java.util.Map; + +/** + * 徽章 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-11-03 + */ +public interface BadgeService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2020-11-03 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2020-11-03 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return BadgeDTO + * @author generator + * @date 2020-11-03 + */ + BadgeDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2020-11-03 + */ + void save(BadgeDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2020-11-03 + */ + void update(BadgeDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2020-11-03 + */ + void delete(String[] ids); + + /** + * 获取徽章列表 + * @author zhaoqifeng + * @date 2020/11/3 17:04 + * @param customerId + * @return java.util.List + */ + List getList(String customerId); + + /** + * 添加徽章 + * @author zhaoqifeng + * @date 2020/11/4 10:09 + * @param tokenDto + * @param formDTO + * @return void + */ + void add(TokenDto tokenDto, AddBadgeFormDTO formDTO); + + /** + * 徽章详情 + * @author zhaoqifeng + * @date 2020/11/4 14:25 + * @param tokenDto + * @param formDTO + * @return com.epmet.dto.result.BadgeDetailResultDTO + */ + BadgeDetailResultDTO detail(TokenDto tokenDto, BadgeFormDTO formDTO); + + /** + * 编辑徽章 + * @author zhaoqifeng + * @date 2020/11/4 14:28 + * @param tokenDto + * @param formDTO + * @return void + */ + void edit(TokenDto tokenDto, EditBadgeFormDTO formDTO); + + /** + * 删除徽章 + * @author zhaoqifeng + * @date 2020/11/4 15:34 + * @param tokenDto + * @param formDTO + * @return void + */ + void deleteBadge(TokenDto tokenDto, BadgeFormDTO formDTO); +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/BadgeCertificationConfigServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/BadgeCertificationConfigServiceImpl.java new file mode 100644 index 0000000000..2af4587368 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/BadgeCertificationConfigServiceImpl.java @@ -0,0 +1,149 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service.impl; + +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.page.PageData; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.dao.BadgeCertificationConfigDao; +import com.epmet.dto.BadgeCertificationConfigDTO; +import com.epmet.entity.BadgeCertificationConfigEntity; +import com.epmet.service.BadgeCertificationConfigService; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * 徽章认证配置 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-11-03 + */ +@Service +public class BadgeCertificationConfigServiceImpl extends BaseServiceImpl implements BadgeCertificationConfigService { + + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, BadgeCertificationConfigDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, BadgeCertificationConfigDTO.class); + } + + private QueryWrapper getWrapper(Map params){ + String id = (String)params.get(FieldConstant.ID_HUMP); + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); + + return wrapper; + } + + @Override + public BadgeCertificationConfigDTO get(String id) { + BadgeCertificationConfigEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, BadgeCertificationConfigDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(BadgeCertificationConfigDTO dto) { + BadgeCertificationConfigEntity entity = ConvertUtils.sourceToTarget(dto, BadgeCertificationConfigEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(BadgeCertificationConfigDTO dto) { + BadgeCertificationConfigEntity entity = ConvertUtils.sourceToTarget(dto, BadgeCertificationConfigEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + /** + * 获取认证信息类型 + * + * @param customerId + * @param badgeId + * @return java.util.List + * @author zhaoqifeng + * @date 2020/11/4 14:39 + */ + @Override + public List getCertificationType(String customerId, String badgeId) { + List list = baseDao.getCertificationType(customerId, badgeId); + if (CollectionUtils.isEmpty(list)) { + list = baseDao.getCertificationType("default", badgeId); + } + return list; + } + + /** + * 保存认证信息配置 + * + * @param list + * @return void + * @author zhaoqifeng + * @date 2020/11/4 15:28 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void saveConfig(String customerId, String badgeId, List list) { + baseDao.deleteConfig(customerId, badgeId); + insertBatch(list); + } + + /** + * 删除配置 + * + * @param customerId + * @param badgeId + * @return void + * @author zhaoqifeng + * @date 2020/11/4 15:41 + */ + @Override + public void deleteConfig(String customerId, String badgeId) { + baseDao.deleteConfig(customerId, badgeId); + } + +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/BadgeServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/BadgeServiceImpl.java new file mode 100644 index 0000000000..021b0c734a --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/BadgeServiceImpl.java @@ -0,0 +1,248 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service.impl; + +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.NumConstant; +import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.RenException; +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.commons.tools.constant.FieldConstant; +import com.epmet.constant.BadgeConstant; +import com.epmet.dao.BadgeDao; +import com.epmet.dto.BadgeDTO; +import com.epmet.dto.form.AddBadgeFormDTO; +import com.epmet.dto.form.BadgeFormDTO; +import com.epmet.dto.form.EditBadgeFormDTO; +import com.epmet.dto.result.BadgeDetailResultDTO; +import com.epmet.dto.result.BadgeListResultDTO; +import com.epmet.entity.BadgeCertificationConfigEntity; +import com.epmet.entity.BadgeEntity; +import com.epmet.service.BadgeCertificationConfigService; +import com.epmet.service.BadgeService; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * 徽章 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-11-03 + */ +@Service +public class BadgeServiceImpl extends BaseServiceImpl implements BadgeService { + + @Autowired + private BadgeCertificationConfigService badgeCertificationConfigService; + + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, BadgeDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, BadgeDTO.class); + } + + private QueryWrapper getWrapper(Map params){ + String id = (String)params.get(FieldConstant.ID_HUMP); + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); + + return wrapper; + } + + @Override + public BadgeDTO get(String id) { + BadgeEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, BadgeDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(BadgeDTO dto) { + BadgeEntity entity = ConvertUtils.sourceToTarget(dto, BadgeEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(BadgeDTO dto) { + BadgeEntity entity = ConvertUtils.sourceToTarget(dto, BadgeEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + /** + * 获取徽章列表 + * + * @param customerId + * @return java.util.List + * @author zhaoqifeng + * @date 2020/11/3 17:04 + */ + @Override + public List getList(String customerId) { + return baseDao.selectList(customerId); + } + + /** + * 添加徽章 + * + * @param tokenDto + * @param formDTO + * @return void + * @author zhaoqifeng + * @date 2020/11/4 10:09 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void add(TokenDto tokenDto, AddBadgeFormDTO formDTO) { + //重名校验 + List list = baseDao.getDuplicateName(tokenDto.getCustomerId(), formDTO.getBadgeName()); + if (CollectionUtils.isNotEmpty(list)) { + throw new RenException(EpmetErrorCode.DUPLICATE_BADGE_NAME.getCode()); + } + BadgeEntity entity = ConvertUtils.sourceToTarget(formDTO, BadgeEntity.class); + entity.setCustomerId(tokenDto.getCustomerId()); + entity.setFixationBadgeType(BadgeConstant.NONE); + insert(entity); + //保存徽章认证配置 + List badgeList = new ArrayList<>(); + formDTO.getCertificationTypes().forEach(item -> { + BadgeCertificationConfigEntity badge = new BadgeCertificationConfigEntity(); + badge.setBadgeId(entity.getId()); + badge.setCertificationType(item); + badge.setCustomerId(tokenDto.getCustomerId()); + badgeList.add(badge); + }); + badgeCertificationConfigService.insertBatch(badgeList); + } + + /** + * 徽章详情 + * + * @param tokenDto + * @param formDTO + * @return com.epmet.dto.result.BadgeDetailResultDTO + * @author zhaoqifeng + * @date 2020/11/4 14:25 + */ + @Override + public BadgeDetailResultDTO detail(TokenDto tokenDto, BadgeFormDTO formDTO) { + BadgeDetailResultDTO result = baseDao.selectDetail(tokenDto.getCustomerId(), formDTO.getBadgeId()); + List types = badgeCertificationConfigService.getCertificationType(tokenDto.getCustomerId(), formDTO.getBadgeId()); + result.setCertificationTypes(types); + return result; + } + + /** + * 编辑徽章 + * + * @param tokenDto + * @param formDTO + * @return void + * @author zhaoqifeng + * @date 2020/11/4 14:28 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void edit(TokenDto tokenDto, EditBadgeFormDTO formDTO) { + //重名校验 + List list = baseDao.getDuplicateNameForEdit(tokenDto.getCustomerId(), formDTO.getBadgeId(), formDTO.getBadgeName()); + if (CollectionUtils.isNotEmpty(list)) { + throw new RenException(EpmetErrorCode.DUPLICATE_BADGE_NAME.getCode()); + } + + BadgeEntity badgeEntity = baseDao.selectBadgeInfo(tokenDto.getCustomerId(), formDTO.getBadgeId()); + if (null == badgeEntity) { + badgeEntity = baseDao.selectBadgeInfo("default", formDTO.getBadgeId()); + badgeEntity.setCustomerId(tokenDto.getCustomerId()); + badgeEntity.setBadgeName(formDTO.getBadgeName()); + badgeEntity.setBadgeIcon(formDTO.getBadgeIcon()); + badgeEntity.setBadgeStatus(formDTO.getBadgeStatus()); + baseDao.insert(badgeEntity); + } else { + badgeEntity.setBadgeName(formDTO.getBadgeName()); + badgeEntity.setBadgeIcon(formDTO.getBadgeIcon()); + badgeEntity.setBadgeStatus(formDTO.getBadgeStatus()); + baseDao.updateBadge(badgeEntity); + } + //保存徽章认证配置 + List badgeList = new ArrayList<>(); + formDTO.getCertificationTypes().forEach(item -> { + BadgeCertificationConfigEntity badge = new BadgeCertificationConfigEntity(); + badge.setBadgeId(formDTO.getBadgeId()); + badge.setCertificationType(item); + badge.setCustomerId(tokenDto.getCustomerId()); + badgeList.add(badge); + }); + badgeCertificationConfigService.saveConfig(tokenDto.getCustomerId(), formDTO.getBadgeId(), badgeList); + } + + /** + * 删除徽章 + * + * @param tokenDto + * @param formDTO + * @return void + * @author zhaoqifeng + * @date 2020/11/4 15:34 + */ + @Override + public void deleteBadge(TokenDto tokenDto, BadgeFormDTO formDTO) { + BadgeEntity badgeEntity = baseDao.selectBadgeInfo(tokenDto.getCustomerId(), formDTO.getBadgeId()); + if (null == badgeEntity) { + badgeEntity = baseDao.selectBadgeInfo("default", formDTO.getBadgeId()); + badgeEntity.setCustomerId(tokenDto.getCustomerId()); + badgeEntity.setDelFlag(NumConstant.ONE_STR); + baseDao.insert(badgeEntity); + } else { + baseDao.deleteBadge(tokenDto.getCustomerId(), formDTO.getBadgeId()); + } + badgeCertificationConfigService.deleteConfig(tokenDto.getCustomerId(), formDTO.getBadgeId()); + } + +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/BadgeCertificationConfigDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/BadgeCertificationConfigDao.xml new file mode 100644 index 0000000000..251523c8d3 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/BadgeCertificationConfigDao.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + DELETE a + FROM + badge_certification_config a + WHERE + EXISTS ( + SELECT + * + FROM + ( SELECT ID FROM badge_certification_config + WHERE CUSTOMER_ID = #{customerId} + AND BADGE_ID = #{badgeId} + AND DEL_FLAG = '0' ) b + WHERE + a.ID = b.ID) + + + + + \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/BadgeDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/BadgeDao.xml new file mode 100644 index 0000000000..322604bc70 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/BadgeDao.xml @@ -0,0 +1,116 @@ + + + + + + + + + + + + + + + + + + + + + update badge set + BADGE_NAME = #{badgeName}, + BADGE_ICON = #{badgeIcon}, + BADGE_STATUS = #{badgeStatus} + where ID = #{id} AND CUSTOMER_ID = #{customerId} + + + + update badge set + DEL_FLAG = '1' + where ID = #{badgeId} AND CUSTOMER_ID = #{customerId} + + + + + + + + + \ No newline at end of file From 27268ab2b69c29cb6467027a43237c7788200301 Mon Sep 17 00:00:00 2001 From: jianjun Date: Wed, 4 Nov 2020 17:27:55 +0800 Subject: [PATCH 12/16] =?UTF-8?q?=E5=B1=8F=E8=94=BD=E9=83=A8=E5=88=86?= =?UTF-8?q?=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/logback-spring.xml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/logback-spring.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/logback-spring.xml index f099678400..b2e0b7a9da 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/logback-spring.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/logback-spring.xml @@ -173,6 +173,13 @@ + + + + + + + From b34751518dba1d35de4473bffa6aa46fe42df0c3 Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Wed, 4 Nov 2020 17:36:43 +0800 Subject: [PATCH 13/16] =?UTF-8?q?=E4=B8=AA=E4=BA=BA=E4=B8=AD=E5=BF=83-?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E5=BE=BD=E7=AB=A0=E8=A6=81=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E7=9A=84=E8=AE=A4=E8=AF=81=E4=BF=A1=E6=81=AF=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/epmet/dto/form/AuthFieldFormDTO.java | 24 +++++++++++ .../epmet/dto/result/AuthFieldResultDTO.java | 40 +++++++++++++++++++ .../epmet/controller/UserBadgeController.java | 13 ++++++ .../main/java/com/epmet/dao/UserBadgeDao.java | 10 +++++ .../com/epmet/service/UserBadgeService.java | 11 ++++- .../service/impl/UserBadgeServiceImpl.java | 18 ++++++++- .../main/resources/mapper/UserBadgeDao.xml | 17 ++++++++ 7 files changed, 129 insertions(+), 4 deletions(-) create mode 100644 epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/AuthFieldFormDTO.java create mode 100644 epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/AuthFieldResultDTO.java diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/AuthFieldFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/AuthFieldFormDTO.java new file mode 100644 index 0000000000..b5c716470f --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/AuthFieldFormDTO.java @@ -0,0 +1,24 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Author zxc + * @DateTime 2020/11/4 4:54 下午 + */ +@Data +public class AuthFieldFormDTO implements Serializable { + + private static final long serialVersionUID = 1976515427065841752L; + + public interface AuthField{} + + @NotBlank(message = "客户ID不能为空",groups = {AuthField.class}) + private String customerId; + + @NotBlank(message = "徽章ID不能为空",groups = {AuthField.class}) + private String badgeId; +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/AuthFieldResultDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/AuthFieldResultDTO.java new file mode 100644 index 0000000000..9c68bf19af --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/AuthFieldResultDTO.java @@ -0,0 +1,40 @@ +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author zxc + * @DateTime 2020/11/4 4:54 下午 + */ +@Data +public class AuthFieldResultDTO implements Serializable { + + private static final long serialVersionUID = 1856490232343125419L; + + /** + * 中文名 + */ + private String cnName; + + /** + * 英文名【字段】 + */ + private String enName; + + /** + * 字段类型,text:文本,img:图片 + */ + private String fieldType; + + /** + * 是否必填 + */ + private String isRequired; + + /** + * 排序 + */ + private Integer sort; +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserBadgeController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserBadgeController.java index ff5767867e..3a4a590a81 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserBadgeController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserBadgeController.java @@ -5,6 +5,7 @@ import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.dto.form.*; +import com.epmet.dto.result.AuthFieldResultDTO; import com.epmet.dto.result.CertificationDetailResultDTO; import com.epmet.dto.result.UserBadgeListResultDTO; import com.epmet.dto.result.UserOperListResultDTO; @@ -88,4 +89,16 @@ public class UserBadgeController { return new Result().ok(userBadgeService.certificationDetail(tokenDto,certificationDetailFormDTO)); } + /** + * @Description 个人中心-查询徽章要显示的认证信息字段 + * @Param authFieldFormDTO + * @author zxc + * @date 2020/11/4 5:05 下午 + */ + @PostMapping("authfield") + public Result> authField(@RequestBody AuthFieldFormDTO authFieldFormDTO){ + ValidatorUtils.validateEntity(authFieldFormDTO, AuthFieldFormDTO.AuthField.class); + return new Result>().ok(userBadgeService.authField(authFieldFormDTO)); + } + } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/UserBadgeDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/UserBadgeDao.java index 7025c1870c..6db7752cfd 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/UserBadgeDao.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/UserBadgeDao.java @@ -1,7 +1,9 @@ package com.epmet.dao; import com.epmet.dto.UserBadgeCertificateRecordDTO; +import com.epmet.dto.form.AuthFieldFormDTO; import com.epmet.dto.form.UserBadgeListFormDTO; +import com.epmet.dto.result.AuthFieldResultDTO; import com.epmet.dto.result.CertificationDetailResultDTO; import com.epmet.dto.result.UserBadgeListResultDTO; import com.epmet.dto.result.UserOperListResultDTO; @@ -74,4 +76,12 @@ public interface UserBadgeDao { * @date 2020/11/4 4:09 下午 */ CertificationDetailResultDTO selectBadgeAuthRecord(@Param("userId")String userId, @Param("badgeId")String badgeId); + + /** + * @Description 个人中心-查询徽章要显示的认证信息字段 + * @Param authFieldFormDTO + * @author zxc + * @date 2020/11/4 5:05 下午 + */ + List selectAuthField(AuthFieldFormDTO authFieldFormDTO); } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserBadgeService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserBadgeService.java index e9cc979c91..b8bf156046 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserBadgeService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserBadgeService.java @@ -1,13 +1,12 @@ package com.epmet.service; -import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.form.*; +import com.epmet.dto.result.AuthFieldResultDTO; import com.epmet.dto.result.CertificationDetailResultDTO; import com.epmet.dto.result.UserBadgeListResultDTO; import com.epmet.dto.result.UserOperListResultDTO; -import org.springframework.web.bind.annotation.RequestBody; import java.util.List; @@ -58,4 +57,12 @@ public interface UserBadgeService { */ CertificationDetailResultDTO certificationDetail(TokenDto tokenDto, CertificationDetailFormDTO certificationDetailFormDTO); + /** + * @Description 个人中心-查询徽章要显示的认证信息字段 + * @Param authFieldFormDTO + * @author zxc + * @date 2020/11/4 5:05 下午 + */ + List authField(AuthFieldFormDTO authFieldFormDTO); + } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBadgeServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBadgeServiceImpl.java index 2d96216eaa..d1d8d1266f 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBadgeServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBadgeServiceImpl.java @@ -46,8 +46,6 @@ public class UserBadgeServiceImpl implements UserBadgeService { @Autowired private UserBaseInfoService userBaseInfoService; @Autowired - private CustomerStaffService customerStaffService; - @Autowired private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient; /** @@ -209,4 +207,20 @@ public class UserBadgeServiceImpl implements UserBadgeService { return userBadgeDao.selectBadgeAuthRecord(certificationDetailFormDTO.getUserId(), certificationDetailFormDTO.getBadgeId()); } + + /** + * @Description 个人中心-查询徽章要显示的认证信息字段 + * @Param authFieldFormDTO + * @author zxc + * @date 2020/11/4 5:05 下午 + */ + @Override + public List authField(AuthFieldFormDTO authFieldFormDTO) { + List authFieldResultDTOS = userBadgeDao.selectAuthField(authFieldFormDTO); + if (CollectionUtils.isEmpty(authFieldResultDTOS)){ + return new ArrayList<>(); + } + return authFieldResultDTOS; + } + } diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/UserBadgeDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/UserBadgeDao.xml index 5d46734499..bbecca58ec 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/UserBadgeDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/UserBadgeDao.xml @@ -92,6 +92,23 @@ AND USER_ID = #{userId} + + + INSERT INTO user_badge_certificate_record ( From 28b1d13eea39d161872dc644a0edb09ec233c91a Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Thu, 5 Nov 2020 09:49:43 +0800 Subject: [PATCH 14/16] =?UTF-8?q?=E5=BE=BD=E7=AB=A0=E7=82=B9=E4=BA=AE/?= =?UTF-8?q?=E5=8F=96=E6=B6=88=E7=82=B9=E4=BA=AE=F0=9F=9B=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../badege/controller/BadgeController.java | 14 ++++++++++ .../modules/badege/service/BadgeService.java | 9 +++++++ .../badege/service/impl/BadgeServiceImpl.java | 16 ++++++++++++ .../epmet/dto/form/OpenedOrClosedFormDTO.java | 26 +++++++++++++++++++ .../epmet/feign/EpmetUserOpenFeignClient.java | 9 +++++++ .../EpmetUserOpenFeignClientFallback.java | 5 ++++ .../epmet/controller/UserBadgeController.java | 12 +++++++++ .../main/java/com/epmet/dao/UserBadgeDao.java | 8 ++++++ .../com/epmet/service/UserBadgeService.java | 8 ++++++ .../service/impl/UserBadgeServiceImpl.java | 12 ++++++++- .../main/resources/mapper/UserBadgeDao.xml | 10 +++++++ 11 files changed, 128 insertions(+), 1 deletion(-) create mode 100644 epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/OpenedOrClosedFormDTO.java diff --git a/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/controller/BadgeController.java b/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/controller/BadgeController.java index 8d70e5d097..da3bfca3d2 100644 --- a/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/controller/BadgeController.java +++ b/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/controller/BadgeController.java @@ -4,6 +4,7 @@ import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.dto.form.OpenedOrClosedFormDTO; import com.epmet.modules.badege.service.BadgeService; import com.epmet.resi.mine.dto.from.BadgeListFormDTO; import com.epmet.dto.form.CertificationAddFormDTO; @@ -67,5 +68,18 @@ public class BadgeController { return new Result(); } + /** + * @Description 个人中心-取消/点亮徽章 + * @Param openedOrClosedFormDTO + * @author zxc + * @date 2020/11/5 9:23 上午 + */ + @PostMapping("openedorclosed") + public Result openedOrClosed(@LoginUser TokenDto tokenDto,@RequestBody OpenedOrClosedFormDTO openedOrClosedFormDTO){ + ValidatorUtils.validateEntity(openedOrClosedFormDTO, OpenedOrClosedFormDTO.OpenedOrClosed.class); + badgeService.openedOrClosed(tokenDto,openedOrClosedFormDTO); + return new Result(); + } + } diff --git a/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/service/BadgeService.java b/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/service/BadgeService.java index 6d020bc286..1b67df51f8 100644 --- a/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/service/BadgeService.java +++ b/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/service/BadgeService.java @@ -1,6 +1,7 @@ package com.epmet.modules.badege.service; import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.dto.form.OpenedOrClosedFormDTO; import com.epmet.resi.mine.dto.from.BadgeListFormDTO; import com.epmet.dto.form.CertificationAddFormDTO; import com.epmet.resi.mine.dto.from.OperListFormDTO; @@ -40,4 +41,12 @@ public interface BadgeService { */ void certificationAdd(TokenDto tokenDto, CertificationAddFormDTO certificationAddFormDTO); + /** + * @Description 个人中心-取消/点亮徽章 + * @Param openedOrClosedFormDTO + * @author zxc + * @date 2020/11/5 9:23 上午 + */ + void openedOrClosed(TokenDto tokenDto,OpenedOrClosedFormDTO openedOrClosedFormDTO); + } diff --git a/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/service/impl/BadgeServiceImpl.java b/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/service/impl/BadgeServiceImpl.java index 259ffc23ae..4abc5853b6 100644 --- a/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/service/impl/BadgeServiceImpl.java +++ b/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/badege/service/impl/BadgeServiceImpl.java @@ -4,6 +4,7 @@ import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.form.OpenedOrClosedFormDTO; import com.epmet.dto.form.UserBadgeListFormDTO; import com.epmet.dto.form.UserOperListFormDTO; import com.epmet.dto.result.UserBadgeListResultDTO; @@ -92,4 +93,19 @@ public class BadgeServiceImpl implements BadgeService { throw new RenException("提交徽章认证失败......"); } } + + /** + * @Description 个人中心-取消/点亮徽章 + * @Param openedOrClosedFormDTO + * @author zxc + * @date 2020/11/5 9:23 上午 + */ + @Override + public void openedOrClosed(TokenDto tokenDto,OpenedOrClosedFormDTO openedOrClosedFormDTO) { + openedOrClosedFormDTO.setUserId(tokenDto.getUserId()); + Result result = epmetUserOpenFeignClient.openedOrClosed(openedOrClosedFormDTO); + if (!result.success()){ + throw new RenException("取消/点亮徽章失败了......"); + } + } } diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/OpenedOrClosedFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/OpenedOrClosedFormDTO.java new file mode 100644 index 0000000000..15353d9685 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/OpenedOrClosedFormDTO.java @@ -0,0 +1,26 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Author zxc + * @DateTime 2020/11/4 5:43 下午 + */ +@Data +public class OpenedOrClosedFormDTO implements Serializable { + + private static final long serialVersionUID = 483466676158603066L; + + public interface OpenedOrClosed{} + + @NotBlank(message = "客户ID不能为空",groups = {OpenedOrClosed.class}) + private String customerId; + + private String userId; + + @NotBlank(message = "徽章ID不能为空",groups = {OpenedOrClosed.class}) + private String badgeId; +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java index f5f531b656..00397c89e1 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java @@ -364,4 +364,13 @@ public interface EpmetUserOpenFeignClient { */ @PostMapping("/epmetuser/more/badge/authbadgerecord") Result authBadgeRecord(@RequestBody CertificationAddFormDTO certificationAddFormDTO); + + /** + * @Description 个人中心-取消/点亮徽章 + * @Param openedOrClosedFormDTO + * @author zxc + * @date 2020/11/5 9:23 上午 + */ + @PostMapping("/epmetuser/more/badge/openedorclosed") + Result openedOrClosed(@RequestBody OpenedOrClosedFormDTO openedOrClosedFormDTO); } diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java index 789acb75f4..6091c24821 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java @@ -240,4 +240,9 @@ public class EpmetUserOpenFeignClientFallback implements EpmetUserOpenFeignClien public Result authBadgeRecord(CertificationAddFormDTO certificationAddFormDTO) { return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "authBadgeRecord", certificationAddFormDTO); } + + @Override + public Result openedOrClosed(OpenedOrClosedFormDTO openedOrClosedFormDTO) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "openedOrClosed", openedOrClosedFormDTO); + } } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserBadgeController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserBadgeController.java index 3a4a590a81..c0aa74d53e 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserBadgeController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserBadgeController.java @@ -101,4 +101,16 @@ public class UserBadgeController { return new Result>().ok(userBadgeService.authField(authFieldFormDTO)); } + /** + * @Description 个人中心-取消/点亮徽章 + * @Param openedOrClosedFormDTO + * @author zxc + * @date 2020/11/4 5:47 下午 + */ + @PostMapping("openedorclosed") + public Result openedOrClosed(@RequestBody OpenedOrClosedFormDTO openedOrClosedFormDTO){ + userBadgeService.openedOrClosed(openedOrClosedFormDTO); + return new Result(); + } + } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/UserBadgeDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/UserBadgeDao.java index 6db7752cfd..a100a80ec2 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/UserBadgeDao.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/UserBadgeDao.java @@ -2,6 +2,7 @@ package com.epmet.dao; import com.epmet.dto.UserBadgeCertificateRecordDTO; import com.epmet.dto.form.AuthFieldFormDTO; +import com.epmet.dto.form.OpenedOrClosedFormDTO; import com.epmet.dto.form.UserBadgeListFormDTO; import com.epmet.dto.result.AuthFieldResultDTO; import com.epmet.dto.result.CertificationDetailResultDTO; @@ -84,4 +85,11 @@ public interface UserBadgeDao { * @date 2020/11/4 5:05 下午 */ List selectAuthField(AuthFieldFormDTO authFieldFormDTO); + /** + * @Description 个人中心-取消/点亮徽章 + * @Param openedOrClosedFormDTO + * @author zxc + * @date 2020/11/4 6:04 下午 + */ + void updateIsOpen(OpenedOrClosedFormDTO openedOrClosedFormDTO); } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserBadgeService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserBadgeService.java index b8bf156046..227584a101 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserBadgeService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserBadgeService.java @@ -65,4 +65,12 @@ public interface UserBadgeService { */ List authField(AuthFieldFormDTO authFieldFormDTO); + /** + * @Description 个人中心-取消/点亮徽章 + * @Param openedOrClosedFormDTO + * @author zxc + * @date 2020/11/4 5:47 下午 + */ + void openedOrClosed(OpenedOrClosedFormDTO openedOrClosedFormDTO); + } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBadgeServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBadgeServiceImpl.java index d1d8d1266f..24af3d436b 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBadgeServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBadgeServiceImpl.java @@ -16,7 +16,6 @@ import com.epmet.dto.form.*; import com.epmet.dto.result.*; import com.epmet.feign.EpmetMessageOpenFeignClient; import com.epmet.redis.UserBadgeRedis; -import com.epmet.service.CustomerStaffService; import com.epmet.service.UserBadgeService; import com.epmet.service.UserBaseInfoService; import lombok.extern.slf4j.Slf4j; @@ -223,4 +222,15 @@ public class UserBadgeServiceImpl implements UserBadgeService { return authFieldResultDTOS; } + /** + * @Description 个人中心-取消/点亮徽章 + * @Param openedOrClosedFormDTO + * @author zxc + * @date 2020/11/4 5:47 下午 + */ + @Override + public void openedOrClosed(OpenedOrClosedFormDTO openedOrClosedFormDTO) { + userBadgeDao.updateIsOpen(openedOrClosedFormDTO); + } + } diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/UserBadgeDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/UserBadgeDao.xml index bbecca58ec..436898cc61 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/UserBadgeDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/UserBadgeDao.xml @@ -12,6 +12,16 @@ AND USER_ID = #{userId} + + + UPDATE resi_user_badge + SET IS_OPENED = (case when IS_OPENED = 1 THEN 0 ELSE 1 END), + UPDATED_TIME = NOW() + WHERE DEL_FLAG = '0' + AND USER_ID = #{userId} + AND BADGE_ID = #{badgeId} + +