提交 53bbefb5 编写于 作者: rushui.chen's avatar rushui.chen

20190916 双写模式

上级 4994b549
流水线 #14526 已失败 于阶段
in 0 second
......@@ -116,7 +116,6 @@ public abstract class AccountBaseController extends BaseController {
picapSendMsgModel.setExtend("");
picapSendMsgModel.setSupplementFlag(true);
picapSendMsgModel.setSms_entity_id(0);
long currentTimeMillis = System.currentTimeMillis();
picapSendMsgModel.setTime(String.valueOf(currentTimeMillis));
picapSendMsgModel.setKey(MD5Util.MD5("pica" + currentTimeMillis));
......@@ -138,7 +137,6 @@ public abstract class AccountBaseController extends BaseController {
* @return
*/
public AccountUser getAccountUser() {
//无论是否登录,当前对象都应该存在
//把所有请求头信息都封装到当前模型中
String token = this.getToken();
AccountUser accountUser = super.getRedisClient().getToken(token, AccountUser.class);
......
package com.pica.cloud.account.account.server.controller;
import com.pica.cloud.account.account.server.entity.Account;
import com.pica.cloud.account.account.server.mapper.AccountMapper;
import com.pica.cloud.account.account.server.req.AccountReq;
import com.pica.cloud.account.account.server.service.AccountService;
import com.pica.cloud.account.account.server.service.CaptchaService;
......@@ -147,7 +148,8 @@ public class AccountController extends AccountBaseController {
default:
account.setRegisterSource(7); //H5注册
}
accountService.createAccount(account); //创建账号
//创建账号
accountService.createAccount(account);
//生成token并返回
String newToken = this.generateToken(account, deviceType);
......
package com.pica.cloud.account.account.server.controller;
import com.pica.cloud.account.account.server.util.RSAUtil;
import com.pica.cloud.foundation.entity.PicaResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* Created on 2019/9/16 15:29
* author:crs
* Description:H5端获取公钥资源
*/
@Api("密钥接口资源")
@RestController
public class CipherController {
@ApiOperation("获取公钥Key接口")
@GetMapping(value = "/cipher/key")
public PicaResponse<String> getPublicKey() {
return PicaResponse.toResponse(RSAUtil.publicKey);
}
}
......@@ -137,20 +137,20 @@ public class LoginController extends AccountBaseController {
/**
* 退出登录接口,返回一个随机token
* 1)登录状态调用,2)清除token
*
* @return
*/
@ApiOperation(value = "退出登录接口")
@GetMapping("/logout")
public PicaResponse loginOut() {
//只有在登录状态下才能调用此接口;
String token = super.getToken();
if (StringUtils.isNotEmpty(token)) {
Integer acctId = super.getAcctId();
redisClient.deleteToken(token);
Map<String, Object> headersMap = super.getHeaders();
String newToken = tokenService.getToken(headersMap);
//记录登录日志
LogLoginEntity entity = AccountLogEntityUtils.getLogLoginEntity(super.getAcctId(), super.getProductType(), super.getSourceType(),
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());
picaLogUtils.info(entity);
return PicaResponse.toResponse(newToken);
......
......@@ -11,29 +11,31 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.beanutils.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
@Api(description = "云鹊健康用户信息信息资源")
@RestController
@RequestMapping(value = "/patient")
public class PatientInfoController extends AccountBaseController {
@Autowired
private PatientInfoService patientInfoService;
/**
* 获取用户信息接口
* 获取用户信息接口,产品线不同,用户信息不同(云鹊医,云鹊健康)
*
* @return
*/
@ApiOperation("获取用户信息接口")
@GetMapping(value = "/user/info")
@GetMapping(value = "/info")
public PicaResponse getUserInfo() {
AccountUser accountUser = super.getAccountUser();
AccountPatientInfoEntity userInfo = null;
Integer loginFrom = accountUser.getLoginFrom();
Integer userId = accountUser.getId();
AccountPatientInfoEntity userInfo = patientInfoService.getUserInfo(userId);
if (loginFrom == 2) {
userInfo = patientInfoService.getUserInfo(userId);
}
return PicaResponse.toResponse(userInfo);
}
......@@ -43,7 +45,7 @@ public class PatientInfoController extends AccountBaseController {
* @return
*/
@ApiOperation("修改用户信息")
@PutMapping(value = "/user/info")
@PutMapping(value = "/info")
public PicaResponse putUserInfo(@RequestBody EncryptEntity entity) throws Exception {
Integer id = super.getAccountUser().getId();
PatientReq request = CryptoUtil.decrypt(entity, PatientReq.class);
......
......@@ -30,4 +30,6 @@ public class TokenController extends AccountBaseController {
return PicaResponse.toResponse(token);
}
}
......@@ -93,7 +93,7 @@ public class Doctor {
private Integer totalSmsSendNum;
private Boolean entireFlag;
private Integer entireFlag;
private Integer doctorProjectType;
......@@ -483,11 +483,11 @@ public class Doctor {
this.totalSmsSendNum = totalSmsSendNum;
}
public Boolean getEntireFlag() {
public Integer getEntireFlag() {
return entireFlag;
}
public void setEntireFlag(Boolean entireFlag) {
public void setEntireFlag(Integer entireFlag) {
this.entireFlag = entireFlag;
}
......
package com.pica.cloud.account.account.server.service.impl;
import com.pica.cloud.account.account.server.entity.Account;
import com.pica.cloud.account.account.server.entity.AccountInfoEntity;
import com.pica.cloud.account.account.server.mapper.AccountInfoDetailMapper;
import com.pica.cloud.account.account.server.mapper.AccountMapper;
import com.pica.cloud.account.account.server.service.AccountService;
import com.pica.cloud.foundation.redis.ICacheClient;
......@@ -11,8 +13,10 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
......@@ -31,9 +35,14 @@ public class AccountServiceImpl implements AccountService {
@Autowired
private AccountMapper accountMapper;
@Autowired
private AccountInfoDetailMapper accountInfoDetailMapper;
@Autowired
@Qualifier("cacheMigrateClient")
private ICacheClient cacheClient;
@Value("${doubleWritingMode}")
private boolean doubleWritingMode;
//根据ID获取账号
@Override
public Account getById(long id) {
......@@ -56,17 +65,35 @@ public class AccountServiceImpl implements AccountService {
@Override
@Transactional
public void createAccount(Account account) {
//账户表
AccountInfoEntity accountInfo = new AccountInfoEntity();
Date currentTime = new Date();
accountInfo.setPassword("");
accountInfo.setCreatedTime(currentTime);
accountInfo.setCreatedId(0);
accountInfo.setModifiedId(0);
accountInfo.setModifiedTime(currentTime);
accountInfo.setRegTime(currentTime);
accountInfo.setDeleteFlag(1);
accountInfo.setSex(0);
accountInfo.setRegisterProduct(1);
accountInfo.setRegisterSource(5);
accountInfoDetailMapper.insertSelective(accountInfo);
Integer acctId = accountInfo.getId();
//doctor表,存入用户id
if (doubleWritingMode) {
account.setMobilePhone(EncryptCreateUtil.encrypt(account.getMobilePhone())); //手机号加密
account.setDeleteFlag(1);
account.setCreatId(0L);
account.setModifyId(0L);
account.setAcctId(acctId);
account.setCreatTime(currentTime);
account.setModifyTime(currentTime);
account.setFirstLoginTime(currentTime);
account.setLastLoginTime(currentTime);
accountMapper.insertSelective(account);
}
}
//更新账号信息
@Override
......
......@@ -78,13 +78,12 @@ public class LoginServiceImpl implements LoginService {
@Override
public String login(BaseRequest request) {
String mobile = request.getMobile();
AccountInfoEntity accountInfoEntity = accountInfoDetailMapper.selectByMobile(EncryptCreateUtil.encrypt(mobile));
String encrypt = EncryptCreateUtil.encrypt(mobile);
AccountInfoEntity accountInfoEntity = accountInfoDetailMapper.selectByMobile(encrypt);
if (accountInfoEntity != null) {
String oldPwd = accountInfoEntity.getPassword();
String password = request.getPassword();
if (password.equals(oldPwd)) {
//登陆成功,返回新的token
//通过账户id查询用户id
Date currentTime = new Date();
Integer acctId = accountInfoEntity.getId();
int productType = request.getProductType();
......@@ -100,12 +99,10 @@ public class LoginServiceImpl implements LoginService {
JSONObject jsonObject = new JSONObject();
jsonObject.put(Constants.TOKEN, newToken);
jsonObject.put(Constants.USER_ID, userId);
//是否完善过个人信息(云鹊医app才需要)
if (productType == AccountTypeEnum.PRODUCT_TYPE_DOCTOR.getCode()) {
DoctorEntity doctorEntity = doctorInfoMapper.getDoctorInfoByMobile(EncryptCreateUtil.encrypt(mobile));
jsonObject.put(Constants.USER_ENTIRE_FLAG, doctorEntity.getEntire_flag());
Doctor doctorEntity = doctorInfoMapper.selectByPrimaryKey(userId.intValue());
jsonObject.put(Constants.USER_ENTIRE_FLAG, doctorEntity.getEntireFlag());
}
//记录登录日志
LogLoginEntity entity = AccountLogEntityUtils.getLogLoginEntity(acctId, productType, request.getSourceType(),
AccountTypeEnum.LOGIN_PWD.getCode(), request.getLoginIp(), AccountTypeEnum.LOGIN_STATUS_SUCCESS.getCode(),
AccountTypeEnum.LOG_TYPE_LOGIN.getCode());
......@@ -155,6 +152,11 @@ public class LoginServiceImpl implements LoginService {
JSONObject jsonObject = new JSONObject();
jsonObject.put(Constants.TOKEN, newToken);
jsonObject.put(Constants.USER_ID, userId);
//是否完善过个人信息(云鹊医app才需要)
if (baseRequest.getProductType() == AccountTypeEnum.PRODUCT_TYPE_DOCTOR.getCode()) {
Doctor doctorEntity = doctorInfoMapper.selectByPrimaryKey(userId.intValue());
jsonObject.put(Constants.USER_ENTIRE_FLAG, doctorEntity.getEntireFlag());
}
//记录登录日志
LogLoginEntity entity = AccountLogEntityUtils.getLogLoginEntity(acctId, baseRequest.getProductType(), baseRequest.getSourceType(),
loginType, baseRequest.getLoginIp(), AccountTypeEnum.LOGIN_STATUS_SUCCESS.getCode(), AccountTypeEnum.LOG_TYPE_LOGIN.getCode());
......@@ -294,17 +296,14 @@ public class LoginServiceImpl implements LoginService {
accountWeChatInfoEntity.setProvince(weChatUserInfoEntity.getProvince());
accountWeChatInfoEntity.setLanguage(weChatUserInfoEntity.getLanguage());
accountWeChatInfoMapper.insertSelective(accountWeChatInfoEntity);
}
//校验验证码
private void checkAuthCode(AccountReq req) {
String flag = StringUtils.isBlank(req.getFlag()) ? "0" : req.getFlag();
if (StringUtils.isBlank(req.getAuthCode())) {
throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "短信验证码错误");
}
String authCodeKey = AccountUtils.getAuthCodeKey(req.getMobilePhone(), flag);
String cacheCode = redisClient.get(authCodeKey); //从redis获取验证码
if (StringUtils.isBlank(cacheCode)) {
......
......@@ -8,11 +8,11 @@ import com.pica.cloud.account.account.server.mapper.AccountInfoDetailMapper;
import com.pica.cloud.account.account.server.mapper.DoctorMapper;
import com.pica.cloud.account.account.server.service.ModifyMobileService;
import com.pica.cloud.foundation.utils.utils.EncryptCreateUtil;
import com.sun.org.apache.bcel.internal.generic.IF_ACMPEQ;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
......@@ -29,6 +29,7 @@ public class ModifyMobileServiceImpl implements ModifyMobileService {
private boolean doubleWritingMode;
@Override
@Transactional
public void modify(Integer acctId, String mobile) {
AccountInfoEntity entity = accountInfoDetailMapper.selectByPrimaryKey(acctId);
String mobilePhone = entity.getMobilePhone();
......
......@@ -16,6 +16,7 @@ import com.pica.cloud.foundation.utils.utils.EncryptCreateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
......@@ -35,6 +36,7 @@ public class PasswordServiceImpl implements PasswordService {
private boolean doubleWritingMode;
@Override
@Transactional
public void modifyPassword(Integer acctId, String oldPwd, String pwd) {
AccountInfoEntity entity = accountInfoDetailMapper.selectByPrimaryKey(acctId);
if (entity.getPassword().equals(oldPwd)) {
......@@ -58,6 +60,7 @@ public class PasswordServiceImpl implements PasswordService {
}
@Override
@Transactional
public void forgetPassword(BaseRequest request) {
AccountInfoEntity entity = accountInfoDetailMapper.selectByMobile(EncryptCreateUtil.encrypt(request.getMobile()));
if (entity != null) {
......
......@@ -19,6 +19,7 @@ import com.pica.cloud.account.account.server.queue.QueueProducer;
import com.pica.cloud.account.account.server.req.BaseRequest;
import com.pica.cloud.account.account.server.service.RegisterService;
import com.pica.cloud.account.account.server.util.AccountUtils;
import com.pica.cloud.account.account.server.util.TokenUtils;
import com.pica.cloud.foundation.redis.ICacheClient;
import com.pica.cloud.foundation.utils.utils.EncryptCreateUtil;
import org.apache.commons.lang3.StringUtils;
......@@ -38,8 +39,6 @@ import java.util.*;
@Service
public class RegisterServiceImpl implements RegisterService {
private Logger logger = LoggerFactory.getLogger(this.getClass());
@Autowired
private AccountInfoDetailMapper accountInfoDetailMapper;
......@@ -59,6 +58,9 @@ public class RegisterServiceImpl implements RegisterService {
@Autowired
private AccountUtils accountUtils;
@Autowired
private TokenUtils tokenUtils;
@Autowired
private QueueProducer queueProducer;
......@@ -102,15 +104,15 @@ public class RegisterServiceImpl implements RegisterService {
} else {
Account account = new Account();
account.setAcctId(acctId);
account.setMobilePhone(EncryptCreateUtil.encrypt(account.getMobilePhone()));
account.setMobilePhone(EncryptCreateUtil.encrypt(mobile));
account.setDeleteFlag(1);
account.setCreatId(0L);
account.setModifyId(0L);
account.setPassword(password);
account.setCreatTime(currentTime);
account.setModifyTime(currentTime);
account.setFirstLoginTime(currentTime);
account.setLastLoginTime(currentTime);
account.setPassword(password);
accountMapper.insertSelective(account);
}
Long userId = accountUtils.getUserIdByAcctId(productType, acctId);
......@@ -120,10 +122,12 @@ public class RegisterServiceImpl implements RegisterService {
account.setCreatTime(currentTime);
account.setMobilePhone(mobile);
account.setRegisterSource(sourceType);
String newToken = this.generateToken(account);
String newToken = tokenUtils.generateToken(account);
JSONObject jsonObject = new JSONObject();
jsonObject.put(Constants.TOKEN, newToken);
jsonObject.put(Constants.USER_ID, userId);
//注册功能:默认未完善信息
jsonObject.put(Constants.USER_ENTIRE_FLAG, 1);
//注册成功后发送mq消息,让别的服务初始化数据
ByteArrayOutputStream bos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(bos);
......@@ -143,49 +147,4 @@ public class RegisterServiceImpl implements RegisterService {
throw new AccountException(AccountExceptionEnum.PICA_ALREADY_REGISTER);
}
}
/**
* 生成新的token
*
* @param account
* @return
*/
private String generateToken(Account account) {
String sourceType = AccountUtils.getSourceType(account.getRegisterSource());
String newToken = org.apache.commons.lang3.StringUtils.EMPTY;
try {
String value = "token-doctor-" + account.getId().toString();
//生成新token
int expiredSeconds = 30 * 24 * 60 * 60;//token有效期30天
newToken = UUID.randomUUID().toString().replace("-", "").toUpperCase();
String Key = "token-" + newToken;
//存储token:(token-FF9FCB0D93A642328A01C279701B7607:token-doctor-1)
cacheClient.set(Key, value, expiredSeconds);
//存储token:(token-doctor-12345678-app:token-FF9FCB0D93A642328A01C279701B7607)
cacheClient.set(value + sourceType, Key, expiredSeconds);
//用户数据放入缓存
String userData = cacheClient.hget(value, "id");
if (org.apache.commons.lang3.StringUtils.isEmpty(userData)) {
Map<String, String> data = new HashMap<>();
data.put("token", newToken);
data.put("id", account.getId() + "");
data.put("acctId", account.getAcctId() + "");
data.put("mobile", account.getMobilePhone());
data.put("name", account.getMobilePhone().replaceAll("(\\d{3})\\d{4}(\\w{4})", "$1****$2"));
data.put("created_time", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(account.getCreatTime()));
data.put("sysCode", sourceType);
Iterator<Map.Entry<String, String>> iterator = data.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<String, String> map = iterator.next();
String key = map.getKey();
String valueInfo = map.getValue();
//存储token:(token-doctor-1:用户数据)
cacheClient.hset(value, key, valueInfo);
}
}
} catch (Exception ex) {
logger.error("生成token异常:{}" + ex.getMessage(), ex);
}
return newToken;
}
}
......@@ -6,7 +6,6 @@ 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.mapper.AccountPatientInfoMapper;
import com.pica.cloud.account.account.server.mapper.DoctorMapper;
import com.pica.cloud.account.account.server.req.BaseRequest;
import com.pica.cloud.foundation.entity.PicaException;
import com.pica.cloud.foundation.entity.PicaResultCode;
import com.pica.cloud.foundation.redis.ICacheClient;
......@@ -113,13 +112,17 @@ public class AccountUtils {
*/
public static String getSourceType(Integer registerSource) {
String sourceType = null;
if (registerSource == 4) {
sourceType = "h5";
} else if (registerSource == 3) {
switch (registerSource) {
case 3:
sourceType = "web";
} else if (registerSource == 5) {
break;
case 4:
sourceType = "h5";
break;
case 5:
sourceType = "admin";
} else {
break;
default:
sourceType = "app";
}
return sourceType;
......
......@@ -21,7 +21,7 @@ public class RSAUtil {
//用于封装随机产生的公钥与私钥
private static Map<Integer, String> keyMap = new HashMap<>();
private static final String privateKey="MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAO+zh8bnUA+elnRy1BHKEGrbTmh/" +
private static final String privateKey = "MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAO+zh8bnUA+elnRy1BHKEGrbTmh/" +
"r71zFboVTznwAuEzPnvOezQBOY+623mIXh86/cyCLlCRzbGm0Q5M3LSY6sTemNXtupVnb1lWwD1xDrSG0JsCgeS/weCLI9gHaknNuMfVlg+" +
"5esYcy2JlyG5ldcJahCgAOog2lJr4pLUSj8fJAgMBAAECgYEAiJIlnjJU71FQL/Ds22XhjMB/IBMAMlTL4EYb6crSGTV1OF0g3TSFc1rniY" +
"sk9W5LBKZ3dPhd1gZRvnAUn+EwgPh1bVBG0Z30vr2Ea0w9v+D3T96byeCKh+xoKQqG+Yp+u5w8v6MNNX6sVN2D0gks9YgY+2xGEeAf9kuF5" +
......@@ -31,7 +31,7 @@ public class RSAUtil {
"v4J8WlsQOnRTvF/Q43wo3TeuY29p1749qHf5Z3QQJBANnZYSe93QlOT+6PFT1Dkv8osnOY/93CZYD2IvTpfXfqJnbBZ9bkSe7xcxIIqGO6M" +
"JWlZjItnYBZLLHP3JKVgOQ=";
private static final String publicKey="MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDvs4fG51APnpZ0ctQRyhBq205of6+9cxW6FU858" +
public static final String publicKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDvs4fG51APnpZ0ctQRyhBq205of6+9cxW6FU858" +
"ALhMz57zns0ATmPutt5iF4fOv3Mgi5Qkc2xptEOTNy0mOrE3pjV7bqVZ29ZVsA9cQ60htCbAoHkv8HgiyPYB2pJzbjH1ZYPuXrGHMtiZchu" +
"ZXXCWoQoADqINpSa+KS1Eo/HyQIDAQAB";
......@@ -42,7 +42,7 @@ public class RSAUtil {
* @return
*/
public static String encrypt(String keyString) throws Exception {
return encrypt(keyString,publicKey);
return encrypt(keyString, publicKey);
}
/**
......@@ -52,7 +52,7 @@ public class RSAUtil {
* @return
*/
public static String decrypt(String key) throws Exception {
return decrypt(key,privateKey);
return decrypt(key, privateKey);
}
/**
......@@ -120,8 +120,8 @@ public class RSAUtil {
public static void main(String[] args) throws Exception {
//生成公钥和私钥
//genKeyPair();
keyMap.put(0,publicKey);
keyMap.put(1,privateKey);
keyMap.put(0, publicKey);
keyMap.put(1, privateKey);
//加密字符串
String message = "df723820";
System.out.println("随机生成的公钥为:" + keyMap.get(0));
......
......@@ -44,7 +44,8 @@ public class TokenUtils {
*/
public String generateToken(Account account) {
//判断用户终端类型
String sourceType = AccountUtils.getSourceType(account.getRegisterSource());
Integer registerSource = account.getRegisterSource();
String sourceType = AccountUtils.getSourceType(registerSource);
String newToken = StringUtils.EMPTY;
//用户唯一key
String tokenDoctorId = "token-doctor-" + account.getId().toString();
......@@ -55,13 +56,23 @@ public class TokenUtils {
}
//生成新的token,并和用户唯一key绑定
newToken = UUID.randomUUID().toString().replace("-", "").toUpperCase();
int expiredSeconds = 30 * 24 * 60 * 60;
//过期时间处理
int expiredSeconds = 0;
switch (registerSource) {
case 3:
case 5:
expiredSeconds = 24 * 60 * 60;
break;
default:
expiredSeconds = expiredSeconds * 30;
}
cacheClient.set("token-" + newToken, tokenDoctorId, expiredSeconds);
//存储当前登录终端对应的token
cacheClient.set(tokenDoctorId + "-" + sourceType, "token-" + newToken, expiredSeconds);
String userData = cacheClient.hget(tokenDoctorId, "id");
if (StringUtils.isEmpty(userData)) {
Map<String, String> map = new HashMap<>();
//重新登录后token没有更新
map.put("token", newToken);
map.put("id", account.getId() + "");
map.put("acctId", account.getAcctId() + "");
......@@ -77,6 +88,9 @@ public class TokenUtils {
//存储token:(token-doctor-1:用户数据)
cacheClient.hset(tokenDoctorId, key, valueInfo);
}
} else {
//每次登录成功,手动更新token
cacheClient.hset(tokenDoctorId, "token", newToken);
}
return newToken;
}
......
......@@ -36,6 +36,9 @@ weChatURL=https://api.weixin.qq.com/sns/userinfo?
#是否开启双写模式,是否需要向p_doctor表写数据
doubleWritingMode=true
#rabbitmq settings
spring.rabbitmq.host=192.168.110.206
spring.rabbitmq.port=5672
spring.rabbitmq.username=appuser
spring.rabbitmq.password=AqLfvyWOvLQEUzdI
spring.rabbitmq.virtual-host=account-register-vhost
\ No newline at end of file
......@@ -7,6 +7,7 @@
<result column="sex" jdbcType="INTEGER" property="sex" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="mobile_phone" jdbcType="VARCHAR" property="mobilePhone" />
<result column="acct_id" jdbcType="INTEGER" property="acctId" />
<result column="status" jdbcType="INTEGER" property="status" />
<result column="avatar_image_url" jdbcType="VARCHAR" property="avatarImageUrl" />
<result column="email" jdbcType="VARCHAR" property="email" />
......@@ -140,6 +141,9 @@
<if test="avatarImageUrl != null">
#{avatarImageUrl,jdbcType=VARCHAR},
</if>
<if test="acctId != null">
#{acctId,jdbcType=INTEGER},
</if>
<if test="email != null">
#{email,jdbcType=VARCHAR},
</if>
......
......@@ -47,7 +47,7 @@
<result column="gaoxueya_password" property="gaoxueyaPassword" jdbcType="VARCHAR"/>
<result column="sms_send_num" property="smsSendNum" jdbcType="INTEGER"/>
<result column="total_sms_send_num" property="totalSmsSendNum" jdbcType="INTEGER"/>
<result column="entire_flag" property="entireFlag" jdbcType="BIT"/>
<result column="entire_flag" property="entireFlag" jdbcType="INTEGER"/>
<result column="doctor_project_type" property="doctorProjectType" jdbcType="INTEGER"/>
<result column="reg_time" property="regTime" jdbcType="DATE"/>
<result column="last_login_time" property="lastLoginTime" jdbcType="TIMESTAMP"/>
......@@ -74,6 +74,21 @@
administer_title, register_type, first_login_time, card, birthday, show_flag, acct_id
</sql>
<!--通过账户id查询用户信息-->
<select id="selectUserIdByAcctId" parameterType="java.lang.Integer" resultType="java.lang.Long">
SELECT id
FROM p_doctor
where acct_id = #{acctId}
and delete_flag = 1
</select>
<!--通过手机号码查询医生信息-->
<select id="getDoctorInfoByMobile" parameterType="java.lang.String" resultMap="BaseResultMap">
SELECT <include refid="Base_Column_List"/>
FROM p_doctor
where mobile_phone = #{phone}
and delete_flag = 1
</select>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer">
select
......@@ -83,44 +98,36 @@
</select>
<!--根据手机号获取数据-->
<select id="getDoctorInfoByMobile" resultType="com.pica.cloud.account.account.server.entity.DoctorEntity"
parameterType="java.lang.String">
SELECT aa.id, aa.sex, aa.unionid, aa.name, aa.mobile_phone, aa.status, aa.type, aa.hospital_id, aa.department_id,
aa.title_id, ifnull(bb.name,aa.hospital) as hospital,
ifnull(pde.name,aa.department) as department, ifnull(pt.name,aa.title) as title, aa.cert_image_url,
aa.avatar_image_url, aa.auth_time, aa.invite_start_time, aa.honor, aa.skills, aa.thumb_up_num, aa.email,
aa.qrcode, aa.nickname, aa.personal_sign, aa.delete_flag, aa.creat_id, aa.creat_time, aa.modify_id,
aa.modify_time, aa.praise_num, aa.password, aa.info, aa.rank, aa.province, aa.city, aa.county,
aa.province_name, aa.city_name, aa.county_name,
aa.invite_code, aa.gaoxueya_password, aa.sms_send_num, aa.total_sms_send_num, aa.entire_flag, aa.doctor_project_type,
aa.administer_title_id, aa.administer_title,
pded.school_name, pded.major_id, pded.major_name, pded.education_id, pded.education_name, pded.year
FROM
p_doctor aa
left join
p_hospital bb
on aa.hospital_id = bb.id and bb.delete_flag=1
left join
p_title pt
on aa.title_id = pt.title_id
left join
p_department pde
on aa.department_id = pde.id
left join
p_doctor_education pded
on pded.doctor_id = aa.id
where aa.mobile_phone = #{mobile}
and aa.delete_flag = 1
limit 0,1
</select>
<!--通过账户id查询用户信息-->
<select id="selectUserIdByAcctId" parameterType="java.lang.Integer">
SELECT id
FROM p_doctor
where acct_id = #{acctId}
and delete_flag = 1
</select>
<!--<select id="getDoctorInfoByMobile" resultType="com.pica.cloud.account.account.server.entity.DoctorEntity"-->
<!--parameterType="java.lang.String">-->
<!--SELECT aa.id, aa.sex, aa.unionid, aa.name, aa.mobile_phone, aa.status, aa.type, aa.hospital_id, aa.department_id,-->
<!--aa.title_id, ifnull(bb.name,aa.hospital) as hospital,-->
<!--ifnull(pde.name,aa.department) as department, ifnull(pt.name,aa.title) as title, aa.cert_image_url,-->
<!--aa.avatar_image_url, aa.auth_time, aa.invite_start_time, aa.honor, aa.skills, aa.thumb_up_num, aa.email,-->
<!--aa.qrcode, aa.nickname, aa.personal_sign, aa.delete_flag, aa.creat_id, aa.creat_time, aa.modify_id,-->
<!--aa.modify_time, aa.praise_num, aa.password, aa.info, aa.rank, aa.province, aa.city, aa.county,-->
<!--aa.province_name, aa.city_name, aa.county_name,-->
<!--aa.invite_code, aa.gaoxueya_password, aa.sms_send_num, aa.total_sms_send_num, aa.entire_flag, aa.doctor_project_type,-->
<!--aa.administer_title_id, aa.administer_title,-->
<!--pded.school_name, pded.major_id, pded.major_name, pded.education_id, pded.education_name, pded.year-->
<!--FROM-->
<!--p_doctor aa-->
<!--left join-->
<!--p_hospital bb-->
<!--on aa.hospital_id = bb.id and bb.delete_flag=1-->
<!--left join-->
<!--p_title pt-->
<!--on aa.title_id = pt.title_id-->
<!--left join-->
<!--p_department pde-->
<!--on aa.department_id = pde.id-->
<!--left join-->
<!--p_doctor_education pded-->
<!--on pded.doctor_id = aa.id-->
<!--where aa.mobile_phone = #{mobile}-->
<!--and aa.delete_flag = 1-->
<!--limit 0,1-->
<!--</select>-->
<!--通过账户id更新用户信息-->
<update id="updateByAcctId" parameterType="com.pica.cloud.account.account.server.entity.Doctor">
......@@ -259,7 +266,7 @@
total_sms_send_num = #{totalSmsSendNum,jdbcType=INTEGER},
</if>
<if test="entireFlag != null">
entire_flag = #{entireFlag,jdbcType=BIT},
entire_flag = #{entireFlag,jdbcType=INTEGER},
</if>
<if test="doctorProjectType != null">
doctor_project_type = #{doctorProjectType,jdbcType=INTEGER},
......@@ -862,7 +869,7 @@
total_sms_send_num = #{totalSmsSendNum,jdbcType=INTEGER},
</if>
<if test="entireFlag != null">
entire_flag = #{entireFlag,jdbcType=BIT},
entire_flag = #{entireFlag,jdbcType=INTEGER},
</if>
<if test="doctorProjectType != null">
doctor_project_type = #{doctorProjectType,jdbcType=INTEGER},
......@@ -958,7 +965,7 @@
gaoxueya_password = #{gaoxueyaPassword,jdbcType=VARCHAR},
sms_send_num = #{smsSendNum,jdbcType=INTEGER},
total_sms_send_num = #{totalSmsSendNum,jdbcType=INTEGER},
entire_flag = #{entireFlag,jdbcType=BIT},
entire_flag = #{entireFlag,jdbcType=INTEGER},
doctor_project_type = #{doctorProjectType,jdbcType=INTEGER},
reg_time = #{regTime,jdbcType=DATE},
last_login_time = #{lastLoginTime,jdbcType=TIMESTAMP},
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册