提交 1a89708f 编写于 作者: rushui.chen's avatar rushui.chen

20190821 注册接口

上级 af92ebe1
流水线 #13564 已失败 于阶段
in 3 second
...@@ -19,6 +19,7 @@ import org.slf4j.Logger; ...@@ -19,6 +19,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import javax.servlet.http.HttpServletRequest;
import java.util.*; import java.util.*;
/** /**
...@@ -50,10 +51,42 @@ public abstract class AccountBaseController extends BaseController { ...@@ -50,10 +51,42 @@ public abstract class AccountBaseController extends BaseController {
* @return * @return
*/ */
public AccountUser getAccountUser() { public AccountUser getAccountUser() {
// TODO: 2019/8/20 未实现 //无论是否登录,当前对象都应该存在
//无论是否登录,当前对象都应该存在。 //把所有请求头信息都封装到当前模型中
String token = this.getToken();
AccountUser accountUser = super.getRedisClient().getToken(token, AccountUser.class);
accountUser.setLoginFrom(this.getSourceType());
accountUser.setLoginPlatform(this.getProductType());
accountUser.setLoginIp(super.getIpAddr());
return accountUser;
}
return new AccountUser(); /**
* 产品线类型:productType: 1.云鹊医(默认值) 2云鹊健康
*
* @return
*/
public Integer getProductType() {
HttpServletRequest request = super.getRequest();
String str = request.getHeader("productType");
if (StringUtils.isNotEmpty(str)) {
return Integer.parseInt(str);
}
return null;
}
/**
* 终端来源 sourceType:1.android 2.ios 3.web 4.wechat(例如微信小程序) 5.h5
*
* @return
*/
public Integer getSourceType() {
HttpServletRequest request = super.getRequest();
String str = request.getHeader("sourceType");
if (StringUtils.isNotEmpty(str)) {
return Integer.parseInt(str);
}
return null;
} }
//获取deviceInfo信息 //获取deviceInfo信息
......
...@@ -72,7 +72,6 @@ public class PasswordController extends AccountBaseController { ...@@ -72,7 +72,6 @@ public class PasswordController extends AccountBaseController {
@ApiOperation(value = "忘记密码操作") @ApiOperation(value = "忘记密码操作")
@PostMapping(value = "/reset") @PostMapping(value = "/reset")
public PicaResponse forwardPassword(@RequestBody String params) throws Exception { public PicaResponse forwardPassword(@RequestBody String params) throws Exception {
//TODO: 2019/8/20 当前手机号是否注册过,如果没有注册,请先注册
String json = RSAUtils.decrypt(params, RSAUtils.getPrivateKey()); String json = RSAUtils.decrypt(params, RSAUtils.getPrivateKey());
ForgetPasswordReq forwardPasswordReq = JSONObject.parseObject(json, ForgetPasswordReq.class); ForgetPasswordReq forwardPasswordReq = JSONObject.parseObject(json, ForgetPasswordReq.class);
forwardPasswordReq.setFlag("4"); forwardPasswordReq.setFlag("4");
...@@ -106,11 +105,15 @@ public class PasswordController extends AccountBaseController { ...@@ -106,11 +105,15 @@ public class PasswordController extends AccountBaseController {
*/ */
private void checkAuthCode(ForgetPasswordReq req) { private void checkAuthCode(ForgetPasswordReq req) {
String flag = StringUtils.isBlank(req.getFlag()) ? "0" : req.getFlag(); String flag = StringUtils.isBlank(req.getFlag()) ? "0" : req.getFlag();
if (StringUtils.isBlank(req.getAuthCode())) { if (StringUtils.isBlank(req.getAuthCode())) {
throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "短信验证码错误"); throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "短信验证码错误");
} }
String authCodeKey = AccountUtils.getAuthCodeKey(req.getMobile(), flag); String authCodeKey = AccountUtils.getAuthCodeKey(req.getMobile(), flag);
String cacheCode = cacheClient.get(authCodeKey); //从redis获取验证码 String cacheCode = cacheClient.get(authCodeKey); //从redis获取验证码
if (StringUtils.isBlank(cacheCode)) { if (StringUtils.isBlank(cacheCode)) {
throw new PicaException(PicaResultCode.RESULE_DATA_NONE.code(), "短信验证码已过期,请重新获取"); throw new PicaException(PicaResultCode.RESULE_DATA_NONE.code(), "短信验证码已过期,请重新获取");
} }
......
package com.pica.cloud.account.account.server.controller;
import com.alibaba.fastjson.JSONObject;
import com.pica.cloud.account.account.server.entity.Account;
import com.pica.cloud.account.account.server.entity.AccountContact;
import com.pica.cloud.account.account.server.entity.AccountInfo;
import com.pica.cloud.account.account.server.entity.AccountUser;
import com.pica.cloud.account.account.server.req.RegisterReq;
import com.pica.cloud.account.account.server.service.*;
import com.pica.cloud.account.account.server.util.AccountUtils;
import com.pica.cloud.account.account.server.util.RSAUtils;
import com.pica.cloud.foundation.entity.PicaException;
import com.pica.cloud.foundation.entity.PicaResponse;
import com.pica.cloud.foundation.redis.CacheClient;
import com.pica.cloud.foundation.utils.utils.EncryptCreateUtil;
import com.pica.cloud.foundation.utils.utils.json.Object2Map;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Date;
import java.util.Map;
import java.util.UUID;
@Api("注册资源")
@RestController
@RequestMapping("/register")
public class RegisterController extends AccountBaseController {
private Logger logger = LoggerFactory.getLogger(this.getClass());
@Autowired
private AccountUtils accountUtils;
@Autowired
private AccountContactServer accountContactServer;
@Autowired
private AccountDetailsService accountDetailsService;
@Autowired
private AccountProductService accountProductService;
@Autowired
private AccountUserInfoService accountUserInfoService;
@Autowired
private AccountLoginOutService accountLoginOutService;
@Autowired
private CacheClient cacheClient;
@ApiOperation("注册接口")
@PostMapping(value = "")
public PicaResponse<String> register(@RequestBody String params) throws Exception {
String json = RSAUtils.decrypt(params, RSAUtils.getPrivateKey());
RegisterReq registerReq = JSONObject.parseObject(json, RegisterReq.class);
String mobile = registerReq.getMobile();
String authCode = registerReq.getAuthCode();
AccountUtils.checkMobilePhone(mobile);
accountUtils.checkAuthCode(mobile, "1", authCode);
//校验用户用户是否已经存在
AccountContact accountContact = accountContactServer.selectByMobile(mobile);
if (accountContact == null) {
//账号信息表
AccountInfo accountInfo = new AccountInfo();
accountInfo.setPassword(EncryptCreateUtil.encrypt(registerReq.getPassword()));
Integer acctId = accountDetailsService.insertAccountInfo(accountInfo);
accountDetailsService.updateAccountInfo(acctId);
//账号产品线表
accountProductService.insertSelective(acctId, super.getProductType());
//账号联系人表
accountContactServer.insertSelective(mobile, acctId);
//用户信息表
Integer userId = accountUserInfoService.insertUserInfo(acctId);
//保存用户登陆成功状态
AccountUser accountUser = super.getAccountUser();
accountLoginOutService.insertLoginLog(accountUser);
Account account = new Account();
account.setId(userId.longValue());
account.setAcctId(acctId);
account.setCreatTime(new Date());
account.setMobilePhone(mobile);
account.setRegisterSource(super.getSourceType());
String newToken = this.generateToken(account);
JSONObject jsonObject = new JSONObject();
jsonObject.put("token", newToken);
jsonObject.put("userId", userId);
return PicaResponse.toResponse(jsonObject.toJSONString());
} else {
throw new PicaException("您已注册,请直接登录");
}
}
//生成token
private String generateToken(Account account) {
String sourceType = null;
Integer registerSource = account.getRegisterSource();
if (registerSource.intValue() == 5) {
sourceType = "h5";
} else if (registerSource.intValue() == 3) {
sourceType = "saas";
} else {
sourceType = "app";
}
String newToken = org.apache.commons.lang3.StringUtils.EMPTY;
try {
//先清除旧token
String tokenValue = "token-doctor-" + account.getId().toString();
//String oldToken = cacheClient.get(tokenValue + "-h5");
//if (org.apache.commons.lang3.StringUtils.isNotBlank(oldToken)) {
// cacheClient.del(oldToken);
//}
//生成新token
int expiredSeconds = 30 * 24 * 60 * 60;//token有效期30天
newToken = UUID.randomUUID().toString().replace("-", "").toUpperCase();
String tokenKey = "token-" + newToken;
cacheClient.set(tokenKey, tokenValue, expiredSeconds);
cacheClient.set(tokenValue + sourceType, tokenKey, expiredSeconds);
//用户数据放入缓存
String userData = cacheClient.hget(tokenValue, "id");
if (org.apache.commons.lang3.StringUtils.isEmpty(userData)) {
AccountUser picaUser = new AccountUser();
picaUser.setToken(newToken);
//用户id
picaUser.setId(account.getId().intValue());
//
picaUser.setAcctId(account.getAcctId());
picaUser.setMobile(account.getMobilePhone());
picaUser.setName(EncryptCreateUtil.dencrypt(account.getMobilePhone()).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", sourceType);
data.forEach((key, value) -> {
value = value == null ? "" : value;
cacheClient.hset(tokenValue, key, value);
});
}
} catch (Exception ex) {
logger.error("生成H5 token异常:{}" + ex.getMessage(), ex);
}
return newToken;
}
}
package com.pica.cloud.account.account.server.controller;
import com.alibaba.fastjson.JSONObject;
import com.pica.cloud.account.account.server.entity.Account;
import com.pica.cloud.account.account.server.entity.AccountUnion;
import com.pica.cloud.account.account.server.entity.AccountUser;
import com.pica.cloud.account.account.server.req.SysCodeReq;
import com.pica.cloud.account.account.server.service.AccountService;
import com.pica.cloud.account.account.server.service.AccountUnionServer;
import com.pica.cloud.account.account.server.util.AccountUtils;
import com.pica.cloud.account.account.server.util.RSAUtils;
import com.pica.cloud.foundation.entity.PicaException;
import com.pica.cloud.foundation.entity.PicaResponse;
import com.pica.cloud.foundation.redis.CacheClient;
import com.pica.cloud.foundation.utils.utils.CommonUtil;
import com.pica.cloud.foundation.utils.utils.EncryptCreateUtil;
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.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Api("短信验证码")
@RestController
@RequestMapping(value = "/authCode")
public class SysCodeController extends AccountBaseController {
private final String AUTH_CODE_PREFIX = "authCode-";
@Autowired
private AccountService accountService;
@Autowired
private AccountUnionServer accountUnionServer;
@Autowired
private CacheClient cacheClient;
@ApiOperation("获取短信验证码")
@GetMapping(value = "")
public PicaResponse getSysCode(@RequestBody String params) throws Exception {
String json = RSAUtils.decrypt(params, RSAUtils.getPrivateKey());
SysCodeReq sysCodeReq = JSONObject.parseObject(json, SysCodeReq.class);
AccountUtils.checkMobilePhone(sysCodeReq.getMobilePhone());
processSysCode(sysCodeReq.getMobilePhone(), sysCodeReq.getFlag());
return PicaResponse.toResponse(StringUtils.EMPTY);
}
@ApiOperation("微信获取短信验证码")
@GetMapping(value = "/wechat")
public PicaResponse getWeChatSysCode(String params) throws Exception {
AccountUser accountUser = super.getAccountUser();
String token = accountUser.getToken();
if (StringUtils.isNotEmpty(token)) {
String json = RSAUtils.decrypt(params, RSAUtils.getPrivateKey());
SysCodeReq sysCodeReq = JSONObject.parseObject(json, SysCodeReq.class);
AccountUtils.checkMobilePhone(sysCodeReq.getMobilePhone());
//联合登录表查询是否存在记录
sysCodeReq.setAcctId(accountUser.getAcctId());
sysCodeReq.setUnionId(sysCodeReq.getUnionId());
AccountUnion accountUnion = accountUnionServer.selectByUnionIdAndAcctId(sysCodeReq);
if (accountUnion == null) {
processSysCode(sysCodeReq.getMobilePhone(), sysCodeReq.getFlag());
return PicaResponse.toResponse(StringUtils.EMPTY);
} else {
throw new PicaException("您已绑定过微信");
}
} else {
throw new PicaException("请重新登陆");
}
}
/**
* 验证码发送逻辑
*
* @param mobilePhone
* @param flag
*/
private void processSysCode(String mobilePhone, Integer flag) {
//随机生成验证码
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);
}
//获取验证码redis key
private String getAuthCodeKey(String mobilePhone, String flag) {
return AUTH_CODE_PREFIX + flag + "-" + EncryptCreateUtil.encrypt(mobilePhone);
}
}
...@@ -13,6 +13,8 @@ public class Account { ...@@ -13,6 +13,8 @@ public class Account {
private Long id; private Long id;
private Integer acctId;
private Integer sex; private Integer sex;
private String name; private String name;
...@@ -67,6 +69,14 @@ public class Account { ...@@ -67,6 +69,14 @@ public class Account {
private Date birthday; private Date birthday;
public Integer getAcctId() {
return acctId;
}
public void setAcctId(Integer acctId) {
this.acctId = acctId;
}
public Long getId() { public Long getId() {
return id; return id;
} }
......
...@@ -13,7 +13,7 @@ public class AccountInfo { ...@@ -13,7 +13,7 @@ public class AccountInfo {
private Date birthday; private Date birthday;
private Byte sex; private int sex;
private String idCard; private String idCard;
...@@ -31,13 +31,6 @@ public class AccountInfo { ...@@ -31,13 +31,6 @@ public class AccountInfo {
private Date modifiedTime; private Date modifiedTime;
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public Long getId() { public Long getId() {
return id; return id;
...@@ -52,7 +45,7 @@ public class AccountInfo { ...@@ -52,7 +45,7 @@ public class AccountInfo {
} }
public void setPassword(String password) { public void setPassword(String password) {
this.password = password == null ? null : password.trim(); this.password = password;
} }
public String getName() { public String getName() {
...@@ -60,10 +53,16 @@ public class AccountInfo { ...@@ -60,10 +53,16 @@ public class AccountInfo {
} }
public void setName(String name) { public void setName(String name) {
this.name = name == null ? null : name.trim(); this.name = name;
} }
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public Date getBirthday() { public Date getBirthday() {
return birthday; return birthday;
...@@ -73,11 +72,11 @@ public class AccountInfo { ...@@ -73,11 +72,11 @@ public class AccountInfo {
this.birthday = birthday; this.birthday = birthday;
} }
public Byte getSex() { public int getSex() {
return sex; return sex;
} }
public void setSex(Byte sex) { public void setSex(int sex) {
this.sex = sex; this.sex = sex;
} }
...@@ -86,7 +85,7 @@ public class AccountInfo { ...@@ -86,7 +85,7 @@ public class AccountInfo {
} }
public void setIdCard(String idCard) { public void setIdCard(String idCard) {
this.idCard = idCard == null ? null : idCard.trim(); this.idCard = idCard;
} }
public Date getRegTime() { public Date getRegTime() {
......
package com.pica.cloud.account.account.server.entity;
import java.util.Date;
public class AccountProduct {
private Long id;
private Long acctId;
private Integer productType;
private Integer deleteFlag;
private Long createdId;
private Date createdTime;
private Long modifiedId;
private Date modifiedTime;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getAcctId() {
return acctId;
}
public void setAcctId(Long acctId) {
this.acctId = acctId;
}
public Integer getProductType() {
return productType;
}
public void setProductType(Integer productType) {
this.productType = productType;
}
public Integer getDeleteFlag() {
return deleteFlag;
}
public void setDeleteFlag(Integer deleteFlag) {
this.deleteFlag = deleteFlag;
}
public Long getCreatedId() {
return createdId;
}
public void setCreatedId(Long createdId) {
this.createdId = createdId;
}
public Date getCreatedTime() {
return createdTime;
}
public void setCreatedTime(Date createdTime) {
this.createdTime = createdTime;
}
public Long getModifiedId() {
return modifiedId;
}
public void setModifiedId(Long modifiedId) {
this.modifiedId = modifiedId;
}
public Date getModifiedTime() {
return modifiedTime;
}
public void setModifiedTime(Date modifiedTime) {
this.modifiedTime = modifiedTime;
}
}
\ No newline at end of file
package com.pica.cloud.account.account.server.entity;
import java.util.Date;
public class AccountUnion {
private Long id;
private Long acctId;
private Integer unionType;
private String unionId;
private String nickname;
private String headImgUrl;
private Integer deleteFlag;
private Long createdId;
private Date createdTime;
private Long modifiedId;
private Date modifiedTime;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getAcctId() {
return acctId;
}
public void setAcctId(Long acctId) {
this.acctId = acctId;
}
public Integer getUnionType() {
return unionType;
}
public void setUnionType(Integer unionType) {
this.unionType = unionType;
}
public String getUnionId() {
return unionId;
}
public void setUnionId(String unionId) {
this.unionId = unionId == null ? null : unionId.trim();
}
public String getNickname() {
return nickname;
}
public void setNickname(String nickname) {
this.nickname = nickname == null ? null : nickname.trim();
}
public String getHeadImgUrl() {
return headImgUrl;
}
public void setHeadImgUrl(String headImgUrl) {
this.headImgUrl = headImgUrl == null ? null : headImgUrl.trim();
}
public Integer getDeleteFlag() {
return deleteFlag;
}
public void setDeleteFlag(Integer deleteFlag) {
this.deleteFlag = deleteFlag;
}
public Long getCreatedId() {
return createdId;
}
public void setCreatedId(Long createdId) {
this.createdId = createdId;
}
public Date getCreatedTime() {
return createdTime;
}
public void setCreatedTime(Date createdTime) {
this.createdTime = createdTime;
}
public Long getModifiedId() {
return modifiedId;
}
public void setModifiedId(Long modifiedId) {
this.modifiedId = modifiedId;
}
public Date getModifiedTime() {
return modifiedTime;
}
public void setModifiedTime(Date modifiedTime) {
this.modifiedTime = modifiedTime;
}
}
\ No newline at end of file
...@@ -4,37 +4,37 @@ import com.pica.cloud.foundation.utils.entity.PicaUser; ...@@ -4,37 +4,37 @@ import com.pica.cloud.foundation.utils.entity.PicaUser;
public class AccountUser extends PicaUser { public class AccountUser extends PicaUser {
//账户id //账户id
private int acctId; private Integer acctId;
//渠道来源 //渠道来源
private int loginFrom; private Integer loginFrom;
//平台来源 //平台来源
private int loginPlatform; private Integer loginPlatform;
//账户名 //账户名
private String acctName; private String acctName;
//登录ip //登录ip
private String loginIp; private String loginIp;
public int getAcctId() { public Integer getAcctId() {
return acctId; return acctId;
} }
public void setAcctId(int acctId) { public void setAcctId(Integer acctId) {
this.acctId = acctId; this.acctId = acctId;
} }
public int getLoginFrom() { public Integer getLoginFrom() {
return loginFrom; return loginFrom;
} }
public void setLoginFrom(int loginFrom) { public void setLoginFrom(Integer loginFrom) {
this.loginFrom = loginFrom; this.loginFrom = loginFrom;
} }
public int getLoginPlatform() { public Integer getLoginPlatform() {
return loginPlatform; return loginPlatform;
} }
public void setLoginPlatform(int loginPlatform) { public void setLoginPlatform(Integer loginPlatform) {
this.loginPlatform = loginPlatform; this.loginPlatform = loginPlatform;
} }
......
...@@ -21,14 +21,20 @@ public interface AccountContactMapper { ...@@ -21,14 +21,20 @@ public interface AccountContactMapper {
*/ */
AccountContact selectByPrimaryKey(Long id); AccountContact selectByPrimaryKey(Long id);
/** /**
* 通过手机号获取账户信息 * 通过手机号获取账户信息
* *
* @param mobile * @param mobile mobile
* @return * @return
*/ */
AccountContact selectByMobile(String mobile); AccountContact selectByMobile(String mobile);
/**
* 插入账户联系人记录
*
* @param accountContact accountContact
*/
void insertSelective(AccountContact accountContact);
} }
\ No newline at end of file
...@@ -8,11 +8,9 @@ public interface AccountDetailsMapper { ...@@ -8,11 +8,9 @@ public interface AccountDetailsMapper {
int insert(AccountInfo record); int insert(AccountInfo record);
int insertSelective(AccountInfo record);
AccountInfo selectByPrimaryKey(Long id); AccountInfo selectByPrimaryKey(Long id);
int updateByPrimaryKeySelective(AccountInfo record);
int updateByPrimaryKey(AccountInfo record); int updateByPrimaryKey(AccountInfo record);
...@@ -24,4 +22,20 @@ public interface AccountDetailsMapper { ...@@ -24,4 +22,20 @@ public interface AccountDetailsMapper {
*/ */
int updatePasswordById(AccountInfo record); int updatePasswordById(AccountInfo record);
/**
* 插入新的用户记录
*
* @param record
* @return
*/
int insertSelective(AccountInfo record);
/**
* 更新用户信息
* @param record
* @return
*/
int updateByPrimaryKeySelective(AccountInfo record);
} }
\ No newline at end of file
package com.pica.cloud.account.account.server.mapper;
import com.pica.cloud.account.account.server.entity.AccountProduct;
public interface AccountProductMapper {
int deleteByPrimaryKey(Long id);
int insert(AccountProduct record);
int insertSelective(AccountProduct record);
AccountProduct selectByPrimaryKey(Long id);
int updateByPrimaryKeySelective(AccountProduct record);
int updateByPrimaryKey(AccountProduct record);
}
\ No newline at end of file
package com.pica.cloud.account.account.server.mapper;
import com.pica.cloud.account.account.server.entity.AccountUnion;
import com.pica.cloud.account.account.server.req.SysCodeReq;
public interface AccountUnionMapper {
/**
* 查询是否绑定过微信
* @param sysCodeReq
* @return
*/
AccountUnion selectByUnionIdAndAcctId(SysCodeReq sysCodeReq);
int insert(AccountUnion record);
int insertSelective(AccountUnion record);
AccountUnion selectByPrimaryKey(Long id);
int updateByPrimaryKeySelective(AccountUnion record);
int updateByPrimaryKey(AccountUnion record);
}
\ No newline at end of file
...@@ -5,15 +5,22 @@ import com.pica.cloud.account.account.server.entity.AcctUserInfo; ...@@ -5,15 +5,22 @@ import com.pica.cloud.account.account.server.entity.AcctUserInfo;
public interface AcctUserInfoMapper { public interface AcctUserInfoMapper {
int deleteByPrimaryKey(Integer id); int deleteByPrimaryKey(Integer id);
int insert(AcctUserInfo record); int insert(AcctUserInfo record);
int insertSelective(AcctUserInfo record);
AcctUserInfo selectByPrimaryKey(Integer id); AcctUserInfo selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(AcctUserInfo record); int updateByPrimaryKeySelective(AcctUserInfo record);
int updateByPrimaryKey(AcctUserInfo record); int updateByPrimaryKey(AcctUserInfo record);
/**
* 插入用户信息
*
* @param record
* @return
*/
int insertSelective(AcctUserInfo record);
} }
\ No newline at end of file
package com.pica.cloud.account.account.server.req;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
@ApiModel
public class RegisterReq {
@ApiModelProperty("手机号")
private String mobile;
@ApiModelProperty("密码")
private String password;
@ApiModelProperty("验证码")
private String authCode;
@ApiModelProperty("邀请码")
private String inviteCode;
@ApiModelProperty("验证码标记")
private String flag;
public String getFlag() {
return flag;
}
public void setFlag(String flag) {
this.flag = flag;
}
public String getMobile() {
return mobile;
}
public void setMobile(String mobile) {
this.mobile = mobile;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getAuthCode() {
return authCode;
}
public void setAuthCode(String authCode) {
this.authCode = authCode;
}
public String getInviteCode() {
return inviteCode;
}
public void setInviteCode(String inviteCode) {
this.inviteCode = inviteCode;
}
}
package com.pica.cloud.account.account.server.req;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
@ApiModel
public class SysCodeReq {
@ApiModelProperty("账户id")
private Integer acctId;
@ApiModelProperty("手机号")
private String mobilePhone;
@ApiModelProperty("验证码类型")
private Integer flag;
@ApiModelProperty("unionId")
private String unionId;
public Integer getAcctId() {
return acctId;
}
public void setAcctId(Integer acctId) {
this.acctId = acctId;
}
public String getMobilePhone() {
return mobilePhone;
}
public void setMobilePhone(String mobilePhone) {
this.mobilePhone = mobilePhone;
}
public Integer getFlag() {
return flag;
}
public void setFlag(Integer flag) {
this.flag = flag;
}
public String getUnionId() {
return unionId;
}
public void setUnionId(String unionId) {
this.unionId = unionId;
}
}
...@@ -6,4 +6,6 @@ public interface AccountContactServer { ...@@ -6,4 +6,6 @@ public interface AccountContactServer {
AccountContact selectByMobile(String mobile); AccountContact selectByMobile(String mobile);
void insertSelective(String mobile,Integer acctId);
} }
package com.pica.cloud.account.account.server.service;
import com.pica.cloud.account.account.server.entity.AccountInfo;
public interface AccountDetailsService {
int insertAccountInfo(AccountInfo accountInfo);
int updateAccountInfo(Integer id);
}
package com.pica.cloud.account.account.server.service;
public interface AccountProductService {
int insertSelective(Integer acctId,Integer productType);
}
package com.pica.cloud.account.account.server.service;
import com.pica.cloud.account.account.server.entity.AccountUnion;
import com.pica.cloud.account.account.server.req.SysCodeReq;
public interface AccountUnionServer {
AccountUnion selectByUnionIdAndAcctId(SysCodeReq sysCodeReq);
}
...@@ -14,12 +14,19 @@ public interface AccountUserInfoService { ...@@ -14,12 +14,19 @@ public interface AccountUserInfoService {
/** /**
* 获取用户信息 * 获取用户信息
*
* @param id * @param id
* @return * @return
*/ */
AcctUserInfo getUserInfo(Integer id); AcctUserInfo getUserInfo(Integer id);
/**
* 插入新的记录
*
* @param acctId acctId
* @return
*/
int insertUserInfo(Integer acctId);
} }
...@@ -3,9 +3,12 @@ package com.pica.cloud.account.account.server.service.impl; ...@@ -3,9 +3,12 @@ package com.pica.cloud.account.account.server.service.impl;
import com.pica.cloud.account.account.server.entity.AccountContact; import com.pica.cloud.account.account.server.entity.AccountContact;
import com.pica.cloud.account.account.server.mapper.AccountContactMapper; import com.pica.cloud.account.account.server.mapper.AccountContactMapper;
import com.pica.cloud.account.account.server.service.AccountContactServer; import com.pica.cloud.account.account.server.service.AccountContactServer;
import com.pica.cloud.foundation.utils.utils.EncryptCreateUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Date;
@Service @Service
public class AccountContactServerImpl implements AccountContactServer { public class AccountContactServerImpl implements AccountContactServer {
...@@ -16,4 +19,17 @@ public class AccountContactServerImpl implements AccountContactServer { ...@@ -16,4 +19,17 @@ public class AccountContactServerImpl implements AccountContactServer {
public AccountContact selectByMobile(String mobile) { public AccountContact selectByMobile(String mobile) {
return accountContactMapper.selectByMobile(mobile); return accountContactMapper.selectByMobile(mobile);
} }
@Override
public void insertSelective(String mobile, Integer acctId) {
AccountContact accountContact = new AccountContact();
accountContact.setModifiedId(acctId.longValue());
accountContact.setCreatedId(acctId.longValue());
accountContact.setMobilePhone(EncryptCreateUtil.encrypt(mobile));
accountContact.setAcctId(acctId);
accountContact.setCreatedTime(new Date());
accountContact.setModifiedTime(new Date());
accountContact.setDeleteFlag(1);
}
} }
package com.pica.cloud.account.account.server.service.impl;
import com.pica.cloud.account.account.server.entity.AccountInfo;
import com.pica.cloud.account.account.server.mapper.AccountDetailsMapper;
import com.pica.cloud.account.account.server.service.AccountDetailsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
@Service
public class AccountDetailsServiceImpl implements AccountDetailsService {
@Autowired
private AccountDetailsMapper accountDetailsMapper;
@Override
public int insertAccountInfo(AccountInfo accountInfo) {
accountInfo.setSex(0);
accountInfo.setCreatedId(0);
accountInfo.setModifiedId(0L);
accountInfo.setCreatedTime(new Date());
accountInfo.setRegTime(new Date());
accountInfo.setModifiedTime(new Date());
accountInfo.setDeleteFlag(1);
return accountDetailsMapper.insertSelective(accountInfo);
}
@Override
public int updateAccountInfo(Integer id) {
AccountInfo accountInfo = new AccountInfo();
accountInfo.setId(id.longValue());
accountInfo.setCreatedId(id);
accountInfo.setModifiedId(id.longValue());
return accountDetailsMapper.updateByPrimaryKeySelective(accountInfo);
}
}
...@@ -5,6 +5,7 @@ import com.pica.cloud.account.account.server.mapper.AccountInfoMapper; ...@@ -5,6 +5,7 @@ import com.pica.cloud.account.account.server.mapper.AccountInfoMapper;
import com.pica.cloud.account.account.server.service.AccountInfoService; import com.pica.cloud.account.account.server.service.AccountInfoService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
/** /**
...@@ -31,4 +32,6 @@ public class AccountInfoServiceImpl implements AccountInfoService { ...@@ -31,4 +32,6 @@ public class AccountInfoServiceImpl implements AccountInfoService {
public List<Integer> getDoctorIds(AccountInfoReq req) { public List<Integer> getDoctorIds(AccountInfoReq req) {
return accountInfoMapper.getDoctorIds(req); return accountInfoMapper.getDoctorIds(req);
} }
} }
package com.pica.cloud.account.account.server.service.impl;
import com.pica.cloud.account.account.server.entity.AccountProduct;
import com.pica.cloud.account.account.server.mapper.AccountProductMapper;
import com.pica.cloud.account.account.server.service.AccountProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
@Service
public class AccountProductServiceImpl implements AccountProductService {
@Autowired
private AccountProductMapper accountProductMapper;
@Override
public int insertSelective(Integer acctId, Integer productType) {
AccountProduct accountProduct = new AccountProduct();
accountProduct.setAcctId(acctId.longValue());
accountProduct.setCreatedId(acctId.longValue());
accountProduct.setModifiedId(acctId.longValue());
accountProduct.setCreatedTime(new Date());
accountProduct.setModifiedTime(new Date());
accountProduct.setDeleteFlag(1);
accountProduct.setProductType(productType);
return accountProductMapper.insertSelective(accountProduct);
}
}
package com.pica.cloud.account.account.server.service.impl;
import com.pica.cloud.account.account.server.entity.AccountUnion;
import com.pica.cloud.account.account.server.mapper.AccountUnionMapper;
import com.pica.cloud.account.account.server.req.SysCodeReq;
import com.pica.cloud.account.account.server.service.AccountUnionServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class AccountUnionServerImpl implements AccountUnionServer {
@Autowired
private AccountUnionMapper accountUnionMapper;
@Override
public AccountUnion selectByUnionIdAndAcctId(SysCodeReq sysCodeReq) {
return accountUnionMapper.selectByUnionIdAndAcctId(sysCodeReq);
}
}
...@@ -6,6 +6,8 @@ import com.pica.cloud.account.account.server.service.AccountUserInfoService; ...@@ -6,6 +6,8 @@ import com.pica.cloud.account.account.server.service.AccountUserInfoService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Date;
@Service @Service
public class AccountUserInfoServiceImpl implements AccountUserInfoService { public class AccountUserInfoServiceImpl implements AccountUserInfoService {
...@@ -20,7 +22,6 @@ public class AccountUserInfoServiceImpl implements AccountUserInfoService { ...@@ -20,7 +22,6 @@ public class AccountUserInfoServiceImpl implements AccountUserInfoService {
int result = acctUserInfoMapper.updateByPrimaryKeySelective(acctUserInfo); int result = acctUserInfoMapper.updateByPrimaryKeySelective(acctUserInfo);
//把更新日志插入到记录表中 //把更新日志插入到记录表中
Integer acctId = acctUserInfo.getAcctId(); Integer acctId = acctUserInfo.getAcctId();
//todo:两个实体怎么转化? 不可能把数据全部取出来赋值吧 //todo:两个实体怎么转化? 不可能把数据全部取出来赋值吧
AcctUserInfo newAcctUserInfo = acctUserInfoMapper.selectByPrimaryKey(acctId); AcctUserInfo newAcctUserInfo = acctUserInfoMapper.selectByPrimaryKey(acctId);
acctUserInfoMapper.insert(newAcctUserInfo); acctUserInfoMapper.insert(newAcctUserInfo);
...@@ -31,4 +32,18 @@ public class AccountUserInfoServiceImpl implements AccountUserInfoService { ...@@ -31,4 +32,18 @@ public class AccountUserInfoServiceImpl implements AccountUserInfoService {
public AcctUserInfo getUserInfo(Integer id) { public AcctUserInfo getUserInfo(Integer id) {
return acctUserInfoMapper.selectByPrimaryKey(id); return acctUserInfoMapper.selectByPrimaryKey(id);
} }
@Override
public int insertUserInfo(Integer acctId) {
AcctUserInfo acctUserInfo = new AcctUserInfo();
acctUserInfo.setAcctId(acctId);
acctUserInfo.setCreateId(acctId);
acctUserInfo.setCreateTime(new Date());
acctUserInfo.setModifyId(acctId);
acctUserInfo.setModifyTime(new Date());
acctUserInfo.setDeleteFlag(1);
int userId = acctUserInfoMapper.insertSelective(acctUserInfo);
return userId;
}
} }
package com.pica.cloud.account.account.server.service; package com.pica.cloud.account.account.server.service.impl;
import com.pica.cloud.account.account.server.entity.AccountContact; import com.pica.cloud.account.account.server.entity.AccountContact;
import com.pica.cloud.account.account.server.mapper.AccountContactMapper; import com.pica.cloud.account.account.server.mapper.AccountContactMapper;
import com.pica.cloud.account.account.server.service.ModifyMobileService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
......
...@@ -10,6 +10,7 @@ import com.pica.cloud.account.account.server.mapper.LogPasswordModifyMapper; ...@@ -10,6 +10,7 @@ import com.pica.cloud.account.account.server.mapper.LogPasswordModifyMapper;
import com.pica.cloud.account.account.server.req.ForgetPasswordReq; import com.pica.cloud.account.account.server.req.ForgetPasswordReq;
import com.pica.cloud.account.account.server.req.PasswordReq; import com.pica.cloud.account.account.server.req.PasswordReq;
import com.pica.cloud.account.account.server.service.PasswordService; import com.pica.cloud.account.account.server.service.PasswordService;
import com.pica.cloud.foundation.utils.utils.EncryptCreateUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -33,14 +34,14 @@ public class PasswordServiceImpl implements PasswordService { ...@@ -33,14 +34,14 @@ public class PasswordServiceImpl implements PasswordService {
//更新密码 //更新密码
AccountInfo accountInfo = new AccountInfo(); AccountInfo accountInfo = new AccountInfo();
accountInfo.setId(id.longValue()); accountInfo.setId(id.longValue());
accountInfo.setPassword(modifyPasswordReq.getOldPsw()); accountInfo.setPassword(EncryptCreateUtil.encrypt(modifyPasswordReq.getOldPsw()));
accountDetailsMapper.updatePasswordById(accountInfo); accountDetailsMapper.updatePasswordById(accountInfo);
//记录密码更新日志 //记录密码更新日志
LogPasswordModify logPasswordModify = new LogPasswordModify(); LogPasswordModify logPasswordModify = new LogPasswordModify();
logPasswordModify.setCreatedId(id.longValue()); logPasswordModify.setCreatedId(id.longValue());
logPasswordModify.setModifiedId(id); logPasswordModify.setModifiedId(id);
logPasswordModify.setNewPwd(modifyPasswordReq.getNewPsw()); logPasswordModify.setNewPwd(EncryptCreateUtil.encrypt(modifyPasswordReq.getNewPsw()));
logPasswordModify.setOldPwd(AccountInfoEntity.getPassword()); logPasswordModify.setOldPwd(EncryptCreateUtil.encrypt(AccountInfoEntity.getPassword()));
AccountContact accountContact = accountContactMapper.selectByPrimaryKey(id.longValue()); AccountContact accountContact = accountContactMapper.selectByPrimaryKey(id.longValue());
logPasswordModify.setMobilePhone(accountContact.getMobilePhone()); logPasswordModify.setMobilePhone(accountContact.getMobilePhone());
logPasswordModifyMapper.insertSelective(logPasswordModify); logPasswordModifyMapper.insertSelective(logPasswordModify);
...@@ -51,13 +52,13 @@ public class PasswordServiceImpl implements PasswordService { ...@@ -51,13 +52,13 @@ public class PasswordServiceImpl implements PasswordService {
AccountContact accountContact = accountContactMapper.selectByMobile(forgetPasswordReq.getMobile()); AccountContact accountContact = accountContactMapper.selectByMobile(forgetPasswordReq.getMobile());
AccountInfo accountInfo = new AccountInfo(); AccountInfo accountInfo = new AccountInfo();
accountInfo.setId(accountContact.getAcctId().longValue()); accountInfo.setId(accountContact.getAcctId().longValue());
accountInfo.setPassword(forgetPasswordReq.getNewPsw()); accountInfo.setPassword(EncryptCreateUtil.encrypt(forgetPasswordReq.getNewPsw()));
accountDetailsMapper.updatePasswordById(accountInfo); accountDetailsMapper.updatePasswordById(accountInfo);
//记录更新日志 //记录更新日志
LogPasswordModify logPasswordModify = new LogPasswordModify(); LogPasswordModify logPasswordModify = new LogPasswordModify();
logPasswordModify.setCreatedId(accountContact.getAcctId().longValue()); logPasswordModify.setCreatedId(accountContact.getAcctId().longValue());
logPasswordModify.setModifiedId(accountContact.getAcctId()); logPasswordModify.setModifiedId(accountContact.getAcctId());
logPasswordModify.setNewPwd(forgetPasswordReq.getNewPsw()); logPasswordModify.setNewPwd(EncryptCreateUtil.encrypt(forgetPasswordReq.getNewPsw()));
logPasswordModify.setOldPwd(""); logPasswordModify.setOldPwd("");
logPasswordModify.setMobilePhone(forgetPasswordReq.getMobile()); logPasswordModify.setMobilePhone(forgetPasswordReq.getMobile());
logPasswordModifyMapper.insertSelective(logPasswordModify); logPasswordModifyMapper.insertSelective(logPasswordModify);
......
...@@ -2,15 +2,22 @@ package com.pica.cloud.account.account.server.util; ...@@ -2,15 +2,22 @@ package com.pica.cloud.account.account.server.util;
import com.pica.cloud.foundation.entity.PicaException; import com.pica.cloud.foundation.entity.PicaException;
import com.pica.cloud.foundation.entity.PicaResultCode; import com.pica.cloud.foundation.entity.PicaResultCode;
import com.pica.cloud.foundation.redis.CacheClient;
import com.pica.cloud.foundation.utils.utils.EncryptCreateUtil; import com.pica.cloud.foundation.utils.utils.EncryptCreateUtil;
import com.pica.cloud.foundation.utils.utils.ValidateUtils; import com.pica.cloud.foundation.utils.utils.ValidateUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/** /**
* 账户工具类 * 账户工具类
*/ */
@Component
public class AccountUtils { public class AccountUtils {
@Autowired
private CacheClient cacheClient;
private static final String AUTH_CODE_PREFIX = "authCode-"; private static final String AUTH_CODE_PREFIX = "authCode-";
//手机格式校验 //手机格式校验
...@@ -25,4 +32,23 @@ public class AccountUtils { ...@@ -25,4 +32,23 @@ public class AccountUtils {
return AUTH_CODE_PREFIX + flag + "-" + EncryptCreateUtil.encrypt(mobilePhone); return AUTH_CODE_PREFIX + flag + "-" + EncryptCreateUtil.encrypt(mobilePhone);
} }
//校验验证码
public void checkAuthCode(String mobile, String type, String sysCode) {
String flag = org.apache.commons.lang.StringUtils.isBlank(type) ? "0" : type;
if (org.apache.commons.lang.StringUtils.isBlank(sysCode)) {
throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "短信验证码错误");
}
String authCodeKey = AccountUtils.getAuthCodeKey(mobile, flag);
String cacheCode = cacheClient.get(authCodeKey); //从redis获取验证码
if (org.apache.commons.lang.StringUtils.isBlank(cacheCode)) {
throw new PicaException(PicaResultCode.RESULE_DATA_NONE.code(), "短信验证码已过期,请重新获取");
}
if (!org.apache.commons.lang.StringUtils.equals(sysCode, cacheCode)) {
throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "短信验证码错误");
}
//清除验证码
cacheClient.del(authCodeKey);
}
} }
...@@ -27,22 +27,13 @@ ...@@ -27,22 +27,13 @@
from accout_info from accout_info
where id = #{id,jdbcType=BIGINT} where id = #{id,jdbcType=BIGINT}
</select> </select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from accout_info <!--通过id更新密码-->
where id = #{id,jdbcType=BIGINT} <update id="updatePasswordById" parameterType="com.pica.cloud.account.account.server.entity.AccountInfo">
</delete> update accout_info set password=#{password,jdbcType=VARCHAR} where id=#{id}
<insert id="insert" parameterType="com.pica.cloud.account.account.server.entity.AccountInfo"> </update>
insert into accout_info (id, password, name,
age, birthday, sex, id_card, <!--插入用户信息-->
reg_time, register_source, delete_flag,
created_id, created_time, modified_id,
modified_time)
values (#{id,jdbcType=BIGINT}, #{password,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
#{age,jdbcType=TINYINT}, #{birthday,jdbcType=DATE}, #{sex,jdbcType=TINYINT}, #{idCard,jdbcType=VARCHAR},
#{regTime,jdbcType=TIMESTAMP}, #{registerSource,jdbcType=INTEGER}, #{deleteFlag,jdbcType=INTEGER},
#{createdId,jdbcType=INTEGER}, #{createdTime,jdbcType=TIMESTAMP}, #{modifiedId,jdbcType=BIGINT},
#{modifiedTime,jdbcType=TIMESTAMP})
</insert>
<insert id="insertSelective" parameterType="com.pica.cloud.account.account.server.entity.AccountInfo"> <insert id="insertSelective" parameterType="com.pica.cloud.account.account.server.entity.AccountInfo">
insert into accout_info insert into accout_info
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
...@@ -135,13 +126,7 @@ ...@@ -135,13 +126,7 @@
</trim> </trim>
</insert> </insert>
<!--通过id更新密码--> <!--更新用户信息-->
<update id="updatePasswordById" parameterType="com.pica.cloud.account.account.server.entity.AccountInfo">
update accout_info set password=#{password,jdbcType=VARCHAR} where id=#{id}
</update>
<update id="updateByPrimaryKeySelective" parameterType="com.pica.cloud.account.account.server.entity.AccountInfo"> <update id="updateByPrimaryKeySelective" parameterType="com.pica.cloud.account.account.server.entity.AccountInfo">
update accout_info update accout_info
<set> <set>
...@@ -187,6 +172,29 @@ ...@@ -187,6 +172,29 @@
</set> </set>
where id = #{id,jdbcType=BIGINT} where id = #{id,jdbcType=BIGINT}
</update> </update>
<insert id="insert" parameterType="com.pica.cloud.account.account.server.entity.AccountInfo">
insert into accout_info (id, password, name,
age, birthday, sex, id_card,
reg_time, register_source, delete_flag,
created_id, created_time, modified_id,
modified_time)
values (#{id,jdbcType=BIGINT}, #{password,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
#{age,jdbcType=TINYINT}, #{birthday,jdbcType=DATE}, #{sex,jdbcType=TINYINT}, #{idCard,jdbcType=VARCHAR},
#{regTime,jdbcType=TIMESTAMP}, #{registerSource,jdbcType=INTEGER}, #{deleteFlag,jdbcType=INTEGER},
#{createdId,jdbcType=INTEGER}, #{createdTime,jdbcType=TIMESTAMP}, #{modifiedId,jdbcType=BIGINT},
#{modifiedTime,jdbcType=TIMESTAMP})
</insert>
<update id="updateByPrimaryKey" parameterType="com.pica.cloud.account.account.server.entity.AccountInfo"> <update id="updateByPrimaryKey" parameterType="com.pica.cloud.account.account.server.entity.AccountInfo">
update accout_info update accout_info
set password = #{password,jdbcType=VARCHAR}, set password = #{password,jdbcType=VARCHAR},
......
<?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.AccountProductMapper" >
<resultMap id="BaseResultMap" type="com.pica.cloud.account.account.server.entity.AccountProduct" >
<id column="id" property="id" jdbcType="BIGINT" />
<result column="acct_id" property="acctId" jdbcType="BIGINT" />
<result column="product_type" property="productType" jdbcType="INTEGER" />
<result column="delete_flag" property="deleteFlag" jdbcType="INTEGER" />
<result column="created_id" property="createdId" jdbcType="BIGINT" />
<result column="created_time" property="createdTime" jdbcType="TIMESTAMP" />
<result column="modified_id" property="modifiedId" jdbcType="BIGINT" />
<result column="modified_time" property="modifiedTime" jdbcType="TIMESTAMP" />
</resultMap>
<sql id="Base_Column_List" >
id, acct_id, product_type, 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 account_product
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long" >
delete from account_product
where id = #{id,jdbcType=BIGINT}
</delete>
<insert id="insert" parameterType="com.pica.cloud.account.account.server.entity.AccountProduct" >
insert into account_product (id, acct_id, product_type,
delete_flag, created_id, created_time,
modified_id, modified_time)
values (#{id,jdbcType=BIGINT}, #{acctId,jdbcType=BIGINT}, #{productType,jdbcType=INTEGER},
#{deleteFlag,jdbcType=INTEGER}, #{createdId,jdbcType=BIGINT}, #{createdTime,jdbcType=TIMESTAMP},
#{modifiedId,jdbcType=BIGINT}, #{modifiedTime,jdbcType=TIMESTAMP})
</insert>
<insert id="insertSelective" parameterType="com.pica.cloud.account.account.server.entity.AccountProduct" >
insert into account_product
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="acctId != null" >
acct_id,
</if>
<if test="productType != null" >
product_type,
</if>
<if test="deleteFlag != null" >
delete_flag,
</if>
<if test="createdId != null" >
created_id,
</if>
<if test="createdTime != null" >
created_time,
</if>
<if test="modifiedId != null" >
modified_id,
</if>
<if test="modifiedTime != null" >
modified_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=BIGINT},
</if>
<if test="acctId != null" >
#{acctId,jdbcType=BIGINT},
</if>
<if test="productType != null" >
#{productType,jdbcType=INTEGER},
</if>
<if test="deleteFlag != null" >
#{deleteFlag,jdbcType=INTEGER},
</if>
<if test="createdId != null" >
#{createdId,jdbcType=BIGINT},
</if>
<if test="createdTime != null" >
#{createdTime,jdbcType=TIMESTAMP},
</if>
<if test="modifiedId != null" >
#{modifiedId,jdbcType=BIGINT},
</if>
<if test="modifiedTime != null" >
#{modifiedTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.pica.cloud.account.account.server.entity.AccountProduct" >
update account_product
<set >
<if test="acctId != null" >
acct_id = #{acctId,jdbcType=BIGINT},
</if>
<if test="productType != null" >
product_type = #{productType,jdbcType=INTEGER},
</if>
<if test="deleteFlag != null" >
delete_flag = #{deleteFlag,jdbcType=INTEGER},
</if>
<if test="createdId != null" >
created_id = #{createdId,jdbcType=BIGINT},
</if>
<if test="createdTime != null" >
created_time = #{createdTime,jdbcType=TIMESTAMP},
</if>
<if test="modifiedId != null" >
modified_id = #{modifiedId,jdbcType=BIGINT},
</if>
<if test="modifiedTime != null" >
modified_time = #{modifiedTime,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="com.pica.cloud.account.account.server.entity.AccountProduct" >
update account_product
set acct_id = #{acctId,jdbcType=BIGINT},
product_type = #{productType,jdbcType=INTEGER},
delete_flag = #{deleteFlag,jdbcType=INTEGER},
created_id = #{createdId,jdbcType=BIGINT},
created_time = #{createdTime,jdbcType=TIMESTAMP},
modified_id = #{modifiedId,jdbcType=BIGINT},
modified_time = #{modifiedTime,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.AccountUnionMapper">
<resultMap id="BaseResultMap" type="com.pica.cloud.account.account.server.entity.AccountUnion">
<id column="id" property="id" jdbcType="BIGINT"/>
<result column="acct_id" property="acctId" jdbcType="BIGINT"/>
<result column="union_type" property="unionType" jdbcType="INTEGER"/>
<result column="union_id" property="unionId" jdbcType="VARCHAR"/>
<result column="nickname" property="nickname" jdbcType="VARCHAR"/>
<result column="head_img_url" property="headImgUrl" jdbcType="VARCHAR"/>
<result column="delete_flag" property="deleteFlag" jdbcType="INTEGER"/>
<result column="created_id" property="createdId" jdbcType="BIGINT"/>
<result column="created_time" property="createdTime" jdbcType="TIMESTAMP"/>
<result column="modified_id" property="modifiedId" jdbcType="BIGINT"/>
<result column="modified_time" property="modifiedTime" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id, acct_id, union_type, union_id, nickname, head_img_url, delete_flag, created_id,
created_time, modified_id, modified_time
</sql>
<!--查询是否绑定过微信-->
<select id="selectByUnionIdAndAcctId" parameterType="com.pica.cloud.account.account.server.req.SysCodeReq" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from account_union
where acct_id=#{acctId} and union_id =#{unionId}
</select>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">
select
<include refid="Base_Column_List"/>
from account_union
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from account_union
where id = #{id,jdbcType=BIGINT}
</delete>
<insert id="insert" parameterType="com.pica.cloud.account.account.server.entity.AccountUnion">
insert into account_union (id, acct_id, union_type,
union_id, nickname, head_img_url,
delete_flag, created_id, created_time,
modified_id, modified_time)
values (#{id,jdbcType=BIGINT}, #{acctId,jdbcType=BIGINT}, #{unionType,jdbcType=INTEGER},
#{unionId,jdbcType=VARCHAR}, #{nickname,jdbcType=VARCHAR}, #{headImgUrl,jdbcType=VARCHAR},
#{deleteFlag,jdbcType=INTEGER}, #{createdId,jdbcType=BIGINT}, #{createdTime,jdbcType=TIMESTAMP},
#{modifiedId,jdbcType=BIGINT}, #{modifiedTime,jdbcType=TIMESTAMP})
</insert>
<insert id="insertSelective" parameterType="com.pica.cloud.account.account.server.entity.AccountUnion">
insert into account_union
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="acctId != null">
acct_id,
</if>
<if test="unionType != null">
union_type,
</if>
<if test="unionId != null">
union_id,
</if>
<if test="nickname != null">
nickname,
</if>
<if test="headImgUrl != null">
head_img_url,
</if>
<if test="deleteFlag != null">
delete_flag,
</if>
<if test="createdId != null">
created_id,
</if>
<if test="createdTime != null">
created_time,
</if>
<if test="modifiedId != null">
modified_id,
</if>
<if test="modifiedTime != null">
modified_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=BIGINT},
</if>
<if test="acctId != null">
#{acctId,jdbcType=BIGINT},
</if>
<if test="unionType != null">
#{unionType,jdbcType=INTEGER},
</if>
<if test="unionId != null">
#{unionId,jdbcType=VARCHAR},
</if>
<if test="nickname != null">
#{nickname,jdbcType=VARCHAR},
</if>
<if test="headImgUrl != null">
#{headImgUrl,jdbcType=VARCHAR},
</if>
<if test="deleteFlag != null">
#{deleteFlag,jdbcType=INTEGER},
</if>
<if test="createdId != null">
#{createdId,jdbcType=BIGINT},
</if>
<if test="createdTime != null">
#{createdTime,jdbcType=TIMESTAMP},
</if>
<if test="modifiedId != null">
#{modifiedId,jdbcType=BIGINT},
</if>
<if test="modifiedTime != null">
#{modifiedTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.pica.cloud.account.account.server.entity.AccountUnion">
update account_union
<set>
<if test="acctId != null">
acct_id = #{acctId,jdbcType=BIGINT},
</if>
<if test="unionType != null">
union_type = #{unionType,jdbcType=INTEGER},
</if>
<if test="unionId != null">
union_id = #{unionId,jdbcType=VARCHAR},
</if>
<if test="nickname != null">
nickname = #{nickname,jdbcType=VARCHAR},
</if>
<if test="headImgUrl != null">
head_img_url = #{headImgUrl,jdbcType=VARCHAR},
</if>
<if test="deleteFlag != null">
delete_flag = #{deleteFlag,jdbcType=INTEGER},
</if>
<if test="createdId != null">
created_id = #{createdId,jdbcType=BIGINT},
</if>
<if test="createdTime != null">
created_time = #{createdTime,jdbcType=TIMESTAMP},
</if>
<if test="modifiedId != null">
modified_id = #{modifiedId,jdbcType=BIGINT},
</if>
<if test="modifiedTime != null">
modified_time = #{modifiedTime,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="com.pica.cloud.account.account.server.entity.AccountUnion">
update account_union
set acct_id = #{acctId,jdbcType=BIGINT},
union_type = #{unionType,jdbcType=INTEGER},
union_id = #{unionId,jdbcType=VARCHAR},
nickname = #{nickname,jdbcType=VARCHAR},
head_img_url = #{headImgUrl,jdbcType=VARCHAR},
delete_flag = #{deleteFlag,jdbcType=INTEGER},
created_id = #{createdId,jdbcType=BIGINT},
created_time = #{createdTime,jdbcType=TIMESTAMP},
modified_id = #{modifiedId,jdbcType=BIGINT},
modified_time = #{modifiedTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>
\ No newline at end of file
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册