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

20190902 自测完成的接口并完善

上级 8f53065c
流水线 #13875 已失败 于阶段
in 1 second
package com.pica.cloud.account.account.server.service;
package com.pica.cloud.account.account.server;
import com.alibaba.fastjson.JSONObject;
import com.pica.cloud.account.account.server.entity.EncryptEntity;
import com.pica.cloud.account.account.server.req.BaseRequest;
import com.pica.cloud.account.account.server.req.PatientReq;
public class Test {
......@@ -22,7 +23,7 @@ public class Test {
System.out.println("------------------------------>");
//获取注册参数
BaseRequest register=null;
BaseRequest register = null;
register = new BaseRequest();
register.setMobile("13024112588");
register.setPassword("qq123456");
......@@ -34,11 +35,18 @@ public class Test {
System.out.println(JSONObject.toJSONString(registerEncryptEntity));
System.out.println("------------------------------>");
//修改用户信息接口
PatientReq req=new PatientReq();
req.setAddress("测试数据");
req.setEmail("2586622608@qq.com");
req.setTelephone("座机号码");
String json = JSONObject.toJSONString(req);
System.out.println(json);
EncryptEntity patientReqEncryptEntity = new EncryptEntity();
patientReqEncryptEntity.setContent(json);
System.out.println(JSONObject.toJSONString(patientReqEncryptEntity));
}
}
......@@ -6,6 +6,7 @@ import com.pica.cloud.account.account.server.configuration.PropertiesConfigurati
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.enums.ExceptionType;
import com.pica.cloud.account.account.server.exception.AccountException;
import com.pica.cloud.account.account.server.util.PICAPSendMsgModel;
import com.pica.cloud.foundation.entity.PicaException;
import com.pica.cloud.foundation.entity.PicaResultCode;
......@@ -158,7 +159,7 @@ public abstract class AccountBaseController extends BaseController {
return accountUser.getAcctId();
} catch (Exception e) {
e.printStackTrace();
throw new PicaException(ExceptionType.PICA_LOGIN_AGAIN.getCode(), ExceptionType.PICA_LOGIN_AGAIN.getMessage());
throw new AccountException(ExceptionType.PICA_LOGIN_AGAIN);
}
}
......
......@@ -35,5 +35,4 @@ public class ModifyMobileController extends AccountBaseController {
modifyMobileService.modify(acctId, mobile);
return PicaResponse.toResponse();
}
}
package com.pica.cloud.account.account.server.controller;
import com.pica.cloud.account.account.server.entity.AccountUser;
import com.pica.cloud.account.account.server.entity.EncryptEntity;
import com.pica.cloud.account.account.server.enums.EnumsType;
import com.pica.cloud.account.account.server.enums.ExceptionType;
......@@ -30,7 +29,6 @@ public class PasswordController extends AccountBaseController {
@Autowired
private AccountUtils accountUtils;
/**
* 修改密码
*
......@@ -63,14 +61,12 @@ public class PasswordController extends AccountBaseController {
@ApiOperation("忘记密码接口")
@PostMapping(value = "/reset")
public PicaResponse forgetPassword(@RequestBody EncryptEntity entity) throws Exception {
Integer acctId = super.getAcctId();
BaseRequest request = CryptoUtil.decrypt(entity, BaseRequest.class);
accountUtils.checkMobilePhone(request.getMobile());
accountUtils.checkAuthCode(request.getMobile(), EnumsType.SYSCODE_TYPE_RESET_PASSWORD.getCode() + "", request.getSysCode());
if (StringUtils.isEmpty(request.getPassword())) {
throw new PicaException(ExceptionType.PICA_PASSWORD_ERROR.getCode(), ExceptionType.PICA_PASSWORD_ERROR.getMessage());
}
request.setAccId(acctId);
passwordService.forgetPassword(request);
return PicaResponse.toResponse();
}
......
......@@ -42,11 +42,17 @@ public class SysCodeController extends AccountBaseController {
private ICacheClient cacheClient;
/**
* 必须要传递flag类型
*
* @param entity
* @return
* @throws Exception
*/
@ApiOperation("获取短信验证码")
@PostMapping(value = "")
public PicaResponse getSysCode(@RequestBody EncryptEntity entity) throws Exception {
BaseRequest request = CryptoUtil.decrypt(entity, BaseRequest.class);
request.setFlag(0);
AccountUtils.checkMobilePhone(request.getMobile());
processSysCode(request.getMobile(), request.getFlag());
return PicaResponse.toResponse();
......
......@@ -2,11 +2,14 @@ package com.pica.cloud.account.account.server.controller;
import com.pica.cloud.account.account.server.entity.AccountUserInfoEntity;
import com.pica.cloud.account.account.server.entity.EncryptEntity;
import com.pica.cloud.account.account.server.req.PatientReq;
import com.pica.cloud.account.account.server.service.UserInfoService;
import com.pica.cloud.account.account.server.util.BeanUtil;
import com.pica.cloud.account.account.server.util.CryptoUtil;
import com.pica.cloud.foundation.entity.PicaResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.beanutils.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
......@@ -41,10 +44,12 @@ public class UserInfoController extends AccountBaseController {
@ApiOperation("修改用户信息")
@PutMapping(value = "/user/info")
public PicaResponse putUserInfo(@RequestBody EncryptEntity entity) throws Exception {
Integer acctId = super.getAcctId();
AccountUserInfoEntity request = CryptoUtil.decrypt(entity, AccountUserInfoEntity.class);
request.setAcctId(acctId);
userInfoService.updateUserInfo(request);
Integer id = super.getAccountUser().getId();
PatientReq request = CryptoUtil.decrypt(entity, PatientReq.class);
request.setId(id);
AccountUserInfoEntity accountUserInfoEntity = new AccountUserInfoEntity();
BeanUtils.copyProperties(accountUserInfoEntity,request);
userInfoService.updateUserInfo(accountUserInfoEntity);
return PicaResponse.toResponse();
}
......
......@@ -45,9 +45,6 @@ public enum EnumsType {
LOG_TYPE_PASSWORD(2, "密码更新日志"),
LOG_TYPE_USER_INFO(3, "用户信息更新日志");
private int code;
private String type;
......
......@@ -17,7 +17,6 @@ public enum ExceptionType {
PICA_PASSWORD_EQUAL("216514", "旧密码与新密码不能相同"),
PICA_UNBIND_MOBILE("216515", "该手机号未绑定微信");
private String code;
private String message;
......
package com.pica.cloud.account.account.server.exception;
import com.pica.cloud.account.account.server.enums.ExceptionType;
import com.pica.cloud.foundation.entity.PicaException;
import com.pica.cloud.foundation.entity.PicaResultCode;
/**
* 直接传递枚举类型
*/
public class AccountException extends PicaException {
public AccountException(String code, String msg) {
super(code, msg);
}
public AccountException(PicaResultCode picaResultCode) {
super(picaResultCode);
}
public AccountException(ExceptionType exceptionType) {
super(exceptionType.getCode(), exceptionType.getMessage());
}
}
......@@ -21,7 +21,6 @@ public class PicaLogTask implements Runnable {
private LogUserInfoMapper logUserInfoMapper;
/**
* 日志类型
*/
......@@ -45,7 +44,7 @@ public class PicaLogTask implements Runnable {
if (type == EnumsType.LOG_TYPE_LOGIN.getCode()) {
loginLogMapper.insertSelective((LogLoginEntity) picaLogEntity);
} else if (type == EnumsType.LOG_TYPE_PASSWORD.getCode()) {
logPWDModifyMapper.insertSelective((LogPWDModifyEntity) picaLogEntity);
logPWDModifyMapper.insert((LogPWDModifyEntity) picaLogEntity);
} else if (type == EnumsType.LOG_TYPE_USER_INFO.getCode()) {
logUserInfoMapper.insertSelective((LogUserInfoEntity) picaLogEntity);
}
......
......@@ -4,7 +4,6 @@ import org.springframework.stereotype.Component;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
@Component
public class PicaLogUtils {
......
package com.pica.cloud.account.account.server.req;
import java.util.Date;
/**
* 居民信息
*/
public class PatientReq {
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 int 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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getPatientAddress() {
return patientAddress;
}
public void setPatientAddress(String patientAddress) {
this.patientAddress = patientAddress;
}
public String getTelephone() {
return telephone;
}
public void setTelephone(String telephone) {
this.telephone = telephone;
}
public String getSocialCard() {
return socialCard;
}
public void setSocialCard(String socialCard) {
this.socialCard = socialCard;
}
public String getWorkUnit() {
return workUnit;
}
public void setWorkUnit(String workUnit) {
this.workUnit = workUnit;
}
public String getHealthFileNumber() {
return healthFileNumber;
}
public void setHealthFileNumber(String healthFileNumber) {
this.healthFileNumber = healthFileNumber;
}
public String getPaymentType() {
return paymentType;
}
public void setPaymentType(String paymentType) {
this.paymentType = paymentType;
}
public String getRemarks() {
return remarks;
}
public void setRemarks(String remarks) {
this.remarks = remarks;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getNation() {
return nation;
}
public void setNation(String nation) {
this.nation = nation;
}
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 int getDeleteFlag() {
return deleteFlag;
}
public void setDeleteFlag(int deleteFlag) {
this.deleteFlag = deleteFlag;
}
}
......@@ -4,6 +4,7 @@ import com.pica.cloud.account.account.server.entity.AccountInfoEntity;
import com.pica.cloud.account.account.server.entity.LogPWDModifyEntity;
import com.pica.cloud.account.account.server.enums.EnumsType;
import com.pica.cloud.account.account.server.enums.ExceptionType;
import com.pica.cloud.account.account.server.exception.AccountException;
import com.pica.cloud.account.account.server.log.PicaLogUtils;
import com.pica.cloud.account.account.server.mapper.AccountInfoDetailMapper;
import com.pica.cloud.account.account.server.req.BaseRequest;
......@@ -48,13 +49,15 @@ public class PasswordServiceImpl implements PasswordService {
logPWDModifyEntity.setLogType(EnumsType.LOG_TYPE_PASSWORD.getCode());
picaLogUtils.info(logPWDModifyEntity);
} else {
throw new PicaException(ExceptionType.PICA_PASSWORD_ERROR.getCode(), ExceptionType.PICA_PASSWORD_ERROR.getMessage());
throw new AccountException(ExceptionType.PICA_PASSWORD_ERROR);
}
}
@Override
public void forgetPassword(BaseRequest request) {
Integer accId = request.getAccId();
AccountInfoEntity entity = accountInfoDetailMapper.selectByMobile(EncryptCreateUtil.encrypt(request.getMobile()));
if (entity != null) {
Integer accId = entity.getId();
AccountInfoEntity accountInfoEntity = new AccountInfoEntity();
accountInfoEntity.setId(accId);
accountInfoEntity.setModifiedId(accId);
......@@ -67,12 +70,16 @@ public class PasswordServiceImpl implements PasswordService {
logPWDModifyEntity.setCreatedId(accId);
logPWDModifyEntity.setCreatedTime(currentTime);
logPWDModifyEntity.setDeleteFlag(1);
logPWDModifyEntity.setMobilePhone(request.getMobile());
logPWDModifyEntity.setMobilePhone(entity.getMobilePhone());
logPWDModifyEntity.setModifiedId(accId);
logPWDModifyEntity.setModifiedTime(currentTime);
logPWDModifyEntity.setOldPwd("");
logPWDModifyEntity.setNewPwd(EncryptCreateUtil.encrypt(request.getPassword()));
logPWDModifyEntity.setLogType(EnumsType.LOG_TYPE_PASSWORD.getCode());
picaLogUtils.info(logPWDModifyEntity);
} else {
//未注册,请先注册
throw new AccountException(ExceptionType.PICA_NOT_REGISTER);
}
}
}
......@@ -56,7 +56,7 @@ public class RegisterServiceImpl implements RegisterService {
int sourceType = baseRequest.getSourceType();
AccountInfoEntity accountInfo = new AccountInfoEntity();
accountInfo.setMobilePhone(EncryptCreateUtil.encrypt(baseRequest.getMobile()));
if (!StringUtils.isNotEmpty(baseRequest.getPassword())) {
if (StringUtils.isNotEmpty(baseRequest.getPassword())) {
accountInfo.setPassword(EncryptCreateUtil.encrypt(baseRequest.getPassword()));
} else {
accountInfo.setPassword("");
......
......@@ -27,15 +27,16 @@
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.pica.cloud.account.account.server.entity.LogPWDModifyEntity" >
insert into log_pwd_modify (id, mobile_phone, modified_time,
insert into log_pwd_modify (mobile_phone, modified_time,
modified_id, old_pwd, new_pwd,
delete_flag, created_id, created_time
)
values (#{id,jdbcType=INTEGER}, #{mobilePhone,jdbcType=VARCHAR}, #{modifiedTime,jdbcType=TIMESTAMP},
values (#{mobilePhone,jdbcType=VARCHAR}, #{modifiedTime,jdbcType=TIMESTAMP},
#{modifiedId,jdbcType=INTEGER}, #{oldPwd,jdbcType=VARCHAR}, #{newPwd,jdbcType=VARCHAR},
#{deleteFlag,jdbcType=INTEGER}, #{createdId,jdbcType=INTEGER}, #{createdTime,jdbcType=TIMESTAMP}
)
</insert>
<insert id="insertSelective" parameterType="com.pica.cloud.account.account.server.entity.LogPWDModifyEntity" >
insert into log_pwd_modify
<trim prefix="(" suffix=")" suffixOverrides="," >
......@@ -97,6 +98,7 @@
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.pica.cloud.account.account.server.entity.LogPWDModifyEntity" >
update log_pwd_modify
<set >
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册