From 426b339e4961f3b1c2cf034736e87cc250e10b9a Mon Sep 17 00:00:00 2001 From: zhangyongzhangyong <2012005003@qq.coom> Date: Thu, 30 Jul 2020 15:39:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B4=BB=E5=8A=A8=E6=8A=A5=E5=90=8D=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tools/exception/EpmetErrorCode.java | 4 +- .../resi/ResiActRegistrationResultDTO.java | 27 ----------- .../controller/ResiActListController.java | 4 +- .../epmet/service/ActUserRelationService.java | 5 +- .../impl/ActUserRelationServiceImpl.java | 46 ++++++++----------- 5 files changed, 26 insertions(+), 60 deletions(-) delete mode 100644 epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/resi/ResiActRegistrationResultDTO.java 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 78c341fcb4..23c6567af2 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 @@ -83,9 +83,9 @@ public enum EpmetErrorCode { // 爱心互助 居民端 NOT_IN_THE_SIGN_IN_RANGE(8510, "您还未进入指定的签到范围~"), - NON_CERTIFIED_VOLUNTEER(8511, "活动报名失败,请先认证志愿者"), + // 活动报名失败,弹窗:志愿者认证 + NON_CERTIFIED_VOLUNTEER(8511, "是否认证志愿者,完成报名"), ACT_TIME_CONFLICT(8512, "报名失败。您本次报名活动时间与已报名活动时间间隔较短,为了不影响您已报名的活动,请选择其他时间的活动,谢谢。"), - ACT_REGISTRATION_SUCCESS(8513, "报名成功。"), // 该错误不会提示给前端,只是后端传输错误信息用。 ACCESS_SQL_FILTER_MISSION_ARGS(8701, "缺少生成权限过滤SQL所需参数"), diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/resi/ResiActRegistrationResultDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/resi/ResiActRegistrationResultDTO.java deleted file mode 100644 index 96ca7a6e61..0000000000 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/resi/ResiActRegistrationResultDTO.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.epmet.dto.result.resi; - -import lombok.Data; - -import java.io.Serializable; - -/** - * 活动报名 - 返回值 - * - * @Auther: zhangyong - * @Date: 2020-07-28 16:22 - */ -@Data -public class ResiActRegistrationResultDTO implements Serializable { - - private static final long serialVersionUID = 1L; - - /** - * 异常编码 - */ - private Integer flag; - - /** - * 提示信息 - */ - private String tip; -} diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/ResiActListController.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/ResiActListController.java index 046a2c6854..73605d19a9 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/ResiActListController.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/ResiActListController.java @@ -294,12 +294,12 @@ public class ResiActListController { * * @param tokenDto * @param formDTO - * @return com.epmet.commons.tools.utils.Result + * @return com.epmet.commons.tools.utils.Result * @Author zhangyong * @Date 16:26 2020-07-28 **/ @PostMapping("registration") - public Result registration(@LoginUser TokenDto tokenDto, @RequestBody ResiActRegistrationFormDTO formDTO) { + public Result registration(@LoginUser TokenDto tokenDto, @RequestBody ResiActRegistrationFormDTO formDTO) { ValidatorUtils.validateEntity(formDTO, ResiActRegistrationFormDTO.AddUserInternalGroup.class); return actUserRelationService.registration(tokenDto, formDTO); } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/ActUserRelationService.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/ActUserRelationService.java index a290d59c5f..f77b373208 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/ActUserRelationService.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/ActUserRelationService.java @@ -24,7 +24,6 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.dto.ActUserRelationDTO; import com.epmet.dto.form.resi.ResiActRegistrationFormDTO; import com.epmet.dto.form.resi.ResiActUserCancelSignUpFormDTO; -import com.epmet.dto.result.resi.ResiActRegistrationResultDTO; import com.epmet.entity.ActUserRelationEntity; import org.apache.ibatis.annotations.Param; @@ -146,9 +145,9 @@ public interface ActUserRelationService extends BaseService> + * @return com.epmet.commons.tools.utils.Result * @Author zhangyong * @Date 15:54 2020-07-28 **/ - Result registration(TokenDto tokenDto, ResiActRegistrationFormDTO formDTO); + Result registration(TokenDto tokenDto, ResiActRegistrationFormDTO formDTO); } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/ActUserRelationServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/ActUserRelationServiceImpl.java index 3f677f0d5d..e9e675b7e4 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/ActUserRelationServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/ActUserRelationServiceImpl.java @@ -39,7 +39,6 @@ import com.epmet.dto.ActUserRelationDTO; import com.epmet.dto.form.resi.ResiActRegistrationFormDTO; import com.epmet.dto.form.resi.ResiActUserCancelSignUpFormDTO; import com.epmet.dto.result.UserRoleResultDTO; -import com.epmet.dto.result.resi.ResiActRegistrationResultDTO; import com.epmet.entity.ActUserLogEntity; import com.epmet.entity.ActUserRelationEntity; import com.epmet.entity.HeartUserInfoEntity; @@ -48,6 +47,7 @@ import com.epmet.redis.ActUserRelationRedis; import com.epmet.service.ActInfoService; import com.epmet.service.ActUserLogService; import com.epmet.service.ActUserRelationService; +import com.epmet.utils.ModuleConstant; import org.apache.commons.lang3.StringUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -195,46 +195,40 @@ public class ActUserRelationServiceImpl extends BaseServiceImpl registration(TokenDto tokenDto, ResiActRegistrationFormDTO formDTO) { + public Result registration(TokenDto tokenDto, ResiActRegistrationFormDTO formDTO) { formDTO.setUserId(tokenDto.getUserId()); boolean satisfy = false; - ResiActRegistrationResultDTO resultDTO = new ResiActRegistrationResultDTO(); + // 查询活动信息 ActInfoDTO actInfoDTO = actInfoService.get(formDTO.getActId()); // >0 当前用户是志愿者 Integer volunteerFlag = volunteerInfoDao.queryVolunteerFlagByUserId(formDTO.getUserId()); - if (actInfoDTO.getVolunteerLimit()){ - // 活动只能志愿者参加, 当前用户是否满足条件 - satisfy = this.volunteerParticipationAct(volunteerFlag); - if (!satisfy){ - logger.info(EpmetErrorCode.NON_CERTIFIED_VOLUNTEER.getMsg()); - resultDTO.setFlag(EpmetErrorCode.NON_CERTIFIED_VOLUNTEER.getCode()); - resultDTO.setTip(EpmetErrorCode.NON_CERTIFIED_VOLUNTEER.getMsg()); - return new Result().ok(resultDTO); - } + if (NumConstant.ZERO < volunteerFlag){ + // 志愿者身份,可参加所有活动 + satisfy = true; } else { - // 活动不限制志愿者身份,但要求是 居民身份, 当前用户是否满足条件 - satisfy = this.resiParticipationAct(formDTO.getUserId()); - if (!satisfy){ - logger.info(EpmetErrorCode.CANNOT_AUDIT_WARM.getMsg()); - resultDTO.setFlag(EpmetErrorCode.CANNOT_AUDIT_WARM.getCode()); - resultDTO.setTip(EpmetErrorCode.CANNOT_AUDIT_WARM.getMsg()); - return new Result().ok(resultDTO); + // 如果用户不是志愿者,则需判断,当前活动 非志愿者是非可报名 + if (actInfoDTO.getVolunteerLimit()){ + // 活动只能志愿者参加, 当前用户是否满足条件 + satisfy = this.volunteerParticipationAct(volunteerFlag); + } else { + // 活动不限制志愿者身份,但要求是 居民身份, 当前用户是否满足条件 + satisfy = this.resiParticipationAct(formDTO.getUserId()); } } if (satisfy){ // 开始报名 boolean actTimeConflict = this.actStartSignUp(actInfoDTO, formDTO, volunteerFlag); if (!actTimeConflict){ - logger.info(EpmetErrorCode.ACT_TIME_CONFLICT.getMsg()); - resultDTO.setFlag(EpmetErrorCode.ACT_TIME_CONFLICT.getCode()); - resultDTO.setTip(EpmetErrorCode.ACT_TIME_CONFLICT.getMsg()); - return new Result().ok(resultDTO); + logger.info(EpmetErrorCode.ACT_TIME_CONFLICT); + throw new RenException(EpmetErrorCode.ACT_TIME_CONFLICT.getCode()); } + } else { + // 不满足,提示用户去认证志愿者 + logger.info(EpmetErrorCode.NON_CERTIFIED_VOLUNTEER); + throw new RenException(EpmetErrorCode.NON_CERTIFIED_VOLUNTEER.getCode()); } - resultDTO.setFlag(EpmetErrorCode.ACT_REGISTRATION_SUCCESS.getCode()); - resultDTO.setTip(EpmetErrorCode.ACT_REGISTRATION_SUCCESS.getMsg()); - return new Result().ok(resultDTO); + return new Result(); } /**