提交 27767e0d 编写于 作者: dong.an's avatar dong.an

merge

流水线 #15828 已失败 于阶段
in 0 second
package com.pica.cloud.account.account.server.controller;
import com.pica.cloud.account.account.server.entity.Account;
import com.pica.cloud.account.account.server.entity.EncryptEntity;
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.req.BaseRequest;
import com.pica.cloud.account.account.server.service.AccountService;
import com.pica.cloud.account.account.server.service.CaptchaService;
import com.pica.cloud.account.account.server.util.CryptoUtil;
import com.pica.cloud.foundation.encryption.common.constants.EncryptConstants;
import com.pica.cloud.foundation.encryption.util.EncryptUtils;
import com.pica.cloud.foundation.entity.PicaException;
......@@ -25,12 +28,14 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.*;
import java.util.Date;
import java.util.Map;
import java.util.UUID;
/**
* 账号相关controller
*
* @author andong
* @create 2019/5/20
*/
......@@ -43,38 +48,17 @@ public class AccountController extends AccountBaseController {
private Logger logger = LoggerFactory.getLogger(AccountController.class);
@Autowired
private AccountService accountService;
@Autowired
private CaptchaService captchaService;
@Autowired
@Qualifier("cacheMigrateClient")
private ICacheClient redisClient;
@GetMapping("/test")
public String test() {return "test";}
@ApiOperation("获取登录验证码")
@GetMapping("/authCode")
public PicaResponse<String> getAuthCode(@ApiParam(value = "手机号", required = true) @RequestParam("mobilePhone") String mobilePhone,
@ApiParam(value = "验证码类型 0默认 1注册 2修改密码 4微信登录绑定手机 5修改手机 6重置密码") @RequestParam(value = "flag", defaultValue = "0") String flag,
@ApiParam(value = "图形验证码token", required = true) @RequestParam("captchaToken") String captchaToken,
@ApiParam(value = "图形验证码答案", required = true) @RequestParam("captchaAnswer") String captchaAnswer) {
//校验图形验证码
if (!captchaService.acknowledge(captchaToken, captchaAnswer)) {
return PicaResponse.toResponse(null, PicaResultCode.PARAM_IS_INVALID.code(), "图形验证码错误");
}
this.checkMobilePhone(mobilePhone);
String authCode = CommonUtil.createValidateCode(); //随机生成验证码
String message = "您的验证码是" + authCode + ",在10分钟内有效。如非本人操作,请忽略本短信!";
//判断账号是否已经存在
Account account = accountService.getByMobilePhone(mobilePhone);
long senderId = account == null ? 0L : account.getId();
//验证码保存到redis,失效时间10分钟
redisClient.set(this.getAuthCodeKey(mobilePhone, flag), authCode, 600);
//发送短信
super.sendMobileMessage(mobilePhone, message, senderId);
return PicaResponse.toResponse(StringUtils.EMPTY);
public String test() {
return "test";
}
@ApiOperation("微信登录")
@PostMapping("/login/wechat")
public PicaResponse<String> wechatLogin(@RequestBody AccountReq req) {
......@@ -93,8 +77,8 @@ public class AccountController extends AccountBaseController {
return PicaResponse.toResponse(newToken);
}
@ApiOperation("密码或验证码登录")
@PostMapping("/login")
// @ApiOperation("密码或验证码登录")
// @PostMapping("/login")
public PicaResponse<String> login(@RequestBody AccountReq req) {
this.checkMobilePhone(req.getMobilePhone());
Account account = accountService.getByMobilePhone(req.getMobilePhone()); //获取账号信息
......@@ -128,8 +112,8 @@ public class AccountController extends AccountBaseController {
return PicaResponse.toResponse(newToken);
}
@ApiOperation("注册")
@PostMapping("/register")
// @ApiOperation("注册")
// @PostMapping("/register")
public PicaResponse<String> register(@RequestBody AccountReq req) {
this.checkMobilePhone(req.getMobilePhone());
this.checkAuthCode(req);
......@@ -157,7 +141,7 @@ public class AccountController extends AccountBaseController {
return PicaResponse.toResponse(newToken);
}
@ApiOperation("登录或注册")
@ApiOperation("H5端一键登录功能,无需完善信息")
@PostMapping("/login-register")
public PicaResponse<String> loginRegister(@RequestBody AccountReq req) {
this.checkMobilePhone(req.getMobilePhone());
......@@ -214,7 +198,7 @@ public class AccountController extends AccountBaseController {
redisClient.del(oldToken);
}
//生成新token
int expiredSeconds = 30*24*60*60; //H5 token有效期30天
int expiredSeconds = 30 * 24 * 60 * 60; //H5 token有效期30天
newToken = UUID.randomUUID().toString().replace("-", "").toUpperCase();
String tokenKey = "token-" + newToken;
redisClient.set(tokenKey, tokenValue, expiredSeconds);
......@@ -226,11 +210,14 @@ public class AccountController extends AccountBaseController {
picaUser.setToken(newToken);
picaUser.setId(account.getId().intValue());
picaUser.setMobile(account.getMobilePhone());
picaUser.setName(EncryptUtils.decryptContent(account.getMobilePhone(), EncryptConstants.ENCRYPT_TYPE_MOBILE, EncryptConstants.ENCRYPT_DECRYPT_KEY).replaceAll("(\\d{3})\\d{4}(\\w{4})","$1****$2"));
picaUser.setName(EncryptUtils.decryptContent(account.getMobilePhone(), EncryptConstants.ENCRYPT_TYPE_MOBILE, EncryptConstants.ENCRYPT_DECRYPT_KEY).replaceAll("(\\d{3})\\d{4}(\\w{4})", "$1****$2"));
picaUser.setCreated_time(account.getCreatTime());
Map<String, String> data = Object2Map.objectToMapString("yyyy-MM-dd HH:mm:ss", picaUser, new String[0]);
data.put("sysCode", "h5");
data.forEach((key, value) -> {value = value == null ? "" : value; redisClient.hset(tokenValue, key, value);});
data.forEach((key, value) -> {
value = value == null ? "" : value;
redisClient.hset(tokenValue, key, value);
});
}
} catch (Exception ex) {
logger.error("生成H5 token异常:{}" + ex.getMessage(), ex);
......
package com.pica.cloud.account.account.server.controller;
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.entity.AccountUnionEntity;
import com.pica.cloud.account.account.server.entity.EncryptEntity;
......@@ -8,15 +9,21 @@ import com.pica.cloud.account.account.server.enums.AccountTypeEnum;
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.req.BaseRequest;
import com.pica.cloud.account.account.server.service.AccountService;
import com.pica.cloud.account.account.server.service.AccountUnionService;
import com.pica.cloud.account.account.server.service.CaptchaService;
import com.pica.cloud.account.account.server.util.AESUtil;
import com.pica.cloud.account.account.server.util.AccountUtils;
import com.pica.cloud.account.account.server.util.CryptoUtil;
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.redis.ICacheClient;
import com.pica.cloud.foundation.utils.utils.CommonUtil;
import com.pica.cloud.foundation.utils.utils.ValidateUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.PostMapping;
......@@ -26,8 +33,7 @@ import org.springframework.web.bind.annotation.RestController;
@Api(description = "短信验证码资源")
@RestController
@RequestMapping(value = "/authCode")
public class SysCodeController extends AccountBaseController {
public class AutoCodeController extends AccountBaseController {
private final String AUTH_CODE_PREFIX = "authCode-";
......@@ -37,19 +43,19 @@ public class SysCodeController extends AccountBaseController {
@Autowired
private AccountUnionService accountUnionService;
@Autowired
private CaptchaService captchaService;
@Autowired
private AccountService accountService;
@Autowired
@Qualifier("cacheMigrateClient")
private ICacheClient cacheClient;
/**
* 必须要传递flag类型
*
* @param entity
* @return
* @throws Exception
*/
@ApiOperation("获取短信验证码")
@PostMapping(value = "")
@ApiOperation("获取短信验证码,无需图形验证码,如app端")
@PostMapping(value = "/authCode")
public PicaResponse getAuthCode(@RequestBody EncryptEntity entity) throws Exception {
BaseRequest request = CryptoUtil.decrypt(entity, BaseRequest.class);
AccountUtils.checkMobilePhone(request.getMobile());
......@@ -57,6 +63,31 @@ public class SysCodeController extends AccountBaseController {
return PicaResponse.toResponse();
}
@ApiOperation("获取短信验证码,需要图形验证码,如H5端和PC端;验证码类型 0默认 1注册 2微信登录绑定手机 3修改手机 4重置密码 5忘记密码 7患者招募提交问卷(效验)")
@PostMapping("/account/authCode")
public PicaResponse<String> getAuthCodeWithCaptcha(@RequestBody EncryptEntity entity) throws Exception {
BaseRequest request = CryptoUtil.decrypt(entity, BaseRequest.class);
String mobilePhone = request.getMobile();
String flag = request.getFlag() + "";
String captchaToken = request.getCaptchaToken();
String captchaAnswer = request.getCaptchaAnswer();
//校验图形验证码
if (!captchaService.acknowledge(captchaToken, captchaAnswer)) {
return PicaResponse.toResponse(null, PicaResultCode.PARAM_IS_INVALID.code(), "图形验证码错误");
}
this.checkMobilePhone(mobilePhone);
String authCode = CommonUtil.createValidateCode(); //随机生成验证码
String message = "您的验证码是" + authCode + ",在10分钟内有效。如非本人操作,请忽略本短信!";
//判断账号是否已经存在
Account account = accountService.getByMobilePhone(mobilePhone);
long senderId = account == null ? 0L : account.getId();
//验证码保存到redis,失效时间10分钟
cacheClient.set(this.getAuthCodeKey(mobilePhone, flag), authCode, 600);
//发送短信
super.sendMobileMessage(mobilePhone, message, senderId);
return PicaResponse.toResponse(StringUtils.EMPTY);
}
@ApiOperation("微信获取验证码")
@PostMapping(value = "/authCode/wechat")
public PicaResponse getWChatSysCode(@RequestBody EncryptEntity entity) throws Exception {
......@@ -88,14 +119,15 @@ public class SysCodeController extends AccountBaseController {
if (cacheClient.exists(authCodeKey)) {
Long time = cacheClient.get(this.getAuthCodeKey(mobilePhone, flag.toString()) + "-secure", Long.class);
if (time == null) {
time = 0L;
}
int remainTime = 59 - (int) (System.currentTimeMillis() - time) / 1000;
if (remainTime > 0) {
throw new AccountException(AccountExceptionEnum.PICA_SYSCODE_RETRY.getCode(),
AccountExceptionEnum.PICA_SYSCODE_RETRY.getMessage().replace("X", String.valueOf(remainTime)));
} else {
processSendAuthCode(mobilePhone, flag, authCodeKeySecure);
} else {
int remainTime = 59 - (int) (System.currentTimeMillis() - time) / 1000;
if (remainTime > 0) {
throw new AccountException(AccountExceptionEnum.PICA_SYSCODE_RETRY.getCode(),
AccountExceptionEnum.PICA_SYSCODE_RETRY.getMessage().replace("X", String.valueOf(remainTime)));
} else {
processSendAuthCode(mobilePhone, flag, authCodeKeySecure);
}
}
} else {
processSendAuthCode(mobilePhone, flag, authCodeKeySecure);
......@@ -123,4 +155,11 @@ public class SysCodeController extends AccountBaseController {
private String getAuthCodeKey(String mobilePhone, String flag) {
return AUTH_CODE_PREFIX + flag + "-" + AESUtil.encryptV0(mobilePhone);
}
//手机格式校验
private void checkMobilePhone(String mobilePhone) {
if (StringUtils.isBlank(mobilePhone) || !ValidateUtils.isMobile(mobilePhone)) {
throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "请输入正确的手机号");
}
}
}
......@@ -3,6 +3,7 @@ package com.pica.cloud.account.account.server.controller;
import com.pica.cloud.account.account.server.entity.EncryptEntity;
import com.pica.cloud.account.account.server.entity.LogLoginEntity;
import com.pica.cloud.account.account.server.entity.LoginResult;
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.exception.AccountException;
......@@ -53,15 +54,15 @@ public class LoginController extends AccountBaseController {
*/
@ApiOperation("密码登录接口")
@PostMapping("/login")
public PicaResponse<String> loginByPassword(@RequestBody EncryptEntity entity) throws Exception {
public PicaResponse<LoginResult> loginByPassword(@RequestBody EncryptEntity entity) throws Exception {
BaseRequest request = CryptoUtil.decrypt(entity, BaseRequest.class);
request.setProductType(super.getProductType());
request.setSourceType(super.getSourceType());
request.setLoginIp(super.getIpAddr());
AccountUtils.checkMobilePhone(request.getMobile());
AccountUtils.checkPassword(request.getPassword());
String result = loginService.login(request);
return PicaResponse.toResponse(result);
LoginResult login = loginService.login(request);
return PicaResponse.toResponse(login);
}
/**
......@@ -71,38 +72,38 @@ public class LoginController extends AccountBaseController {
* @return
* @throws Exception
*/
@ApiOperation("一键登录接口")
@ApiOperation("PC,App端一键登录接口,需要完善信息")
@PostMapping(value = "/login-register")
public PicaResponse loginAndRegister(@RequestBody EncryptEntity entity) throws Exception {
public PicaResponse<LoginResult> loginAndRegister(@RequestBody EncryptEntity entity) throws Exception {
BaseRequest request = CryptoUtil.decrypt(entity, BaseRequest.class);
accountUtils.checkMobilePhoneAndAuthCode(request.getMobile(), AccountTypeEnum.SYSCODE_TYPE_LOGIN.getCode() + "",request.getAuthCode());
request.setProductType(super.getProductType());
request.setSourceType(super.getSourceType());
request.setLoginIp(super.getIpAddr());
String json = loginService.loginAndRegister(request);
return PicaResponse.toResponse(json);
LoginResult login =loginService.loginAndRegister(request);
return PicaResponse.toResponse(login);
}
@ApiOperation("微信登录接口")
@PostMapping(value = "/login/wechat")
public PicaResponse loginByWeChat(@RequestBody EncryptEntity entity) throws Exception {
public PicaResponse<LoginResult> loginByWeChat(@RequestBody EncryptEntity entity) throws Exception {
BaseRequest request = CryptoUtil.decrypt(entity, BaseRequest.class);
request.setProductType(super.getProductType());
request.setSourceType(super.getSourceType());
request.setLoginIp(super.getIpAddr());
String result = loginService.loginByWeChat(request);
LoginResult result = loginService.loginByWeChat(request);
return PicaResponse.toResponse(result);
}
@ApiOperation("微信登录第二步接口")
@PostMapping(value = "/login/wechat/step2")
public PicaResponse loginByWeChatStep(@RequestBody EncryptEntity entity) throws Exception {
public PicaResponse<LoginResult> loginByWeChatStep(@RequestBody EncryptEntity entity) throws Exception {
BaseRequest request = CryptoUtil.decrypt(entity, BaseRequest.class);
accountUtils.checkMobilePhoneAndAuthCode(request.getMobile(), AccountTypeEnum.SYSCODE_TYPE_WE_CHAT.getCode() + "", request.getAuthCode());
request.setProductType(super.getProductType());
request.setSourceType(super.getSourceType());
request.setLoginIp(super.getIpAddr());
String result = loginService.loginByWeChatStep(request);
LoginResult result = loginService.loginByWeChatStep(request);
return PicaResponse.toResponse(result);
}
......@@ -115,7 +116,7 @@ public class LoginController extends AccountBaseController {
*/
@ApiOperation("绑定微信接口")
@PostMapping("/login/wechat/bind")
public PicaResponse<String> bindWeChat(@RequestBody EncryptEntity entity) throws Exception {
public PicaResponse bindWeChat(@RequestBody EncryptEntity entity) throws Exception {
BaseRequest request = CryptoUtil.decrypt(entity, BaseRequest.class);
request.setAccId(super.getAcctId());
loginService.bindWeChat(request);
......@@ -138,7 +139,7 @@ public class LoginController extends AccountBaseController {
*/
@ApiOperation(value = "退出登录接口")
@GetMapping("/logout")
public PicaResponse loginOut() {
public PicaResponse<String> loginOut() {
String token = super.getToken();
if (StringUtils.isNotEmpty(token)) {
Integer acctId = super.getAcctId();
......
package com.pica.cloud.account.account.server.controller;
import com.pica.cloud.account.account.server.entity.EncryptEntity;
import com.pica.cloud.account.account.server.entity.LoginResult;
import com.pica.cloud.account.account.server.enums.AccountTypeEnum;
import com.pica.cloud.account.account.server.req.BaseRequest;
import com.pica.cloud.account.account.server.service.RegisterService;
......@@ -26,9 +27,9 @@ public class RegisterController extends AccountBaseController {
@Autowired
private AccountUtils accountUtils;
@ApiOperation("注册接口")
@ApiOperation("PC端,移动端注册接口")
@PostMapping(value = "")
public PicaResponse<String> register(@RequestBody EncryptEntity entity) throws Exception {
public PicaResponse<LoginResult> register(@RequestBody EncryptEntity entity) throws Exception {
BaseRequest request = CryptoUtil.decrypt(entity, BaseRequest.class);
accountUtils.checkMobilePhoneAndAuthCode(request.getMobile(),AccountTypeEnum.SYSCODE_TYPE_REGISTER.getCode()+"", request.getAuthCode());
accountUtils.checkPassword(request.getPassword());
......@@ -36,7 +37,7 @@ public class RegisterController extends AccountBaseController {
request.setProductType(super.getProductType());
request.setSourceType(super.getSourceType());
request.setLoginIp(super.getIpAddr());
String result = registerService.register(request);
LoginResult result = registerService.register(request);
return PicaResponse.toResponse(result);
}
}
package com.pica.cloud.account.account.server.entity;
import java.util.Date;
public class AgreementEntity {
private Long id;
private Integer agreement_type;
private String version;
private String agreement_content;
private Integer delete_flag;
private Long created_id;
private Date created_time;
private Long modified_id;
private Date modified_time;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Integer getAgreement_type() {
return agreement_type;
}
public void setAgreement_type(Integer agreement_type) {
this.agreement_type = agreement_type;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version == null ? null : version.trim();
}
public Integer getDelete_flag() {
return delete_flag;
}
public void setDelete_flag(Integer delete_flag) {
this.delete_flag = delete_flag;
}
public Long getCreated_id() {
return created_id;
}
public void setCreated_id(Long created_id) {
this.created_id = created_id;
}
public Date getCreated_time() {
return created_time;
}
public void setCreated_time(Date created_time) {
this.created_time = created_time;
}
public Long getModified_id() {
return modified_id;
}
public void setModified_id(Long modified_id) {
this.modified_id = modified_id;
}
public Date getModified_time() {
return modified_time;
}
public void setModified_time(Date modified_time) {
this.modified_time = modified_time;
}
public String getAgreement_content() {
return agreement_content;
}
public void setAgreement_content(String agreement_content) {
this.agreement_content = agreement_content == null ? null : agreement_content.trim();
}
}
\ No newline at end of file
package com.pica.cloud.account.account.server.entity;
import java.util.Date;
public class AgreementLogEntity {
private Long id;
private Long doctor_id;
private Integer agreement_type;
private String version;
private Integer delete_flag;
private Long created_id;
private Date created_time;
private Long modified_id;
private Date modified_time;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getDoctor_id() {
return doctor_id;
}
public void setDoctor_id(Long doctor_id) {
this.doctor_id = doctor_id;
}
public Integer getAgreement_type() {
return agreement_type;
}
public void setAgreement_type(Integer agreement_type) {
this.agreement_type = agreement_type;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version == null ? null : version.trim();
}
public Integer getDelete_flag() {
return delete_flag;
}
public void setDelete_flag(Integer delete_flag) {
this.delete_flag = delete_flag;
}
public Long getCreated_id() {
return created_id;
}
public void setCreated_id(Long created_id) {
this.created_id = created_id;
}
public Date getCreated_time() {
return created_time;
}
public void setCreated_time(Date created_time) {
this.created_time = created_time;
}
public Long getModified_id() {
return modified_id;
}
public void setModified_id(Long modified_id) {
this.modified_id = modified_id;
}
public Date getModified_time() {
return modified_time;
}
public void setModified_time(Date modified_time) {
this.modified_time = modified_time;
}
}
\ No newline at end of file
package com.pica.cloud.account.account.server.entity;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* Created on 2019/10/9 17:41
* author:crs
* Description: 登录状态返回
*/
@ApiModel
@JsonInclude(JsonInclude.Include.NON_NULL)
public class LoginResult {
@ApiModelProperty("token")
private String token;
@ApiModelProperty("用户id")
private Long userId;
@ApiModelProperty("是否绑定")
private String bindFlag;
@ApiModelProperty("联合登录id")
private String unionId;
@ApiModelProperty("是否完善过信息,1.信息未补全, 2信息已补全,3已补全密码")
private int entireFlag;
public String getToken() {
return token;
}
public void setToken(String token) {
this.token = token;
}
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public String getBindFlag() {
return bindFlag;
}
public void setBindFlag(String bindFlag) {
this.bindFlag = bindFlag;
}
public String getUnionId() {
return unionId;
}
public void setUnionId(String unionId) {
this.unionId = unionId;
}
public int getEntireFlag() {
return entireFlag;
}
public void setEntireFlag(int entireFlag) {
this.entireFlag = entireFlag;
}
}
package com.pica.cloud.account.account.server.enums;
/**
* Created on 2019/10/11 19:08
* author:crs
* Description:账户协议类型
*/
public enum AccountAgreementEnum {
USER_AGREEMENT(1, "用户协议"),
PRIVACY_AGREEMENT(5, "隐私协议");
private int code;
private String desc;
AccountAgreementEnum(int code, String desc) {
this.code = code;
this.desc = desc;
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
}
package com.pica.cloud.account.account.server.log;
import com.pica.cloud.account.account.server.util.ExecutorServiceUtils;
import org.springframework.stereotype.Component;
import java.util.concurrent.ExecutorService;
......@@ -13,17 +14,12 @@ import java.util.concurrent.Executors;
@Component
public class AccountLogUtils {
/**
* 线程池
*/
ExecutorService executor = Executors.newFixedThreadPool(30);
/**
* 日志记录方法
*
* @param accountLogEntity
*/
public void info(AccountLogEntity accountLogEntity) {
executor.submit(new AccountLogTask(accountLogEntity));
ExecutorServiceUtils.getExecutor().submit(new AccountLogTask(accountLogEntity));
}
}
package com.pica.cloud.account.account.server.mapper;
import com.pica.cloud.account.account.server.entity.AgreementEntity;
public interface AgreementEntityMapper {
int deleteByPrimaryKey(Long id);
int insert(AgreementEntity record);
int insertSelective(AgreementEntity record);
AgreementEntity selectByPrimaryKey(Long id);
/**
* 根据协议类型查询协议
*
* @param agreementType
* @return
*/
Integer selectByType(int agreementType);
int updateByPrimaryKeySelective(AgreementEntity record);
int updateByPrimaryKeyWithBLOBs(AgreementEntity record);
int updateByPrimaryKey(AgreementEntity record);
}
\ No newline at end of file
package com.pica.cloud.account.account.server.mapper;
import com.pica.cloud.account.account.server.entity.AgreementLogEntity;
public interface AgreementLogEntityMapper {
int deleteByPrimaryKey(Long id);
int insert(AgreementLogEntity record);
int insertSelective(AgreementLogEntity record);
AgreementLogEntity selectByPrimaryKey(Long id);
int updateByPrimaryKeySelective(AgreementLogEntity record);
int updateByPrimaryKey(AgreementLogEntity record);
}
\ No newline at end of file
......@@ -30,7 +30,26 @@ public class BaseRequest {
private String weChatCode;
@ApiModelProperty("微信登录类型")
private Integer weChatLoginType;
@ApiModelProperty("图片验证码token")
private String captchaToken;
@ApiModelProperty("图片验证码答案")
private String captchaAnswer;
public String getCaptchaToken() {
return captchaToken;
}
public void setCaptchaToken(String captchaToken) {
this.captchaToken = captchaToken;
}
public String getCaptchaAnswer() {
return captchaAnswer;
}
public void setCaptchaAnswer(String captchaAnswer) {
this.captchaAnswer = captchaAnswer;
}
public Integer getAccId() {
return accId;
......
package com.pica.cloud.account.account.server.service;
import com.pica.cloud.account.account.server.entity.LoginResult;
import com.pica.cloud.account.account.server.req.BaseRequest;
public interface LoginService {
......@@ -9,7 +10,7 @@ public interface LoginService {
* @param request 参数模型
* @return
*/
String login(BaseRequest request);
LoginResult login(BaseRequest request);
/**
* 一键登录功能
......@@ -17,14 +18,14 @@ public interface LoginService {
* @param request 参数模型
* @return
*/
String loginAndRegister(BaseRequest request);
LoginResult loginAndRegister(BaseRequest request);
/**
* 微信登录
*
* @param baseRequest 参数模型
*/
String loginByWeChat(BaseRequest baseRequest);
LoginResult loginByWeChat(BaseRequest baseRequest);
/**
* 微信登陆第二步
......@@ -32,7 +33,7 @@ public interface LoginService {
* @param request 参数模型
* @return
*/
String loginByWeChatStep(BaseRequest request);
LoginResult loginByWeChatStep(BaseRequest request);
/**
* 解除绑定
......
package com.pica.cloud.account.account.server.service;
import com.pica.cloud.account.account.server.entity.LoginResult;
import com.pica.cloud.account.account.server.req.BaseRequest;
......@@ -11,7 +12,7 @@ public interface RegisterService {
* @param baseRequest 参数模型
* @return token和userId
*/
String register(BaseRequest baseRequest);
LoginResult register(BaseRequest baseRequest);
}
package com.pica.cloud.account.account.server.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.pica.cloud.account.account.server.constants.Constants;
import com.pica.cloud.account.account.server.entity.*;
import com.pica.cloud.account.account.server.enums.AccountExceptionEnum;
import com.pica.cloud.account.account.server.enums.AccountTypeEnum;
......@@ -81,7 +79,7 @@ public class LoginServiceImpl implements LoginService {
private String weChatURL;
@Override
public String login(BaseRequest request) {
public LoginResult login(BaseRequest request) {
String mobile = request.getMobile();
String encrypt = AESUtil.encryptV0(mobile);
AccountInfoEntity accountInfoEntity = accountInfoDetailMapper.selectByMobile(encrypt);
......@@ -108,17 +106,17 @@ public class LoginServiceImpl implements LoginService {
account.setMobilePhone(mobile);
account.setRegisterSource(sourceType);
String newToken = tokenUtils.generateToken(account);
JSONObject jsonObject = new JSONObject();
jsonObject.put(Constants.TOKEN, newToken);
jsonObject.put(Constants.USER_ID, userId);
LoginResult result = new LoginResult();
result.setToken(newToken);
result.setUserId(userId.longValue());
if (productType == AccountTypeEnum.PRODUCT_TYPE_DOCTOR.getCode()) {
jsonObject.put(Constants.USER_ENTIRE_FLAG, doctorInfo.getEntireFlag());
result.setEntireFlag(doctorInfo.getEntireFlag());
}
LogLoginEntity entity = AccountLogEntityUtils.getLogLoginEntity(acctId, productType, sourceType,
AccountTypeEnum.LOGIN_PWD.getCode(), request.getLoginIp(), AccountTypeEnum.LOGIN_STATUS_SUCCESS.getCode(),
AccountTypeEnum.LOG_TYPE_LOGIN.getCode());
picaLogUtils.info(entity);
return jsonObject.toJSONString();
return result;
} else {
logger.info("login failure:" + mobile);
throw new PicaException(AccountExceptionEnum.PICA_PASSWORD_ERROR.getCode(), AccountExceptionEnum.PICA_PASSWORD_ERROR.getMessage());
......@@ -129,7 +127,7 @@ public class LoginServiceImpl implements LoginService {
}
@Override
public String loginAndRegister(BaseRequest baseRequest) {
public LoginResult loginAndRegister(BaseRequest baseRequest) {
String mobile = baseRequest.getMobile();
AccountInfoEntity accountInfoEntity = accountInfoDetailMapper.selectByMobile(AESUtil.encryptV0(mobile));
if (accountInfoEntity == null) {
......@@ -144,7 +142,7 @@ public class LoginServiceImpl implements LoginService {
*
* @param baseRequest
*/
private String processLogin(BaseRequest baseRequest, Integer acctId, Integer loginType) {
private LoginResult processLogin(BaseRequest baseRequest, Integer acctId, Integer loginType) {
Date currentTime = new Date();
Long userId = accountUtils.getUserIdByAcctId(baseRequest.getProductType(), acctId);
Account account = new Account();
......@@ -154,24 +152,24 @@ public class LoginServiceImpl implements LoginService {
account.setMobilePhone(baseRequest.getMobile());
account.setRegisterSource(baseRequest.getSourceType());
String newToken = tokenUtils.generateToken(account);
JSONObject jsonObject = new JSONObject();
jsonObject.put(Constants.TOKEN, newToken);
jsonObject.put(Constants.USER_ID, userId);
LoginResult result = new LoginResult();
result.setToken(newToken);
result.setUserId(userId);
//是否完善过个人信息(云鹊医app才需要)
if (baseRequest.getProductType() == AccountTypeEnum.PRODUCT_TYPE_DOCTOR.getCode()) {
Doctor doctorEntity = doctorInfoMapper.selectByPrimaryKey(userId.intValue());
jsonObject.put(Constants.USER_ENTIRE_FLAG, doctorEntity.getEntireFlag());
result.setEntireFlag(doctorEntity.getEntireFlag());
}
//记录登录日志
LogLoginEntity entity = AccountLogEntityUtils.getLogLoginEntity(acctId, baseRequest.getProductType(), baseRequest.getSourceType(),
loginType, baseRequest.getLoginIp(), AccountTypeEnum.LOGIN_STATUS_SUCCESS.getCode(), AccountTypeEnum.LOG_TYPE_LOGIN.getCode());
;
picaLogUtils.info(entity);
return jsonObject.toJSONString();
return result;
}
@Override
public String loginByWeChat(BaseRequest request) {
public LoginResult loginByWeChat(BaseRequest request) {
WeChatEntity weChatEntity = WeChatUtils.getAuthorizationInfo(appId, appSecret, request.getWeChatCode());
//todo:微信登录获取个人信息
Map map = new HashMap();
......@@ -193,50 +191,47 @@ public class LoginServiceImpl implements LoginService {
account.setMobilePhone("");
account.setRegisterSource(request.getSourceType());
String newToken = tokenUtils.generateToken(account);
JSONObject jsonObject = new JSONObject();
jsonObject.put(Constants.TOKEN, newToken);
jsonObject.put(Constants.USER_ID, userId);
jsonObject.put(Constants.BIND_FLAG, AccountTypeEnum.BIND_STATUS_SUCCESS.getCode());
return jsonObject.toJSONString();
LoginResult result = new LoginResult();
result.setToken(newToken);
result.setUserId(userId);
result.setBindFlag(AccountTypeEnum.BIND_STATUS_SUCCESS.getCode()+"");
return result;
} else {
AccountWeChatInfoEntity entity = accountWeChatInfoMapper.selectByUnionId(unionId);
if (entity == null) {
processWeChatInfoUser(weChatUserInfoEntity, request.getWeChatLoginType());
}
JSONObject jsonObject = new JSONObject();
jsonObject.put(Constants.BIND_FLAG, AccountTypeEnum.BIND_STATUS_FAILURE.getCode());
jsonObject.put(Constants.UNION_ID, unionId);
return jsonObject.toJSONString();
LoginResult result = new LoginResult();
result.setUnionId(unionId);
result.setBindFlag(AccountTypeEnum.BIND_STATUS_FAILURE.getCode()+"");
return result;
}
}
@Override
public String loginByWeChatStep(BaseRequest request) {
public LoginResult loginByWeChatStep(BaseRequest request) {
//判断当前手机号是否注册过,注册过,直接登录;没有注册过,进行注册操操作
AccountInfoEntity accountInfoEntity = accountInfoDetailMapper.selectByMobile(AESUtil.encryptV0(request.getMobile()));
String json;
LoginResult result;
if (accountInfoEntity == null) {
json = registerService.register(request);
/*
result = registerService.register(request);
if (doubleWritingMode) {
//双写模式下,要在doctor表存储unionId
JSONObject jsonObject = JSONObject.parseObject(json);
if (jsonObject.containsKey("userId")) {
Integer userId = jsonObject.getInteger("userId");
if (result.getUserId()!=null) {
Doctor doctor = new Doctor();
doctor.setId(userId);
doctor.setId(result.getUserId().intValue());
doctor.setUnionid(request.getUnionId());
doctorInfoMapper.updateByPrimaryKeySelective(doctor);
}
}
*/
} else {
json = processLogin(request, accountInfoEntity.getId(), AccountTypeEnum.LOGIN_WE_CHAT.getCode());
result = processLogin(request, accountInfoEntity.getId(), AccountTypeEnum.LOGIN_WE_CHAT.getCode());
}
AccountInfoEntity accountInfo = accountInfoDetailMapper.selectByMobile(AESUtil.encryptV0(request.getMobile()));
Integer acctId = accountInfo.getId();
processAccountUnion(acctId, request.getUnionId());
return json;
return result;
}
@Override
......
......@@ -2,36 +2,40 @@ package com.pica.cloud.account.account.server.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.pica.cloud.account.account.server.constants.Constants;
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.entity.AccountPatientInfoEntity;
import com.pica.cloud.account.account.server.entity.LogLoginEntity;
import com.pica.cloud.account.account.server.entity.*;
import com.pica.cloud.account.account.server.enums.AccountAgreementEnum;
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.exception.AccountException;
import com.pica.cloud.account.account.server.log.AccountLogEntityUtils;
import com.pica.cloud.account.account.server.log.AccountLogUtils;
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.mapper.AccountPatientInfoMapper;
import com.pica.cloud.account.account.server.mapper.*;
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.AESUtil;
import com.pica.cloud.account.account.server.util.AccountUtils;
import com.pica.cloud.account.account.server.util.ExecutorServiceUtils;
import com.pica.cloud.account.account.server.util.TokenUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.concurrent.ExecutorService;
@Service
public class RegisterServiceImpl implements RegisterService {
private Logger logger= LoggerFactory.getLogger(this.getClass());
@Autowired
private AccountInfoDetailMapper accountInfoDetailMapper;
......@@ -53,6 +57,12 @@ public class RegisterServiceImpl implements RegisterService {
@Autowired
private QueueProducer queueProducer;
@Autowired
private AgreementEntityMapper agreementEntityMapper;
@Autowired
private AgreementLogEntityMapper agreementLogEntityMapper;
/**
* 1)注册功能:默认未完善信息;
* 2)注册成功后发送mq消息,让别的服务初始化数据;
......@@ -62,10 +72,11 @@ public class RegisterServiceImpl implements RegisterService {
* @return
*/
@Override
public String register(BaseRequest baseRequest) {
public LoginResult register(BaseRequest baseRequest) {
String mobile = baseRequest.getMobile();
String mobileEncrypt = AESUtil.encryptV0(mobile);
AccountInfoEntity accountInfoEntity = accountInfoDetailMapper.selectByMobile(mobileEncrypt);
if (accountInfoEntity == null) {
Date currentTime = new Date();
int productType = baseRequest.getProductType();
......@@ -120,10 +131,13 @@ public class RegisterServiceImpl implements RegisterService {
account.setMobilePhone(mobile);
account.setRegisterSource(sourceType);
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);
LoginResult result = new LoginResult();
result.setToken(newToken);
result.setUserId(userId);
result.setEntireFlag(1);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(bos);
try {
......@@ -136,9 +150,46 @@ public class RegisterServiceImpl implements RegisterService {
AccountTypeEnum.LOGIN_REGISTER.getCode(), baseRequest.getLoginIp(), AccountTypeEnum.LOGIN_STATUS_SUCCESS.getCode(),
AccountTypeEnum.LOG_TYPE_LOGIN.getCode());
picaLogUtils.info(entity);
return jsonObject.toJSONString();
processAgreement(userId);
return result;
} else {
throw new AccountException(AccountExceptionEnum.PICA_ALREADY_REGISTER);
}
}
/**
* 异步处理协议信息
* 1)从协议表中获取最新的协议信息;
* 2)将协议加入到用户协议表中
*/
private void processAgreement(Long userId) {
ExecutorService executor = ExecutorServiceUtils.getExecutor();
executor.submit(() -> {
//用户协议
Date currentTime = new Date();
Integer userVersion = agreementEntityMapper.selectByType(AccountAgreementEnum.USER_AGREEMENT.getCode());
AgreementLogEntity userAgreementLogEntity = new AgreementLogEntity();
userAgreementLogEntity.setAgreement_type(AccountAgreementEnum.USER_AGREEMENT.getCode());
userAgreementLogEntity.setDoctor_id(userId);
userAgreementLogEntity.setVersion(userVersion.toString());
userAgreementLogEntity.setCreated_id(userId);
userAgreementLogEntity.setCreated_time(currentTime);
userAgreementLogEntity.setModified_id(userId);
userAgreementLogEntity.setModified_time(currentTime);
userAgreementLogEntity.setDelete_flag(1);
agreementLogEntityMapper.insert(userAgreementLogEntity);
//隐私协议
Integer privateVersion = agreementEntityMapper.selectByType(AccountAgreementEnum.PRIVACY_AGREEMENT.getCode());
AgreementLogEntity privateAgreementLogEntity = new AgreementLogEntity();
privateAgreementLogEntity.setAgreement_type(AccountAgreementEnum.PRIVACY_AGREEMENT.getCode());
privateAgreementLogEntity.setDoctor_id(userId);
privateAgreementLogEntity.setVersion(privateVersion.toString());
privateAgreementLogEntity.setCreated_id(userId);
privateAgreementLogEntity.setCreated_time(currentTime);
privateAgreementLogEntity.setModified_id(userId);
privateAgreementLogEntity.setModified_time(currentTime);
privateAgreementLogEntity.setDelete_flag(1);
agreementLogEntityMapper.insert(privateAgreementLogEntity);
});
}
}
package com.pica.cloud.account.account.server.util;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/**
* Created on 2019/10/11 18:58
* author:crs
* Description:线程池工具类
*/
public class ExecutorServiceUtils {
public static ExecutorService getExecutor() {
return Executors.newFixedThreadPool(30);
}
}
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.pica.cloud.account.account.server.mapper.AgreementEntityMapper">
<resultMap id="BaseResultMap" type="com.pica.cloud.account.account.server.entity.AgreementEntity">
<id column="id" property="id" jdbcType="BIGINT"/>
<result column="agreement_type" property="agreement_type" jdbcType="INTEGER"/>
<result column="version" property="version" jdbcType="VARCHAR"/>
<result column="delete_flag" property="delete_flag" jdbcType="INTEGER"/>
<result column="created_id" property="created_id" jdbcType="BIGINT"/>
<result column="created_time" property="created_time" jdbcType="TIMESTAMP"/>
<result column="modified_id" property="modified_id" jdbcType="BIGINT"/>
<result column="modified_time" property="modified_time" jdbcType="TIMESTAMP"/>
</resultMap>
<resultMap id="ResultMapWithBLOBs" type="com.pica.cloud.account.account.server.entity.AgreementEntity"
extends="BaseResultMap">
<result column="agreement_content" property="agreement_content" jdbcType="LONGVARCHAR"/>
</resultMap>
<sql id="Base_Column_List">
id, agreement_type, version, delete_flag, created_id, created_time, modified_id,
modified_time
</sql>
<sql id="Blob_Column_List">
agreement_content
</sql>
<!--通过类型获取用户同意的协议的版本-->
<select id="selectByType" parameterType="Integer" resultType="Integer">
select version from doctor_agreement
where agreement_type = #{agreementType}
</select>
<select id="selectByPrimaryKey" resultMap="ResultMapWithBLOBs" parameterType="java.lang.Long">
select
<include refid="Base_Column_List"/>
,
<include refid="Blob_Column_List"/>
from doctor_agreement
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from doctor_agreement
where id = #{id,jdbcType=BIGINT}
</delete>
<insert id="insert" parameterType="com.pica.cloud.account.account.server.entity.AgreementEntity">
insert into doctor_agreement (id, agreement_type, version,
delete_flag, created_id, created_time,
modified_id, modified_time, agreement_content
)
values (#{id,jdbcType=BIGINT}, #{agreement_type,jdbcType=INTEGER}, #{version,jdbcType=VARCHAR},
#{delete_flag,jdbcType=INTEGER}, #{created_id,jdbcType=BIGINT}, #{created_time,jdbcType=TIMESTAMP},
#{modified_id,jdbcType=BIGINT}, #{modified_time,jdbcType=TIMESTAMP}, #{agreement_content,jdbcType=LONGVARCHAR}
)
</insert>
<insert id="insertSelective" parameterType="com.pica.cloud.account.account.server.entity.AgreementEntity">
insert into doctor_agreement
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="agreement_type != null">
agreement_type,
</if>
<if test="version != null">
version,
</if>
<if test="delete_flag != null">
delete_flag,
</if>
<if test="created_id != null">
created_id,
</if>
<if test="created_time != null">
created_time,
</if>
<if test="modified_id != null">
modified_id,
</if>
<if test="modified_time != null">
modified_time,
</if>
<if test="agreement_content != null">
agreement_content,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=BIGINT},
</if>
<if test="agreement_type != null">
#{agreement_type,jdbcType=INTEGER},
</if>
<if test="version != null">
#{version,jdbcType=VARCHAR},
</if>
<if test="delete_flag != null">
#{delete_flag,jdbcType=INTEGER},
</if>
<if test="created_id != null">
#{created_id,jdbcType=BIGINT},
</if>
<if test="created_time != null">
#{created_time,jdbcType=TIMESTAMP},
</if>
<if test="modified_id != null">
#{modified_id,jdbcType=BIGINT},
</if>
<if test="modified_time != null">
#{modified_time,jdbcType=TIMESTAMP},
</if>
<if test="agreement_content != null">
#{agreement_content,jdbcType=LONGVARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective"
parameterType="com.pica.cloud.account.account.server.entity.AgreementEntity">
update doctor_agreement
<set>
<if test="agreement_type != null">
agreement_type = #{agreement_type,jdbcType=INTEGER},
</if>
<if test="version != null">
version = #{version,jdbcType=VARCHAR},
</if>
<if test="delete_flag != null">
delete_flag = #{delete_flag,jdbcType=INTEGER},
</if>
<if test="created_id != null">
created_id = #{created_id,jdbcType=BIGINT},
</if>
<if test="created_time != null">
created_time = #{created_time,jdbcType=TIMESTAMP},
</if>
<if test="modified_id != null">
modified_id = #{modified_id,jdbcType=BIGINT},
</if>
<if test="modified_time != null">
modified_time = #{modified_time,jdbcType=TIMESTAMP},
</if>
<if test="agreement_content != null">
agreement_content = #{agreement_content,jdbcType=LONGVARCHAR},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKeyWithBLOBs"
parameterType="com.pica.cloud.account.account.server.entity.AgreementEntity">
update doctor_agreement
set agreement_type = #{agreement_type,jdbcType=INTEGER},
version = #{version,jdbcType=VARCHAR},
delete_flag = #{delete_flag,jdbcType=INTEGER},
created_id = #{created_id,jdbcType=BIGINT},
created_time = #{created_time,jdbcType=TIMESTAMP},
modified_id = #{modified_id,jdbcType=BIGINT},
modified_time = #{modified_time,jdbcType=TIMESTAMP},
agreement_content = #{agreement_content,jdbcType=LONGVARCHAR}
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="com.pica.cloud.account.account.server.entity.AgreementEntity">
update doctor_agreement
set agreement_type = #{agreement_type,jdbcType=INTEGER},
version = #{version,jdbcType=VARCHAR},
delete_flag = #{delete_flag,jdbcType=INTEGER},
created_id = #{created_id,jdbcType=BIGINT},
created_time = #{created_time,jdbcType=TIMESTAMP},
modified_id = #{modified_id,jdbcType=BIGINT},
modified_time = #{modified_time,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.pica.cloud.account.account.server.mapper.AgreementLogEntityMapper" >
<resultMap id="BaseResultMap" type="com.pica.cloud.account.account.server.entity.AgreementLogEntity" >
<id column="id" property="id" jdbcType="BIGINT" />
<result column="doctor_id" property="doctor_id" jdbcType="BIGINT" />
<result column="agreement_type" property="agreement_type" jdbcType="INTEGER" />
<result column="version" property="version" jdbcType="VARCHAR" />
<result column="delete_flag" property="delete_flag" jdbcType="INTEGER" />
<result column="created_id" property="created_id" jdbcType="BIGINT" />
<result column="created_time" property="created_time" jdbcType="TIMESTAMP" />
<result column="modified_id" property="modified_id" jdbcType="BIGINT" />
<result column="modified_time" property="modified_time" jdbcType="TIMESTAMP" />
</resultMap>
<sql id="Base_Column_List" >
id, doctor_id, agreement_type, version, delete_flag, created_id, created_time, modified_id,
modified_time
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
select
<include refid="Base_Column_List" />
from doctor_agreement_log
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long" >
delete from doctor_agreement_log
where id = #{id,jdbcType=BIGINT}
</delete>
<insert id="insert" parameterType="com.pica.cloud.account.account.server.entity.AgreementLogEntity" >
insert into doctor_agreement_log (id, doctor_id, agreement_type,
version, delete_flag, created_id,
created_time, modified_id, modified_time)
values (#{id,jdbcType=BIGINT}, #{doctor_id,jdbcType=BIGINT}, #{agreement_type,jdbcType=INTEGER},
#{version,jdbcType=VARCHAR}, #{delete_flag,jdbcType=INTEGER}, #{created_id,jdbcType=BIGINT},
#{created_time,jdbcType=TIMESTAMP}, #{modified_id,jdbcType=BIGINT}, #{modified_time,jdbcType=TIMESTAMP}
)
</insert>
<insert id="insertSelective" parameterType="com.pica.cloud.account.account.server.entity.AgreementLogEntity" >
insert into doctor_agreement_log
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="doctor_id != null" >
doctor_id,
</if>
<if test="agreement_type != null" >
agreement_type,
</if>
<if test="version != null" >
version,
</if>
<if test="delete_flag != null" >
delete_flag,
</if>
<if test="created_id != null" >
created_id,
</if>
<if test="created_time != null" >
created_time,
</if>
<if test="modified_id != null" >
modified_id,
</if>
<if test="modified_time != null" >
modified_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=BIGINT},
</if>
<if test="doctor_id != null" >
#{doctor_id,jdbcType=BIGINT},
</if>
<if test="agreement_type != null" >
#{agreement_type,jdbcType=INTEGER},
</if>
<if test="version != null" >
#{version,jdbcType=VARCHAR},
</if>
<if test="delete_flag != null" >
#{delete_flag,jdbcType=INTEGER},
</if>
<if test="created_id != null" >
#{created_id,jdbcType=BIGINT},
</if>
<if test="created_time != null" >
#{created_time,jdbcType=TIMESTAMP},
</if>
<if test="modified_id != null" >
#{modified_id,jdbcType=BIGINT},
</if>
<if test="modified_time != null" >
#{modified_time,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.pica.cloud.account.account.server.entity.AgreementLogEntity" >
update doctor_agreement_log
<set >
<if test="doctor_id != null" >
doctor_id = #{doctor_id,jdbcType=BIGINT},
</if>
<if test="agreement_type != null" >
agreement_type = #{agreement_type,jdbcType=INTEGER},
</if>
<if test="version != null" >
version = #{version,jdbcType=VARCHAR},
</if>
<if test="delete_flag != null" >
delete_flag = #{delete_flag,jdbcType=INTEGER},
</if>
<if test="created_id != null" >
created_id = #{created_id,jdbcType=BIGINT},
</if>
<if test="created_time != null" >
created_time = #{created_time,jdbcType=TIMESTAMP},
</if>
<if test="modified_id != null" >
modified_id = #{modified_id,jdbcType=BIGINT},
</if>
<if test="modified_time != null" >
modified_time = #{modified_time,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="com.pica.cloud.account.account.server.entity.AgreementLogEntity" >
update doctor_agreement_log
set doctor_id = #{doctor_id,jdbcType=BIGINT},
agreement_type = #{agreement_type,jdbcType=INTEGER},
version = #{version,jdbcType=VARCHAR},
delete_flag = #{delete_flag,jdbcType=INTEGER},
created_id = #{created_id,jdbcType=BIGINT},
created_time = #{created_time,jdbcType=TIMESTAMP},
modified_id = #{modified_id,jdbcType=BIGINT},
modified_time = #{modified_time,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>
\ No newline at end of file
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册