@@ -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.Role; | ||||
import com.ningdatech.pmapi.sys.model.entity.UserRole; | import com.ningdatech.pmapi.sys.model.entity.UserRole; | ||||
import com.ningdatech.pmapi.sys.service.IUserRoleService; | 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.UserInfo; | ||||
import com.ningdatech.pmapi.user.entity.enumeration.RoleEnum; | import com.ningdatech.pmapi.user.entity.enumeration.RoleEnum; | ||||
import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO; | import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO; | ||||
@@ -118,6 +119,11 @@ public class UserInfoHelperImpl implements UserInfoHelper { | |||||
userFullInfo.setUsername(userInfo.getRealName()); | userFullInfo.setUsername(userInfo.getRealName()); | ||||
userFullInfo.setMobile(userInfo.getMobile()); | userFullInfo.setMobile(userInfo.getMobile()); | ||||
userFullInfo.setAccountId(userInfo.getAccountId()); | userFullInfo.setAccountId(userInfo.getAccountId()); | ||||
String available = userInfo.getAvailable(); | |||||
if (StringUtils.isNotBlank(available)) { | |||||
userFullInfo.setAvailable(UserAvailableEnum.valueOf(available)); | |||||
} | |||||
return userFullInfo; | return userFullInfo; | ||||
} | } | ||||
@@ -6,6 +6,7 @@ import com.ningdatech.pmapi.expert.manage.ExpertAdminManage; | |||||
import com.ningdatech.pmapi.expert.manage.ExpertManage; | import com.ningdatech.pmapi.expert.manage.ExpertManage; | ||||
import com.ningdatech.pmapi.expert.model.ExpertAdminExpertManageQuery; | import com.ningdatech.pmapi.expert.model.ExpertAdminExpertManageQuery; | ||||
import com.ningdatech.pmapi.expert.model.req.AdminExpertBasicInfoModifyRequest; | 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.ExpertUserBasicInfoSubmitRequest; | ||||
import com.ningdatech.pmapi.expert.model.req.GetZzdInfoRequest; | import com.ningdatech.pmapi.expert.model.req.GetZzdInfoRequest; | ||||
import com.ningdatech.pmapi.expert.model.vo.ExpertAdminExpertManageListVO; | import com.ningdatech.pmapi.expert.model.vo.ExpertAdminExpertManageListVO; | ||||
@@ -37,8 +38,14 @@ public class ExpertController { | |||||
private final ExpertManage expertManage; | private final ExpertManage expertManage; | ||||
private final ExpertAdminManage expertAdminManage; | private final ExpertAdminManage expertAdminManage; | ||||
@PostMapping("/registration") | |||||
@ApiOperation("社会专家报名") | |||||
public void expertRegistration(@Valid @RequestBody ExpertRegistrationRequest request) { | |||||
expertManage.expertRegistration(request); | |||||
} | |||||
@PostMapping("/basic-info-submit") | @PostMapping("/basic-info-submit") | ||||
@ApiOperation("填写基本信息接口(专家报名使用))") | |||||
@ApiOperation("专家管理员新增专家)") | |||||
public void expertBasicInfoSubmit(@Valid @RequestBody ExpertUserBasicInfoSubmitRequest request) { | public void expertBasicInfoSubmit(@Valid @RequestBody ExpertUserBasicInfoSubmitRequest request) { | ||||
expertManage.expertBasicInfoSubmit(request); | expertManage.expertBasicInfoSubmit(request); | ||||
} | } | ||||
@@ -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.cmd.ExpertRecommendProofSaveCmd; | ||||
import com.ningdatech.pmapi.expert.model.dto.ExpertDictionaryDTO; | import com.ningdatech.pmapi.expert.model.dto.ExpertDictionaryDTO; | ||||
import com.ningdatech.pmapi.expert.model.dto.ExpertFullInfoAllDTO; | 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.ExpertUserBasicInfoSubmitRequest; | ||||
import com.ningdatech.pmapi.expert.model.req.MetaApplyResultRequest; | |||||
import com.ningdatech.pmapi.expert.model.vo.ExpertFullInfoVO; | import com.ningdatech.pmapi.expert.model.vo.ExpertFullInfoVO; | ||||
import com.ningdatech.pmapi.expert.service.ExpertInfoService; | import com.ningdatech.pmapi.expert.service.ExpertInfoService; | ||||
import com.ningdatech.pmapi.expert.service.IExpertUserFullInfoService; | import com.ningdatech.pmapi.expert.service.IExpertUserFullInfoService; | ||||
import com.ningdatech.pmapi.meta.constant.DictExpertInfoTypeEnum; | import com.ningdatech.pmapi.meta.constant.DictExpertInfoTypeEnum; | ||||
import com.ningdatech.pmapi.meta.model.ExpertRegionInfo; | 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.Role; | ||||
import com.ningdatech.pmapi.sys.model.entity.UserRole; | import com.ningdatech.pmapi.sys.model.entity.UserRole; | ||||
import com.ningdatech.pmapi.sys.service.IRoleService; | import com.ningdatech.pmapi.sys.service.IRoleService; | ||||
@@ -63,59 +65,20 @@ public class ExpertManage { | |||||
private final ExpertMetaApplyManage expertMetaApplyManage; | private final ExpertMetaApplyManage expertMetaApplyManage; | ||||
private final IUserRoleService iUserRoleService; | private final IUserRoleService iUserRoleService; | ||||
private final IRoleService iRoleService; | private final IRoleService iRoleService; | ||||
private final VerifyCodeCheckHelper verifyCodeCheckHelper; | |||||
/** | /** | ||||
* 填写基本信息,只有专家自己可用 | |||||
* 专家管理员新增专家 | |||||
* | * | ||||
* @param req / | * @param req / | ||||
*/ | */ | ||||
@Transactional(rollbackFor = Exception.class) | @Transactional(rollbackFor = Exception.class) | ||||
public void expertBasicInfoSubmit(ExpertUserBasicInfoSubmitRequest req) { | public void expertBasicInfoSubmit(ExpertUserBasicInfoSubmitRequest req) { | ||||
// 用户id | // 用户id | ||||
ExpertBasicInfo basicInfo = req.getBasicInfo(); | |||||
Long userId = generateOrGetUserId(basicInfo); | |||||
// 校验区域编码合法性 校验履职意向编码合法性 | |||||
ExpertRegionInfo expertRegionInfo = basicInfo.getExpertRegionInfo(); | |||||
expertManageHelper.expertRegionInfoCheck(expertRegionInfo); | |||||
List<ExpertRegionInfo> 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<DictionaryFieldInfo> recommendedWay = recommendInfo.getRecommendedWay(); | |||||
// 推荐方式 | |||||
List<FileBasicInfo> recommendProofFile = recommendInfo.getRecommendationProofFile(); | |||||
Long applyId = expertRecommendProofSubmit(recommendedWay, recommendProofFile, userId); | |||||
// 批量通过专家管理员审核 | |||||
MetaApplyResultRequest applyResult = new MetaApplyResultRequest(); | |||||
applyResult.setApplyId(applyId); | |||||
applyResult.setAuditOpinion("同意"); | |||||
applyResult.setApplyResult(true); | |||||
expertMetaApplyManage.metaApplyResult(applyResult); | |||||
Long userId = assemblerAndGenerateExpert(req); | |||||
// 批量通过专家入库审核/专家履职意向审核 | |||||
expertMetaApplyManage.autoPassExpertApply(userId); | |||||
// 增加用户专家角色 | // 增加用户专家角色 | ||||
Role expertRole = iRoleService.getOne(Wrappers.lambdaQuery(Role.class).eq(Role::getCode, RoleEnum.EXPERT.name())); | Role expertRole = iRoleService.getOne(Wrappers.lambdaQuery(Role.class).eq(Role::getCode, RoleEnum.EXPERT.name())); | ||||
@@ -202,4 +165,63 @@ public class ExpertManage { | |||||
} | } | ||||
return userInfo.getId(); | 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<ExpertRegionInfo> 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<DictionaryFieldInfo> recommendedWay = recommendInfo.getRecommendedWay(); | |||||
// 推荐方式 | |||||
List<FileBasicInfo> recommendProofFile = recommendInfo.getRecommendationProofFile(); | |||||
expertRecommendProofSubmit(recommendedWay, recommendProofFile, userId); | |||||
return userId; | |||||
} | |||||
} | } |
@@ -590,4 +590,25 @@ public class ExpertMetaApplyManage { | |||||
expertIntentionApplyDealCmd.setExpertRegionLevel(expertMetaApply.getRegionLevel()); | expertIntentionApplyDealCmd.setExpertRegionLevel(expertMetaApply.getRegionLevel()); | ||||
return expertIntentionApplyDealCmd; | return expertIntentionApplyDealCmd; | ||||
} | } | ||||
/** | |||||
* 专家管理员 新增专家使用使用 | |||||
* @param expertUserId | |||||
*/ | |||||
@Transactional(rollbackFor = Exception.class) | |||||
public void autoPassExpertApply(Long expertUserId) { | |||||
List<ExpertMetaApply> expertIntentionJoinApplyList = iMetaApplyService.list(Wrappers | |||||
.lambdaQuery(ExpertMetaApply.class) | |||||
.eq(ExpertMetaApply::getUserId, expertUserId) | |||||
.in(ExpertMetaApply::getApplyType, ExpertApplyTypeEnum.EXPERT_INTENTION_JOIN.getKey(), ExpertApplyTypeEnum.EXPERT_STORAGE.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); | |||||
} | |||||
} | |||||
} | } |
@@ -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; | |||||
} |
@@ -20,9 +20,14 @@ import java.util.stream.Stream; | |||||
public enum VerificationCodeType { | public enum VerificationCodeType { | ||||
/** | /** | ||||
* 用户注册 | |||||
* 用户登陆 | |||||
*/ | */ | ||||
LOGIN("用户登录", 1, 5, 10); | |||||
LOGIN("用户登录", 1, 5, 10), | |||||
/** | |||||
* 社会专家注册 | |||||
*/ | |||||
EXPERT_REGISTER("社会专家注册", 1, 5, 10); | |||||
@ApiModelProperty(value = "描述") | @ApiModelProperty(value = "描述") | ||||
private String desc; | private String desc; | ||||
@@ -13,7 +13,12 @@ public interface VoiceSmsTemplateConst { | |||||
/** | /** | ||||
* 短信登陆验证码 | * 短信登陆验证码 | ||||
*/ | */ | ||||
String SMS_LOGIN_TEMPLATE = "验证码:%s(有效期为%s分钟),请勿泄露给他人,如非本人操作,请忽略此信息。"; | |||||
String SMS_COMMON_TEMPLATE = "验证码:%s(有效期为%s分钟),请勿泄露给他人,如非本人操作,请忽略此信息。"; | |||||
/** | |||||
* 社会专家报名 | |||||
*/ | |||||
String EXPERT_REGISTER = "专家报名验证码:%s(有效期为%s分钟),请勿泄露给他人,如非本人操作,请忽略此信息。"; | |||||
/** | /** | ||||
* 专家电话通知语音模版 | * 专家电话通知语音模版 | ||||
@@ -66,16 +66,26 @@ public class SmsManage { | |||||
// 创建短信内容 | // 创建短信内容 | ||||
SendSmsCmd sendSmsCmd = new SendSmsCmd(); | SendSmsCmd sendSmsCmd = new SendSmsCmd(); | ||||
switch (verificationCodeTypeEnum) { | switch (verificationCodeTypeEnum) { | ||||
case LOGIN: | |||||
case LOGIN: { | |||||
SendSmsCmd.SendSmsContext sendSmsContext = new SendSmsCmd.SendSmsContext(); | SendSmsCmd.SendSmsContext sendSmsContext = new SendSmsCmd.SendSmsContext(); | ||||
sendSmsContext.setReceiveNumber(request.getMobile()); | 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.setContextList(Collections.singletonList(sendSmsContext)); | ||||
sendSmsCmd.setSmsSignEnum(YxtSmsSignEnum.ZJS_ELECTRONIC_EXPERT_LIB); | 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: | default: | ||||
throw new IllegalArgumentException("非法的短信发送类型"); | throw new IllegalArgumentException("非法的短信发送类型"); | ||||
} | } | ||||
// 发送 短信 | // 发送 短信 | ||||
yxtClient.submitSmsTask(sendSmsCmd); | yxtClient.submitSmsTask(sendSmsCmd); | ||||
log.info("send verificationCode mobile = {},code = {}", request.getMobile(), code); | log.info("send verificationCode mobile = {},code = {}", request.getMobile(), code); | ||||
@@ -2,8 +2,10 @@ package com.ningdatech.pmapi.user.security.auth.agent; | |||||
import com.ningdatech.pmapi.common.helper.UserInfoHelper; | 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.UserFullInfoDTO; | ||||
import com.ningdatech.pmapi.user.security.auth.model.UserInfoDetails; | import com.ningdatech.pmapi.user.security.auth.model.UserInfoDetails; | ||||
import com.ningdatech.pmapi.user.security.auth.validate.CommonLoginException; | |||||
import lombok.RequiredArgsConstructor; | import lombok.RequiredArgsConstructor; | ||||
import org.springframework.security.core.userdetails.UserDetailsService; | import org.springframework.security.core.userdetails.UserDetailsService; | ||||
import org.springframework.security.core.userdetails.UsernameNotFoundException; | import org.springframework.security.core.userdetails.UsernameNotFoundException; | ||||
@@ -32,6 +34,10 @@ public class AgentLoginUserDetailService implements UserDetailsService { | |||||
if (Objects.isNull(userFullInfoDTO)) { | if (Objects.isNull(userFullInfoDTO)) { | ||||
throw new UsernameNotFoundException(String.format("%s user not exist", username)); | throw new UsernameNotFoundException(String.format("%s user not exist", username)); | ||||
} | } | ||||
if (UserAvailableEnum.DISABLE.equals(userFullInfoDTO.getAvailable())) { | |||||
throw new CommonLoginException("该账号已被禁用"); | |||||
} | |||||
UserInfoDetails userInfoDetails = new UserInfoDetails(); | UserInfoDetails userInfoDetails = new UserInfoDetails(); | ||||
userInfoDetails.setUserId(userFullInfoDTO.getUserId()); | userInfoDetails.setUserId(userFullInfoDTO.getUserId()); | ||||
userInfoDetails.setUsername(userFullInfoDTO.getUsername()); | userInfoDetails.setUsername(userFullInfoDTO.getUsername()); | ||||
@@ -1,9 +1,11 @@ | |||||
package com.ningdatech.pmapi.user.security.auth.common; | 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.manage.UserInfoManage; | ||||
import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO; | 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.model.UserInfoDetails; | ||||
import com.ningdatech.pmapi.user.security.auth.validate.CommonLoginException; | |||||
import lombok.RequiredArgsConstructor; | import lombok.RequiredArgsConstructor; | ||||
import org.springframework.security.core.userdetails.UserDetailsService; | import org.springframework.security.core.userdetails.UserDetailsService; | ||||
import org.springframework.security.core.userdetails.UsernameNotFoundException; | import org.springframework.security.core.userdetails.UsernameNotFoundException; | ||||
@@ -30,6 +32,9 @@ public class CommonLoginUserDetailService implements UserDetailsService { | |||||
if (Objects.isNull(userFullInfoDTO)) { | if (Objects.isNull(userFullInfoDTO)) { | ||||
throw new UsernameNotFoundException(String.format("%s user not exist", username)); | throw new UsernameNotFoundException(String.format("%s user not exist", username)); | ||||
} | } | ||||
if (UserAvailableEnum.DISABLE.equals(userFullInfoDTO.getAvailable())) { | |||||
throw new CommonLoginException("该账号已被禁用"); | |||||
} | |||||
UserInfoDetails userInfoDetails = new UserInfoDetails(); | UserInfoDetails userInfoDetails = new UserInfoDetails(); | ||||
userInfoDetails.setUserId(userFullInfoDTO.getUserId()); | userInfoDetails.setUserId(userFullInfoDTO.getUserId()); | ||||
userInfoDetails.setUsername(userFullInfoDTO.getUsername()); | userInfoDetails.setUsername(userFullInfoDTO.getUsername()); | ||||
@@ -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.LoginTypeEnum; | ||||
import com.ningdatech.pmapi.user.constant.UserAvailableEnum; | |||||
import com.ningdatech.pmapi.user.convert.UserInfoConvertor; | import com.ningdatech.pmapi.user.convert.UserInfoConvertor; | ||||
import com.ningdatech.pmapi.user.manage.UserInfoManage; | import com.ningdatech.pmapi.user.manage.UserInfoManage; | ||||
import com.ningdatech.pmapi.user.security.auth.constants.UserDeatilsServiceConstant; | 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)); | throw new UsernameNotFoundException(String.format("%s user not exist", username)); | ||||
} | } | ||||
} | } | ||||
if (UserAvailableEnum.DISABLE.equals(userFullInfo.getAvailable())) { | |||||
throw new CommonLoginException("该账号已被禁用"); | |||||
} | |||||
return UserInfoConvertor.toUserInfoDetails(userFullInfo); | return UserInfoConvertor.toUserInfoDetails(userFullInfo); | ||||
} | } | ||||
} | } |
@@ -2,6 +2,7 @@ package com.ningdatech.pmapi.user.security.auth.model; | |||||
import cn.hutool.core.collection.CollUtil; | import cn.hutool.core.collection.CollUtil; | ||||
import com.ningdatech.pmapi.sys.model.entity.Role; | import com.ningdatech.pmapi.sys.model.entity.Role; | ||||
import com.ningdatech.pmapi.user.constant.UserAvailableEnum; | |||||
import com.ningdatech.pmapi.user.entity.enumeration.RoleEnum; | import com.ningdatech.pmapi.user.entity.enumeration.RoleEnum; | ||||
import lombok.Data; | import lombok.Data; | ||||
@@ -74,6 +75,12 @@ public class UserFullInfoDTO { | |||||
private Long accountId; | private Long accountId; | ||||
/** | /** | ||||
* 用户是否可用 | |||||
*/ | |||||
private UserAvailableEnum available; | |||||
/** | |||||
* 取最高的权限 | * 取最高的权限 | ||||
* | * | ||||
* @return | * @return | ||||
@@ -25,6 +25,7 @@ security: | |||||
- /wflow/** | - /wflow/** | ||||
- /sys/** | - /sys/** | ||||
- /api/v1/verification/** | - /api/v1/verification/** | ||||
- /api/v1/expert/registration | |||||
ignore-csrf-urls: | ignore-csrf-urls: | ||||
- /api/v1/user/auth/** | - /api/v1/user/auth/** | ||||
- /v2/api-docs | - /v2/api-docs | ||||
@@ -42,6 +43,7 @@ security: | |||||
- /wflow/** | - /wflow/** | ||||
- /sys/** | - /sys/** | ||||
- /api/v1/verification/** | - /api/v1/verification/** | ||||
- /api/v1/expert/registration | |||||
role-map: | role-map: | ||||
"engineer": | "engineer": | ||||
"project_manager": | "project_manager": | ||||