feat: 短信验证码
parent
30127d7735
commit
a6b29c5e9f
|
|
@ -35,7 +35,8 @@ public class GbsUserSyncInterceptor implements WebMvcConfigurer {
|
||||||
private final String[] anonymousUrl = {
|
private final String[] anonymousUrl = {
|
||||||
"/**/account/syncUserToGBS/**",
|
"/**/account/syncUserToGBS/**",
|
||||||
"/**/org-info/save/**",
|
"/**/org-info/save/**",
|
||||||
"/**/account/save/**"
|
"/**/account/save/**",
|
||||||
|
"/**/account/sendMessage/**"
|
||||||
};
|
};
|
||||||
@Override
|
@Override
|
||||||
public void addInterceptors(InterceptorRegistry registry) {
|
public void addInterceptors(InterceptorRegistry registry) {
|
||||||
|
|
|
||||||
|
|
@ -21,23 +21,23 @@ public class LocalDevUserContextConfig implements WebMvcConfigurer {
|
||||||
private Long defaultOrgId;
|
private Long defaultOrgId;
|
||||||
|
|
||||||
private static final String[] LOCAL_DEV_PATHS = {
|
private static final String[] LOCAL_DEV_PATHS = {
|
||||||
"/org-info/**",
|
"/**/org-info/**",
|
||||||
"/org-department/**",
|
"/**/org-department/**",
|
||||||
"/org-position/**",
|
"/**/org-position/**",
|
||||||
"/org-qualification/**",
|
"/**/org-qualification/**",
|
||||||
"/org-personnel/**",
|
"/**/org-personnel/**",
|
||||||
"/org-personnel-cert/**",
|
"/**/org-personnel-cert/**",
|
||||||
"/org-personnel-change/**",
|
"/**/org-personnel-change/**",
|
||||||
"/org-resign-apply/**",
|
"/**/org-resign-apply/**",
|
||||||
"/org-equipment/**",
|
"/**/org-equipment/**",
|
||||||
"/qual-filing/**",
|
"/**/qual-filing/**",
|
||||||
"/qual-filing-change/**",
|
"/**/qual-filing-change/**",
|
||||||
"/qual-filing-change-detail/**",
|
"/**/qual-filing-change-detail/**",
|
||||||
"/qual-filing-commitment/**",
|
"/**/qual-filing-commitment/**",
|
||||||
"/qual-filing-equipment/**",
|
"/**/qual-filing-equipment/**",
|
||||||
"/qual-filing-material/**",
|
"/**/qual-filing-material/**",
|
||||||
"/qual-filing-personnel/**",
|
"/**/qual-filing-personnel/**",
|
||||||
"/qual-filing-personnel-cert/**",
|
"/**/qual-filing-personnel-cert/**",
|
||||||
};
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -1,28 +1,17 @@
|
||||||
package org.qinan.safetyeval.adapter.web;
|
package org.qinan.safetyeval.adapter.web;
|
||||||
|
|
||||||
import cn.hutool.json.JSONUtil;
|
|
||||||
import com.jjb.saas.message.client.message.request.MessageSendCmd;
|
|
||||||
import com.jjb.saas.message.client.message.request.MessageTargetCmd;
|
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import io.swagger.annotations.ApiParam;
|
import io.swagger.annotations.ApiParam;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.qinan.safetyeval.client.api.AccountApi;
|
import org.qinan.safetyeval.client.api.AccountApi;
|
||||||
import org.qinan.safetyeval.client.co.AccountCO;
|
import org.qinan.safetyeval.client.co.AccountCO;
|
||||||
import org.qinan.safetyeval.client.dto.*;
|
import org.qinan.safetyeval.client.dto.*;
|
||||||
import org.qinan.safetyeval.domain.exception.BizException;
|
|
||||||
import org.qinan.safetyeval.infrastructure.remote.SmsRemote;
|
import org.qinan.safetyeval.infrastructure.remote.SmsRemote;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import static org.qinan.safetyeval.domain.exception.ErrorCode.SMS_SOURCE_CODE_NOT_EXIST;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户适配层(Controller)
|
* 用户适配层(Controller)
|
||||||
|
|
@ -84,4 +73,10 @@ public class AccountController {
|
||||||
return accountApi.syncUserToGBS(account);
|
return accountApi.syncUserToGBS(account);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation("验证码校验")
|
||||||
|
@GetMapping("/verificationCode")
|
||||||
|
public SingleResponse<AccountCO> verificationCode(@ApiParam("手机号") @RequestParam String phone, @ApiParam("验证码") @RequestParam String code) {
|
||||||
|
return accountApi.verificationCode(phone, code);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ import org.qinan.safetyeval.domain.query.PageResult;
|
||||||
import org.qinan.safetyeval.domain.service.AccountDomainService;
|
import org.qinan.safetyeval.domain.service.AccountDomainService;
|
||||||
import org.qinan.safetyeval.infrastructure.adapter.auth.AuthUserContextAdapter;
|
import org.qinan.safetyeval.infrastructure.adapter.auth.AuthUserContextAdapter;
|
||||||
import org.qinan.safetyeval.infrastructure.adapter.gbs.GbsUserFacadeClient;
|
import org.qinan.safetyeval.infrastructure.adapter.gbs.GbsUserFacadeClient;
|
||||||
|
import org.qinan.safetyeval.infrastructure.remote.SmsRemote;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
|
|
@ -35,10 +36,13 @@ public class AccountExecutor implements AccountApi {
|
||||||
private String defPassword;
|
private String defPassword;
|
||||||
@Value("${def.publicKey:0402df2195296d4062ac85ad766994d73e871b887e18efb9a9a06b4cebc72372869b7da6c347c129dee2b46a0f279ff066b01c76208c2a052af75977c722a2ccee}")
|
@Value("${def.publicKey:0402df2195296d4062ac85ad766994d73e871b887e18efb9a9a06b4cebc72372869b7da6c347c129dee2b46a0f279ff066b01c76208c2a052af75977c722a2ccee}")
|
||||||
private String publicKey;
|
private String publicKey;
|
||||||
|
@Autowired
|
||||||
|
private SmsRemote smsRemote;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public SingleResponse<AccountCO> add(AccountAddCmd cmd) {
|
public SingleResponse<AccountCO> add(AccountAddCmd cmd) {
|
||||||
|
smsRemote.signValidCode(cmd.getPhone(), cmd.getVerificationCode());
|
||||||
AccountEntity entity = new AccountEntity();
|
AccountEntity entity = new AccountEntity();
|
||||||
entity.setUserName(cmd.getUserName());
|
entity.setUserName(cmd.getUserName());
|
||||||
entity.setAccount(cmd.getAccount());
|
entity.setAccount(cmd.getAccount());
|
||||||
|
|
@ -112,6 +116,12 @@ public class AccountExecutor implements AccountApi {
|
||||||
return SingleResponse.success(toCO(result));
|
return SingleResponse.success(toCO(result));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SingleResponse<AccountCO> verificationCode(String phone, String code) {
|
||||||
|
smsRemote.signValidCode(phone, code);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
private AccountCO toCO(AccountEntity entity) {
|
private AccountCO toCO(AccountEntity entity) {
|
||||||
if (entity == null) {
|
if (entity == null) {
|
||||||
return null;
|
return null;
|
||||||
|
|
|
||||||
|
|
@ -25,4 +25,7 @@ public interface AccountApi {
|
||||||
PageResponse<AccountCO> page(AccountPageQuery query);
|
PageResponse<AccountCO> page(AccountPageQuery query);
|
||||||
|
|
||||||
SingleResponse<AccountCO> syncUserToGBS(String account);
|
SingleResponse<AccountCO> syncUserToGBS(String account);
|
||||||
|
|
||||||
|
SingleResponse<AccountCO> verificationCode(String phone, String code);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,9 @@ public class AccountAddCmd {
|
||||||
@ApiModelProperty(value = "头像地址")
|
@ApiModelProperty(value = "头像地址")
|
||||||
private String profileUrl;
|
private String profileUrl;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "验证码")
|
||||||
|
private String verificationCode;
|
||||||
|
|
||||||
@ApiModelProperty(value = "类型(1机构端2监管端)")
|
@ApiModelProperty(value = "类型(1机构端2监管端)")
|
||||||
private Integer type = 1;
|
private Integer type = 1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,6 @@
|
||||||
package org.qinan.safetyeval.infrastructure.adapter;
|
package org.qinan.safetyeval.infrastructure.adapter;
|
||||||
|
|
||||||
|
|
||||||
import org.qinan.safetyeval.infrastructure.utils.RequestHandlerUtil;
|
|
||||||
import org.springframework.web.context.request.RequestContextHolder;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 基于 ThreadLocal 的用户信息适配器默认实现
|
* 基于 ThreadLocal 的用户信息适配器默认实现
|
||||||
* <p>
|
* <p>
|
||||||
|
|
@ -18,7 +15,8 @@ public class ThreadLocalUserInfoAdapter {
|
||||||
private static final ThreadLocal<Long> ORG_ID = new ThreadLocal<>();
|
private static final ThreadLocal<Long> ORG_ID = new ThreadLocal<>();
|
||||||
|
|
||||||
public static Long get() {
|
public static Long get() {
|
||||||
return RequestHandlerUtil.getOrgId();
|
// return RequestHandlerUtil.getOrgId();
|
||||||
|
return ORG_ID.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -79,10 +79,10 @@ public class OrgInfoGatewayImpl implements OrgInfoGateway {
|
||||||
dataObject.setState(0);
|
dataObject.setState(0);
|
||||||
}
|
}
|
||||||
InsertFieldDefaults.apply(dataObject);
|
InsertFieldDefaults.apply(dataObject);
|
||||||
dataObject.setCreateId(entity.getCreateId());
|
dataObject.setCreateId(entity.getRegisterUserId());
|
||||||
dataObject.setUpdateId(entity.getCreateId());
|
dataObject.setUpdateId(entity.getRegisterUserId());
|
||||||
entity.setCreateId(entity.getRegisterUserId());
|
|
||||||
orgInfoMapper.insert(dataObject);
|
orgInfoMapper.insert(dataObject);
|
||||||
|
entity.setId(dataObject.getId());
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -125,7 +125,7 @@ public class SmsRemote {
|
||||||
if (code == null) {
|
if (code == null) {
|
||||||
throw new BizException(SMS_CODE_EXPIRED);
|
throw new BizException(SMS_CODE_EXPIRED);
|
||||||
}
|
}
|
||||||
if (code.toString().equals(validCode)) {
|
if (!code.toString().equals(validCode)) {
|
||||||
throw new BizException(SMS_CODE_NOT_RIGHT);
|
throw new BizException(SMS_CODE_NOT_RIGHT);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue