|
@@ -24,6 +24,7 @@ import com.free.config.ExceptionEnum;
|
|
import com.free.config.ResponseFormat;
|
|
import com.free.config.ResponseFormat;
|
|
import com.free.dto.LoginDTO;
|
|
import com.free.dto.LoginDTO;
|
|
import com.free.dto.PasswordUpdateDTO;
|
|
import com.free.dto.PasswordUpdateDTO;
|
|
|
|
+import com.free.dto.ResetPasswordDTO;
|
|
import com.free.entity.system.Admin;
|
|
import com.free.entity.system.Admin;
|
|
import com.free.entity.system.Customer;
|
|
import com.free.entity.system.Customer;
|
|
import com.free.entity.system.Role;
|
|
import com.free.entity.system.Role;
|
|
@@ -33,6 +34,7 @@ import com.free.service.system.MenusService;
|
|
import com.free.service.system.RoleService;
|
|
import com.free.service.system.RoleService;
|
|
import com.free.utils.BcryptUtil;
|
|
import com.free.utils.BcryptUtil;
|
|
import com.free.utils.JwtUtil;
|
|
import com.free.utils.JwtUtil;
|
|
|
|
+import com.free.utils.Utils;
|
|
|
|
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
@@ -138,6 +140,29 @@ public class LoginController {
|
|
return ResponseFormat.success();
|
|
return ResponseFormat.success();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @ApiOperation("重置密码")
|
|
|
|
+ @PostMapping("/resetPwd")
|
|
|
|
+ public Object resetPassword(@RequestBody @Valid ResetPasswordDTO data) {
|
|
|
|
+ String type = data.getType();
|
|
|
|
+ String password = Utils.randomString(6);
|
|
|
|
+ String cpwd = BcryptUtil.encryptPassword(password);
|
|
|
|
+ if (this.adminLoginType.equals(type)) {
|
|
|
|
+ Admin adminData = new Admin();
|
|
|
|
+ adminData.setId(data.getId());
|
|
|
|
+ adminData.setPassword(cpwd);
|
|
|
|
+ this.adminService.updateById(adminData);
|
|
|
|
+ } else if (this.csLoginType.equals(type)) {
|
|
|
|
+ Customer customerData = new Customer();
|
|
|
|
+ customerData.setId(data.getId());
|
|
|
|
+ customerData.setPassword(cpwd);
|
|
|
|
+ this.customerService.updateById(customerData);
|
|
|
|
+ } else {
|
|
|
|
+ // 用户类型不对,抛出异常
|
|
|
|
+ throw new CustomizationException(ExceptionEnum.USER_TYPE_ERROR);
|
|
|
|
+ }
|
|
|
|
+ return ResponseFormat.success();
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 根据token,查询出用户的权限,目录
|
|
* 根据token,查询出用户的权限,目录
|
|
*
|
|
*
|