提交 6f2ef06b 编写于 作者: chenzhehao's avatar chenzhehao

fix--垃圾的utils升级

上级 6f964293
流水线 #37728 已失败 于阶段
......@@ -63,18 +63,7 @@
<dependency>
<groupId>com.pica.cloud.foundation</groupId>
<artifactId>pica-cloud-service-starter</artifactId>
<version>1.2.6-SNAPSHOT</version>
<!--<version>1.3.2.5</version>-->
<exclusions>
<exclusion>
<artifactId>pica-cloud-redis</artifactId>
<groupId>com.pica.cloud.foundation</groupId>
</exclusion>
<exclusion>
<artifactId>pica-cloud-entity</artifactId>
<groupId>com.pica.cloud.foundation</groupId>
</exclusion>
</exclusions>
<version>1.4.2</version>
</dependency>
<dependency>
......@@ -115,20 +104,31 @@
<version>2.1.0</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>com.pica.cloud.foundation</groupId>
<artifactId>pica-cloud-utils</artifactId>
<!-- <version>1.3.2-OLD</version>-->
<version>1.4.0-OLD</version>
<version>1.4.4</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<artifactId>jedis</artifactId>
<groupId>redis.clients</groupId>
<artifactId>servlet-api</artifactId>
<groupId>javax.servlet</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.pica.cloud.foundation</groupId>
<artifactId>pica-cloud-redis</artifactId>
<version>1.4.0</version>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
......
......@@ -15,8 +15,9 @@ import com.pica.cloud.foundation.entity.PicaException;
import com.pica.cloud.foundation.entity.PicaResponse;
import com.pica.cloud.foundation.entity.PicaResultCode;
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.controller.BaseController;
import com.pica.cloud.foundation.utils.entity.PicaUser;
import com.pica.cloud.foundation.utils.utils.HttpClientUtil;
import com.pica.cloud.foundation.utils.utils.MD5Util;
......@@ -27,7 +28,9 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import javax.servlet.http.HttpServletRequest;
import java.util.*;
import java.util.ArrayList;
import java.util.Map;
import java.util.Objects;
/**
* controller基类
......@@ -38,9 +41,6 @@ import java.util.*;
public abstract class AccountBaseController extends BaseController {
private static final String KEY_PREFIX = "token-doctor-";
private Logger logger = LoggerFactory.getLogger(AccountBaseController.class);
@Autowired
......@@ -48,6 +48,8 @@ public abstract class AccountBaseController extends BaseController {
@Autowired
private IntactUtil intactUtil;
@Autowired
private ICacheClient cacheClient;
//从token获取医生ID
public long getDoctorIdByToken() {
......@@ -61,7 +63,7 @@ public abstract class AccountBaseController extends BaseController {
//获取deviceInfo信息
public String getDeviceInfo(String key) {
String deviceInfo = super.getDeviceInfo();
String deviceInfo = this.getRequest().getHeader("deviceInfo");
if (StringUtils.isBlank(key) || StringUtils.isBlank(deviceInfo)) {
return StringUtils.EMPTY;
}
......@@ -92,14 +94,14 @@ public abstract class AccountBaseController extends BaseController {
picaUser.setToken(token);
}
String sysCode = super.getSysCode();
String sysCode = this.getRequest().getHeader("sysCode");
if ("9".equals(sysCode)) {
sysCode = "saas";
} else if ("10".equals(sysCode)) {
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)) {
return tokenValue.replace("token-", ""); //token已经存在则直接返回
}
......@@ -107,7 +109,7 @@ public abstract class AccountBaseController extends BaseController {
try {
Map<String, String> data = Object2Map.objectToMapString("yyyy-MM-dd HH:mm:ss", picaUser, new String[0]);
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) {
logger.error("保存token失败,doctorId: {}", picaUser.getId());
return StringUtils.EMPTY;
......@@ -118,8 +120,8 @@ public abstract class AccountBaseController extends BaseController {
public void sendMobileMessage(String mobile, String content, long senderId) {
//接入新旭事务一致性
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);
String sysCodeStr = super.getSysCode();
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 = this.getRequest().getHeader("sysCode");
int sysCode = 10; //默认移动端
if (StringUtils.isNotBlank(sysCodeStr)) {
try {
......@@ -151,13 +153,13 @@ public abstract class AccountBaseController extends BaseController {
picapSendMsgModel.setSysName(SysCode.APP.sysName());
String postData = JSON.toJSONString(picapSendMsgModel);
logger.info("sendMobileTo-mobile:{}, senderId-{}",mobile, senderId);
logger.info("sendMobileTo-mobile:{}, senderId-{}", mobile, senderId);
long start = System.currentTimeMillis();
String jsonObj = HttpClientUtil.httpExecute(messageUrl, postData);
intactUtil.sendIntact(batchNo,"sendMobileMessage",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"jsonObj:"+jsonObj);
intactUtil.sendIntact(batchNo, "sendMobileMessage", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3, "jsonObj:" + jsonObj);
long end1 = System.currentTimeMillis();
logger.info("sendMobileMessage-send message used {} million seconds", end1-start);
logger.info("sendMobileMessage-send message used {} million seconds", end1 - start);
logger.info("sendMobileTo-{}", jsonObj);
if (StringUtils.isEmpty(jsonObj)) {
......@@ -167,7 +169,7 @@ public abstract class AccountBaseController extends BaseController {
}
try {
PicaResponse resp = JSON.parseObject(jsonObj, PicaResponse.class);
if(Objects.nonNull(resp) && PicaResultCode.SUCCESS.code().equals(resp.getCode())){
if (Objects.nonNull(resp) && PicaResultCode.SUCCESS.code().equals(resp.getCode())) {
logger.info("send message success, the result is: {}", jsonObj);
} else {
logger.error("send message fail, response code not equals success code");
......@@ -189,8 +191,8 @@ public abstract class AccountBaseController extends BaseController {
*/
public AccountUser getAccountUser() {
//把所有请求头信息都封装到当前模型中
String token = this.getToken();
AccountUser accountUser = super.getRedisClient().getToken(token, AccountUser.class);
String token = this.getRequest().getHeader("token");
AccountUser accountUser = cacheClient.getToken(token, AccountUser.class);
accountUser.setLoginFrom(this.getSourceType());
accountUser.setLoginPlatform(this.getProductType());
accountUser.setLoginIp(super.getIpAddr());
......
......@@ -10,9 +10,10 @@ import com.pica.cloud.foundation.entity.PicaResponse;
import com.pica.cloud.foundation.service.starter.interceptor.EnabledLoginValidate;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
import java.util.Collections;
import java.util.List;
import java.util.Map;
......@@ -68,7 +69,7 @@ public class AccountInfoController extends AccountBaseController {
@ApiOperation("批量获取医生wechat信息")
@PostMapping("/wechat/batch")
public PicaResponse<Map<Integer,String>> getWechatInfoBatch(@RequestBody List<Integer> docIds) {
public PicaResponse<Map<Integer, String>> getWechatInfoBatch(@RequestBody List<Integer> docIds) {
return PicaResponse.toResponse(wechatService.getAccountWechatInfoBatch(docIds));
}
......
......@@ -45,7 +45,7 @@ public class DoctorController extends AccountBaseController {
Integer userId = accountUser.getId();
Doctor doctorInfo = doctorService.getDoctorInfo(userId);
String mobilePhone = doctorInfo.getMobilePhone();
String dencrypt = EncryptUtils.decryptContent(mobilePhone, EncryptConstants.ENCRYPT_TYPE_MOBILE, super.getToken());
String dencrypt = EncryptUtils.decryptContent(mobilePhone, EncryptConstants.ENCRYPT_TYPE_MOBILE, this.getRequest().getHeader("token"));
mobilePhone = dencrypt.substring(0, 3) + "****" + dencrypt.substring(7, 11);
doctorInfo.setMobilePhone(mobilePhone);
if (StringUtils.isNotBlank(doctorInfo.getCard())) {
......
package com.pica.cloud.account.account.server.controller;
import com.alibaba.fastjson.JSONObject;
import com.pica.cloud.account.account.server.entity.AesBean.AesAuthCodeReq;
import com.pica.cloud.account.account.server.entity.*;
import com.pica.cloud.account.account.server.entity.AesBean.AesAuthCodeReq;
import com.pica.cloud.account.account.server.enums.AccountExceptionEnum;
import com.pica.cloud.account.account.server.enums.AccountTypeEnum;
import com.pica.cloud.account.account.server.enums.SourceTypeEnum;
......@@ -25,7 +25,7 @@ import com.pica.cloud.foundation.entity.PicaWarnException;
import com.pica.cloud.foundation.redis.CacheClient;
import com.pica.cloud.foundation.redis.ICacheClient;
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 io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.catalina.servlet4preview.http.HttpServletRequest;
......@@ -78,7 +78,7 @@ public class LoginController extends AccountBaseController {
//added by joy begin
EncryptEntity entity = new EncryptEntity();
if(StringUtils.isEmpty(authCodeReq.getKey()) && StringUtils.isEmpty(authCodeReq.getContent())){
if (StringUtils.isEmpty(authCodeReq.getKey()) && StringUtils.isEmpty(authCodeReq.getContent())) {
//明文时处理
entity = RSAUtil.getAuthCodeEncrypt(authCodeReq);
logger.info("AesAuthCodeReq loginByPassword:" + JSONObject.toJSONString(authCodeReq));
......@@ -91,7 +91,7 @@ public class LoginController extends AccountBaseController {
loginAes.setMobile(authCodeReq.getMobile());
loginAes.setDeviceInfo(super.getDeviceInfoLow("deviceinfo"));
loginService.insertLoginAesLog(loginAes);
}else {
} else {
//执行原逻辑
entity.setKey(authCodeReq.getKey());
entity.setContent(authCodeReq.getContent());
......@@ -127,7 +127,7 @@ public class LoginController extends AccountBaseController {
public PicaResponse<LoginResult> loginAndRegister(@RequestBody AesAuthCodeReq authCodeReq) throws Exception {
//added by joy begin
EncryptEntity entity = new EncryptEntity();
if(StringUtils.isEmpty(authCodeReq.getKey()) && StringUtils.isEmpty(authCodeReq.getContent())){
if (StringUtils.isEmpty(authCodeReq.getKey()) && StringUtils.isEmpty(authCodeReq.getContent())) {
//明文时处理
entity = RSAUtil.getAuthCodeEncrypt(authCodeReq);
logger.info("AesAuthCodeReq loginAndRegister:" + JSONObject.toJSONString(authCodeReq));
......@@ -140,14 +140,14 @@ public class LoginController extends AccountBaseController {
loginAes.setMobile(authCodeReq.getMobile());
loginAes.setDeviceInfo(super.getDeviceInfoLow("deviceinfo"));
loginService.insertLoginAesLog(loginAes);
}else {
} else {
//执行原逻辑
entity.setKey(authCodeReq.getKey());
entity.setContent(authCodeReq.getContent());
}
//added by joy end
BaseRequest request = CryptoUtil.decrypt(entity, BaseRequest.class);
logger.info("login-register:{}",JSONObject.toJSONString(request));
logger.info("login-register:{}", JSONObject.toJSONString(request));
request.setProductType(super.getProductType());
Integer sourceType = super.getSourceType();
request.setSourceType(sourceType == null ? 0 : sourceType);
......@@ -182,7 +182,7 @@ public class LoginController extends AccountBaseController {
request.setSourceType(super.getSourceType());
request.setLoginIp(super.getIpAddr());
request.setUserTokenTourist(super.getUserTokenTourist());
logger.info("loginByWeChatStep:{}",JSONObject.toJSONString(request));
logger.info("loginByWeChatStep:{}", JSONObject.toJSONString(request));
LoginResult result = loginService.loginByWeChatStep(request);
return PicaResponse.toResponse(result);
}
......@@ -198,16 +198,16 @@ public class LoginController extends AccountBaseController {
@PostMapping("/login/wechat/bind")
public PicaResponse bindWeChat(@RequestBody EncryptEntity entity) throws Exception {
BaseRequest request = CryptoUtil.decrypt(entity, BaseRequest.class);
logger.info("bindWeChat:{}",JSONObject.toJSONString(request));
logger.info("bindWeChat:{}", JSONObject.toJSONString(request));
request.setUserTokenTourist(super.getUserTokenTourist());
Long result = cacheClient.setnx(cache_prifix + request.getWeChatCode(), request.getWeChatCode());
if (result == 1) {
try {
cacheClient.expire(cache_prifix + request.getWeChatCode(), 60);
long doctorId = super.getDoctorIdByToken();
logger.info("bindWeChat doctorId:{}",doctorId);
logger.info("bindWeChat doctorId:{}", doctorId);
// String nickname = loginService.bindWeChat(doctorId, request);
Map<String,String> rtnMap = loginService.bindWeChatMap(doctorId, request);
Map<String, String> rtnMap = loginService.bindWeChatMap(doctorId, request);
// Map<String, String> map = new HashMap();
// map.put("nickname", rtnMap.get("nickname"));
......@@ -217,7 +217,7 @@ public class LoginController extends AccountBaseController {
} catch (Exception e) {
cacheClient.del(cache_prifix + request.getWeChatCode());
logger.error("bindWeChat-" + e.getMessage(), e);
if(e instanceof PicaException) {
if (e instanceof PicaException) {
throw new PicaException(((PicaException) e).getCode(), ((PicaException) e).getMsg());
}
throw new PicaWarnException(AccountExceptionEnum.PICA_BIND_WECHAT_FAIL.getCode(), AccountExceptionEnum.PICA_BIND_WECHAT_FAIL.getMessage());
......@@ -245,7 +245,7 @@ public class LoginController extends AccountBaseController {
@ApiOperation(value = "退出登录接口")
@GetMapping("/logout")
public PicaResponse<String> loginOut() {
String token = super.getToken();
String token = this.getRequest().getHeader("token");
if (StringUtils.isNotEmpty(token)) {
Long doctorId = super.getDoctorIdByToken();
Doctor doctorInfo = doctorService.getDoctorInfo(doctorId.intValue());
......@@ -255,7 +255,7 @@ public class LoginController extends AccountBaseController {
String newToken = tokenService.getToken(headersMap);
LogLoginEntity entity = AccountLogEntityUtils.getLogLoginEntity(acctId, super.getProductType(), super.getSourceType(),
AccountTypeEnum.LOGIN_OUT.getCode(), super.getIpAddr(), AccountTypeEnum.LOGIN_STATUS_SUCCESS.getCode(), AccountTypeEnum.LOG_TYPE_LOGIN.getCode(),
newToken,0,super.getUserTokenTourist());
newToken, 0, super.getUserTokenTourist());
picaLogUtils.info(entity);
return PicaResponse.toResponse(newToken);
} else {
......@@ -283,11 +283,11 @@ public class LoginController extends AccountBaseController {
@ApiOperation(value = "统一校验(传空则不会校验)")
@PostMapping("/unifiedVerification")
public PicaResponse unifiedVerification(@RequestBody AesAuthCodeReq req) throws Exception{
public PicaResponse unifiedVerification(@RequestBody AesAuthCodeReq req) throws Exception {
//added by joy begin
EncryptEntity entity = new EncryptEntity();
if(StringUtils.isEmpty(req.getKey()) && StringUtils.isEmpty(req.getContent())){
if (StringUtils.isEmpty(req.getKey()) && StringUtils.isEmpty(req.getContent())) {
//明文时处理
entity = RSAUtil.getAuthCodeEncrypt(req);
logger.info("AesAuthCodeReq unifiedVerification:" + JSONObject.toJSONString(req));
......@@ -300,7 +300,7 @@ public class LoginController extends AccountBaseController {
loginAes.setMobile(req.getMobile());
loginAes.setDeviceInfo(super.getDeviceInfoLow("deviceinfo"));
loginService.insertLoginAesLog(loginAes);
}else {
} else {
//执行原逻辑
entity.setKey(req.getKey());
entity.setContent(req.getContent());
......@@ -309,14 +309,14 @@ public class LoginController extends AccountBaseController {
BaseRequest request = CryptoUtil.decrypt(entity, BaseRequest.class);
request.setSourceType(super.getSourceType());
logger.info("unifiedVerification:{}",JSONObject.toJSONString(request));
logger.info("unifiedVerification:{}", JSONObject.toJSONString(request));
loginService.preLoginValidate(request);
return PicaResponse.toResponse();
}
@ApiOperation(value = "苹果授权登录")
@PostMapping("/login/apple")
public PicaResponse appleAuth(@RequestBody EncryptEntity entity) throws Exception{
public PicaResponse appleAuth(@RequestBody EncryptEntity entity) throws Exception {
BaseRequest request = CryptoUtil.decrypt(entity, BaseRequest.class);
request.setProductType(super.getProductType());
request.setSourceType(super.getSourceType());
......@@ -328,25 +328,25 @@ public class LoginController extends AccountBaseController {
@ApiOperation(value = "苹果登录绑定手机号")
@PostMapping("/login/apple/step2")
public PicaResponse appleAuthBind(@RequestBody EncryptEntity entity) throws Exception{
public PicaResponse appleAuthBind(@RequestBody EncryptEntity entity) throws Exception {
BaseRequest request = CryptoUtil.decrypt(entity, BaseRequest.class);
request.setProductType(super.getProductType());
request.setSourceType(super.getSourceType());
request.setLoginIp(super.getIpAddr());
request.setUserTokenTourist(super.getUserTokenTourist());
logger.info("appleAuthBind:{}",JSONObject.toJSONString(request));
logger.info("appleAuthBind:{}", JSONObject.toJSONString(request));
return PicaResponse.toResponse(loginService.loginByAppleStep(request));
}
@ApiOperation(value = "苹果登录-跳过绑定-静默注册")
@PostMapping("/login/apple/skip/register")
public PicaResponse appleSkipRegister(@RequestBody EncryptEntity entity) throws Exception{
public PicaResponse appleSkipRegister(@RequestBody EncryptEntity entity) throws Exception {
BaseRequest request = CryptoUtil.decrypt(entity, BaseRequest.class);
request.setProductType(super.getProductType());
request.setSourceType(super.getSourceType());
request.setLoginIp(super.getIpAddr());
request.setUserTokenTourist(super.getUserTokenTourist());
logger.info("appleSkipRegister:{}",JSONObject.toJSONString(request));
logger.info("appleSkipRegister:{}", JSONObject.toJSONString(request));
return PicaResponse.toResponse(loginService.appleSkipRegister(request));
}
......@@ -357,7 +357,7 @@ public class LoginController extends AccountBaseController {
//added by joy begin
EncryptEntity entity = new EncryptEntity();
if(StringUtils.isEmpty(aesReq.getKey()) && StringUtils.isEmpty(aesReq.getContent())){
if (StringUtils.isEmpty(aesReq.getKey()) && StringUtils.isEmpty(aesReq.getContent())) {
//明文时处理
entity = RSAUtil.getOneClickEncrypt(aesReq);
logger.info("AesAuthCodeReq oneClickLogin:" + JSONObject.toJSONString(aesReq));
......@@ -371,7 +371,7 @@ public class LoginController extends AccountBaseController {
loginAes.setMobile(aesReq.getMobile());
loginAes.setDeviceInfo(super.getDeviceInfoLow("deviceinfo"));
loginService.insertLoginAesLog(loginAes);
}else {
} else {
//执行原逻辑
entity.setKey(aesReq.getKey());
entity.setContent(aesReq.getContent());
......@@ -383,7 +383,7 @@ public class LoginController extends AccountBaseController {
req.setSourceType(super.getSourceType());
req.setLoginIp(super.getIpAddr());
req.setUserTokenTourist(super.getUserTokenTourist());
logger.info("one-click req:{}",JSONObject.toJSONString(req));
logger.info("one-click req:{}", JSONObject.toJSONString(req));
LoginResult oneClickLoginResultVo = loginService.oneClickLogin(req);
return PicaResponse.toResponse(oneClickLoginResultVo);
}
......@@ -438,7 +438,7 @@ public class LoginController extends AccountBaseController {
@EnabledLoginValidate
public PicaResponse<String> loginSwitch(@RequestBody EncryptEntity entity) throws Exception {
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();
}
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册