From 77ae44c50a80331cf033f22722fe0f2632ae5131 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?niohe=C2=B7erbao?= Date: Sat, 6 May 2023 09:47:25 +0800 Subject: [PATCH 1/4] =?UTF-8?q?fix=20=20=E6=96=B0=E5=A2=9E=E4=B8=93?= =?UTF-8?q?=E5=AE=B6=E7=9A=84=E6=97=B6=E5=80=99=E5=B1=A5=E8=81=8C=E6=84=8F?= =?UTF-8?q?=E5=90=91=E6=B2=A1=E6=9C=89=E8=87=AA=E5=8A=A8=E5=AE=A1=E6=A0=B8?= =?UTF-8?q?=E9=80=9A=E8=BF=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pmapi/expert/controller/ExpertController.java | 8 +++++++- .../com/ningdatech/pmapi/expert/manage/ExpertManage.java | 3 +++ .../pmapi/expert/manage/ExpertMetaApplyManage.java | 16 ++++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/expert/controller/ExpertController.java b/pmapi/src/main/java/com/ningdatech/pmapi/expert/controller/ExpertController.java index 2045526..c20f006 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/expert/controller/ExpertController.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/expert/controller/ExpertController.java @@ -37,8 +37,14 @@ public class ExpertController { private final ExpertManage expertManage; private final ExpertAdminManage expertAdminManage; +// @PostMapping("/basic-info-submit") +// @ApiOperation("专家管理员新增专家)") +// public void expertBasicInfoSubmit(@Valid @RequestBody ExpertUserBasicInfoSubmitRequest request) { +// expertManage.expertBasicInfoSubmit(request); +// } + @PostMapping("/basic-info-submit") - @ApiOperation("填写基本信息接口(专家报名使用))") + @ApiOperation("专家管理员新增专家)") public void expertBasicInfoSubmit(@Valid @RequestBody ExpertUserBasicInfoSubmitRequest request) { expertManage.expertBasicInfoSubmit(request); } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/expert/manage/ExpertManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/expert/manage/ExpertManage.java index 0f2a426..08ee800 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/expert/manage/ExpertManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/expert/manage/ExpertManage.java @@ -117,6 +117,9 @@ public class ExpertManage { applyResult.setApplyResult(true); expertMetaApplyManage.metaApplyResult(applyResult); + // 批量通过专家履职意向审核 + expertMetaApplyManage.autoPassExpertIntentionApply(userId); + // 增加用户专家角色 Role expertRole = iRoleService.getOne(Wrappers.lambdaQuery(Role.class).eq(Role::getCode, RoleEnum.EXPERT.name())); UserRole expertUserRole = iUserRoleService.getOne(Wrappers.lambdaQuery(UserRole.class) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/expert/manage/ExpertMetaApplyManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/expert/manage/ExpertMetaApplyManage.java index 9dbec46..bb7fd84 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/expert/manage/ExpertMetaApplyManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/expert/manage/ExpertMetaApplyManage.java @@ -590,4 +590,20 @@ public class ExpertMetaApplyManage { expertIntentionApplyDealCmd.setExpertRegionLevel(expertMetaApply.getRegionLevel()); return expertIntentionApplyDealCmd; } + + public void autoPassExpertIntentionApply(Long expertUserId) { + List expertIntentionJoinApplyList = iMetaApplyService.list(Wrappers + .lambdaQuery(ExpertMetaApply.class) + .eq(ExpertMetaApply::getUserId, expertUserId) + .eq(ExpertMetaApply::getApplyType, ExpertApplyTypeEnum.EXPERT_INTENTION_JOIN.getKey()) + .eq(ExpertMetaApply::getApplyStatus, ExpertApplyStatusEnum.PENDING_REVIEW.getKey())); + + for (ExpertMetaApply expertMetaApply : expertIntentionJoinApplyList) { + MetaApplyResultRequest applyResult = new MetaApplyResultRequest(); + applyResult.setApplyId(expertMetaApply.getId()); + applyResult.setAuditOpinion("同意"); + applyResult.setApplyResult(true); + metaApplyResult(applyResult); + } + } } From dcda52a9bf3c69f8df7f85ae7e9d67950e61c690 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?niohe=C2=B7erbao?= Date: Sat, 6 May 2023 10:24:01 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=A4=BE=E4=BC=9A?= =?UTF-8?q?=E4=B8=93=E5=AE=B6=E6=8A=A5=E5=90=8D=E5=85=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pmapi/expert/controller/ExpertController.java | 11 +- .../pmapi/expert/manage/ExpertManage.java | 115 ++++++++++++--------- .../pmapi/expert/manage/ExpertMetaApplyManage.java | 9 +- .../model/req/ExpertRegistrationRequest.java | 21 ++++ .../pmapi/sms/constant/VerificationCodeType.java | 9 +- .../pmapi/sms/constant/VoiceSmsTemplateConst.java | 7 +- .../com/ningdatech/pmapi/sms/manage/SmsManage.java | 16 ++- 7 files changed, 127 insertions(+), 61 deletions(-) create mode 100644 pmapi/src/main/java/com/ningdatech/pmapi/expert/model/req/ExpertRegistrationRequest.java diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/expert/controller/ExpertController.java b/pmapi/src/main/java/com/ningdatech/pmapi/expert/controller/ExpertController.java index c20f006..43be4e3 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/expert/controller/ExpertController.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/expert/controller/ExpertController.java @@ -6,6 +6,7 @@ import com.ningdatech.pmapi.expert.manage.ExpertAdminManage; import com.ningdatech.pmapi.expert.manage.ExpertManage; import com.ningdatech.pmapi.expert.model.ExpertAdminExpertManageQuery; import com.ningdatech.pmapi.expert.model.req.AdminExpertBasicInfoModifyRequest; +import com.ningdatech.pmapi.expert.model.req.ExpertRegistrationRequest; import com.ningdatech.pmapi.expert.model.req.ExpertUserBasicInfoSubmitRequest; import com.ningdatech.pmapi.expert.model.req.GetZzdInfoRequest; import com.ningdatech.pmapi.expert.model.vo.ExpertAdminExpertManageListVO; @@ -37,11 +38,11 @@ public class ExpertController { private final ExpertManage expertManage; private final ExpertAdminManage expertAdminManage; -// @PostMapping("/basic-info-submit") -// @ApiOperation("专家管理员新增专家)") -// public void expertBasicInfoSubmit(@Valid @RequestBody ExpertUserBasicInfoSubmitRequest request) { -// expertManage.expertBasicInfoSubmit(request); -// } + @PostMapping("/registration") + @ApiOperation("社会专家报名") + public void expertRegistration(@Valid @RequestBody ExpertRegistrationRequest request) { + expertManage.expertRegistration(request); + } @PostMapping("/basic-info-submit") @ApiOperation("专家管理员新增专家)") diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/expert/manage/ExpertManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/expert/manage/ExpertManage.java index 08ee800..3cfc16a 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/expert/manage/ExpertManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/expert/manage/ExpertManage.java @@ -17,13 +17,15 @@ import com.ningdatech.pmapi.expert.model.cmd.ExpertFullInfoSaveCmd; import com.ningdatech.pmapi.expert.model.cmd.ExpertRecommendProofSaveCmd; import com.ningdatech.pmapi.expert.model.dto.ExpertDictionaryDTO; import com.ningdatech.pmapi.expert.model.dto.ExpertFullInfoAllDTO; +import com.ningdatech.pmapi.expert.model.req.ExpertRegistrationRequest; import com.ningdatech.pmapi.expert.model.req.ExpertUserBasicInfoSubmitRequest; -import com.ningdatech.pmapi.expert.model.req.MetaApplyResultRequest; import com.ningdatech.pmapi.expert.model.vo.ExpertFullInfoVO; import com.ningdatech.pmapi.expert.service.ExpertInfoService; import com.ningdatech.pmapi.expert.service.IExpertUserFullInfoService; import com.ningdatech.pmapi.meta.constant.DictExpertInfoTypeEnum; import com.ningdatech.pmapi.meta.model.ExpertRegionInfo; +import com.ningdatech.pmapi.sms.constant.VerificationCodeType; +import com.ningdatech.pmapi.sms.helper.VerifyCodeCheckHelper; import com.ningdatech.pmapi.sys.model.entity.Role; import com.ningdatech.pmapi.sys.model.entity.UserRole; import com.ningdatech.pmapi.sys.service.IRoleService; @@ -63,62 +65,20 @@ public class ExpertManage { private final ExpertMetaApplyManage expertMetaApplyManage; private final IUserRoleService iUserRoleService; private final IRoleService iRoleService; + private final VerifyCodeCheckHelper verifyCodeCheckHelper; /** - * 填写基本信息,只有专家自己可用 + * 专家管理员新增专家 * * @param req / */ @Transactional(rollbackFor = Exception.class) public void expertBasicInfoSubmit(ExpertUserBasicInfoSubmitRequest req) { // 用户id - ExpertBasicInfo basicInfo = req.getBasicInfo(); - Long userId = generateOrGetUserId(basicInfo); - - // 校验区域编码合法性 校验履职意向编码合法性 - ExpertRegionInfo expertRegionInfo = basicInfo.getExpertRegionInfo(); - expertManageHelper.expertRegionInfoCheck(expertRegionInfo); - List expertIntentionWorkRegions = basicInfo.getExpertIntentionWorkRegions(); - for (ExpertRegionInfo expertIntentionWorkRegion : expertIntentionWorkRegions) { - expertManageHelper.expertRegionInfoCheck(expertIntentionWorkRegion); - } - ExpertEduInfo eduInfo = req.getEduInfo(); - ExpertJobInfo jobInfo = req.getJobInfo(); - ExpertProfessionalInfo professionalInfo = req.getProfessionalInfo(); - // 校验标签字段 - expertManageHelper.tagFieldCheck(professionalInfo, basicInfo); - // 校验字典字段 - expertManageHelper.dictionaryFieldCheck(basicInfo, eduInfo, jobInfo); - // 判断专家提交状态,判断是否可以进行此操作 - ExpertUserFullInfo expertUserFullInfo = iExpertUserFullInfoService.getByUserId(userId); - - boolean submitBasicInfoStatusEnable = Objects.isNull(expertUserFullInfo) - || (ExpertAccountStatusEnum.APPLYING.getKey().equals(expertUserFullInfo.getExpertAccountStatus()) - && !ExpertUserInfoStepEnum.EVIDENCE_HAS_BEEN_SUBMITTED.getKey().equals(expertUserFullInfo.getUserInfoStep())); - if (submitBasicInfoStatusEnable) { - // 新建 保存 - ExpertFullInfoSaveCmd expertFullInfoSaveCmd = ExpertInfoCmdAssembler - .buildExpertFullInfoSaveCmd(userId, basicInfo, eduInfo, jobInfo, professionalInfo); - expertInfoService.saveExpertInfo(expertFullInfoSaveCmd); - } - - ExpertRecommendInfo recommendInfo = req.getRecommendInfo(); - // 推荐证明材料 - List recommendedWay = recommendInfo.getRecommendedWay(); - // 推荐方式 - List recommendProofFile = recommendInfo.getRecommendationProofFile(); - Long applyId = expertRecommendProofSubmit(recommendedWay, recommendProofFile, userId); - - // 批量通过专家管理员审核 - MetaApplyResultRequest applyResult = new MetaApplyResultRequest(); - applyResult.setApplyId(applyId); - applyResult.setAuditOpinion("同意"); - applyResult.setApplyResult(true); - expertMetaApplyManage.metaApplyResult(applyResult); - - // 批量通过专家履职意向审核 - expertMetaApplyManage.autoPassExpertIntentionApply(userId); + Long userId = assemblerAndGenerateExpert(req); + // 批量通过专家入库审核/专家履职意向审核 + expertMetaApplyManage.autoPassExpertApply(userId); // 增加用户专家角色 Role expertRole = iRoleService.getOne(Wrappers.lambdaQuery(Role.class).eq(Role::getCode, RoleEnum.EXPERT.name())); @@ -205,4 +165,63 @@ public class ExpertManage { } return userInfo.getId(); } + + /** + * 社会专家报名 需要校验手机号 + * + * @param request + */ + @Transactional(rollbackFor = Exception.class) + public void expertRegistration(ExpertRegistrationRequest request) { + String verificationCode = request.getVerificationCode(); + String phoneNo = request.getBasicInfo().getPhoneNo(); + //校验 专家验证码 + if (false) { + verifyCodeCheckHelper.verification(VerificationCodeType.EXPERT_REGISTER, phoneNo, verificationCode); + } + assemblerAndGenerateExpert(request); + } + + + @Transactional(rollbackFor = Exception.class) + public Long assemblerAndGenerateExpert(ExpertUserBasicInfoSubmitRequest req) { + ExpertBasicInfo basicInfo = req.getBasicInfo(); + Long userId = generateOrGetUserId(basicInfo); + + // 校验区域编码合法性 校验履职意向编码合法性 + ExpertRegionInfo expertRegionInfo = basicInfo.getExpertRegionInfo(); + expertManageHelper.expertRegionInfoCheck(expertRegionInfo); + List expertIntentionWorkRegions = basicInfo.getExpertIntentionWorkRegions(); + for (ExpertRegionInfo expertIntentionWorkRegion : expertIntentionWorkRegions) { + expertManageHelper.expertRegionInfoCheck(expertIntentionWorkRegion); + } + ExpertEduInfo eduInfo = req.getEduInfo(); + ExpertJobInfo jobInfo = req.getJobInfo(); + ExpertProfessionalInfo professionalInfo = req.getProfessionalInfo(); + // 校验标签字段 + expertManageHelper.tagFieldCheck(professionalInfo, basicInfo); + // 校验字典字段 + expertManageHelper.dictionaryFieldCheck(basicInfo, eduInfo, jobInfo); + // 判断专家提交状态,判断是否可以进行此操作 + ExpertUserFullInfo expertUserFullInfo = iExpertUserFullInfoService.getByUserId(userId); + + boolean submitBasicInfoStatusEnable = Objects.isNull(expertUserFullInfo) + || (ExpertAccountStatusEnum.APPLYING.getKey().equals(expertUserFullInfo.getExpertAccountStatus()) + && !ExpertUserInfoStepEnum.EVIDENCE_HAS_BEEN_SUBMITTED.getKey().equals(expertUserFullInfo.getUserInfoStep())); + if (submitBasicInfoStatusEnable) { + // 新建 保存 + ExpertFullInfoSaveCmd expertFullInfoSaveCmd = ExpertInfoCmdAssembler + .buildExpertFullInfoSaveCmd(userId, basicInfo, eduInfo, jobInfo, professionalInfo); + expertInfoService.saveExpertInfo(expertFullInfoSaveCmd); + } + + ExpertRecommendInfo recommendInfo = req.getRecommendInfo(); + // 推荐证明材料 + List recommendedWay = recommendInfo.getRecommendedWay(); + // 推荐方式 + List recommendProofFile = recommendInfo.getRecommendationProofFile(); + expertRecommendProofSubmit(recommendedWay, recommendProofFile, userId); + return userId; + } + } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/expert/manage/ExpertMetaApplyManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/expert/manage/ExpertMetaApplyManage.java index bb7fd84..a2f301c 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/expert/manage/ExpertMetaApplyManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/expert/manage/ExpertMetaApplyManage.java @@ -591,11 +591,16 @@ public class ExpertMetaApplyManage { return expertIntentionApplyDealCmd; } - public void autoPassExpertIntentionApply(Long expertUserId) { + /** + * 专家管理员 新增专家使用使用 + * @param expertUserId + */ + @Transactional(rollbackFor = Exception.class) + public void autoPassExpertApply(Long expertUserId) { List expertIntentionJoinApplyList = iMetaApplyService.list(Wrappers .lambdaQuery(ExpertMetaApply.class) .eq(ExpertMetaApply::getUserId, expertUserId) - .eq(ExpertMetaApply::getApplyType, ExpertApplyTypeEnum.EXPERT_INTENTION_JOIN.getKey()) + .in(ExpertMetaApply::getApplyType, ExpertApplyTypeEnum.EXPERT_INTENTION_JOIN.getKey(), ExpertApplyTypeEnum.EXPERT_STORAGE.getKey()) .eq(ExpertMetaApply::getApplyStatus, ExpertApplyStatusEnum.PENDING_REVIEW.getKey())); for (ExpertMetaApply expertMetaApply : expertIntentionJoinApplyList) { diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/expert/model/req/ExpertRegistrationRequest.java b/pmapi/src/main/java/com/ningdatech/pmapi/expert/model/req/ExpertRegistrationRequest.java new file mode 100644 index 0000000..67c4ba4 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/expert/model/req/ExpertRegistrationRequest.java @@ -0,0 +1,21 @@ +package com.ningdatech.pmapi.expert.model.req; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; + +/** + * @author liuxinxin + * @date 2022/7/25 下午2:21 + */ +@Data +@ApiModel(value = "ExpertUserBasicInfoSubmitRequest", description = "社会专家报名接口") +public class ExpertRegistrationRequest extends ExpertUserBasicInfoSubmitRequest { + + @NotBlank(message = "手机验证码不能为空") + @ApiModelProperty("手机验证码") + private String verificationCode; + +} \ No newline at end of file diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/sms/constant/VerificationCodeType.java b/pmapi/src/main/java/com/ningdatech/pmapi/sms/constant/VerificationCodeType.java index 9761d18..4c4ac97 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/sms/constant/VerificationCodeType.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/sms/constant/VerificationCodeType.java @@ -20,9 +20,14 @@ import java.util.stream.Stream; public enum VerificationCodeType { /** - * 用户注册 + * 用户登陆 */ - LOGIN("用户登录", 1, 5, 10); + LOGIN("用户登录", 1, 5, 10), + + /** + * 社会专家注册 + */ + EXPERT_REGISTER("社会专家注册", 1, 5, 10); @ApiModelProperty(value = "描述") private String desc; diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/sms/constant/VoiceSmsTemplateConst.java b/pmapi/src/main/java/com/ningdatech/pmapi/sms/constant/VoiceSmsTemplateConst.java index 0fea8eb..030855d 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/sms/constant/VoiceSmsTemplateConst.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/sms/constant/VoiceSmsTemplateConst.java @@ -13,7 +13,12 @@ public interface VoiceSmsTemplateConst { /** * 短信登陆验证码 */ - String SMS_LOGIN_TEMPLATE = "验证码:%s(有效期为%s分钟),请勿泄露给他人,如非本人操作,请忽略此信息。"; + String SMS_COMMON_TEMPLATE = "验证码:%s(有效期为%s分钟),请勿泄露给他人,如非本人操作,请忽略此信息。"; + + /** + * 社会专家报名 + */ + String EXPERT_REGISTER = "专家报名验证码:%s(有效期为%s分钟),请勿泄露给他人,如非本人操作,请忽略此信息。"; /** * 专家电话通知语音模版 diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/sms/manage/SmsManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/sms/manage/SmsManage.java index e65ce28..79717a1 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/sms/manage/SmsManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/sms/manage/SmsManage.java @@ -66,16 +66,26 @@ public class SmsManage { // 创建短信内容 SendSmsCmd sendSmsCmd = new SendSmsCmd(); switch (verificationCodeTypeEnum) { - case LOGIN: + case LOGIN: { SendSmsCmd.SendSmsContext sendSmsContext = new SendSmsCmd.SendSmsContext(); sendSmsContext.setReceiveNumber(request.getMobile()); - sendSmsContext.setContent(String.format(VoiceSmsTemplateConst.SMS_LOGIN_TEMPLATE, code, verificationCodeTypeEnum.getExpireTime())); + sendSmsContext.setContent(String.format(VoiceSmsTemplateConst.SMS_COMMON_TEMPLATE, code, verificationCodeTypeEnum.getExpireTime())); sendSmsCmd.setContextList(Collections.singletonList(sendSmsContext)); sendSmsCmd.setSmsSignEnum(YxtSmsSignEnum.ZJS_ELECTRONIC_EXPERT_LIB); - break; + } + break; + case EXPERT_REGISTER: { + SendSmsCmd.SendSmsContext sendSmsContext = new SendSmsCmd.SendSmsContext(); + sendSmsContext.setReceiveNumber(request.getMobile()); + sendSmsContext.setContent(String.format(VoiceSmsTemplateConst.EXPERT_REGISTER, code, verificationCodeTypeEnum.getExpireTime())); + sendSmsCmd.setContextList(Collections.singletonList(sendSmsContext)); + sendSmsCmd.setSmsSignEnum(YxtSmsSignEnum.ZJS_ELECTRONIC_EXPERT_LIB); + } + break; default: throw new IllegalArgumentException("非法的短信发送类型"); } + // 发送 短信 yxtClient.submitSmsTask(sendSmsCmd); log.info("send verificationCode mobile = {},code = {}", request.getMobile(), code); From 972150e48302dde7c95f561f3341b76cabd28833 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?niohe=C2=B7erbao?= Date: Sat, 6 May 2023 10:27:16 +0800 Subject: [PATCH 3/4] =?UTF-8?q?fix=20=E7=A4=BE=E4=BC=9A=E4=B8=93=E5=AE=B6?= =?UTF-8?q?=E6=8A=A5=E5=90=8D=E5=85=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pmapi/src/main/resources/security/auth-dev.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pmapi/src/main/resources/security/auth-dev.yml b/pmapi/src/main/resources/security/auth-dev.yml index aaa4f21..d8f8181 100644 --- a/pmapi/src/main/resources/security/auth-dev.yml +++ b/pmapi/src/main/resources/security/auth-dev.yml @@ -25,6 +25,7 @@ security: - /wflow/** - /sys/** - /api/v1/verification/** + - /api/v1/expert/registration ignore-csrf-urls: - /api/v1/user/auth/** - /v2/api-docs @@ -42,6 +43,7 @@ security: - /wflow/** - /sys/** - /api/v1/verification/** + - /api/v1/expert/registration role-map: "engineer": "project_manager": From ae4a241413df4333191c74d05b401032f0f6c502 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?niohe=C2=B7erbao?= Date: Sat, 6 May 2023 11:14:47 +0800 Subject: [PATCH 4/4] =?UTF-8?q?fix=20=E7=A6=81=E7=94=A8=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E7=99=BB=E9=99=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ningdatech/pmapi/common/helper/impl/UserInfoHelperImpl.java | 6 ++++++ .../user/security/auth/agent/AgentLoginUserDetailService.java | 6 ++++++ .../user/security/auth/common/CommonLoginUserDetailService.java | 5 +++++ .../security/auth/credential/CredentialLoginUserDetailService.java | 5 +++++ .../ningdatech/pmapi/user/security/auth/model/UserFullInfoDTO.java | 7 +++++++ 5 files changed, 29 insertions(+) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/common/helper/impl/UserInfoHelperImpl.java b/pmapi/src/main/java/com/ningdatech/pmapi/common/helper/impl/UserInfoHelperImpl.java index 1551e98..4eb4bbe 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/common/helper/impl/UserInfoHelperImpl.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/common/helper/impl/UserInfoHelperImpl.java @@ -13,6 +13,7 @@ import com.ningdatech.pmapi.sys.mapper.RoleMapper; import com.ningdatech.pmapi.sys.model.entity.Role; import com.ningdatech.pmapi.sys.model.entity.UserRole; import com.ningdatech.pmapi.sys.service.IUserRoleService; +import com.ningdatech.pmapi.user.constant.UserAvailableEnum; import com.ningdatech.pmapi.user.entity.UserInfo; import com.ningdatech.pmapi.user.entity.enumeration.RoleEnum; import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO; @@ -118,6 +119,11 @@ public class UserInfoHelperImpl implements UserInfoHelper { userFullInfo.setUsername(userInfo.getRealName()); userFullInfo.setMobile(userInfo.getMobile()); userFullInfo.setAccountId(userInfo.getAccountId()); + + String available = userInfo.getAvailable(); + if (StringUtils.isNotBlank(available)) { + userFullInfo.setAvailable(UserAvailableEnum.valueOf(available)); + } return userFullInfo; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/agent/AgentLoginUserDetailService.java b/pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/agent/AgentLoginUserDetailService.java index cce479d..d3234b2 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/agent/AgentLoginUserDetailService.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/agent/AgentLoginUserDetailService.java @@ -2,8 +2,10 @@ package com.ningdatech.pmapi.user.security.auth.agent; import com.ningdatech.pmapi.common.helper.UserInfoHelper; +import com.ningdatech.pmapi.user.constant.UserAvailableEnum; import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO; import com.ningdatech.pmapi.user.security.auth.model.UserInfoDetails; +import com.ningdatech.pmapi.user.security.auth.validate.CommonLoginException; import lombok.RequiredArgsConstructor; import org.springframework.security.core.userdetails.UserDetailsService; import org.springframework.security.core.userdetails.UsernameNotFoundException; @@ -32,6 +34,10 @@ public class AgentLoginUserDetailService implements UserDetailsService { if (Objects.isNull(userFullInfoDTO)) { throw new UsernameNotFoundException(String.format("%s user not exist", username)); } + if (UserAvailableEnum.DISABLE.equals(userFullInfoDTO.getAvailable())) { + throw new CommonLoginException("该账号已被禁用"); + } + UserInfoDetails userInfoDetails = new UserInfoDetails(); userInfoDetails.setUserId(userFullInfoDTO.getUserId()); userInfoDetails.setUsername(userFullInfoDTO.getUsername()); diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/common/CommonLoginUserDetailService.java b/pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/common/CommonLoginUserDetailService.java index 9878d4a..6679760 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/common/CommonLoginUserDetailService.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/common/CommonLoginUserDetailService.java @@ -1,9 +1,11 @@ package com.ningdatech.pmapi.user.security.auth.common; +import com.ningdatech.pmapi.user.constant.UserAvailableEnum; import com.ningdatech.pmapi.user.manage.UserInfoManage; import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO; import com.ningdatech.pmapi.user.security.auth.model.UserInfoDetails; +import com.ningdatech.pmapi.user.security.auth.validate.CommonLoginException; import lombok.RequiredArgsConstructor; import org.springframework.security.core.userdetails.UserDetailsService; import org.springframework.security.core.userdetails.UsernameNotFoundException; @@ -30,6 +32,9 @@ public class CommonLoginUserDetailService implements UserDetailsService { if (Objects.isNull(userFullInfoDTO)) { throw new UsernameNotFoundException(String.format("%s user not exist", username)); } + if (UserAvailableEnum.DISABLE.equals(userFullInfoDTO.getAvailable())) { + throw new CommonLoginException("该账号已被禁用"); + } UserInfoDetails userInfoDetails = new UserInfoDetails(); userInfoDetails.setUserId(userFullInfoDTO.getUserId()); userInfoDetails.setUsername(userFullInfoDTO.getUsername()); diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/credential/CredentialLoginUserDetailService.java b/pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/credential/CredentialLoginUserDetailService.java index fd1e859..20854a9 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/credential/CredentialLoginUserDetailService.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/credential/CredentialLoginUserDetailService.java @@ -2,6 +2,7 @@ package com.ningdatech.pmapi.user.security.auth.credential; import com.ningdatech.pmapi.user.constant.LoginTypeEnum; +import com.ningdatech.pmapi.user.constant.UserAvailableEnum; import com.ningdatech.pmapi.user.convert.UserInfoConvertor; import com.ningdatech.pmapi.user.manage.UserInfoManage; import com.ningdatech.pmapi.user.security.auth.constants.UserDeatilsServiceConstant; @@ -60,6 +61,10 @@ public class CredentialLoginUserDetailService implements UserDetailsService { throw new UsernameNotFoundException(String.format("%s user not exist", username)); } } + + if (UserAvailableEnum.DISABLE.equals(userFullInfo.getAvailable())) { + throw new CommonLoginException("该账号已被禁用"); + } return UserInfoConvertor.toUserInfoDetails(userFullInfo); } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/model/UserFullInfoDTO.java b/pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/model/UserFullInfoDTO.java index f4291be..ae0261e 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/model/UserFullInfoDTO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/user/security/auth/model/UserFullInfoDTO.java @@ -2,6 +2,7 @@ package com.ningdatech.pmapi.user.security.auth.model; import cn.hutool.core.collection.CollUtil; import com.ningdatech.pmapi.sys.model.entity.Role; +import com.ningdatech.pmapi.user.constant.UserAvailableEnum; import com.ningdatech.pmapi.user.entity.enumeration.RoleEnum; import lombok.Data; @@ -74,6 +75,12 @@ public class UserFullInfoDTO { private Long accountId; /** + * 用户是否可用 + */ + private UserAvailableEnum available; + + + /** * 取最高的权限 * * @return