From fb11357bc5f2c036517faeecf9ea2087b2aaa57f Mon Sep 17 00:00:00 2001 From: zhaoqifeng Date: Mon, 23 Nov 2020 17:39:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=BD=E7=AB=A0=E6=9C=80=E5=A4=9A=E4=B8=8A?= =?UTF-8?q?=E7=BA=BF5=E4=B8=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tools/exception/EpmetErrorCode.java | 2 +- .../epmet/service/impl/BadgeServiceImpl.java | 23 +++++++++++++++---- 2 files changed, 20 insertions(+), 5 deletions(-) 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 71b09320b4..a1ead085c7 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 @@ -99,7 +99,7 @@ public enum EpmetErrorCode { //徽章管理 DUPLICATE_BADGE_NAME(8515, "徽章名已存在"), DUPLICATE_PARTY_BADGE_NAME(8516, "不可删除党员徽章"), - NUMBER_BADGE_ERROR(8517, "徽章最多设置5个"), + ONLINE_BADGE_COUNT(8517, "最多上线5个徽章"), // 该错误不会提示给前端,只是后端传输错误信息用。 ACCESS_SQL_FILTER_MISSION_ARGS(8701, "缺少生成权限过滤SQL所需参数"), 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 0611b34385..3a92a310fb 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 @@ -36,6 +36,7 @@ import com.epmet.constant.BadgeConstant; import com.epmet.constant.BadgeMessageConstant; import com.epmet.constant.UserConstant; import com.epmet.dao.BadgeDao; +import com.epmet.dao.UserBadgeDao; import com.epmet.dto.BadgeDTO; import com.epmet.dto.ResiUserBadgeDTO; import com.epmet.dto.UserBadgeCertificateRecordDTO; @@ -80,6 +81,8 @@ public class BadgeServiceImpl extends BaseServiceImpl imp private MessageFeignClient messageFeignClient; @Autowired private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient; + @Autowired + private UserBadgeDao userBadgeDao; @Override @@ -159,10 +162,12 @@ public class BadgeServiceImpl extends BaseServiceImpl imp @Override @Transactional(rollbackFor = Exception.class) public void add(TokenDto tokenDto, AddBadgeFormDTO formDTO) { - //徽章总数校验 - List allList = baseDao.selectList(tokenDto.getCustomerId()); - if (CollectionUtils.isNotEmpty(allList) && allList.size() > NumConstant.FIVE) { - throw new RenException(EpmetErrorCode.NUMBER_BADGE_ERROR.getCode()); + //上线徽章数校验 + if(BadgeConstant.ONLINE.equals(formDTO.getBadgeStatus())) { + List onlineList = userBadgeDao.selectAllBadge(tokenDto.getCustomerId()); + if (CollectionUtils.isNotEmpty(onlineList) && onlineList.size() >= NumConstant.FIVE) { + throw new RenException(EpmetErrorCode.ONLINE_BADGE_COUNT.getCode()); + } } //重名校验 List list = baseDao.getDuplicateName(tokenDto.getCustomerId(), formDTO.getBadgeName()); @@ -220,6 +225,16 @@ public class BadgeServiceImpl extends BaseServiceImpl imp @Override @Transactional(rollbackFor = Exception.class) public void edit(TokenDto tokenDto, EditBadgeFormDTO formDTO) { + //上线徽章数校验 + if(BadgeConstant.ONLINE.equals(formDTO.getBadgeStatus())) { + List onlineList = userBadgeDao.selectAllBadge(tokenDto.getCustomerId()); + if (CollectionUtils.isNotEmpty(onlineList) && onlineList.size() >= NumConstant.FIVE) { + BadgeEntity badge = baseDao.selectBadgeInfo(tokenDto.getCustomerId(), formDTO.getBadgeId()); + if (BadgeConstant.OFFLINE.equals(badge.getBadgeStatus())) { + throw new RenException(EpmetErrorCode.ONLINE_BADGE_COUNT.getCode()); + } + } + } //重名校验 List list = baseDao.getDuplicateNameForEdit(tokenDto.getCustomerId(), formDTO.getBadgeId(), formDTO.getBadgeName()); if (CollectionUtils.isNotEmpty(list)) {