|
|
@ -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<BadgeDao, BadgeEntity> imp |
|
|
|
private MessageFeignClient messageFeignClient; |
|
|
|
@Autowired |
|
|
|
private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient; |
|
|
|
@Autowired |
|
|
|
private UserBadgeDao userBadgeDao; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
@ -159,10 +162,12 @@ public class BadgeServiceImpl extends BaseServiceImpl<BadgeDao, BadgeEntity> imp |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void add(TokenDto tokenDto, AddBadgeFormDTO formDTO) { |
|
|
|
//徽章总数校验
|
|
|
|
List<BadgeListResultDTO> 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<UserBadgeListResultDTO> onlineList = userBadgeDao.selectAllBadge(tokenDto.getCustomerId()); |
|
|
|
if (CollectionUtils.isNotEmpty(onlineList) && onlineList.size() >= NumConstant.FIVE) { |
|
|
|
throw new RenException(EpmetErrorCode.ONLINE_BADGE_COUNT.getCode()); |
|
|
|
} |
|
|
|
} |
|
|
|
//重名校验
|
|
|
|
List<BadgeListResultDTO> list = baseDao.getDuplicateName(tokenDto.getCustomerId(), formDTO.getBadgeName()); |
|
|
@ -220,6 +225,16 @@ public class BadgeServiceImpl extends BaseServiceImpl<BadgeDao, BadgeEntity> imp |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void edit(TokenDto tokenDto, EditBadgeFormDTO formDTO) { |
|
|
|
//上线徽章数校验
|
|
|
|
if(BadgeConstant.ONLINE.equals(formDTO.getBadgeStatus())) { |
|
|
|
List<UserBadgeListResultDTO> 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<BadgeListResultDTO> list = baseDao.getDuplicateNameForEdit(tokenDto.getCustomerId(), formDTO.getBadgeId(), formDTO.getBadgeName()); |
|
|
|
if (CollectionUtils.isNotEmpty(list)) { |
|
|
|