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

fix--垃圾的utils升级

上级 6f964293
流水线 #37728 已失败 于阶段
...@@ -63,18 +63,7 @@ ...@@ -63,18 +63,7 @@
<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>-->
<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>
</dependency> </dependency>
<dependency> <dependency>
...@@ -115,20 +104,31 @@ ...@@ -115,20 +104,31 @@
<version>2.1.0</version> <version>2.1.0</version>
</dependency> </dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency>
<dependency> <dependency>
<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.4.4</version>
<version>1.4.0-OLD</version> <scope>provided</scope>
<exclusions> <exclusions>
<exclusion> <exclusion>
<artifactId>jedis</artifactId> <artifactId>servlet-api</artifactId>
<groupId>redis.clients</groupId> <groupId>javax.servlet</groupId>
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<dependency>
<groupId>com.pica.cloud.foundation</groupId>
<artifactId>pica-cloud-redis</artifactId>
<version>1.4.0</version>
</dependency>
<dependency> <dependency>
<groupId>redis.clients</groupId> <groupId>redis.clients</groupId>
<artifactId>jedis</artifactId> <artifactId>jedis</artifactId>
......
...@@ -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;
...@@ -27,7 +28,9 @@ import org.slf4j.LoggerFactory; ...@@ -27,7 +28,9 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.*; import java.util.ArrayList;
import java.util.Map;
import java.util.Objects;
/** /**
* controller基类 * controller基类
...@@ -38,9 +41,6 @@ import java.util.*; ...@@ -38,9 +41,6 @@ import java.util.*;
public abstract class AccountBaseController extends BaseController { public abstract class AccountBaseController extends BaseController {
private static final String KEY_PREFIX = "token-doctor-"; private static final String KEY_PREFIX = "token-doctor-";
private Logger logger = LoggerFactory.getLogger(AccountBaseController.class); private Logger logger = LoggerFactory.getLogger(AccountBaseController.class);
@Autowired @Autowired
...@@ -48,6 +48,8 @@ public abstract class AccountBaseController extends BaseController { ...@@ -48,6 +48,8 @@ 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() {
...@@ -61,7 +63,7 @@ public abstract class AccountBaseController extends BaseController { ...@@ -61,7 +63,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 = this.getRequest().getHeader("deviceInfo");
if (StringUtils.isBlank(key) || StringUtils.isBlank(deviceInfo)) { if (StringUtils.isBlank(key) || StringUtils.isBlank(deviceInfo)) {
return StringUtils.EMPTY; return StringUtils.EMPTY;
} }
...@@ -92,14 +94,14 @@ public abstract class AccountBaseController extends BaseController { ...@@ -92,14 +94,14 @@ public abstract class AccountBaseController extends BaseController {
picaUser.setToken(token); picaUser.setToken(token);
} }
String sysCode = super.getSysCode(); String sysCode = this.getRequest().getHeader("sysCode");
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已经存在则直接返回
} }
...@@ -107,7 +109,7 @@ public abstract class AccountBaseController extends BaseController { ...@@ -107,7 +109,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;
...@@ -118,8 +120,8 @@ public abstract class AccountBaseController extends BaseController { ...@@ -118,8 +120,8 @@ public abstract class AccountBaseController extends BaseController {
public void sendMobileMessage(String mobile, String content, long senderId) { public void sendMobileMessage(String mobile, String content, long senderId) {
//接入新旭事务一致性 //接入新旭事务一致性
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 = this.getRequest().getHeader("sysCode");
int sysCode = 10; //默认移动端 int sysCode = 10; //默认移动端
if (StringUtils.isNotBlank(sysCodeStr)) { if (StringUtils.isNotBlank(sysCodeStr)) {
try { try {
...@@ -151,13 +153,13 @@ public abstract class AccountBaseController extends BaseController { ...@@ -151,13 +153,13 @@ public abstract class AccountBaseController extends BaseController {
picapSendMsgModel.setSysName(SysCode.APP.sysName()); picapSendMsgModel.setSysName(SysCode.APP.sysName());
String postData = JSON.toJSONString(picapSendMsgModel); String postData = JSON.toJSONString(picapSendMsgModel);
logger.info("sendMobileTo-mobile:{}, senderId-{}",mobile, senderId); logger.info("sendMobileTo-mobile:{}, senderId-{}", mobile, senderId);
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
String jsonObj = HttpClientUtil.httpExecute(messageUrl, postData); 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(); 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); logger.info("sendMobileTo-{}", jsonObj);
if (StringUtils.isEmpty(jsonObj)) { if (StringUtils.isEmpty(jsonObj)) {
...@@ -167,7 +169,7 @@ public abstract class AccountBaseController extends BaseController { ...@@ -167,7 +169,7 @@ public abstract class AccountBaseController extends BaseController {
} }
try { try {
PicaResponse resp = JSON.parseObject(jsonObj, PicaResponse.class); 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); logger.info("send message success, the result is: {}", jsonObj);
} else { } else {
logger.error("send message fail, response code not equals success code"); logger.error("send message fail, response code not equals success code");
...@@ -189,8 +191,8 @@ public abstract class AccountBaseController extends BaseController { ...@@ -189,8 +191,8 @@ public abstract class AccountBaseController extends BaseController {
*/ */
public AccountUser getAccountUser() { public AccountUser getAccountUser() {
//把所有请求头信息都封装到当前模型中 //把所有请求头信息都封装到当前模型中
String token = this.getToken(); String token = this.getRequest().getHeader("token");
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());
......
...@@ -10,9 +10,10 @@ import com.pica.cloud.foundation.entity.PicaResponse; ...@@ -10,9 +10,10 @@ import com.pica.cloud.foundation.entity.PicaResponse;
import com.pica.cloud.foundation.service.starter.interceptor.EnabledLoginValidate; import com.pica.cloud.foundation.service.starter.interceptor.EnabledLoginValidate;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -68,7 +69,7 @@ public class AccountInfoController extends AccountBaseController { ...@@ -68,7 +69,7 @@ public class AccountInfoController extends AccountBaseController {
@ApiOperation("批量获取医生wechat信息") @ApiOperation("批量获取医生wechat信息")
@PostMapping("/wechat/batch") @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)); return PicaResponse.toResponse(wechatService.getAccountWechatInfoBatch(docIds));
} }
......
...@@ -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, this.getRequest().getHeader("token"));
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())) {
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册