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

201960820 账号功能

上级 ced1f707
流水线 #13511 已失败 于阶段
......@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.pica.cloud.account.account.server.configuration.PropertiesConfiguration;
import com.pica.cloud.account.account.server.constants.Constants;
import com.pica.cloud.account.account.server.entity.AccountUser;
import com.pica.cloud.account.account.server.util.PICAPSendMsgModel;
import com.pica.cloud.foundation.entity.PicaException;
import com.pica.cloud.foundation.entity.PicaResultCode;
......@@ -17,10 +18,12 @@ import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.*;
/**
* controller基类
*
* @author andong
* @create 2019/5/21
*/
......@@ -41,6 +44,18 @@ public abstract class AccountBaseController extends BaseController {
}
}
/**
* 账户信息
*
* @return
*/
public AccountUser getAccountUser() {
// TODO: 2019/8/20 未实现
//无论是否登录,当前对象都应该存在。
return new AccountUser();
}
//获取deviceInfo信息
public String getDeviceInfo(String key) {
String deviceInfo = super.getDeviceInfo();
......@@ -76,7 +91,7 @@ public abstract class AccountBaseController extends BaseController {
try {
Map<String, String> data = Object2Map.objectToMapString("yyyy-MM-dd HH:mm:ss", picaUser, new String[0]);
data.put("sysCode", sysCode);
return super.getRedisClient().saveToken(data, 365*24*3600); //token有效期365天
return super.getRedisClient().saveToken(data, 365 * 24 * 3600); //token有效期365天
} catch (Exception ex) {
logger.error("保存token失败,doctorId: {}", picaUser.getId());
return StringUtils.EMPTY;
......
......@@ -43,4 +43,8 @@ public class AccountInfoController {
return PicaResponse.toResponse(accountInfoService.getDoctorIds(req));
}
}
package com.pica.cloud.account.account.server.controller;
import com.pica.cloud.account.account.server.entity.AccountUser;
import com.pica.cloud.account.account.server.service.AccountLoginOutService;
import com.pica.cloud.foundation.entity.PicaResponse;
import com.pica.cloud.foundation.redis.CacheClient;
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.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@Api(value = "登录接口")
@RestController
public class AccountLoginController extends AccountBaseController {
@Autowired
private AccountLoginOutService accountLoginOutService;
@Autowired
private CacheClient cacheClient;
/**
* 退出登录接口
*
* @param sourceType
* @return
*/
@ApiOperation(value = "退出登录操作")
@PostMapping("/logout")
public PicaResponse loginOut(@RequestParam("sourceType") Integer sourceType) {
//只有在登录状态下才能调用此接口;
AccountUser accountUser = super.getAccountUser();
String token = accountUser.getToken();
if (StringUtils.isNotEmpty(token)) {
//记录日志
accountLoginOutService.insertLoginLog(accountUser);
//清除token信息
if (cacheClient.deleteToken(token)) {
return PicaResponse.toResponse();
}
}
return null;
}
}
package com.pica.cloud.account.account.server.controller;
import com.alibaba.fastjson.JSONObject;
import com.pica.cloud.account.account.server.entity.AccountUser;
import com.pica.cloud.account.account.server.entity.AcctUserInfo;
import com.pica.cloud.account.account.server.service.AccountUserInfoService;
import com.pica.cloud.account.account.server.util.RSAUtils;
import com.pica.cloud.foundation.entity.PicaResponse;
import com.pica.cloud.foundation.utils.entity.PicaUser;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 用户信息
*/
@Api(value = "用户信息接口")
@RequestMapping(value = "/user/info")
@RestController
public class AccountUserInfoController extends AccountBaseController {
@Autowired
private AccountUserInfoService accountUserInfoService;
/**
* 修改用户信息接口
*
* @param info
* @return
*/
@ApiOperation(value = "修改用户信息接口")
@PutMapping(value = "")
public PicaResponse updateUserInfo(String info) {
AccountUser accountUser = super.getAccountUser();
//如何获取acct_id 只有注册成功才有
try {
String str = RSAUtils.decrypt(info, RSAUtils.getPrivateKey());
AcctUserInfo acctUserInfo = JSONObject.parseObject(str, AcctUserInfo.class);
accountUserInfoService.updateUserInfo(acctUserInfo);
return PicaResponse.toResponse();
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
/**
* 获取用户信息接口
*
* @return
*/
@ApiOperation(value = "获取用户信息接口")
@GetMapping(value = "")
public PicaResponse<AcctUserInfo> getUserInfo() {
AccountUser accountUser = super.getAccountUser();
Integer id = accountUser.getId();
AcctUserInfo userInfo = accountUserInfoService.getUserInfo(id);
if (userInfo != null) {
return PicaResponse.toResponse(userInfo);
}
return null;
}
}
package com.pica.cloud.account.account.server.controller;
import com.alibaba.fastjson.JSONObject;
import com.pica.cloud.account.account.server.entity.AccountUser;
import com.pica.cloud.account.account.server.req.ModifyMobileReq;
import com.pica.cloud.account.account.server.service.ModifyMobileService;
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.entity.PicaResultCode;
import com.pica.cloud.foundation.redis.CacheClient;
import com.pica.cloud.foundation.utils.utils.EncryptCreateUtil;
import com.pica.cloud.foundation.utils.utils.ValidateUtils;
import io.swagger.annotations.Api;
import org.apache.commons.lang3.StringUtils;
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;
/**
* 修改手机号
*/
@Api(value = "修改手机号")
@RequestMapping(value = "/mobile/modify")
@RestController
public class ModifyMobileController extends AccountBaseController {
private final String AUTH_CODE_PREFIX = "authCode-";
@Autowired
private CacheClient cacheClient;
@Autowired
private ModifyMobileService modifyMobileService;
/**
* 修改手机号
*
* @return
*/
@PostMapping(value = "")
public PicaResponse ModifyMobile(@RequestBody String params) throws Exception {
//加密存储,登录状态下修改手机号,手机号正则表达式,如何校验验证码?
AccountUser accountUser = null;
accountUser = super.getAccountUser();
String token = accountUser.getToken();
if (StringUtils.isNotEmpty(token)) {
String json = RSAUtils.decrypt(params, RSAUtils.getPrivateKey());
ModifyMobileReq modifyMobileReq = JSONObject.parseObject(json, ModifyMobileReq.class);
String mobile = modifyMobileReq.getMobile();
this.checkMobilePhone(mobile);
//flag表示验证码类型,3表示修改手机号
modifyMobileReq.setFlag("3");
this.checkAuthCode(modifyMobileReq);
int acctId = accountUser.getAcctId();
int row = modifyMobileService.modifyMobile(acctId, EncryptCreateUtil.encrypt(mobile));
if (row == 1) {
return PicaResponse.toResponse("手机号修改成功");
}
} else {
throw new PicaException("请重新登陆");
}
return null;
}
//校验验证码
private void checkAuthCode(ModifyMobileReq req) {
String flag = StringUtils.isBlank(req.getFlag()) ? "0" : req.getFlag();
if (StringUtils.isBlank(req.getAuthCode())) {
throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "短信验证码错误");
}
String authCodeKey = this.getAuthCodeKey(req.getMobile(), flag);
String cacheCode = cacheClient.get(authCodeKey); //从redis获取验证码
if (StringUtils.isBlank(cacheCode)) {
throw new PicaException(PicaResultCode.RESULE_DATA_NONE.code(), "短信验证码已过期,请重新获取");
}
if (!StringUtils.equals(req.getAuthCode(), cacheCode)) {
throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "短信验证码错误");
}
cacheClient.del(authCodeKey); //清除验证码
}
//手机格式校验
private void checkMobilePhone(String mobilePhone) {
if (StringUtils.isBlank(mobilePhone) || !ValidateUtils.isMobile(mobilePhone)) {
throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "请输入正确的手机号");
}
}
//获取验证码redis key
private String getAuthCodeKey(String mobilePhone, String flag) {
return AUTH_CODE_PREFIX + flag + "-" + EncryptCreateUtil.encrypt(mobilePhone);
}
}
package com.pica.cloud.account.account.server.controller;
import com.alibaba.fastjson.JSONObject;
import com.pica.cloud.account.account.server.entity.AccountUser;
import com.pica.cloud.account.account.server.req.ModifyPasswordReq;
import com.pica.cloud.account.account.server.service.PasswordService;
import com.pica.cloud.account.account.server.util.RSAUtils;
import com.pica.cloud.foundation.entity.PicaException;
import com.pica.cloud.foundation.entity.PicaResponse;
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.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Api(description = "密码资源")
@RestController
@RequestMapping("/password")
public class PasswordController extends AccountBaseController {
@Autowired
private PasswordService passwordService;
@ApiOperation(value = "修改密码")
@PostMapping(value = "/modify")
public PicaResponse modifyPassword(@RequestBody String params) throws Exception {
AccountUser accountUser = super.getAccountUser();
String token = accountUser.getToken();
if (StringUtils.isNotEmpty(token)) {
String json = RSAUtils.decrypt(params, RSAUtils.getPrivateKey());
ModifyPasswordReq modifyPasswordReq = JSONObject.parseObject(json, ModifyPasswordReq.class);
modifyPasswordReq.setId(accountUser.getAcctId());
passwordService.modifyPassword(modifyPasswordReq);
return PicaResponse.toResponse("密码修改成功");
} else {
throw new PicaException("请登陆");
}
}
}
package com.pica.cloud.account.account.server.entity;
import java.util.Date;
public class AccountContact {
private Long id;
private Integer acctId;
private String mobilePhone;
private Integer deleteFlag;
private Long createdId;
private Date createdTime;
private Long modifiedId;
private Date modifiedTime;
public AccountContact() {
this.deleteFlag = 1;
this.createdTime = new Date();
this.modifiedTime = new Date();
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
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 == null ? null : mobilePhone.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
package com.pica.cloud.account.account.server.entity;
import java.util.Date;
public class AccountInfo {
private Long id;
private String password;
private String name;
private int age;
private Date birthday;
private Byte sex;
private String idCard;
private Date regTime;
private Integer registerSource;
private Integer deleteFlag;
private Integer createdId;
private Date createdTime;
private Long modifiedId;
private Date modifiedTime;
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password == null ? null : password.trim();
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name == null ? null : name.trim();
}
public Date getBirthday() {
return birthday;
}
public void setBirthday(Date birthday) {
this.birthday = birthday;
}
public Byte getSex() {
return sex;
}
public void setSex(Byte sex) {
this.sex = sex;
}
public String getIdCard() {
return idCard;
}
public void setIdCard(String idCard) {
this.idCard = idCard == null ? null : idCard.trim();
}
public Date getRegTime() {
return regTime;
}
public void setRegTime(Date regTime) {
this.regTime = regTime;
}
public Integer getRegisterSource() {
return registerSource;
}
public void setRegisterSource(Integer registerSource) {
this.registerSource = registerSource;
}
public Integer getDeleteFlag() {
return deleteFlag;
}
public void setDeleteFlag(Integer deleteFlag) {
this.deleteFlag = deleteFlag;
}
public Integer getCreatedId() {
return createdId;
}
public void setCreatedId(Integer 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 com.pica.cloud.foundation.utils.entity.PicaUser;
public class AccountUser extends PicaUser {
//账户id
private int acctId;
//渠道来源
private int loginFrom;
//平台来源
private int loginPlatform;
//账户名
private String acctName;
//登录ip
private String loginIp;
public int getAcctId() {
return acctId;
}
public void setAcctId(int acctId) {
this.acctId = acctId;
}
public int getLoginFrom() {
return loginFrom;
}
public void setLoginFrom(int loginFrom) {
this.loginFrom = loginFrom;
}
public int getLoginPlatform() {
return loginPlatform;
}
public void setLoginPlatform(int loginPlatform) {
this.loginPlatform = loginPlatform;
}
public String getAcctName() {
return acctName;
}
public void setAcctName(String acctName) {
this.acctName = acctName;
}
public String getLoginIp() {
return loginIp;
}
public void setLoginIp(String loginIp) {
this.loginIp = loginIp;
}
}
package com.pica.cloud.account.account.server.entity;
import java.util.Date;
/**
* 用户信息表
*/
public class AcctUserInfo {
private Integer id;
private Integer acctId;
private String villageName;
private Long villageId;
private String townName;
private Long townId;
private String countyName;
private Long countyId;
private String cityName;
private Long cityId;
private String provinceName;
private Long provinceId;
private Long country;
private String headImgUrl;
private String address;
private String patientAddress;
private String telephone;
private String socialCard;
private String workUnit;
private String healthFileNumber;
private String paymentType;
private String remarks;
private String email;
private String nation;
private Integer createId;
private Date createTime;
private Integer modifyId;
private Date modifyTime;
private Integer deleteFlag;
public Integer getDeleteFlag() {
return deleteFlag;
}
public void setDeleteFlag(Integer deleteFlag) {
this.deleteFlag = deleteFlag;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getAcctId() {
return acctId;
}
public void setAcctId(Integer acctId) {
this.acctId = acctId;
}
public String getVillageName() {
return villageName;
}
public void setVillageName(String villageName) {
this.villageName = villageName == null ? null : villageName.trim();
}
public Long getVillageId() {
return villageId;
}
public void setVillageId(Long villageId) {
this.villageId = villageId;
}
public String getTownName() {
return townName;
}
public void setTownName(String townName) {
this.townName = townName == null ? null : townName.trim();
}
public Long getTownId() {
return townId;
}
public void setTownId(Long townId) {
this.townId = townId;
}
public String getCountyName() {
return countyName;
}
public void setCountyName(String countyName) {
this.countyName = countyName == null ? null : countyName.trim();
}
public Long getCountyId() {
return countyId;
}
public void setCountyId(Long countyId) {
this.countyId = countyId;
}
public String getCityName() {
return cityName;
}
public void setCityName(String cityName) {
this.cityName = cityName == null ? null : cityName.trim();
}
public Long getCityId() {
return cityId;
}
public void setCityId(Long cityId) {
this.cityId = cityId;
}
public String getProvinceName() {
return provinceName;
}
public void setProvinceName(String provinceName) {
this.provinceName = provinceName == null ? null : provinceName.trim();
}
public Long getProvinceId() {
return provinceId;
}
public void setProvinceId(Long provinceId) {
this.provinceId = provinceId;
}
public Long getCountry() {
return country;
}
public void setCountry(Long country) {
this.country = country;
}
public String getHeadImgUrl() {
return headImgUrl;
}
public void setHeadImgUrl(String headImgUrl) {
this.headImgUrl = headImgUrl == null ? null : headImgUrl.trim();
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address == null ? null : address.trim();
}
public String getPatientAddress() {
return patientAddress;
}
public void setPatientAddress(String patientAddress) {
this.patientAddress = patientAddress == null ? null : patientAddress.trim();
}
public String getTelephone() {
return telephone;
}
public void setTelephone(String telephone) {
this.telephone = telephone == null ? null : telephone.trim();
}
public String getSocialCard() {
return socialCard;
}
public void setSocialCard(String socialCard) {
this.socialCard = socialCard == null ? null : socialCard.trim();
}
public String getWorkUnit() {
return workUnit;
}
public void setWorkUnit(String workUnit) {
this.workUnit = workUnit == null ? null : workUnit.trim();
}
public String getHealthFileNumber() {
return healthFileNumber;
}
public void setHealthFileNumber(String healthFileNumber) {
this.healthFileNumber = healthFileNumber == null ? null : healthFileNumber.trim();
}
public String getPaymentType() {
return paymentType;
}
public void setPaymentType(String paymentType) {
this.paymentType = paymentType == null ? null : paymentType.trim();
}
public String getRemarks() {
return remarks;
}
public void setRemarks(String remarks) {
this.remarks = remarks == null ? null : remarks.trim();
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email == null ? null : email.trim();
}
public String getNation() {
return nation;
}
public void setNation(String nation) {
this.nation = nation == null ? null : nation.trim();
}
public Integer getCreateId() {
return createId;
}
public void setCreateId(Integer createId) {
this.createId = createId;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Integer getModifyId() {
return modifyId;
}
public void setModifyId(Integer modifyId) {
this.modifyId = modifyId;
}
public Date getModifyTime() {
return modifyTime;
}
public void setModifyTime(Date modifyTime) {
this.modifyTime = modifyTime;
}
}
\ No newline at end of file
package com.pica.cloud.account.account.server.entity;
import java.util.Date;
/**
* 用户信息变更记录表
*/
public class AcctUserInfoChangeLog {
private Long id;
private Integer acctId;
private String villageName;
private Long villageId;
private String townName;
private Long townId;
private String countyName;
private Long countyId;
private String cityName;
private Long cityId;
private String provinceName;
private Long provinceId;
private Long country;
private String headImgUrl;
private String address;
private String patientAddress;
private String telephone;
private String socialCard;
private String workUnit;
private String healthFileNumber;
private String paymentType;
private String remarks;
private String email;
private String nation;
private Integer createId;
private Date createTime;
private Integer modifyId;
private Date modifyTime;
private Byte deleteFlag;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Integer getAcctId() {
return acctId;
}
public void setAcctId(Integer acctId) {
this.acctId = acctId;
}
public String getVillageName() {
return villageName;
}
public void setVillageName(String villageName) {
this.villageName = villageName == null ? null : villageName.trim();
}
public Long getVillageId() {
return villageId;
}
public void setVillageId(Long villageId) {
this.villageId = villageId;
}
public String getTownName() {
return townName;
}
public void setTownName(String townName) {
this.townName = townName == null ? null : townName.trim();
}
public Long getTownId() {
return townId;
}
public void setTownId(Long townId) {
this.townId = townId;
}
public String getCountyName() {
return countyName;
}
public void setCountyName(String countyName) {
this.countyName = countyName == null ? null : countyName.trim();
}
public Long getCountyId() {
return countyId;
}
public void setCountyId(Long countyId) {
this.countyId = countyId;
}
public String getCityName() {
return cityName;
}
public void setCityName(String cityName) {
this.cityName = cityName == null ? null : cityName.trim();
}
public Long getCityId() {
return cityId;
}
public void setCityId(Long cityId) {
this.cityId = cityId;
}
public String getProvinceName() {
return provinceName;
}
public void setProvinceName(String provinceName) {
this.provinceName = provinceName == null ? null : provinceName.trim();
}
public Long getProvinceId() {
return provinceId;
}
public void setProvinceId(Long provinceId) {
this.provinceId = provinceId;
}
public Long getCountry() {
return country;
}
public void setCountry(Long country) {
this.country = country;
}
public String getHeadImgUrl() {
return headImgUrl;
}
public void setHeadImgUrl(String headImgUrl) {
this.headImgUrl = headImgUrl == null ? null : headImgUrl.trim();
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address == null ? null : address.trim();
}
public String getPatientAddress() {
return patientAddress;
}
public void setPatientAddress(String patientAddress) {
this.patientAddress = patientAddress == null ? null : patientAddress.trim();
}
public String getTelephone() {
return telephone;
}
public void setTelephone(String telephone) {
this.telephone = telephone == null ? null : telephone.trim();
}
public String getSocialCard() {
return socialCard;
}
public void setSocialCard(String socialCard) {
this.socialCard = socialCard == null ? null : socialCard.trim();
}
public String getWorkUnit() {
return workUnit;
}
public void setWorkUnit(String workUnit) {
this.workUnit = workUnit == null ? null : workUnit.trim();
}
public String getHealthFileNumber() {
return healthFileNumber;
}
public void setHealthFileNumber(String healthFileNumber) {
this.healthFileNumber = healthFileNumber == null ? null : healthFileNumber.trim();
}
public String getPaymentType() {
return paymentType;
}
public void setPaymentType(String paymentType) {
this.paymentType = paymentType == null ? null : paymentType.trim();
}
public String getRemarks() {
return remarks;
}
public void setRemarks(String remarks) {
this.remarks = remarks == null ? null : remarks.trim();
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email == null ? null : email.trim();
}
public String getNation() {
return nation;
}
public void setNation(String nation) {
this.nation = nation == null ? null : nation.trim();
}
public Integer getCreateId() {
return createId;
}
public void setCreateId(Integer createId) {
this.createId = createId;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Integer getModifyId() {
return modifyId;
}
public void setModifyId(Integer modifyId) {
this.modifyId = modifyId;
}
public Date getModifyTime() {
return modifyTime;
}
public void setModifyTime(Date modifyTime) {
this.modifyTime = modifyTime;
}
public Byte getDeleteFlag() {
return deleteFlag;
}
public void setDeleteFlag(Byte deleteFlag) {
this.deleteFlag = deleteFlag;
}
}
\ No newline at end of file
package com.pica.cloud.account.account.server.entity;
import java.util.Date;
public class LogPasswordModify {
private Long id;
private String mobilePhone;
private Date modifiedTime;
private Integer modifiedId;
private String oldPwd;
private String newPwd;
private Integer deleteFlag;
private Long createdId;
private Date createdTime;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getMobilePhone() {
return mobilePhone;
}
public void setMobilePhone(String mobilePhone ) {
this.mobilePhone = mobilePhone == null ? null : mobilePhone.trim();
}
public Date getModifiedTime() {
return modifiedTime;
}
public void setModifiedTime(Date modifiedTime) {
this.modifiedTime = modifiedTime;
}
public Integer getModifiedId() {
return modifiedId;
}
public void setModifiedId(Integer modifiedId) {
this.modifiedId = modifiedId;
}
public String getOldPwd() {
return oldPwd;
}
public void setOldPwd(String oldPwd) {
this.oldPwd = oldPwd == null ? null : oldPwd.trim();
}
public String getNewPwd() {
return newPwd;
}
public void setNewPwd(String newPwd) {
this.newPwd = newPwd == null ? null : newPwd.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;
}
}
\ No newline at end of file
package com.pica.cloud.account.account.server.entity;
import java.util.Date;
public class LoginLog {
public LoginLog() {
this.loginTime = new Date();
this.createTime = new Date();
this.modifyTime = new Date();
this.deleteFlag = 1;
}
private Integer id;
private Integer acctId;
private String acctName;
private Date loginTime;
//用户登录来源:1表示安卓,2表示ios,3表示web,4表示H5登录,5表示admin后台
private Integer loginFrom;
//用户登录方式:1表示验证码登录,2表示密码登录,3表示微信登录,4表示退出登录
private Integer loginType;
private String loginIp;
private Integer loginPlatform;
//登录状态:1、表示登录成功,2表示登录失败,3表示退出登录
private Integer loginStatus;
private Integer createId;
private Date createTime;
private Integer modifyId;
private Date modifyTime;
private Integer deleteFlag;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getAcctId() {
return acctId;
}
public void setAcctId(Integer acctId) {
this.acctId = acctId;
}
public String getAcctName() {
return acctName;
}
public void setAcctName(String acctName) {
this.acctName = acctName;
}
public Date getLoginTime() {
return loginTime;
}
public void setLoginTime(Date loginTime) {
this.loginTime = loginTime;
}
public Integer getLoginFrom() {
return loginFrom;
}
public void setLoginFrom(Integer loginFrom) {
this.loginFrom = loginFrom;
}
public Integer getLoginType() {
return loginType;
}
public void setLoginType(Integer loginType) {
this.loginType = loginType;
}
public String getLoginIp() {
return loginIp;
}
public void setLoginIp(String loginIp) {
this.loginIp = loginIp;
}
public Integer getLoginPlatform() {
return loginPlatform;
}
public void setLoginPlatform(Integer loginPlatform) {
this.loginPlatform = loginPlatform;
}
public Integer getLoginStatus() {
return loginStatus;
}
public void setLoginStatus(Integer loginStatus) {
this.loginStatus = loginStatus;
}
public Integer getCreateId() {
return createId;
}
public void setCreateId(Integer createId) {
this.createId = createId;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Integer getModifyId() {
return modifyId;
}
public void setModifyId(Integer modifyId) {
this.modifyId = modifyId;
}
public Date getModifyTime() {
return modifyTime;
}
public void setModifyTime(Date modifyTime) {
this.modifyTime = modifyTime;
}
}
\ No newline at end of file
package com.pica.cloud.account.account.server.mapper;
import com.pica.cloud.account.account.server.entity.AccountContact;
public interface AccountContactMapper {
/**
* 修改手机号
*
* @param record
* @return
*/
int updateByPrimaryKeySelective(AccountContact record);
}
\ No newline at end of file
package com.pica.cloud.account.account.server.mapper;
import com.pica.cloud.account.account.server.entity.AccountInfo;
public interface AccountDetailsMapper {
int deleteByPrimaryKey(Long id);
int insert(AccountInfo record);
int insertSelective(AccountInfo record);
AccountInfo selectByPrimaryKey(Long id);
int updateByPrimaryKeySelective(AccountInfo record);
int updateByPrimaryKey(AccountInfo record);
/**
* 通过账户id更新密码
*
* @param record
* @return
*/
int updatePasswordById(AccountInfo record);
}
\ No newline at end of file
package com.pica.cloud.account.account.server.mapper;
import com.pica.cloud.account.account.server.entity.AcctUserInfo;
public interface AcctUserInfoMapper {
int deleteByPrimaryKey(Integer id);
int insert(AcctUserInfo record);
int insertSelective(AcctUserInfo record);
AcctUserInfo selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(AcctUserInfo record);
int updateByPrimaryKey(AcctUserInfo record);
}
\ No newline at end of file
package com.pica.cloud.account.account.server.mapper;
import com.pica.cloud.account.account.server.entity.LogPasswordModify;
public interface LogPasswordModifyMapper {
int deleteByPrimaryKey(Long id);
int insert(LogPasswordModify record);
int insertSelective(LogPasswordModify record);
LogPasswordModify selectByPrimaryKey(Long id);
int updateByPrimaryKeySelective(LogPasswordModify record);
int updateByPrimaryKey(LogPasswordModify record);
}
\ No newline at end of file
package com.pica.cloud.account.account.server.mapper;
import com.pica.cloud.account.account.server.entity.LoginLog;
public interface LoginLogMapper {
int insert(LoginLog record);
int insertSelective(LoginLog 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(description = "修改手机号")
public class ModifyMobileReq {
@ApiModelProperty(value = "手机号")
private String mobile;
@ApiModelProperty(value = "验证码")
private String authCode;
@ApiModelProperty(value = "验证码类型")
private String flag;
public String getMobile() {
return mobile;
}
public void setMobile(String mobile) {
this.mobile = mobile;
}
public String getAuthCode() {
return authCode;
}
public void setAuthCode(String authCode) {
this.authCode = authCode;
}
public String getFlag() {
return flag;
}
public void setFlag(String flag) {
this.flag = flag;
}
}
package com.pica.cloud.account.account.server.req;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
@ApiModel(description = "修改密码")
public class ModifyPasswordReq {
@ApiModelProperty("账户id")
private int id;
@ApiModelProperty("旧密码")
private String oldPsw;
@ApiModelProperty("新密码")
private String newPsw;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getOldPsw() {
return oldPsw;
}
public void setOldPsw(String oldPsw) {
this.oldPsw = oldPsw;
}
public String getNewPsw() {
return newPsw;
}
public void setNewPsw(String newPsw) {
this.newPsw = newPsw;
}
}
package com.pica.cloud.account.account.server.service;
import com.pica.cloud.account.account.server.entity.AccountUser;
import com.pica.cloud.account.account.server.entity.LoginLog;
/**
* 退出登录
*/
public interface AccountLoginOutService {
void insertLoginLog(AccountUser accountUser);
}
package com.pica.cloud.account.account.server.service;
import com.pica.cloud.account.account.server.entity.AcctUserInfo;
public interface AccountUserInfoService {
/**
* 更新用户信息
*
* @param acctUserInfo
* @return
*/
int updateUserInfo(AcctUserInfo acctUserInfo);
/**
* 获取用户信息
* @param id
* @return
*/
AcctUserInfo getUserInfo(Integer id);
}
package com.pica.cloud.account.account.server.service;
public interface ModifyMobileService {
int modifyMobile(Integer acctId,String mobile);
}
package com.pica.cloud.account.account.server.service;
import com.pica.cloud.account.account.server.entity.AccountContact;
import com.pica.cloud.account.account.server.mapper.AccountContactMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class ModifyMobileServiceImpl implements ModifyMobileService {
@Autowired
private AccountContactMapper accountContactMapper;
@Override
public int modifyMobile(Integer acctId,String mobile) {
AccountContact accountContact = new AccountContact();
accountContact.setAcctId(acctId);
accountContact.setMobilePhone(mobile);
accountContact.setCreatedId(acctId.longValue());
accountContact.setModifiedId(acctId.longValue());
return accountContactMapper.updateByPrimaryKeySelective(accountContact);
}
}
package com.pica.cloud.account.account.server.service;
import com.pica.cloud.account.account.server.req.ModifyPasswordReq;
public interface PasswordService {
/**
* 修改密码接口
*
* @param modifyPasswordReq
* @return
*/
void modifyPassword(ModifyPasswordReq modifyPasswordReq);
}
package com.pica.cloud.account.account.server.service.impl;
import com.pica.cloud.account.account.server.entity.AccountUser;
import com.pica.cloud.account.account.server.entity.LoginLog;
import com.pica.cloud.account.account.server.mapper.LoginLogMapper;
import com.pica.cloud.account.account.server.service.AccountLoginOutService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class AccountLoginOutServiceImpl implements AccountLoginOutService {
@Autowired
private LoginLogMapper loginLogMapper;
@Override
public void insertLoginLog(AccountUser accountUser) {
LoginLog loginLog = new LoginLog();
loginLog.setAcctId(accountUser.getAcctId());
loginLog.setAcctName(accountUser.getName());
loginLog.setCreateId(accountUser.getId());
loginLog.setModifyId(accountUser.getId());
loginLog.setLoginFrom(accountUser.getLoginFrom());
loginLog.setLoginIp(accountUser.getLoginIp());
loginLog.setLoginPlatform(accountUser.getLoginPlatform());
loginLog.setLoginStatus(3);
loginLog.setLoginType(4);
loginLogMapper.insertSelective(loginLog);
}
}
package com.pica.cloud.account.account.server.service.impl;
import com.pica.cloud.account.account.server.entity.AcctUserInfo;
import com.pica.cloud.account.account.server.mapper.AcctUserInfoMapper;
import com.pica.cloud.account.account.server.service.AccountUserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class AccountUserInfoServiceImpl implements AccountUserInfoService {
@Autowired
private AcctUserInfoMapper acctUserInfoMapper;
@Override
public int updateUserInfo(AcctUserInfo acctUserInfo) {
//todo:保留字段怎么处理? 时间修改人等
//更新用户信息
int result = acctUserInfoMapper.updateByPrimaryKeySelective(acctUserInfo);
//把更新日志插入到记录表中
Integer acctId = acctUserInfo.getAcctId();
//todo:两个实体怎么转化? 不可能把数据全部取出来赋值吧
AcctUserInfo newAcctUserInfo = acctUserInfoMapper.selectByPrimaryKey(acctId);
acctUserInfoMapper.insert(newAcctUserInfo);
return acctId;
}
@Override
public AcctUserInfo getUserInfo(Integer id) {
return acctUserInfoMapper.selectByPrimaryKey(id);
}
}
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.req.ModifyPasswordReq;
import com.pica.cloud.account.account.server.service.PasswordService;
import com.sun.xml.internal.bind.v2.TODO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class PasswordServiceImpl implements PasswordService {
@Autowired
private AccountDetailsMapper accountDetailsMapper;
@Override
public void modifyPassword(ModifyPasswordReq modifyPasswordReq) {
Integer id = modifyPasswordReq.getId();
AccountInfo accountInfo = new AccountInfo();
accountInfo.setId(id.longValue());
accountInfo.setPassword(modifyPasswordReq.getOldPsw());
accountDetailsMapper.updatePasswordById(accountInfo);
//记录密码更新日志
// TODO: 2019/8/20
}
}
package com.pica.cloud.account.account.server.util;
import org.apache.tomcat.util.codec.binary.Base64;
import javax.crypto.Cipher;
import java.io.ByteArrayOutputStream;
import java.security.*;
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.X509EncodedKeySpec;
/**
* RSA加解密工具类
*/
public class RSAUtils {
/**
* RSA最大加密明文大小
*/
private static final int MAX_ENCRYPT_BLOCK = 117;
/**
* RSA最大解密密文大小
*/
private static final int MAX_DECRYPT_BLOCK = 128;
/**
* 不能修改
*/
private static final String publicKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCOzS18i+vI6UdPB3snRz1BzwPyaLRHPwlT4a3lu" +
"9ETUDbe2yKH+4lriAJpUOEA7oxEF+rucoDpFFcLMt3wx9yqnFNkyhz5FRt7ijUskzJHEHla/uPDyaenAEjYZtToIsUlhlmTSpDtQVXAoXIl5/" +
"JF1QcdRpxGJrSwn5QgmXaZ+QIDAQAB";
/**
* 不能修改
*/
private static final String privateKey = "MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAI7NLXyL68jpR08HeydHPUHPA/JotEc/" +
"CVPhreW70RNQNt7bIof7iWuIAmlQ4QDujEQX6u5ygOkUVwsy3fDH3KqcU2TKHPkVG3uKNSyTMkcQeVr+48PJp6cASNhm1OgixSWGWZNKkO1BVcC" +
"hciXn8kXVBx1GnEYmtLCflCCZdpn5AgMBAAECgYBJp6Sdh+IO19vy9E3ePY1oAynq/3x0/xuFi3LReuVlC8uxeN+/ucrwjs+HmLLlcyUf/iIr6R" +
"16mwYmfY8iIUQ8ZOCM8Wfqw/1l3WpsUygU08O8JKj9mZJmb8cmLhe7ldL/I5mdLt/VqQExemEnDJVp2B1Cj095P40Ug3aH4j/UcQJBAPJvIlKP8" +
"oXP282gwQQD+dulTsVk3o5tziJcp2CsS3O+3aIa/mIYrxKlifdex7I6s7VPqSLXhJE+W/aplvFDJ00CQQCWys6iQfsGvXlwnhIL0aw6yMOlkMgV" +
"xqo03A2aGJMCJQN2XYzuAXG2V54Utd1psGc5im7TlwJfh8ORC3iqCx9dAkAPkADFCgaIfnperdYWGuc8KVVwKHR88iGMZSQ9eXHygSsbD96Kj4k" +
"Viljb71KkZ05H8lAqM2mIJVej8ukEncn1AkAl3iRqJvutQ6PdnjSV9z+zO3u2dldo8I0J3UElM4qnfTgTX4bmtkIiMnqmZM2Hnx8tGhCe3ktgRi" +
"3cnO7edRCZAkEA0Ga3amAEafBN0LEP7UzrWQ3tMoytZ51snEKJHhobGLxzJCxNvwm0KQKEru24THYKGeVYUo/kjYWbiBvm3aEsYw==";
/**
* 获取密钥对
*
* @return 密钥对
*/
public static String[] getKeyPair() {
String[] result = new String[2];
KeyPairGenerator generator = null;
try {
generator = KeyPairGenerator.getInstance("RSA");
generator.initialize(1024);
generator.generateKeyPair();
String privateKey = new String(Base64.encodeBase64(generator.generateKeyPair().getPrivate().getEncoded()));
String publicKey = new String(Base64.encodeBase64(generator.generateKeyPair().getPublic().getEncoded()));
result[0] = publicKey;
result[1] = privateKey;
return result;
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
return null;
}
}
/**
* 通过私钥key获取私钥
*
* @return
* @throws Exception
*/
public static PrivateKey getPrivateKey() {
KeyFactory keyFactory = null;
try {
keyFactory = KeyFactory.getInstance("RSA");
byte[] decodedKey = Base64.decodeBase64(privateKey.getBytes());
PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(decodedKey);
return keyFactory.generatePrivate(keySpec);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
/**
* 通过公钥key获取公钥
*
* @return
* @throws Exception
*/
public static PublicKey getPublicKey() {
KeyFactory keyFactory = null;
try {
keyFactory = KeyFactory.getInstance("RSA");
byte[] decodedKey = Base64.decodeBase64(publicKey.getBytes());
X509EncodedKeySpec keySpec = new X509EncodedKeySpec(decodedKey);
return keyFactory.generatePublic(keySpec);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
/**
* RSA加密
*
* @param data 待加密的数据
* @param publicKey 公钥
* @return
* @throws Exception
*/
public static String encrypt(String data, PublicKey publicKey) throws Exception {
Cipher cipher = Cipher.getInstance("RSA");
cipher.init(Cipher.ENCRYPT_MODE, publicKey);
int inputLen = data.getBytes().length;
ByteArrayOutputStream out = new ByteArrayOutputStream();
int offset = 0;
byte[] cache;
int i = 0;
// 对数据分段加密
while (inputLen - offset > 0) {
if (inputLen - offset > MAX_ENCRYPT_BLOCK) {
cache = cipher.doFinal(data.getBytes(), offset, MAX_ENCRYPT_BLOCK);
} else {
cache = cipher.doFinal(data.getBytes(), offset, inputLen - offset);
}
out.write(cache, 0, cache.length);
i++;
offset = i * MAX_ENCRYPT_BLOCK;
}
byte[] encryptedData = out.toByteArray();
out.close();
// 获取加密内容使用base64进行编码,并以UTF-8为标准转化成字符串
// 加密后的字符串
return new String(Base64.encodeBase64String(encryptedData));
}
/**
* RSA解密
*
* @param data 待解密数据
* @param privateKey 私钥
* @return
* @throws Exception
*/
public static String decrypt(String data, PrivateKey privateKey) throws Exception {
Cipher cipher = Cipher.getInstance("RSA");
cipher.init(Cipher.DECRYPT_MODE, privateKey);
byte[] dataBytes = Base64.decodeBase64(data);
int inputLen = dataBytes.length;
ByteArrayOutputStream out = new ByteArrayOutputStream();
int offset = 0;
byte[] cache;
int i = 0;
// 对数据分段解密
while (inputLen - offset > 0) {
if (inputLen - offset > MAX_DECRYPT_BLOCK) {
cache = cipher.doFinal(dataBytes, offset, MAX_DECRYPT_BLOCK);
} else {
cache = cipher.doFinal(dataBytes, offset, inputLen - offset);
}
out.write(cache, 0, cache.length);
i++;
offset = i * MAX_DECRYPT_BLOCK;
}
byte[] decryptedData = out.toByteArray();
out.close();
// 解密后的内容
return new String(decryptedData, "UTF-8");
}
public static void main(String[] args) throws Exception {
String[] keyPair = getKeyPair();
System.out.println("公钥:"+keyPair[0]);
System.out.println("私钥:"+keyPair[1]);
String str = "测试加解密效果";
//公钥加密
String encrypt = encrypt(str, getPublicKey());
//私钥解密
String decrypt = decrypt(encrypt, getPrivateKey());
System.out.println(decrypt);
}
}
<?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.AccountDetailsMapper">
<resultMap id="BaseResultMap" type="com.pica.cloud.account.account.server.entity.AccountInfo">
<id column="id" property="id" jdbcType="BIGINT"/>
<result column="password" property="password" jdbcType="VARCHAR"/>
<result column="name" property="name" jdbcType="VARCHAR"/>
<result column="age" property="age" jdbcType="TINYINT"/>
<result column="birthday" property="birthday" jdbcType="DATE"/>
<result column="sex" property="sex" jdbcType="TINYINT"/>
<result column="id_card" property="idCard" jdbcType="VARCHAR"/>
<result column="reg_time" property="regTime" jdbcType="TIMESTAMP"/>
<result column="register_source" property="registerSource" jdbcType="INTEGER"/>
<result column="delete_flag" property="deleteFlag" jdbcType="INTEGER"/>
<result column="created_id" property="createdId" jdbcType="INTEGER"/>
<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, password, name, age, birthday, sex, id_card, reg_time, register_source, 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 accout_info
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from accout_info
where id = #{id,jdbcType=BIGINT}
</delete>
<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>
<insert id="insertSelective" parameterType="com.pica.cloud.account.account.server.entity.AccountInfo">
insert into accout_info
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="password != null">
password,
</if>
<if test="name != null">
name,
</if>
<if test="age != null">
age,
</if>
<if test="birthday != null">
birthday,
</if>
<if test="sex != null">
sex,
</if>
<if test="idCard != null">
id_card,
</if>
<if test="regTime != null">
reg_time,
</if>
<if test="registerSource != null">
register_source,
</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="password != null">
#{password,jdbcType=VARCHAR},
</if>
<if test="name != null">
#{name,jdbcType=VARCHAR},
</if>
<if test="age != null">
#{age,jdbcType=TINYINT},
</if>
<if test="birthday != null">
#{birthday,jdbcType=DATE},
</if>
<if test="sex != null">
#{sex,jdbcType=TINYINT},
</if>
<if test="idCard != null">
#{idCard,jdbcType=VARCHAR},
</if>
<if test="regTime != null">
#{regTime,jdbcType=TIMESTAMP},
</if>
<if test="registerSource != null">
#{registerSource,jdbcType=INTEGER},
</if>
<if test="deleteFlag != null">
#{deleteFlag,jdbcType=INTEGER},
</if>
<if test="createdId != null">
#{createdId,jdbcType=INTEGER},
</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>
<!--通过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 accout_info
<set>
<if test="password != null">
password = #{password,jdbcType=VARCHAR},
</if>
<if test="name != null">
name = #{name,jdbcType=VARCHAR},
</if>
<if test="age != null">
age = #{age,jdbcType=TINYINT},
</if>
<if test="birthday != null">
birthday = #{birthday,jdbcType=DATE},
</if>
<if test="sex != null">
sex = #{sex,jdbcType=TINYINT},
</if>
<if test="idCard != null">
id_card = #{idCard,jdbcType=VARCHAR},
</if>
<if test="regTime != null">
reg_time = #{regTime,jdbcType=TIMESTAMP},
</if>
<if test="registerSource != null">
register_source = #{registerSource,jdbcType=INTEGER},
</if>
<if test="deleteFlag != null">
delete_flag = #{deleteFlag,jdbcType=INTEGER},
</if>
<if test="createdId != null">
created_id = #{createdId,jdbcType=INTEGER},
</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.AccountInfo">
update accout_info
set password = #{password,jdbcType=VARCHAR},
name = #{name,jdbcType=VARCHAR},
age = #{age,jdbcType=TINYINT},
birthday = #{birthday,jdbcType=DATE},
sex = #{sex,jdbcType=TINYINT},
id_card = #{idCard,jdbcType=VARCHAR},
reg_time = #{regTime,jdbcType=TIMESTAMP},
register_source = #{registerSource,jdbcType=INTEGER},
delete_flag = #{deleteFlag,jdbcType=INTEGER},
created_id = #{createdId,jdbcType=INTEGER},
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.AccountContactMapper" >
<resultMap id="BaseResultMap" type="com.pica.cloud.account.account.server.entity.AccountContact" >
<id column="id" property="id" jdbcType="BIGINT" />
<result column="acct_id" property="acctId" jdbcType="INTEGER" />
<result column="mobile_phone" property="mobilePhone" 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, mobile_phone, 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 acct_contact
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long" >
delete from acct_contact
where id = #{id,jdbcType=BIGINT}
</delete>
<insert id="insert" parameterType="com.pica.cloud.account.account.server.entity.AccountContact" >
insert into acct_contact (id, acct_id, mobile_phone,
delete_flag, created_id, created_time,
modified_id, modified_time)
values (#{id,jdbcType=BIGINT}, #{acctId,jdbcType=INTEGER}, #{mobilePhone,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.AccountContact" >
insert into acct_contact
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="acctId != null" >
acct_id,
</if>
<if test="mobilePhone != null" >
mobile_phone,
</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=INTEGER},
</if>
<if test="mobilePhone != null" >
#{mobilePhone,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.AccountContact" >
update acct_contact
<set >
<if test="mobilePhone != null" >
mobile_phone = #{mobilePhone,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 acct_id = #{acctId,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.LogPasswordModifyMapper" >
<resultMap id="BaseResultMap" type="com.pica.cloud.account.account.server.entity.LogPasswordModify" >
<id column="id" property="id" jdbcType="BIGINT" />
<result column="mobile_phone" property="mobilePhone" jdbcType="VARCHAR" />
<result column="modified_time" property="modifiedTime" jdbcType="TIMESTAMP" />
<result column="modified_id" property="modifiedId" jdbcType="INTEGER" />
<result column="old_pwd" property="oldPwd" jdbcType="VARCHAR" />
<result column="new_pwd" property="newPwd" 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" />
</resultMap>
<sql id="Base_Column_List" >
id, mobile_phone, modified_time, modified_id, old_pwd, new_pwd, delete_flag, created_id,
created_time
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
select
<include refid="Base_Column_List" />
from log_password_modify
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long" >
delete from log_password_modify
where id = #{id,jdbcType=BIGINT}
</delete>
<insert id="insert" parameterType="com.pica.cloud.account.account.server.entity.LogPasswordModify" >
insert into log_password_modify (id, mobile_phone, modified_time,
modified_id, old_pwd, new_pwd,
delete_flag, created_id, created_time
)
values (#{id,jdbcType=BIGINT}, #{mobilePhone,jdbcType=VARCHAR}, #{modifiedTime,jdbcType=TIMESTAMP},
#{modifiedId,jdbcType=INTEGER}, #{oldPwd,jdbcType=VARCHAR}, #{newPwd,jdbcType=VARCHAR},
#{deleteFlag,jdbcType=INTEGER}, #{createdId,jdbcType=BIGINT}, #{createdTime,jdbcType=TIMESTAMP}
)
</insert>
<insert id="insertSelective" parameterType="com.pica.cloud.account.account.server.entity.LogPasswordModify" >
insert into log_password_modify
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="mobilePhone != null" >
mobile_phone,
</if>
<if test="modifiedTime != null" >
modified_time,
</if>
<if test="modifiedId != null" >
modified_id,
</if>
<if test="oldPwd != null" >
old_pwd,
</if>
<if test="newPwd != null" >
new_pwd,
</if>
<if test="deleteFlag != null" >
delete_flag,
</if>
<if test="createdId != null" >
created_id,
</if>
<if test="createdTime != null" >
created_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=BIGINT},
</if>
<if test="mobilePhone != null" >
#{mobilePhone,jdbcType=VARCHAR},
</if>
<if test="modifiedTime != null" >
#{modifiedTime,jdbcType=TIMESTAMP},
</if>
<if test="modifiedId != null" >
#{modifiedId,jdbcType=INTEGER},
</if>
<if test="oldPwd != null" >
#{oldPwd,jdbcType=VARCHAR},
</if>
<if test="newPwd != null" >
#{newPwd,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>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.pica.cloud.account.account.server.entity.LogPasswordModify" >
update log_password_modify
<set >
<if test="mobilePhone != null" >
mobile_phone = #{mobilePhone,jdbcType=VARCHAR},
</if>
<if test="modifiedTime != null" >
modified_time = #{modifiedTime,jdbcType=TIMESTAMP},
</if>
<if test="modifiedId != null" >
modified_id = #{modifiedId,jdbcType=INTEGER},
</if>
<if test="oldPwd != null" >
old_pwd = #{oldPwd,jdbcType=VARCHAR},
</if>
<if test="newPwd != null" >
new_pwd = #{newPwd,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>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="com.pica.cloud.account.account.server.entity.LogPasswordModify" >
update log_password_modify
set mobile_phone = #{mobilePhone,jdbcType=VARCHAR},
modified_time = #{modifiedTime,jdbcType=TIMESTAMP},
modified_id = #{modifiedId,jdbcType=INTEGER},
old_pwd = #{oldPwd,jdbcType=VARCHAR},
new_pwd = #{newPwd,jdbcType=VARCHAR},
delete_flag = #{deleteFlag,jdbcType=INTEGER},
created_id = #{createdId,jdbcType=BIGINT},
created_time = #{createdTime,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.LoginLogMapper" >
<resultMap id="BaseResultMap" type="com.pica.cloud.account.account.server.entity.LoginLog" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="acct_id" property="acctId" jdbcType="INTEGER" />
<result column="acct_name" property="acctName" jdbcType="VARCHAR" />
<result column="login_time" property="loginTime" jdbcType="TIMESTAMP" />
<result column="login_from" property="loginFrom" jdbcType="TINYINT" />
<result column="login_type" property="loginType" jdbcType="TINYINT" />
<result column="login_ip" property="loginIp" jdbcType="VARCHAR" />
<result column="login_platform" property="loginPlatform" jdbcType="TINYINT" />
<result column="login_status" property="loginStatus" jdbcType="TINYINT" />
<result column="create_id" property="createId" jdbcType="INTEGER" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="modify_id" property="modifyId" jdbcType="INTEGER" />
<result column="modify_time" property="modifyTime" jdbcType="TIMESTAMP" />
<result column="delete_flag" property="deleteFlag" jdbcType="TINYINT" />
</resultMap>
<sql id="Base_Column_List" >
id, acct_id, acct_name, login_time, login_from, login_type, login_ip, login_platform,
login_status, create_id, create_time, modify_id, modify_time, delete_flag
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from log_login
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from log_login
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.pica.cloud.account.account.server.entity.LoginLog" >
insert into log_login (id, acct_id, acct_name,
login_time, login_from, login_type,
login_ip, login_platform, login_status,
create_id, create_time, modify_id,
modify_time, delete_flag)
values (#{id,jdbcType=INTEGER}, #{acctId,jdbcType=INTEGER}, #{acctName,jdbcType=VARCHAR},
#{loginTime,jdbcType=TIMESTAMP}, #{loginFrom,jdbcType=TINYINT}, #{loginType,jdbcType=TINYINT},
#{loginIp,jdbcType=VARCHAR}, #{loginPlatform,jdbcType=TINYINT}, #{loginStatus,jdbcType=TINYINT},
#{createId,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{modifyId,jdbcType=INTEGER},
#{modifyTime,jdbcType=TIMESTAMP}, #{deleteFlag,jdbcType=TINYINT})
</insert>
<insert id="insertSelective" parameterType="com.pica.cloud.account.account.server.entity.LoginLog" >
insert into log_login
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="acctId != null" >
acct_id,
</if>
<if test="acctName != null" >
acct_name,
</if>
<if test="loginTime != null" >
login_time,
</if>
<if test="loginFrom != null" >
login_from,
</if>
<if test="loginType != null" >
login_type,
</if>
<if test="loginIp != null" >
login_ip,
</if>
<if test="loginPlatform != null" >
login_platform,
</if>
<if test="loginStatus != null" >
login_status,
</if>
<if test="createId != null" >
create_id,
</if>
<if test="createTime != null" >
create_time,
</if>
<if test="modifyId != null" >
modify_id,
</if>
<if test="modifyTime != null" >
modify_time,
</if>
<if test="deleteFlag != null" >
delete_flag,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=INTEGER},
</if>
<if test="acctId != null" >
#{acctId,jdbcType=INTEGER},
</if>
<if test="acctName != null" >
#{acctName,jdbcType=VARCHAR},
</if>
<if test="loginTime != null" >
#{loginTime,jdbcType=TIMESTAMP},
</if>
<if test="loginFrom != null" >
#{loginFrom,jdbcType=TINYINT},
</if>
<if test="loginType != null" >
#{loginType,jdbcType=TINYINT},
</if>
<if test="loginIp != null" >
#{loginIp,jdbcType=VARCHAR},
</if>
<if test="loginPlatform != null" >
#{loginPlatform,jdbcType=TINYINT},
</if>
<if test="loginStatus != null" >
#{loginStatus,jdbcType=TINYINT},
</if>
<if test="createId != null" >
#{createId,jdbcType=INTEGER},
</if>
<if test="createTime != null" >
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="modifyId != null" >
#{modifyId,jdbcType=INTEGER},
</if>
<if test="modifyTime != null" >
#{modifyTime,jdbcType=TIMESTAMP},
</if>
<if test="deleteFlag != null" >
#{deleteFlag,jdbcType=TINYINT},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.pica.cloud.account.account.server.entity.LoginLog" >
update log_login
<set >
<if test="acctId != null" >
acct_id = #{acctId,jdbcType=INTEGER},
</if>
<if test="acctName != null" >
acct_name = #{acctName,jdbcType=VARCHAR},
</if>
<if test="loginTime != null" >
login_time = #{loginTime,jdbcType=TIMESTAMP},
</if>
<if test="loginFrom != null" >
login_from = #{loginFrom,jdbcType=TINYINT},
</if>
<if test="loginType != null" >
login_type = #{loginType,jdbcType=TINYINT},
</if>
<if test="loginIp != null" >
login_ip = #{loginIp,jdbcType=VARCHAR},
</if>
<if test="loginPlatform != null" >
login_platform = #{loginPlatform,jdbcType=TINYINT},
</if>
<if test="loginStatus != null" >
login_status = #{loginStatus,jdbcType=TINYINT},
</if>
<if test="createId != null" >
create_id = #{createId,jdbcType=INTEGER},
</if>
<if test="createTime != null" >
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="modifyId != null" >
modify_id = #{modifyId,jdbcType=INTEGER},
</if>
<if test="modifyTime != null" >
modify_time = #{modifyTime,jdbcType=TIMESTAMP},
</if>
<if test="deleteFlag != null" >
delete_flag = #{deleteFlag,jdbcType=TINYINT},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.pica.cloud.account.account.server.entity.LoginLog" >
update log_login
set acct_id = #{acctId,jdbcType=INTEGER},
acct_name = #{acctName,jdbcType=VARCHAR},
login_time = #{loginTime,jdbcType=TIMESTAMP},
login_from = #{loginFrom,jdbcType=TINYINT},
login_type = #{loginType,jdbcType=TINYINT},
login_ip = #{loginIp,jdbcType=VARCHAR},
login_platform = #{loginPlatform,jdbcType=TINYINT},
login_status = #{loginStatus,jdbcType=TINYINT},
create_id = #{createId,jdbcType=INTEGER},
create_time = #{createTime,jdbcType=TIMESTAMP},
modify_id = #{modifyId,jdbcType=INTEGER},
modify_time = #{modifyTime,jdbcType=TIMESTAMP},
delete_flag = #{deleteFlag,jdbcType=TINYINT}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>
\ No newline at end of file
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册