提交 a53d1252 编写于 作者: zhehao.chen's avatar zhehao.chen

Merge branch 'release' into 'master'

Release

See merge request !82
流水线 #39645 已失败 于阶段
......@@ -11,7 +11,7 @@
<groupId>com.pica.cloud.account</groupId>
<artifactId>pica-cloud-account-client</artifactId>
<version>1.0.5.3</version>
<version>1.0.6</version>
<name>pica-cloud-account-client</name>
<packaging>jar</packaging>
......
......@@ -40,5 +40,8 @@ public interface AccountInfoClient {
@GetMapping(value = "/account/info/doctor/union")
PicaResponse<DoctorUnionResp> getDoctorByUnionid( @RequestParam(value = "unionid") String unionid);
@GetMapping(value = "/account/info/doctor/openid")
PicaResponse<Integer> getDoctorByOpenid( @RequestParam(value = "openid") String openid);
}
......@@ -80,4 +80,13 @@ public class AccountInfoController extends AccountBaseController {
DoctorUnionResp personalInfoDto = wechatService.getDoctorByUnionid(unionid);
return PicaResponse.toResponse(personalInfoDto);
}
@ApiOperation(value = "根据openid查看医生id")
@GetMapping(value = "/doctor/openid", produces = "application/json;charset=UTF-8")
public PicaResponse<Integer> getDoctorByOpenid(@RequestParam(value = "openid") String openid) {
Integer doctorId = wechatService.getDoctorByOpenid(openid);
return PicaResponse.toResponse(doctorId);
}
}
......@@ -2,13 +2,13 @@ package com.pica.cloud.account.account.server.controller;
import com.pica.cloud.account.account.server.service.TokenService;
import com.pica.cloud.foundation.entity.PicaResponse;
import com.pica.cloud.foundation.utils.entity.PicaAdmin;
import com.pica.cloud.foundation.utils.entity.PicaUser;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import java.util.Map;
......@@ -42,6 +42,10 @@ public class TokenController extends AccountBaseController {
return PicaResponse.toResponse();
}
@ApiIgnore
@GetMapping(value = "/token/remove")
public PicaResponse removeToken(@RequestParam("timestamp") Long timestamp) {
tokenService.removeToken(timestamp);
return PicaResponse.toResponse();
}
}
......@@ -15,6 +15,8 @@ public interface AccountWeChatInfoMapper {
*/
AccountWeChatInfoEntity selectByUnionId(String id);
AccountWeChatInfoEntity selectByOpenId(String openId);
int deleteByPrimaryKey(Integer id);
int insert(AccountWeChatInfoEntity record);
......
......@@ -8,6 +8,7 @@ import com.pica.cloud.account.account.server.model.WechatInfoDto;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
......@@ -122,4 +123,9 @@ public interface DoctorMapper {
DoctorUnionResp getDoctorByAcctId(Long acctId);
List<Integer> selectIdByParams(@Param("fromId") Integer fromId,
@Param("toId") Integer toId,
@Param("loginTime") Date loginTime);
String selectIdByOpenId(String openId);
}
\ No newline at end of file
......@@ -13,4 +13,6 @@ public interface TokenService {
void tokenContinueTime(String token, Integer sourceType, Integer seconds);
/** 删除token */
void removeToken(Long timestamp);
}
......@@ -18,4 +18,6 @@ public interface WechatService {
DoctorUnionResp getDoctorByUnionid(String unionid);
Integer getDoctorByOpenid(String openId);
}
......@@ -183,7 +183,7 @@ public class DoctorServiceImpl implements DoctorService {
doctor.setModifyId(doctorId.intValue());
doctor.setCreatId(doctorId.intValue());
doctor.setCreatTime(currentTime);
doctor.setModifyTime(new Date());
doctor.setModifyTime(currentTime);
doctor.setRegisterSource(AccountTypeEnum.DEVICE_TYPE_ADMIN.getCode());
doctor.setDeleteFlag(1);
doctorMapper.insertSelective(doctor);
......
......@@ -1097,7 +1097,7 @@ public class LoginServiceImpl implements LoginService {
tokenUtils.tokenContinueTime(loginUser.getToken(), oldUser.getLoginFrom(), 0);
//记录登录日志
LogLoginEntity entity = AccountLogEntityUtils.getLogLoginEntity(
Integer.valueOf(String.valueOf(loginUser.getAcctId())),
loginUser.getAcctId(),
oldUser.getLoginPlatform(), oldUser.getLoginFrom(),
AccountTypeEnum.LOGIN_WE_CHAT.getCode(),
oldUser.getLoginIp(),
......
package com.pica.cloud.account.account.server.service.impl;
import com.pica.cloud.account.account.server.constants.Constants;
import com.pica.cloud.account.account.server.mapper.DoctorMapper;
import com.pica.cloud.account.account.server.service.TokenService;
import com.pica.cloud.account.account.server.util.TokenUtils;
import com.pica.cloud.foundation.redis.ICacheClient;
import com.pica.cloud.foundation.utils.entity.PicaUser;
import com.pica.cloud.foundation.utils.utils.CommonUtil;
import com.pica.cloud.foundation.utils.utils.date.D;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -16,6 +18,7 @@ import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.UUID;
......@@ -40,6 +43,9 @@ public class TokenServiceImpl implements TokenService {
@Qualifier("accountThreadPool")
private ThreadPoolTaskExecutor threadPoolTaskExecutor;
@Autowired
private DoctorMapper doctorMapper;
@Override
public String getToken(Map<String, Object> headersMap) {
String mobile = new StringBuilder("9").append(CommonUtil.getRandom(10)).toString();
......@@ -90,4 +96,40 @@ public class TokenServiceImpl implements TokenService {
return;
}
@Override
public void removeToken(Long timestamp) {
//new Thread(() -> {
try {
Date lastLoginTime = new Date(timestamp);
for (Integer fromDoctorId = 0; fromDoctorId < 1000412091; fromDoctorId += 10000) {
logger.info("start remove token: {}", fromDoctorId);
List<Integer> doctorIdList = doctorMapper.selectIdByParams(fromDoctorId, fromDoctorId + 10000, lastLoginTime);
if (CollectionUtils.isEmpty(doctorIdList)) {
Thread.sleep(2000);
continue;
}
removeTokenByDoctorIdList(doctorIdList);
logger.info("remove token done: {} {}", fromDoctorId, doctorIdList.size());
}
} catch (Exception ex) {
// ingnore
}
//});
}
private void removeTokenByDoctorIdList(List<Integer> doctorIdList) throws Exception {
for (Integer doctorId : doctorIdList) {
String key1 = String.format("token-doctor-%d-app", doctorId);
String key2 = String.format("token-doctor-%d", doctorId);
String key3 = redisClient.get(key1);
redisClient.del(key1);
redisClient.del(key2);
if (!StringUtils.isEmpty(key3)) {
redisClient.del(key3);
}
Thread.sleep(10);
}
}
}
......@@ -98,4 +98,21 @@ public class WechatServiceImpl implements WechatService {
}
return doctorUnionfoModel;
}
@Override
public Integer getDoctorByOpenid(String openId) {
AccountWeChatInfoEntity entity = weChatInfoMapper.selectByOpenId(openId);
String unionId = "";
if (StringUtil.isNotNull(entity)) {
unionId = entity.getUnionid();
} else {
unionId = doctorMapper.selectIdByOpenId(openId);
}
DoctorUnionResp doctorUnionfoModel = getDoctorByUnionid(unionId);
if (StringUtil.isNotNull(doctorUnionfoModel)) {
return doctorUnionfoModel.getDoctorId();
}
return null;
}
}
......@@ -48,6 +48,14 @@
limit 1
</select>
<select id="selectByOpenId" resultMap="BaseResultMap" parameterType="java.lang.String">
select
<include refid="Base_Column_List"/>
from account_wechat_info
where openid = #{openId} and delete_flag = 1
limit 1
</select>
<select id="selectBatchByUnionId" resultMap="BaseResultMap" parameterType="java.util.List">
select
<include refid="Base_Column_List"/>
......
......@@ -1093,4 +1093,16 @@
where d.acct_id = #{acctId} and d.delete_flag = 1
</select>
<select id="selectIdByParams" parameterType="java.util.Map" resultType="java.lang.Integer">
select id from p_doctor
where id &gt;= #{fromId}
and id &lt;= #{toId}
and last_login_time &lt;= #{loginTime}
</select>
<select id="selectIdByOpenId" parameterType="java.lang.String" resultType="java.lang.String">
select unionid from p_wechat_doctor
where openid = #{openId} and delete_flag = 1
limit 1
</select>
</mapper>
\ No newline at end of file
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册