Commit 6278fb78 authored by huangcb's avatar huangcb

新增司机重置密码功能接口、货主重置密码功能接口

parent ea632aa1
......@@ -53,6 +53,9 @@ public class ErrorMessageComponent {
@Value("${error-message.goodsowner.account.password-check.1002}")
private String goodsOwnerAccountPasswordCheck1002;
@Value("${error-message.goodsowner.account.password-reset.1001}")
private String goodsOwnerAccountPasswordReset1001;
@Value("${error-message.goodsowner.account.register.1001}")
private String goodsOwnerAccountRegister1001;
......@@ -212,6 +215,9 @@ public class ErrorMessageComponent {
@Value("${error-message.carrier.driver.register.1002}")
private String carrierDriverRegister1002;
@Value("${error-message.carrier.driver.password-reset.1001}")
private String carrierDriverPasswordReset1001;
@Value("${error-message.carrier.driver.audit-history.1001}")
private String carrierDriverAuditHistory1001;
......
......@@ -22,6 +22,7 @@ import com.esv.freight.customer.module.driver.form.DriverQueryForm;
import com.esv.freight.customer.module.driver.service.DriverAccountService;
import com.esv.freight.customer.module.driver.validator.groups.ValidatorDetailAccount;
import com.esv.freight.customer.module.driver.validator.groups.ValidatorLogin;
import com.esv.freight.customer.module.driver.validator.groups.ValidatorPasswordReset;
import com.esv.freight.customer.module.driver.validator.groups.ValidatorRegister;
import com.esv.freight.customer.module.driver.vo.DriverAuditHistoryVO;
import com.esv.freight.customer.module.driver.vo.DriverDetailVO;
......@@ -298,4 +299,17 @@ public class DriverController {
return EResponse.ok(vo);
}
/**
* description 重置司机帐号密码
* param [form]
* return com.esv.freight.customer.common.response.EResponse
* author Administrator
* createTime 2020/05/16 16:51
**/
@PostMapping("/account/password/reset")
public EResponse resetDriverPwd(@RequestBody @Validated(ValidatorPasswordReset.class) DriverInfoForm form) throws EException {
driverAccountService.resetDriverPwd(form);
return EResponse.ok();
}
}
......@@ -3,6 +3,7 @@ package com.esv.freight.customer.module.driver.form;
import com.esv.freight.customer.common.validator.groups.ValidatorInsert;
import com.esv.freight.customer.common.validator.groups.ValidatorUpdate;
import com.esv.freight.customer.module.driver.validator.groups.ValidatorLogin;
import com.esv.freight.customer.module.driver.validator.groups.ValidatorPasswordReset;
import com.esv.freight.customer.module.driver.validator.groups.ValidatorRegister;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
......@@ -28,7 +29,7 @@ public class DriverInfoForm {
/**
*
*/
@NotNull(message = "参数id不能为空", groups = {ValidatorUpdate.class})
@NotNull(message = "参数id不能为空", groups = {ValidatorUpdate.class, ValidatorPasswordReset.class})
private Long id;
/**
* 承运商帐号ID
......@@ -44,8 +45,8 @@ public class DriverInfoForm {
/**
* 密码
*/
@Length(min = 32, max = 32, message = "参数password长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class, ValidatorLogin.class})
@NotBlank(message = "参数password不能为空", groups = {ValidatorInsert.class, ValidatorLogin.class})
@Length(min = 32, max = 32, message = "参数password长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class, ValidatorLogin.class, ValidatorPasswordReset.class})
@NotBlank(message = "参数password不能为空", groups = {ValidatorInsert.class, ValidatorLogin.class, ValidatorPasswordReset.class})
private String password;
/**
* 帐号状态:1-正常、2-停用
......
......@@ -111,13 +111,13 @@ public interface DriverAccountService extends IService<DriverAccountEntity> {
PageResultVO getDriver4Page(DriverQueryForm queryObj);
/**
* description 帐号密码校验
* description 重置司机帐号密码
* param [form]
* return com.esv.freight.customer.module.driver.dto.DriverDetailDto
* return java.lang.Integer
* author Administrator
* createTime 2020/04/30 11:21
* createTime 2020/05/16 16:45
**/
DriverDetailDto checkAccount(DriverInfoForm form);
Integer resetDriverPwd(DriverInfoForm form);
}
......@@ -353,7 +353,15 @@ public class DriverAccountServiceImpl extends ServiceImpl<DriverAccountDao, Driv
}
@Override
public DriverDetailDto checkAccount(DriverInfoForm form) {
return null;
public Integer resetDriverPwd(DriverInfoForm form) {
DriverAccountEntity record = this.baseMapper.selectById(form.getId());
if (null == record) {
throw new EException(1001, errorMessageComponent.getCarrierDriverPasswordReset1001());
}
DriverAccountEntity driverAccountEntity = new DriverAccountEntity();
driverAccountEntity.setId(form.getId());
driverAccountEntity.setPassword(passwordComponent.generatePwd4Salt(form.getPassword(), record.getSalt()));
return this.baseMapper.updateById(driverAccountEntity);
}
}
\ No newline at end of file
package com.esv.freight.customer.module.driver.validator.groups;
import javax.validation.groups.Default;
/**
* @description: 参数校验分组:帐号密码重置
* @project: SpringCloudTemplate
* @name: com.esv.freight.customer.module.driver.validator.groups.ValidatorPasswordReset
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/03/12 17:58
* @version:1.0
*/
public interface ValidatorPasswordReset extends Default {
}
......@@ -220,7 +220,7 @@ public class GoodsOwnerController {
* createTime 2020/04/20 11:22
**/
@PostMapping("/password/check")
public EResponse checkAccountPwd(@RequestBody @Validated(ValidatorPassword.class) AccountForm form) throws EException {
public EResponse checkAccountPwd(@RequestBody @Validated(ValidatorPasswordCheck.class) AccountForm form) throws EException {
AccountInfoDto accountInfoDto = accountService.getAccountInfo(form);
// 校验帐号是否存在
if (null == accountInfoDto) {
......@@ -236,6 +236,19 @@ public class GoodsOwnerController {
return EResponse.ok(accountInfoVO);
}
/**
* description 重置帐号密码
* param [form]
* return com.esv.freight.customer.common.response.EResponse
* author Administrator
* createTime 2020/05/16 16:29
**/
@PostMapping("/password/reset")
public EResponse resetAccountPwd(@RequestBody @Validated(ValidatorPasswordReset.class) AccountForm form) throws EException {
accountService.resetAccountPwd(form);
return EResponse.ok();
}
/**
* description 帐号注册
* param [form]
......
package com.esv.freight.customer.module.goodsowner.form;
import com.esv.freight.customer.common.validator.groups.ValidatorDetail;
import com.esv.freight.customer.common.validator.groups.ValidatorInsert;
import com.esv.freight.customer.module.goodsowner.validator.groups.*;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
......@@ -22,7 +23,7 @@ import javax.validation.constraints.NotNull;
@Data
public class AccountForm {
@NotNull(message = "参数id不能为空", groups = {ValidatorBlock.class, ValidatorUnblock.class, ValidatorAudit.class, ValidatorAuditHistory.class})
@NotNull(message = "参数id不能为空", groups = {ValidatorBlock.class, ValidatorUnblock.class, ValidatorAudit.class, ValidatorAuditHistory.class, ValidatorPasswordReset.class})
private Long id;
@NotNull(message = "参数auditStatus不能为空", groups = {ValidatorAudit.class})
......@@ -31,11 +32,12 @@ public class AccountForm {
@Length(max = 100, message = "参数remark长度不合法", groups = {ValidatorAudit.class})
private String remark;
@Length(min = 11, max = 11, message = "参数account长度不合法", groups = {ValidatorDetail.class, ValidatorPassword.class, ValidatorRegister.class})
@Length(min = 11, max = 11, message = "参数account长度不合法", groups = {ValidatorDetail.class, ValidatorPasswordCheck.class, ValidatorRegister.class})
@NotBlank(message = "参数account不能为空", groups = {ValidatorRegister.class})
private String account;
@Length(min = 32, max = 32, message = "参数password长度不合法", groups = {ValidatorPassword.class})
@Length(min = 32, max = 32, message = "参数password长度不合法", groups = {ValidatorPasswordCheck.class, ValidatorPasswordReset.class})
@NotBlank(message = "参数password不能为空", groups = {ValidatorPasswordReset.class})
private String password;
@Override
......
......@@ -129,5 +129,14 @@ public interface AccountService extends IService<AccountEntity> {
**/
List<AccountAvailableVO> selectAllAvailableAccount();
/**
* description 重置帐号密码
* param [form]
* return java.lang.Integer
* author Administrator
* createTime 2020/05/16 16:19
**/
Integer resetAccountPwd(AccountForm form);
}
......@@ -371,4 +371,17 @@ public class AccountServiceImpl extends ServiceImpl<AccountDao, AccountEntity> i
return targetRecordList;
}
@Override
public Integer resetAccountPwd(AccountForm form) {
AccountEntity record = this.getAccountRecordById(form.getId());
if (null == record) {
throw new EException(1001, errorMessageComponent.getGoodsOwnerAccountPasswordReset1001());
}
AccountEntity accountEntity = new AccountEntity();
accountEntity.setId(form.getId());
accountEntity.setPassword(passwordComponent.generatePwd4Salt(form.getPassword(), record.getSalt()));
return this.baseMapper.updateById(accountEntity);
}
}
\ No newline at end of file
......@@ -3,13 +3,13 @@ package com.esv.freight.customer.module.goodsowner.validator.groups;
import javax.validation.groups.Default;
/**
* @description: 参数校验分组:帐号密码
* @description: 参数校验分组:帐号密码校验
* @project: SpringCloudTemplate
* @name: com.esv.freight.customer.module.goodsowner.validator.groups.ValidatorPassword
* @name: com.esv.freight.customer.module.goodsowner.validator.groups.ValidatorPasswordCheck
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/03/12 17:58
* @version:1.0
*/
public interface ValidatorPassword extends Default {
public interface ValidatorPasswordCheck extends Default {
}
package com.esv.freight.customer.module.goodsowner.validator.groups;
import javax.validation.groups.Default;
/**
* @description: 参数校验分组:帐号密码重置
* @project: SpringCloudTemplate
* @name: com.esv.freight.customer.module.goodsowner.validator.groups.ValidatorPasswordReset
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/03/12 17:58
* @version:1.0
*/
public interface ValidatorPasswordReset extends Default {
}
......@@ -81,6 +81,8 @@ error-message:
password-check:
1001: 无效的手机号
1002: 密码错误
password-reset:
1001: 无效的帐号ID
register:
1001: 帐号已存在
delivery-address:
......@@ -183,6 +185,8 @@ error-message:
register:
1001: 帐号已存在
1002: 无效的承运商ID​
password-reset:
1001: 无效的帐号ID
audit-history:
1001: 无效的账号ID
vehicle-list:
......
......@@ -81,6 +81,8 @@ error-message:
password-check:
1001: 无效的手机号
1002: 密码错误
password-reset:
1001: 无效的帐号ID
register:
1001: 帐号已存在
delivery-address:
......@@ -183,6 +185,8 @@ error-message:
register:
1001: 帐号已存在
1002: 无效的承运商ID​
password-reset:
1001: 无效的帐号ID
audit-history:
1001: 无效的账号ID
vehicle-list:
......
......@@ -696,4 +696,59 @@ public class DriverAccountTest extends BaseTestController {
JSONObject result = JSONObject.parseObject(responseStr);
Assert.assertEquals(1001, result.getIntValue("code"));
}
/**
* 重置司机帐号密码
**/
@Test
public void i1_resetDriverPwd_success_test() throws Exception {
String url = "/carrier/driver/account/password/reset";
// 构造数据
DriverInfoForm form = new DriverInfoForm();
form.setId(1L);
form.setPassword("e28bec3e2feb42598b8cf1a1d3b11f4a");
MvcResult mvcResult = this.getMockMvc().perform(MockMvcRequestBuilders.post(url)
.contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)
.headers(this.getDefaultHttpHeaders())
.content(form.toString()))
.andDo(MockMvcResultHandlers.print())
.andExpect(MockMvcResultMatchers.status().isOk())
.andReturn();
String responseStr = mvcResult.getResponse().getContentAsString();
log.info(responseStr);
JSONObject result = JSONObject.parseObject(responseStr);
Assert.assertEquals(ECode.SUCCESS.code(), result.getIntValue("code"));
}
/**
* 重置司机帐号密码:无效的账号ID
**/
@Test
public void i2_resetDriverPwd_wrong_id_failure_test() throws Exception {
// 构造数据
String url = "/carrier/driver/account/password/reset";
// 构造数据
DriverInfoForm form = new DriverInfoForm();
form.setId(99999L);
form.setPassword("e28bec3e2feb42598b8cf1a1d3b11f4a");
MvcResult mvcResult = this.getMockMvc().perform(MockMvcRequestBuilders.post(url)
.contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)
.headers(this.getDefaultHttpHeaders())
.content(form.toString()))
.andDo(MockMvcResultHandlers.print())
.andExpect(MockMvcResultMatchers.status().isOk())
.andReturn();
String responseStr = mvcResult.getResponse().getContentAsString();
log.info(responseStr);
JSONObject result = JSONObject.parseObject(responseStr);
Assert.assertEquals(1001, result.getIntValue("code"));
}
}
......@@ -767,4 +767,58 @@ public class GoodsOwnerControllerTest extends BaseTestController {
Assert.assertEquals(ECode.SUCCESS.code(), result.getIntValue("code"));
Assert.assertTrue(null != result.getJSONArray("data"));
}
/**
* 重置帐号密码
**/
@Test
public void i1_resetAccountPwd_success_test() throws Exception {
String url = "/goodsowner/account/password/reset";
// 构造数据
AccountForm form = new AccountForm();
form.setId(1L);
form.setPassword("e28bec3e2feb42598b8cf1a1d3b11f4a");
MvcResult mvcResult = this.getMockMvc().perform(MockMvcRequestBuilders.post(url)
.contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)
.headers(this.getDefaultHttpHeaders())
.content(form.toString()))
.andDo(MockMvcResultHandlers.print())
.andExpect(MockMvcResultMatchers.status().isOk())
.andReturn();
String responseStr = mvcResult.getResponse().getContentAsString();
log.info(responseStr);
JSONObject result = JSONObject.parseObject(responseStr);
Assert.assertEquals(ECode.SUCCESS.code(), result.getIntValue("code"));
}
/**
* 重置帐号密码:无效的帐号ID
**/
@Test
public void i2_resetAccountPwd_wrong_id_failure_test() throws Exception {
String url = "/goodsowner/account/password/reset";
// 构造数据
AccountForm form = new AccountForm();
form.setId(99999L);
form.setPassword("e28bec3e2feb42598b8cf1a1d3b11f4a");
MvcResult mvcResult = this.getMockMvc().perform(MockMvcRequestBuilders.post(url)
.contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)
.headers(this.getDefaultHttpHeaders())
.content(form.toString()))
.andDo(MockMvcResultHandlers.print())
.andExpect(MockMvcResultMatchers.status().isOk())
.andReturn();
String responseStr = mvcResult.getResponse().getContentAsString();
log.info(responseStr);
JSONObject result = JSONObject.parseObject(responseStr);
Assert.assertEquals(1001, result.getIntValue("code"));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment