添加校验,二创作品不能参与活动
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.");
|
throw new BusinessException("The title of the published work has been used.");
|
||||||
}
|
}
|
||||||
// 判断用户是否参与#RCAworkshop_2024的活动
|
// 判断用户是否参与#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());
|
throw new BusinessException("you.have.participated.in.the.event", ResultEnum.PROMPT.getCode());
|
||||||
}
|
}
|
||||||
if (file != null && file.getOriginalFilename() != null) {
|
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());
|
List<String> collect = tags.stream().map(Tags::getTagName).collect(Collectors.toList());
|
||||||
if (!collect.contains(CommonConstant.RCA_WORKSHOP_TAG)){
|
if (!collect.contains(CommonConstant.RCA_WORKSHOP_TAG)){
|
||||||
return false;
|
return false;
|
||||||
}else {
|
}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);
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -140,6 +140,7 @@ slogan.image.cannot.be.empty=Slogan image cannot be empty.
|
|||||||
questionnaire.filled.out=You have filled out the current questionnaire.
|
questionnaire.filled.out=You have filled out the current questionnaire.
|
||||||
user.has.no.account=The current user has no account!
|
user.has.no.account=The current user has no account!
|
||||||
you.have.participated.in.the.event=You have participated in the event.
|
you.have.participated.in.the.event=You have participated in the event.
|
||||||
|
only.original.works.can.participate.in.the.event=Sorry, only original works can participate in the event.
|
||||||
|
|
||||||
# 可能会报异常
|
# 可能会报异常
|
||||||
# Informative:
|
# Informative:
|
||||||
|
|||||||
@@ -134,7 +134,8 @@ slogan.style.cannot.be.empty=标语风格文本不能为空。
|
|||||||
slogan.image.cannot.be.empty=标语图片不能为空。
|
slogan.image.cannot.be.empty=标语图片不能为空。
|
||||||
questionnaire.filled.out=您已填写过当前问卷。
|
questionnaire.filled.out=您已填写过当前问卷。
|
||||||
user.has.no.account=当前用户没有账号。
|
user.has.no.account=当前用户没有账号。
|
||||||
you.have.participated.in.the.event=您已经参与活动
|
you.have.participated.in.the.event=您已经参与活动。
|
||||||
|
only.original.works.can.participate.in.the.event=抱歉,只有原创作品能参与活动。
|
||||||
|
|
||||||
# 可能会报异常
|
# 可能会报异常
|
||||||
# Informative:
|
# Informative:
|
||||||
|
|||||||
Reference in New Issue
Block a user