提交 5ba5f3ae 编写于 作者: minghao.wu's avatar minghao.wu

fix: swagger test

上级 a26beadc
流水线 #47861 已失败 于阶段
...@@ -69,18 +69,15 @@ ...@@ -69,18 +69,15 @@
<dependency> <dependency>
<groupId>com.pica.cloud.foundation</groupId> <groupId>com.pica.cloud.foundation</groupId>
<artifactId>pica-cloud-service-starter</artifactId> <artifactId>pica-cloud-service-starter</artifactId>
<version>1.2.6-SNAPSHOT</version> <version>1.4.2</version>
<!--<version>1.3.2.5</version>--> <!--<version>1.3.2.5</version>-->
<exclusions> </dependency>
<exclusion>
<artifactId>pica-cloud-redis</artifactId> <dependency>
<groupId>com.pica.cloud.foundation</groupId> <groupId>com.zaxxer</groupId>
</exclusion> <artifactId>HikariCP</artifactId>
<exclusion> <version>2.7.9</version>
<artifactId>pica-cloud-entity</artifactId> <scope>provided</scope>
<groupId>com.pica.cloud.foundation</groupId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
...@@ -136,13 +133,13 @@ ...@@ -136,13 +133,13 @@
<groupId>com.pica.cloud.foundation</groupId> <groupId>com.pica.cloud.foundation</groupId>
<artifactId>pica-cloud-utils</artifactId> <artifactId>pica-cloud-utils</artifactId>
<!-- <version>1.3.2-OLD</version>--> <!-- <version>1.3.2-OLD</version>-->
<version>1.4.0-OLD</version> <version>1.4.1</version>
<exclusions> </dependency>
<exclusion>
<artifactId>jedis</artifactId> <dependency>
<groupId>redis.clients</groupId> <groupId>com.pica.cloud.foundation</groupId>
</exclusion> <artifactId>pica-cloud-redis</artifactId>
</exclusions> <version>1.4.1</version>
</dependency> </dependency>
<dependency> <dependency>
......
...@@ -3,6 +3,7 @@ package com.pica.cloud.account.account.server.configuration; ...@@ -3,6 +3,7 @@ package com.pica.cloud.account.account.server.configuration;
import com.pica.cloud.foundation.kafka.producer.ISimpleProducer; import com.pica.cloud.foundation.kafka.producer.ISimpleProducer;
import com.pica.cloud.foundation.kafka.producer.SimpleProducer; import com.pica.cloud.foundation.kafka.producer.SimpleProducer;
import com.pica.cloud.foundation.service.starter.SpringContextAware;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
...@@ -21,12 +22,15 @@ public class BeanConfiguration { ...@@ -21,12 +22,15 @@ public class BeanConfiguration {
@Autowired @Autowired
private PropertiesConfiguration propertiesConfiguration; private PropertiesConfiguration propertiesConfiguration;
@Autowired
SpringContextAware springContextAware;
// 定义 ISimplerProducer bean 默认投递模式为 Delivery.AT_LEAST_ONCE // 定义 ISimplerProducer bean 默认投递模式为 Delivery.AT_LEAST_ONCE
// Key:类型为String // Key:类型为String
// Value:类型为PicaUser // Value:类型为PicaUser
@Bean @Bean
public ISimpleProducer<String, Object> simpleProducer() { public ISimpleProducer<String, Object> simpleProducer() {
return new SimpleProducer<>(propertiesConfiguration.getEnvironment()); return new SimpleProducer<>(springContextAware.getActiveProfile());
} }
} }
...@@ -15,8 +15,9 @@ import com.pica.cloud.foundation.entity.PicaException; ...@@ -15,8 +15,9 @@ import com.pica.cloud.foundation.entity.PicaException;
import com.pica.cloud.foundation.entity.PicaResponse; import com.pica.cloud.foundation.entity.PicaResponse;
import com.pica.cloud.foundation.entity.PicaResultCode; import com.pica.cloud.foundation.entity.PicaResultCode;
import com.pica.cloud.foundation.entity.PicaWarnException; import com.pica.cloud.foundation.entity.PicaWarnException;
import com.pica.cloud.foundation.redis.ICacheClient;
import com.pica.cloud.foundation.service.starter.common.BaseController;
import com.pica.cloud.foundation.utils.constants.SysCode; import com.pica.cloud.foundation.utils.constants.SysCode;
import com.pica.cloud.foundation.utils.controller.BaseController;
import com.pica.cloud.foundation.utils.entity.PicaUser; import com.pica.cloud.foundation.utils.entity.PicaUser;
import com.pica.cloud.foundation.utils.utils.HttpClientUtil; import com.pica.cloud.foundation.utils.utils.HttpClientUtil;
import com.pica.cloud.foundation.utils.utils.MD5Util; import com.pica.cloud.foundation.utils.utils.MD5Util;
...@@ -46,6 +47,9 @@ public abstract class AccountBaseController extends BaseController { ...@@ -46,6 +47,9 @@ public abstract class AccountBaseController extends BaseController {
@Autowired @Autowired
private IntactUtil intactUtil; private IntactUtil intactUtil;
@Autowired
private ICacheClient cacheClient;
//从token获取医生ID //从token获取医生ID
public long getDoctorIdByToken() { public long getDoctorIdByToken() {
try { try {
...@@ -58,7 +62,7 @@ public abstract class AccountBaseController extends BaseController { ...@@ -58,7 +62,7 @@ public abstract class AccountBaseController extends BaseController {
//获取deviceInfo信息 //获取deviceInfo信息
public String getDeviceInfo(String key) { public String getDeviceInfo(String key) {
String deviceInfo = super.getDeviceInfo(); String deviceInfo = super.getDeviceInfoFromHeader();
if (StringUtils.isBlank(key) || StringUtils.isBlank(deviceInfo)) { if (StringUtils.isBlank(key) || StringUtils.isBlank(deviceInfo)) {
return StringUtils.EMPTY; return StringUtils.EMPTY;
} }
...@@ -69,6 +73,9 @@ public abstract class AccountBaseController extends BaseController { ...@@ -69,6 +73,9 @@ public abstract class AccountBaseController extends BaseController {
return StringUtils.EMPTY; return StringUtils.EMPTY;
} }
} }
public String getDeviceInfo() {
return super.getDeviceInfoFromHeader();
}
public String getDeviceInfoLow(String key) { public String getDeviceInfoLow(String key) {
String deviceInfo = this.getRequest().getHeader("deviceinfo"); String deviceInfo = this.getRequest().getHeader("deviceinfo");
...@@ -89,14 +96,14 @@ public abstract class AccountBaseController extends BaseController { ...@@ -89,14 +96,14 @@ public abstract class AccountBaseController extends BaseController {
picaUser.setToken(token); picaUser.setToken(token);
} }
String sysCode = super.getSysCode(); String sysCode = super.getSysCodeFromHeader();
if ("9".equals(sysCode)) { if ("9".equals(sysCode)) {
sysCode = "saas"; sysCode = "saas";
} else if ("10".equals(sysCode)) { } else if ("10".equals(sysCode)) {
sysCode = "app"; sysCode = "app";
} }
String tokenValue = super.getRedisClient().get(KEY_PREFIX + picaUser.getId().toString() + "-" + sysCode); String tokenValue = cacheClient.get(KEY_PREFIX + picaUser.getId().toString() + "-" + sysCode);
if (StringUtils.isNotBlank(tokenValue)) { if (StringUtils.isNotBlank(tokenValue)) {
return tokenValue.replace("token-", ""); //token已经存在则直接返回 return tokenValue.replace("token-", ""); //token已经存在则直接返回
} }
...@@ -104,7 +111,7 @@ public abstract class AccountBaseController extends BaseController { ...@@ -104,7 +111,7 @@ public abstract class AccountBaseController extends BaseController {
try { try {
Map<String, String> data = Object2Map.objectToMapString("yyyy-MM-dd HH:mm:ss", picaUser, new String[0]); Map<String, String> data = Object2Map.objectToMapString("yyyy-MM-dd HH:mm:ss", picaUser, new String[0]);
data.put("sysCode", sysCode); data.put("sysCode", sysCode);
return super.getRedisClient().saveToken(data, 365 * 24 * 3600); //token有效期365天 return cacheClient.saveToken(data, 365 * 24 * 3600); //token有效期365天
} catch (Exception ex) { } catch (Exception ex) {
logger.error("保存token失败,doctorId: {}", picaUser.getId()); logger.error("保存token失败,doctorId: {}", picaUser.getId());
return StringUtils.EMPTY; return StringUtils.EMPTY;
...@@ -116,7 +123,7 @@ public abstract class AccountBaseController extends BaseController { ...@@ -116,7 +123,7 @@ public abstract class AccountBaseController extends BaseController {
//接入新旭事务一致性 //接入新旭事务一致性
String batchNo = IntactUtils.getUUID(); String batchNo = IntactUtils.getUUID();
intactUtil.sendIntact(batchNo, "sendMobileMessage", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_1, "mobile:" + mobile + ",content:" + content + ",senderId:" + senderId); intactUtil.sendIntact(batchNo, "sendMobileMessage", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_1, "mobile:" + mobile + ",content:" + content + ",senderId:" + senderId);
String sysCodeStr = super.getSysCode(); String sysCodeStr = super.getSysCodeFromHeader();
int sysCode = 10; //默认移动端 int sysCode = 10; //默认移动端
if (StringUtils.isNotBlank(sysCodeStr)) { if (StringUtils.isNotBlank(sysCodeStr)) {
try { try {
...@@ -186,8 +193,8 @@ public abstract class AccountBaseController extends BaseController { ...@@ -186,8 +193,8 @@ public abstract class AccountBaseController extends BaseController {
*/ */
public AccountUser getAccountUser() { public AccountUser getAccountUser() {
//把所有请求头信息都封装到当前模型中 //把所有请求头信息都封装到当前模型中
String token = this.getToken(); String token = this.getTokenFromHeader();
AccountUser accountUser = super.getRedisClient().getToken(token, AccountUser.class); AccountUser accountUser = cacheClient.getToken(token, AccountUser.class);
accountUser.setLoginFrom(this.getSourceType()); accountUser.setLoginFrom(this.getSourceType());
accountUser.setLoginPlatform(this.getProductType()); accountUser.setLoginPlatform(this.getProductType());
accountUser.setLoginIp(super.getIpAddr()); accountUser.setLoginIp(super.getIpAddr());
......
...@@ -143,7 +143,7 @@ public class AutoCodeController extends AccountBaseController { ...@@ -143,7 +143,7 @@ public class AutoCodeController extends AccountBaseController {
logger.info("input select patient record "); logger.info("input select patient record ");
} }
// 调用风控接口 // 调用风控接口
authCodeService.rcValidate(req, request, super.getDeviceInfo(), super.getSourceType()); authCodeService.rcValidate(req, request, getDeviceInfo(), super.getSourceType());
// 发送短信验证码 // 发送短信验证码
processSysCode(request.getMobile(), request.getFlag()); processSysCode(request.getMobile(), request.getFlag());
return PicaResponse.toResponse(); return PicaResponse.toResponse();
......
...@@ -45,7 +45,7 @@ public class DoctorController extends AccountBaseController { ...@@ -45,7 +45,7 @@ public class DoctorController extends AccountBaseController {
Integer userId = accountUser.getId(); Integer userId = accountUser.getId();
Doctor doctorInfo = doctorService.getDoctorInfo(userId); Doctor doctorInfo = doctorService.getDoctorInfo(userId);
String mobilePhone = doctorInfo.getMobilePhone(); String mobilePhone = doctorInfo.getMobilePhone();
String dencrypt = EncryptUtils.decryptContent(mobilePhone, EncryptConstants.ENCRYPT_TYPE_MOBILE, super.getToken()); String dencrypt = EncryptUtils.decryptContent(mobilePhone, EncryptConstants.ENCRYPT_TYPE_MOBILE, getTokenFromHeader());
mobilePhone = dencrypt.substring(0, 3) + "****" + dencrypt.substring(7, 11); mobilePhone = dencrypt.substring(0, 3) + "****" + dencrypt.substring(7, 11);
doctorInfo.setMobilePhone(mobilePhone); doctorInfo.setMobilePhone(mobilePhone);
if (StringUtils.isNotBlank(doctorInfo.getCard())) { if (StringUtils.isNotBlank(doctorInfo.getCard())) {
......
...@@ -25,7 +25,7 @@ import com.pica.cloud.foundation.entity.PicaWarnException; ...@@ -25,7 +25,7 @@ import com.pica.cloud.foundation.entity.PicaWarnException;
import com.pica.cloud.foundation.redis.CacheClient; import com.pica.cloud.foundation.redis.CacheClient;
import com.pica.cloud.foundation.redis.ICacheClient; import com.pica.cloud.foundation.redis.ICacheClient;
import com.pica.cloud.foundation.service.starter.interceptor.EnabledLoginValidate; import com.pica.cloud.foundation.service.starter.interceptor.EnabledLoginValidate;
import com.pica.cloud.foundation.utils.annotation.LoginPermission; import com.pica.cloud.foundation.service.starter.interceptor.LoginPermission;
import com.pica.cloud.foundation.utils.utils.StringUtil; import com.pica.cloud.foundation.utils.utils.StringUtil;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
...@@ -246,7 +246,7 @@ public class LoginController extends AccountBaseController { ...@@ -246,7 +246,7 @@ public class LoginController extends AccountBaseController {
@ApiOperation(value = "退出登录接口") @ApiOperation(value = "退出登录接口")
@GetMapping("/logout") @GetMapping("/logout")
public PicaResponse<String> loginOut() { public PicaResponse<String> loginOut() {
String token = super.getToken(); String token = super.getTokenFromHeader();
if (StringUtils.isNotEmpty(token)) { if (StringUtils.isNotEmpty(token)) {
Long doctorId = super.getDoctorIdByToken(); Long doctorId = super.getDoctorIdByToken();
Doctor doctorInfo = doctorService.getDoctorInfo(doctorId.intValue()); Doctor doctorInfo = doctorService.getDoctorInfo(doctorId.intValue());
...@@ -426,7 +426,7 @@ public class LoginController extends AccountBaseController { ...@@ -426,7 +426,7 @@ public class LoginController extends AccountBaseController {
@ApiOperation(value = "二维码扫码登录") @ApiOperation(value = "二维码扫码登录")
@PostMapping("/login/QRCode") @PostMapping("/login/QRCode")
@LoginPermission @EnabledLoginValidate
public PicaResponse<String> loginQRCode() { public PicaResponse<String> loginQRCode() {
BaseRequest request = new BaseRequest(); BaseRequest request = new BaseRequest();
request.setProductType(1); request.setProductType(1);
...@@ -444,7 +444,7 @@ public class LoginController extends AccountBaseController { ...@@ -444,7 +444,7 @@ public class LoginController extends AccountBaseController {
@EnabledLoginValidate @EnabledLoginValidate
public PicaResponse<String> loginSwitch(@RequestBody EncryptEntity entity) throws Exception { public PicaResponse<String> loginSwitch(@RequestBody EncryptEntity entity) throws Exception {
Map<String, Object> req = CryptoUtil.decrypt(entity, Map.class); Map<String, Object> req = CryptoUtil.decrypt(entity, Map.class);
loginService.loginSwitch(super.getAccountUser(), super.getRedisClient().getToken(String.valueOf(req.get("token")), AccountUser.class)); loginService.loginSwitch(super.getAccountUser(), cacheClient.getToken(String.valueOf(req.get("token")), AccountUser.class));
return PicaResponse.toResponse(); return PicaResponse.toResponse();
} }
......
...@@ -9,6 +9,7 @@ import com.pica.cloud.account.account.server.exception.AccountException; ...@@ -9,6 +9,7 @@ import com.pica.cloud.account.account.server.exception.AccountException;
import com.pica.cloud.account.account.server.mapper.AccountInfoDetailMapper; import com.pica.cloud.account.account.server.mapper.AccountInfoDetailMapper;
import com.pica.cloud.account.account.server.req.BaseRequest; import com.pica.cloud.account.account.server.req.BaseRequest;
import com.pica.cloud.account.account.server.service.AccountInfoService; import com.pica.cloud.account.account.server.service.AccountInfoService;
import com.pica.cloud.account.account.server.service.AccountService;
import com.pica.cloud.account.account.server.service.DoctorService; import com.pica.cloud.account.account.server.service.DoctorService;
import com.pica.cloud.account.account.server.service.ModifyMobileService; import com.pica.cloud.account.account.server.service.ModifyMobileService;
import com.pica.cloud.account.account.server.service.impl.AccountServiceImpl; import com.pica.cloud.account.account.server.service.impl.AccountServiceImpl;
...@@ -38,7 +39,7 @@ public class ModifyMobileController extends AccountBaseController { ...@@ -38,7 +39,7 @@ public class ModifyMobileController extends AccountBaseController {
private DoctorService doctorService; private DoctorService doctorService;
@Autowired @Autowired
private AccountServiceImpl accountService; private AccountService accountService;
@ApiOperation("修改手机号") @ApiOperation("修改手机号")
......
...@@ -23,7 +23,6 @@ import com.pica.cloud.foundation.encryption.common.constants.EncryptConstants; ...@@ -23,7 +23,6 @@ import com.pica.cloud.foundation.encryption.common.constants.EncryptConstants;
import com.pica.cloud.foundation.encryption.util.EncryptUtils; import com.pica.cloud.foundation.encryption.util.EncryptUtils;
import com.pica.cloud.foundation.entity.PicaResponse; import com.pica.cloud.foundation.entity.PicaResponse;
import com.pica.cloud.foundation.redis.ICacheClient; import com.pica.cloud.foundation.redis.ICacheClient;
import com.pica.cloud.foundation.utils.utils.RequestUtils;
import com.pica.cloud.foundation.utils.utils.StringUtil; import com.pica.cloud.foundation.utils.utils.StringUtil;
import com.pica.cloud.tag.transport.client.ITransportDoctorClient; import com.pica.cloud.tag.transport.client.ITransportDoctorClient;
import com.pica.cloud.tag.transport.contract.req.StickerProfileDto; import com.pica.cloud.tag.transport.contract.req.StickerProfileDto;
...@@ -35,6 +34,8 @@ import org.springframework.beans.factory.annotation.Qualifier; ...@@ -35,6 +34,8 @@ import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import java.util.Date; import java.util.Date;
import java.util.UUID; import java.util.UUID;
...@@ -134,7 +135,8 @@ public class RegisterServiceImpl implements RegisterService { ...@@ -134,7 +135,8 @@ public class RegisterServiceImpl implements RegisterService {
/*注册app版本*/ /*注册app版本*/
try { try {
JSONObject jsonObject = JSONObject.parseObject(RequestUtils.getRequest().getHeader("deviceInfo")); ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.currentRequestAttributes();
JSONObject jsonObject = JSONObject.parseObject(servletRequestAttributes.getRequest().getHeader("deviceInfo"));
accountInfo.setRegVersion(jsonObject.getString("app_version")); accountInfo.setRegVersion(jsonObject.getString("app_version"));
} catch (Exception ex) { } catch (Exception ex) {
logger.error("从header中获取app版本异常", ex); logger.error("从header中获取app版本异常", ex);
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册