添加校验,二创作品不能参与活动
This commit is contained in:
@@ -136,7 +136,7 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
|
||||
throw new BusinessException("The title of the published work has been used.");
|
||||
}
|
||||
// 判断用户是否参与#RCAworkshop_2024的活动
|
||||
if (Objects.isNull(portfolioDTO.getId()) && hasParticipatedRCAWorkshop(authPrincipalVo.getId(), portfolioDTO.getTagsDTO())){
|
||||
if (hasParticipatedRCAWorkshop(authPrincipalVo.getId(), portfolioDTO.getTagsDTO(), portfolioDTO.getId(), portfolioDTO.getUserLikeGroupId())){
|
||||
throw new BusinessException("you.have.participated.in.the.event", ResultEnum.PROMPT.getCode());
|
||||
}
|
||||
if (file != null && file.getOriginalFilename() != null) {
|
||||
@@ -1078,13 +1078,25 @@ public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio
|
||||
}
|
||||
|
||||
// 验证该用户是否已参加活动
|
||||
public Boolean hasParticipatedRCAWorkshop(Long accountId, List<TagsDTO> tags) {
|
||||
public Boolean hasParticipatedRCAWorkshop(Long accountId, List<TagsDTO> tags, Long portfolioId, Long userLikeGroupId) {
|
||||
List<String> collect = tags.stream().map(Tags::getTagName).collect(Collectors.toList());
|
||||
if (!collect.contains(CommonConstant.RCA_WORKSHOP_TAG)){
|
||||
return false;
|
||||
}else {
|
||||
UserLikeGroup userLikeGroup = userLikeGroupService.getById(userLikeGroupId);
|
||||
// 不是原创的作品不能参与活动
|
||||
if (userLikeGroup.getOriginal().equals(0)){
|
||||
throw new BusinessException("only.original.works.can.participate.in.the.event", ResultEnum.PROMPT.getCode());
|
||||
}
|
||||
List<Portfolio> byTag = baseMapper.getByTag(accountId, CommonConstant.RCA_WORKSHOP_TAG);
|
||||
return !byTag.isEmpty();
|
||||
if (byTag.isEmpty()){
|
||||
return false;
|
||||
}else if (!Objects.isNull(portfolioId)){
|
||||
boolean contains = byTag.stream().map(Portfolio::getId).collect(Collectors.toList()).contains(portfolioId);
|
||||
return !contains;
|
||||
}else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user