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 daa42dc9eb..de2af9b1f1 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 @@ -97,6 +97,7 @@ public enum EpmetErrorCode { //徽章管理 DUPLICATE_BADGE_NAME(8515, "徽章名已存在"), + DUPLICATE_PARTY_BADGE_NAME(8516, "不可删除党员徽章"), // 该错误不会提示给前端,只是后端传输错误信息用。 ACCESS_SQL_FILTER_MISSION_ARGS(8701, "缺少生成权限过滤SQL所需参数"), diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisUtils.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisUtils.java index 27a081dacc..19d8e73374 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisUtils.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisUtils.java @@ -9,16 +9,23 @@ package com.epmet.commons.tools.redis; import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.exception.RenException; +import com.epmet.commons.tools.utils.ConvertUtils; +import org.apache.poi.ss.formula.functions.T; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory; import org.springframework.data.redis.core.*; import org.springframework.data.redis.support.atomic.RedisAtomicLong; import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; import java.util.Collection; +import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; /** * Redis工具类 @@ -171,10 +178,40 @@ public class RedisUtils { } } - public Object lindex(String key,Long index){ - return redisTemplate.opsForList().index(key,index); + public Object lindex(String key,Long index){ return redisTemplate.opsForList().index(key,index); } + public List lrange(String key,long start,long end,Class clazz){ + List content = redisTemplate.opsForList().range(key,start,end); + if(CollectionUtils.isEmpty(content)) return null; + return content.stream().map( o -> { + try { + T target = clazz.newInstance(); + BeanUtils.copyProperties(o, target); + return target; + }catch (Exception e){throw new RenException("convert error");} + }).collect(Collectors.toList()); + } + + /** + * @Description Redis lrem : + * 根据参数 count 的值,移除列表中与参数 value 相等的元素 + * COUNT 的值可以是以下几种 : + * count > 0 : 从表头开始向表尾搜索,移除与 value 相等的元素,数量为 count + * count < 0 : 从表尾开始向表头搜索,移除与 value 相等的元素,数量为 count 的绝对值 + * count = 0 : 移除表中所有与 value 相等的值 + * 返回值 : + * 被移除元素的数量 + * 列表不存在时返回 0 + * @param key + * @param count + * @param o 这里的Object需要重写equals(FIXME 注意序列化) + * @return long + * @author wangc + * @date 2020.11.05 10:22 + */ + public long lrem(String key,long count,Object o){ return redisTemplate.opsForList().remove(key,count,o);} + public Object rightPop(String key) { return redisTemplate.opsForList().rightPop(key); } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerAgencyController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerAgencyController.java index 80acd68b46..3d14c14ea7 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerAgencyController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerAgencyController.java @@ -17,7 +17,9 @@ package com.epmet.controller; +import com.baomidou.mybatisplus.extension.api.R; import com.epmet.commons.tools.annotation.LoginUser; +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.ExcelUtils; @@ -32,10 +34,13 @@ import com.epmet.dto.form.*; import com.epmet.dto.result.*; import com.epmet.excel.CustomerAgencyExcel; import com.epmet.service.CustomerAgencyService; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletResponse; +import javax.validation.constraints.NotBlank; import java.util.List; import java.util.Map; @@ -244,20 +249,17 @@ public class CustomerAgencyController { } /** - * @Description 对外接口-根据组织Id获取组织信息 - * @author sun - **/ - @PostMapping("agencyinfo") - Result agencyInfo(@RequestBody AgencyInfoFormDTO formDTO) { - return new Result().ok(customerAgencyService.agencyInfo(formDTO)); - } - - /** - * @Description 外挂-获取当前组织及部门、网格数据,递归查询所有下级数据 - * @author sun - **/ - @PostMapping("organizetree/{agencyId}") - Result organizeTree(@PathVariable("agencyId") String agencyId) { - return new Result().ok(customerAgencyService.organizeTree(agencyId)); + * @Description 对外接口,根据customerId返回Element UI中Tree结构的agency列表 + * @param customerId + * @return com.epmet.commons.tools.utils.Result + * @Author liushaowen + * @Date 2020/11/6 13:51 + */ + @PostMapping("getagencyelementtree") + public Result getAgencyElementTree(String customerId){ + if (StringUtils.isBlank(customerId)){ + throw new RenException("customerId不能为空"); + } + return new Result().ok(customerAgencyService.getAgencyElementTree(customerId)); } -} \ No newline at end of file +} diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java index 1c6f42456c..19b2e338b4 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java @@ -57,7 +57,7 @@ public interface CustomerAgencyDao extends BaseDao { * @Author sun * @Description 组织首页-下级机关列表 **/ - List selectSubAgencyById(@Param("pId") String pId, @Param("agencyNum") Integer agencyNum); + List selectSubAgencyById(@Param("pId") String pId); /** * @param pId @@ -177,23 +177,12 @@ public interface CustomerAgencyDao extends BaseDao { AgencyResultDTO selectAgencyByStaffId(@Param("staffId") String staffId); /** - * @Description 外挂-获取当前组织及部门、网格数据,递归查询所有下级数据 - * @author sun - **/ - OrganizeTreeResultDTO selectorganizeTree(@Param("agencyId") String agencyId); - /** - * @Description 外挂-获取当前组织及部门、网格数据,递归查询所有下级数据 - * @author sun - **/ - List selectAgencyGridList(@Param("agencyId") String agencyId); - /** - * @Description 外挂-获取当前组织及部门、网格数据,递归查询所有下级数据 - * @author sun - **/ - List selectAgencyDeptList(@Param("agencyId") String agencyId); - /** - * @Description 外挂-获取当前组织及部门、网格数据,递归查询所有下级数据 - * @author sun - **/ - List selectAllSub(@Param("agencyId") String agencyId); -} \ No newline at end of file + * @Description 返回elementTree结构的agency树 + * @param customerId + * @param pid + * @return java.util.List + * @Author liushaowen + * @Date 2020/11/6 14:57 + */ + List getAgencyElementTree(@Param("customerId") String customerId,@Param("pid") String pid); +} diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerAgencyService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerAgencyService.java index 9297e8f5f1..aecfd85109 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerAgencyService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerAgencyService.java @@ -215,14 +215,11 @@ public interface CustomerAgencyService extends BaseService StaffInAgencyListResultDTO staffInAgencyList(String staffId); /** - * @Description 对外接口-根据组织Id获取组织信息 - * @author sun - **/ - AgencyInfoResultDTO agencyInfo(AgencyInfoFormDTO formDTO); - - /** - * @Description 外挂-获取当前组织及部门、网格数据,递归查询所有下级数据 - * @author sun - **/ - OrganizeTreeResultDTO organizeTree(String agencyId); -} \ No newline at end of file + * @Description 运营端-返回element ui - tree 结构agency列表 + * @param customerId + * @return com.epmet.dto.result.AgencyElementTreeResultDTO + * @Author liushaowen + * @Date 2020/11/6 14:02 + */ + AgencyElementTreeResultDTO getAgencyElementTree(String customerId); +} diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java index dd3360a781..9838fdd95f 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java @@ -995,39 +995,30 @@ public class CustomerAgencyServiceImpl extends BaseServiceImpl agencyList = baseDao.getAgencyElementTree(customerId, "0"); + Set defaultKeys = new HashSet<>(); + traversalAgencyList(agencyList,0,defaultKeys); + AgencyElementTreeResultDTO dto = new AgencyElementTreeResultDTO(); + dto.setList(agencyList); + dto.setDefaultKeys(defaultKeys); + return dto; + } + private void traversalAgencyList(List agencyList,int times,Set set){ + if (agencyList.size() > 0 && times < 2){ + for (AgencyElementTreeResultDTO.Agency list : agencyList) { + set.add(list.getId()); + times++; + traversalAgencyList(list.getChildren(),times,set); } - agencyId = gridEntity.getPid(); } - //2.查询组织基本信息 - CustomerAgencyEntity entity = baseDao.selectById(agencyId); - if(entity!=null){ - resultDTO = ConvertUtils.sourceToTarget(entity, AgencyInfoResultDTO.class); - resultDTO.setAgencyId(entity.getId()); - resultDTO.setAgencyName(entity.getOrganizationName()); - } - return resultDTO; - } - - /** - * @Description 外挂-获取当前组织及部门、网格数据,递归查询所有下级数据 - * @author sun - **/ - @Override - public OrganizeTreeResultDTO organizeTree(String agencyId) { - return baseDao.selectorganizeTree(agencyId); } -} \ No newline at end of file +} diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml index 300f559468..7326a91f31 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml @@ -62,13 +62,11 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + - - - + select id,organization_name,customer_id from customer_agency where pid = #{pid} and customer_id = #{customerId} - - - - \ No newline at end of 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 315bf66a30..f8b6dcc2e5 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 @@ -24,4 +24,10 @@ public interface BadgeConstant { String SMS_CODE_KEY = "epmet:smsCode:badge:"; + String PARTY ="party"; + + String ONLINE ="online"; + + String OFFLINE ="offline"; + } 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 ffa2be3013..820f0fa45c 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 @@ -13,7 +13,7 @@ import java.util.Date; public class UserBadgeCertificateRecordDTO implements Serializable { private static final long serialVersionUID = 3207509834642386145L; - + private String id; private String customerId; private String gridId; private String userId; diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/BadgeAuditFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/BadgeAuditFormDTO.java new file mode 100644 index 0000000000..f7d3deac7d --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/BadgeAuditFormDTO.java @@ -0,0 +1,20 @@ +package com.epmet.dto.form; + +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/11/5 11:06 + */ +@NoArgsConstructor +@Data +public class BadgeAuditFormDTO implements Serializable { + private static final long serialVersionUID = 2209535364555130964L; + private String recordId; + private String auditStatus; + private String auditRemark; +} 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 index 4b35497e8b..e9702144f0 100644 --- 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 @@ -13,4 +13,12 @@ import java.io.Serializable; public class BadgeFormDTO implements Serializable { private static final long serialVersionUID = 9156247659994638103L; private String badgeId; + /** + * 页码 + */ + private Integer pageNo; + /** + * 每页显示数量 + */ + private Integer pageSize; } diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/UserBadgeUnitFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/UserBadgeUnitFormDTO.java new file mode 100644 index 0000000000..406f527bb9 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/UserBadgeUnitFormDTO.java @@ -0,0 +1,48 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Objects; + +/** + * @Description 用户-徽章缓存单元 + * @ClassName UserBadgeUnitFormDTO + * @Auth wangc + * @Date 2020-11-05 10:00 + */ +@Data +public class UserBadgeUnitFormDTO implements Serializable { + private static final long serialVersionUID = -4497394865738168850L; + + /** + * 徽章Id + */ + private String badgeId; + + /** + * 徽章图标 url + */ + private String badgeIcon; + + /** + * 徽章名称 + */ + private String badgeName; + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + UserBadgeUnitFormDTO that = (UserBadgeUnitFormDTO) o; + return badgeId.equals(that.badgeId) && + badgeIcon.equals(that.badgeIcon) && + badgeName.equals(that.badgeName); + } + + @Override + public int hashCode() { + return Objects.hash(badgeId, badgeIcon, badgeName); + } +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/BadgeAuditRecordResultDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/BadgeAuditRecordResultDTO.java new file mode 100644 index 0000000000..363441ad46 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/BadgeAuditRecordResultDTO.java @@ -0,0 +1,43 @@ +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/11/5 10:57 + */ +@Data +public class BadgeAuditRecordResultDTO implements Serializable { + private static final long serialVersionUID = 6004101838042628105L; + /** + * 徽章Id + */ + private String badgeId; + /** + * 徽章名称 + */ + private String badgeName; + /** + * 徽章图标url + */ + private String badgeIcon; + /** + * 用户Id + */ + private String userId; + /** + * 用户名 + */ + private String userName; + /** + * 创建时间 + */ + private Long createTime; + /** + * 用户名 + */ + private String auditStatus; +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/BadgeAuditingResultDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/BadgeAuditingResultDTO.java new file mode 100644 index 0000000000..bbf6381d82 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/BadgeAuditingResultDTO.java @@ -0,0 +1,43 @@ +package com.epmet.dto.result; + +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/11/5 9:34 + */ +@NoArgsConstructor +@Data +public class BadgeAuditingResultDTO implements Serializable { + + private static final long serialVersionUID = -361914591952483084L; + /** + * 徽章Id + */ + private String badgeId; + /** + * 徽章名称 + */ + private String badgeName; + /** + * 徽章图标url + */ + private String badgeIcon; + /** + * 用户Id + */ + private String userId; + /** + * 用户名 + */ + private String userName; + /** + * 创建时间 + */ + private Long createTime; + +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/constant/UserRedisKeys.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/constant/UserRedisKeys.java index f4fffb6975..46f5ad1fa2 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/constant/UserRedisKeys.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/constant/UserRedisKeys.java @@ -23,4 +23,14 @@ public class UserRedisKeys { public static String getResiUserKey(String userId){ return rootPrefix.concat("resi:user:").concat(userId); } + + /** + * @Description 用户勋章缓存 epmet:badge:user:[customerId]:[userId] + * @param userId + * @return epmet:badge:user:[customerId]:[userId] + * @author wangc + * @date 2020.11.05 13:34 + */ + public static String getResiUserBadgeKey(String customerId,String userId){ + return rootPrefix.concat("badge:user:").concat(customerId).concat(":").concat(userId);} } 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 index 92a2621013..12042c4fbd 100644 --- 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 @@ -5,8 +5,11 @@ 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.BadgeAuditFormDTO; import com.epmet.dto.form.BadgeFormDTO; import com.epmet.dto.form.EditBadgeFormDTO; +import com.epmet.dto.result.BadgeAuditRecordResultDTO; +import com.epmet.dto.result.BadgeAuditingResultDTO; import com.epmet.dto.result.BadgeDetailResultDTO; import com.epmet.dto.result.BadgeListResultDTO; import com.epmet.service.BadgeService; @@ -100,5 +103,51 @@ public class BadgeController { return new Result(); } + @PostMapping("test-cache") + public Result testCache(){ + badgeService.testCache(); + return new Result(); + } + /** + * 待审核列表 + * @author zhaoqifeng + * @date 2020/11/5 9:51 + * @param tokenDto + * @param formDTO + * @return com.epmet.commons.tools.utils.Result> + */ + @PostMapping("auditinglist") + public Result> auditingList(@LoginUser TokenDto tokenDto, @RequestBody BadgeFormDTO formDTO) { + List result = badgeService.auditingList(tokenDto, formDTO); + return new Result>().ok(result); + } + + /** + * 审核历史列表 + * @author zhaoqifeng + * @date 2020/11/5 10:59 + * @param tokenDto + * @param formDTO + * @return com.epmet.commons.tools.utils.Result> + */ + @PostMapping("auditrecord") + public Result> auditRecord(@LoginUser TokenDto tokenDto, @RequestBody BadgeFormDTO formDTO) { + List result = badgeService.auditRecord(tokenDto, formDTO); + return new Result>().ok(result); + } + + /** + * 审核 + * @author zhaoqifeng + * @date 2020/11/5 11:09 + * @param tokenDto + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + */ + @PostMapping("audit") + public Result audit(@LoginUser TokenDto tokenDto, @RequestBody BadgeAuditFormDTO formDTO) { + badgeService.audit(tokenDto, formDTO); + return new Result(); + } } 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 index 965f753b6e..a0c2fb42b6 100644 --- 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 @@ -18,8 +18,11 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.result.BadgeAuditRecordResultDTO; +import com.epmet.dto.result.BadgeAuditingResultDTO; import com.epmet.dto.result.BadgeDetailResultDTO; import com.epmet.dto.result.BadgeListResultDTO; +import com.epmet.dto.result.UserBadgeListResultDTO; import com.epmet.entity.BadgeEntity; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -105,4 +108,38 @@ public interface BadgeDao extends BaseDao { * @return void */ void deleteBadge(@Param("customerId") String customerId, @Param("badgeId") String badgeId); + + + /** + * 待审核列表 + * @author zhaoqifeng + * @date 2020/11/5 10:01 + * @param customerId + * @param pageNo + * @param pageSize + * @return java.util.List + */ + List selectAuditingList(@Param("customerId") String customerId, @Param("pageNo") Integer pageNo, + @Param("pageSize") Integer pageSize); + + /** + * 审核历史列表 + * @author zhaoqifeng + * @date 2020/11/5 11:01 + * @param customerId + * @param pageNo + * @param pageSize + * @return java.util.List + */ + List selectAuditRecord(@Param("customerId") String customerId, @Param("pageNo") Integer pageNo, + @Param("pageSize") Integer pageSize); + + /** + * @Description 查询客户的徽章 + * @param customerId + * @return java.util.List + * @author wangc + * @date 2020.11.05 15:50 + */ + List selectCustomerBadgePool(@Param("customerId") String customerId); } \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/UserBadgeCertificateRecordDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/UserBadgeCertificateRecordDao.java new file mode 100644 index 0000000000..f7f4dba91c --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/UserBadgeCertificateRecordDao.java @@ -0,0 +1,33 @@ +/** + * 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.UserBadgeCertificateRecordEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 用户认证徽章记录表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-11-05 + */ +@Mapper +public interface UserBadgeCertificateRecordDao extends BaseDao { + +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/UserBadgeCertificateRecordEntity.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/UserBadgeCertificateRecordEntity.java new file mode 100644 index 0000000000..867ae11bdb --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/UserBadgeCertificateRecordEntity.java @@ -0,0 +1,116 @@ +/** + * 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-05 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("user_badge_certificate_record") +public class UserBadgeCertificateRecordEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户Id + */ + private String customerId; + + /** + * 用户注册网格ID + */ + private String gridId; + + /** + * 用户ID + */ + private String userId; + + /** + * 徽章ID + */ + private String badgeId; + + /** + * 姓 + */ + private String surname; + + /** + * 名 + */ + private String name; + + /** + * 手机号 + */ + private String mobile; + + /** + * 身份证号 网格内去重 + */ + private String idNum; + + /** + * 认证证件图片 + */ + private String certificationImg; + + /** + * 认证说明(备注) + */ + private String remaek; + + /** + * 审核状态 approved:审核通过,rejected:审核驳回;auditing:审核中 + */ + private String auditStatus; + + /** + * 审核意见 + */ + private String auditRemark; + + /** + * 审核人 审核人Id + */ + private String staffId; + + /** + * 审核时间 + */ + private Date auditTime; + + /** + * 是否是最新纪录:yes:最新纪录,no:非最新纪录 + */ + private String isLast; + +} 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 c9eaee4367..0b57fcbb9f 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,13 +1,25 @@ package com.epmet.redis; + + import com.alibaba.fastjson.JSON; +import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.redis.RedisUtils; +import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.constant.BadgeConstant; +import com.epmet.constant.UserRedisKeys; +import com.epmet.dao.BadgeDao; +import com.epmet.dto.form.UserBadgeUnitFormDTO; import com.epmet.dto.result.UserBadgeListResultDTO; +import com.epmet.service.UserBadgeService; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.util.List; +import java.util.Optional; import static com.epmet.commons.tools.redis.RedisUtils.MINUTE_THIRTY_EXPIRE; @@ -16,45 +28,50 @@ import static com.epmet.commons.tools.redis.RedisUtils.MINUTE_THIRTY_EXPIRE; * @DateTime 2020/11/3 2:21 下午 */ @Component +@Slf4j public class UserBadgeRedis { @Autowired private RedisUtils redisUtils; + @Autowired + private BadgeDao badgeDao; + @Autowired + private UserBadgeService badgeService; /** - * @Description 获取客户徽章信息 + * @Description 获取客户徽章信息 * @Param customerId * @author zxc * @date 2020/11/3 2:50 下午 */ - public Object getCustomerBadge(String customerId){ + public Object getCustomerBadge(String customerId) { Object userBadge = redisUtils.hGet(BadgeConstant.BADGE_KEY + customerId, BadgeConstant.BADGE); return userBadge; } /** - * @Description 存放客户徽章信息 + * @Description 存放客户徽章信息 * @Param userBadge * @Param customerId * @author zxc * @date 2020/11/3 2:51 下午 */ - public void setCustomerBadge(List userBadge, String customerId){ - redisUtils.hSet(BadgeConstant.BADGE_KEY+customerId,BadgeConstant.BADGE, JSON.toJSON(userBadge).toString(),-1); + public void setCustomerBadge(List userBadge, String customerId) { + redisUtils.hSet(BadgeConstant.BADGE_KEY + customerId, BadgeConstant.BADGE, JSON.toJSON(userBadge).toString(), -1); } /** - * @Description 删除客户徽章信息 + * @Description 删除客户徽章信息 * @Param customerId * @author zxc * @date 2020/11/5 3:06 下午 */ - public void delCustomerBadge(String customerId){ - redisUtils.hDel(BadgeConstant.BADGE_KEY+customerId,BadgeConstant.BADGE); + public void delCustomerBadge(String customerId) { + redisUtils.hDel(BadgeConstant.BADGE_KEY + customerId, BadgeConstant.BADGE); } /** - * @Description 存放徽章审核 手机验证码 + * @Description 存放徽章审核 手机验证码 * @Param mobile * @author zxc * @date 2020/11/5 10:30 上午 @@ -65,7 +82,7 @@ public class UserBadgeRedis { } /** - * @Description 获取徽章审核 手机验证码 + * @Description 获取徽章审核 手机验证码 * @Param mobile * @author zxc * @date 2020/11/5 10:30 上午 @@ -76,4 +93,58 @@ public class UserBadgeRedis { return smsCode; } -} + /** + * @param userId + * @return java.util.List + * @Description 获取用户的全部勋章信息(点亮的 、 排序从前到后) + * @author wangc + * @date 2020.11.05 13:26 + */ + public List obtainUserBadge2List(String userId,String customerId) { + //TODO 补偿 + return redisUtils.lrange(UserRedisKeys.getResiUserBadgeKey(customerId,userId), NumConstant.ZERO, NumConstant.ONE_NEG, UserBadgeUnitFormDTO.class); + } + + /** + * 用户点亮或取消徽章 + * @param + * @return int + * @Description 入栈时使用lpush 出栈时使用lrem + * @author wangc + * @date 2020.11.05 13:37 + */ + public long pushOrRemoveUserBadge4List(String userId, String badgeId, String customerId) { + List orient = obtainUserBadge2List(userId,customerId); + UserBadgeUnitFormDTO unit = null; + + if (!CollectionUtils.isEmpty(orient)) { + Optional opt = orient.stream().filter(badge -> StringUtils.equals(badgeId, badge.getBadgeId())).findFirst(); + if (opt.isPresent()) { + unit = opt.get(); + return redisUtils.lrem(UserRedisKeys.getResiUserBadgeKey(customerId, userId), NumConstant.ONE, unit); + } + } + + //徽章池 + Object badgeObj = getCustomerBadge(customerId); + + List badgePool = + null == badgeObj ? badgeDao.selectCustomerBadgePool(customerId) : JSON.parseArray(badgeObj.toString(), UserBadgeListResultDTO.class); + + if (CollectionUtils.isEmpty(badgePool)) { + log.error("com.epmet.redis.UserBadgeRedis.pushOrRemoveUserBadge4List,缓存中客户{}下的徽章池为空", customerId); + return NumConstant.ZERO; + } + + if (null == unit) { + Optional poolOpt = + badgePool.stream().filter(badge -> StringUtils.equals(badge.getBadgeId(), badgeId)).findFirst(); + if (poolOpt.isPresent()) unit = ConvertUtils.sourceToTarget(poolOpt.get(), UserBadgeUnitFormDTO.class); + else return NumConstant.ZERO; + } + redisUtils.leftPush(UserRedisKeys.getResiUserBadgeKey(customerId, userId), unit); + return NumConstant.ONE; + } + + } + 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 index 7b73e28561..9b13682b6f 100644 --- 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 @@ -22,8 +22,11 @@ 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.BadgeAuditFormDTO; import com.epmet.dto.form.BadgeFormDTO; import com.epmet.dto.form.EditBadgeFormDTO; +import com.epmet.dto.result.BadgeAuditRecordResultDTO; +import com.epmet.dto.result.BadgeAuditingResultDTO; import com.epmet.dto.result.BadgeDetailResultDTO; import com.epmet.dto.result.BadgeListResultDTO; import com.epmet.entity.BadgeEntity; @@ -147,4 +150,36 @@ public interface BadgeService extends BaseService { * @return void */ void deleteBadge(TokenDto tokenDto, BadgeFormDTO formDTO); + + /** + * 待审核列表 + * @author zhaoqifeng + * @date 2020/11/5 9:50 + * @param tokenDto + * @param formDTO + * @return java.util.List + */ + List auditingList(TokenDto tokenDto, BadgeFormDTO formDTO); + + /** + * 审核历史列表 + * @author zhaoqifeng + * @date 2020/11/5 10:59 + * @param tokenDto + * @param formDTO + * @return java.util.List + */ + List auditRecord(TokenDto tokenDto, BadgeFormDTO formDTO); + + /** + * 审核 + * @author zhaoqifeng + * @date 2020/11/5 11:08 + * @param tokenDto + * @param formDTO + * @return void + */ + void audit(TokenDto tokenDto, BadgeAuditFormDTO formDTO); + + void testCache(); } \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserBadgeCertificateRecordService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserBadgeCertificateRecordService.java new file mode 100644 index 0000000000..154c8685db --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserBadgeCertificateRecordService.java @@ -0,0 +1,95 @@ +/** + * 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.UserBadgeCertificateRecordDTO; +import com.epmet.entity.UserBadgeCertificateRecordEntity; + +import java.util.List; +import java.util.Map; + +/** + * 用户认证徽章记录表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-11-05 + */ +public interface UserBadgeCertificateRecordService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2020-11-05 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2020-11-05 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return UserBadgeCertificateRecordDTO + * @author generator + * @date 2020-11-05 + */ + UserBadgeCertificateRecordDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2020-11-05 + */ + void save(UserBadgeCertificateRecordDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2020-11-05 + */ + void update(UserBadgeCertificateRecordDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2020-11-05 + */ + void delete(String[] ids); +} \ 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 index 021b0c734a..36ea72d2ff 100644 --- 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 @@ -30,25 +30,30 @@ 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.UserBadgeCertificateRecordDTO; import com.epmet.dto.form.AddBadgeFormDTO; +import com.epmet.dto.form.BadgeAuditFormDTO; import com.epmet.dto.form.BadgeFormDTO; import com.epmet.dto.form.EditBadgeFormDTO; +import com.epmet.dto.result.BadgeAuditRecordResultDTO; +import com.epmet.dto.result.BadgeAuditingResultDTO; +import com.epmet.dto.form.UserBadgeUnitFormDTO; 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.redis.UserBadgeRedis; import com.epmet.service.BadgeCertificationConfigService; import com.epmet.service.BadgeService; +import com.epmet.service.UserBadgeCertificateRecordService; +import com.epmet.service.UserBadgeService; 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; +import java.util.*; /** * 徽章 @@ -61,6 +66,10 @@ public class BadgeServiceImpl extends BaseServiceImpl imp @Autowired private BadgeCertificationConfigService badgeCertificationConfigService; + @Autowired + private UserBadgeCertificateRecordService userBadgeCertificateRecordService; + @Autowired + private UserBadgeRedis badgeRedis; @Override @@ -159,6 +168,9 @@ public class BadgeServiceImpl extends BaseServiceImpl imp badgeList.add(badge); }); badgeCertificationConfigService.insertBatch(badgeList); + if (BadgeConstant.ONLINE.equals(formDTO.getBadgeStatus())) { + //TODO 更新Redis + } } /** @@ -220,6 +232,9 @@ public class BadgeServiceImpl extends BaseServiceImpl imp badgeList.add(badge); }); badgeCertificationConfigService.saveConfig(tokenDto.getCustomerId(), formDTO.getBadgeId(), badgeList); + if (BadgeConstant.OFFLINE.equals(formDTO.getBadgeStatus())) { + //TODO 更新Redis + } } /** @@ -236,13 +251,90 @@ public class BadgeServiceImpl extends BaseServiceImpl imp BadgeEntity badgeEntity = baseDao.selectBadgeInfo(tokenDto.getCustomerId(), formDTO.getBadgeId()); if (null == badgeEntity) { badgeEntity = baseDao.selectBadgeInfo("default", formDTO.getBadgeId()); + if (BadgeConstant.PARTY.equals(badgeEntity.getFixationBadgeType())) { + throw new RenException(EpmetErrorCode.DUPLICATE_PARTY_BADGE_NAME.getCode()); + } badgeEntity.setCustomerId(tokenDto.getCustomerId()); badgeEntity.setDelFlag(NumConstant.ONE_STR); baseDao.insert(badgeEntity); } else { + if (BadgeConstant.PARTY.equals(badgeEntity.getFixationBadgeType())) { + throw new RenException(EpmetErrorCode.DUPLICATE_PARTY_BADGE_NAME.getCode()); + } baseDao.deleteBadge(tokenDto.getCustomerId(), formDTO.getBadgeId()); } badgeCertificationConfigService.deleteConfig(tokenDto.getCustomerId(), formDTO.getBadgeId()); + //TODO 更新Redis + } + + /** + * 待审核列表 + * + * @param tokenDto + * @param formDTO + * @return java.util.List + * @author zhaoqifeng + * @date 2020/11/5 9:50 + */ + @Override + public List auditingList(TokenDto tokenDto, BadgeFormDTO formDTO) { + int pageIndex = (formDTO.getPageNo() - NumConstant.ONE) * formDTO.getPageSize(); + List list = baseDao.selectAuditingList(tokenDto.getCustomerId(), pageIndex, formDTO.getPageSize()); + list.forEach(item -> { + item.setCreateTime(item.getCreateTime()/NumConstant.SIXTY); + }); + return list; + } + + /** + * 审核历史列表 + * + * @param tokenDto + * @param formDTO + * @return java.util.List + * @author zhaoqifeng + * @date 2020/11/5 10:59 + */ + @Override + public List auditRecord(TokenDto tokenDto, BadgeFormDTO formDTO) { + int pageIndex = (formDTO.getPageNo() - NumConstant.ONE) * formDTO.getPageSize(); + List list = baseDao.selectAuditRecord(tokenDto.getCustomerId(), pageIndex, formDTO.getPageSize()); + list.forEach(item -> { + item.setCreateTime(item.getCreateTime()/NumConstant.SIXTY); + }); + return list; + } + + /** + * 审核 + * + * @param tokenDto + * @param formDTO + * @return void + * @author zhaoqifeng + * @date 2020/11/5 11:08 + */ + @Override + public void audit(TokenDto tokenDto, BadgeAuditFormDTO formDTO) { + UserBadgeCertificateRecordDTO dto = new UserBadgeCertificateRecordDTO(); + dto.setId(formDTO.getRecordId()); + dto.setAuditStatus(formDTO.getAuditStatus()); + dto.setAuditRemark(formDTO.getAuditRemark()); + dto.setStaffId(tokenDto.getUserId()); + dto.setAuditTime(new Date()); + + userBadgeCertificateRecordService.update(dto); + + if(BadgeConstant.APPROVED.equals(formDTO.getAuditStatus())) { + //TODO 更新Redis + } + } + + @Override + public void testCache() { + badgeRedis.pushOrRemoveUserBadge4List("test-wc","1","45687aa479955f9d06204d415238f7cc"); + List cache = badgeRedis.obtainUserBadge2List("test-wc","45687aa479955f9d06204d415238f7cc"); + System.out.println(cache); } } \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBadgeCertificateRecordServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBadgeCertificateRecordServiceImpl.java new file mode 100644 index 0000000000..6f798abc79 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBadgeCertificateRecordServiceImpl.java @@ -0,0 +1,100 @@ +/** + * 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.FieldConstant; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.dao.UserBadgeCertificateRecordDao; +import com.epmet.dto.UserBadgeCertificateRecordDTO; +import com.epmet.entity.UserBadgeCertificateRecordEntity; +import com.epmet.service.UserBadgeCertificateRecordService; +import org.apache.commons.lang3.StringUtils; +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-05 + */ +@Service +public class UserBadgeCertificateRecordServiceImpl extends BaseServiceImpl implements UserBadgeCertificateRecordService { + + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, UserBadgeCertificateRecordDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, UserBadgeCertificateRecordDTO.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 UserBadgeCertificateRecordDTO get(String id) { + UserBadgeCertificateRecordEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, UserBadgeCertificateRecordDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(UserBadgeCertificateRecordDTO dto) { + UserBadgeCertificateRecordEntity entity = ConvertUtils.sourceToTarget(dto, UserBadgeCertificateRecordEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(UserBadgeCertificateRecordDTO dto) { + UserBadgeCertificateRecordEntity entity = ConvertUtils.sourceToTarget(dto, UserBadgeCertificateRecordEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + +} \ No newline at end of file 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 986d9eed7f..32b0cef882 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 @@ -218,8 +218,9 @@ public class UserBadgeServiceImpl implements UserBadgeService { */ @Override @Transactional(rollbackFor = Exception.class) - public void openedOrClosed(OpenedOrClosedFormDTO openedOrClosedFormDTO) { - userBadgeDao.updateIsOpen(openedOrClosedFormDTO); + public void openedOrClosed(OpenedOrClosedFormDTO form) { + userBadgeDao.updateIsOpen(form); + userBadgeRedis.pushOrRemoveUserBadge4List(form.getUserId(),form.getBadgeId(),form.getCustomerId()); } /** @@ -239,12 +240,14 @@ public class UserBadgeServiceImpl implements UserBadgeService { List badgeByCustomer = groupByCustomer.get(customerId); if (!CollectionUtils.isEmpty(badgeByCustomer)) { resultUserBadge.forEach(r -> { - badgeByCustomer.forEach(b -> { - if (r.getBadgeId().equals(b.getBadgeId())) { - BeanUtils.copyProperties(b, r); + for (int i = NumConstant.ZERO; i < badgeByCustomer.size(); i++) { + if (r.getBadgeId().equals(badgeByCustomer.get(i).getBadgeId())) { + BeanUtils.copyProperties(badgeByCustomer.get(i), r); + badgeByCustomer.remove(badgeByCustomer.get(i)); } - }); + } }); + resultUserBadge.addAll(badgeByCustomer); } userBadgeRedis.setCustomerBadge(resultUserBadge, customerId); } 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 index 322604bc70..978a9cf13b 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/BadgeDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/BadgeDao.xml @@ -44,7 +44,7 @@ SELECT * FROM badge a WHERE CUSTOMER_ID = 'default' AND a.DEL_FLAG = '0' AND NOT EXISTS - ( SELECT ID FROM badge b WHERE CUSTOMER_ID = #{customerId} AND a.BADGE_NAME = b.BADGE_NAME AND b.DEL_FLAG = '0')) t + ( SELECT ID FROM badge b WHERE CUSTOMER_ID = #{customerId} AND a.ID = b.ID)) t ORDER BY CREATED_TIME DESC @@ -65,7 +65,7 @@ SELECT * FROM badge a WHERE CUSTOMER_ID = 'default' AND a.DEL_FLAG = '0' AND NOT EXISTS - ( SELECT ID FROM badge b WHERE CUSTOMER_ID = #{customerId} AND a.BADGE_NAME = b.BADGE_NAME AND b.DEL_FLAG = '0' )) t) a + ( SELECT ID FROM badge b WHERE CUSTOMER_ID = #{customerId} AND a.BADGE_NAME = b.BADGE_NAME)) t) a WHERE BADGE_NAME = #{badgeName} + + + + + \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/UserBadgeCertificateRecordDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/UserBadgeCertificateRecordDao.xml new file mode 100644 index 0000000000..a2f59e8b8e --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/UserBadgeCertificateRecordDao.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file