|
|
@ -25,6 +25,7 @@ import com.epmet.commons.tools.page.PageData; |
|
|
|
import com.epmet.commons.tools.security.dto.TokenDto; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.utils.ExcelUtils; |
|
|
|
import com.epmet.commons.tools.utils.RSASignature; |
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.commons.tools.validator.AssertUtils; |
|
|
|
import com.epmet.commons.tools.validator.ValidatorUtils; |
|
|
@ -38,6 +39,7 @@ import com.epmet.excel.OperUserExcel; |
|
|
|
import com.epmet.service.OperUserService; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
@ -54,6 +56,8 @@ import java.util.Map; |
|
|
|
@RestController |
|
|
|
@RequestMapping("operuser") |
|
|
|
public class OperUserController { |
|
|
|
@Value("${epmet.login.privateKey}") |
|
|
|
private String privateKey; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private OperUserService operUserService; |
|
|
@ -72,9 +76,18 @@ public class OperUserController { |
|
|
|
} |
|
|
|
|
|
|
|
@PostMapping |
|
|
|
public Result save(@RequestBody OperUserDTO dto) { |
|
|
|
public Result save(@RequestBody OperUserDTO dto) throws Exception { |
|
|
|
//效验数据
|
|
|
|
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); |
|
|
|
//解密密码
|
|
|
|
if (dto.getPassword().length() > 50) { |
|
|
|
String password = RSASignature.decryptByPrivateKey(dto.getPassword(), privateKey); |
|
|
|
String email = RSASignature.decryptByPrivateKey(dto.getEmail(), privateKey); |
|
|
|
String phone = RSASignature.decryptByPrivateKey(dto.getPhone(), privateKey); |
|
|
|
dto.setPassword(password); |
|
|
|
dto.setEmail(email); |
|
|
|
dto.setPhone(phone); |
|
|
|
} |
|
|
|
operUserService.save(dto); |
|
|
|
return new Result(); |
|
|
|
} |
|
|
@ -94,10 +107,22 @@ public class OperUserController { |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@PostMapping(value = "updatePwd") |
|
|
|
public Result updatePwd(@LoginUser TokenDto tokenDto,@RequestBody PasswordDTO dto) { |
|
|
|
public Result updatePwd(@LoginUser TokenDto tokenDto,@RequestBody PasswordDTO dto) throws Exception { |
|
|
|
if (StringUtils.isBlank(dto.getNewPassword()) && AppClientConstant.APP_OPER.equals(tokenDto.getClient())){ |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"参数错误","参数错误"); |
|
|
|
} |
|
|
|
//解密密码
|
|
|
|
if (dto.getPassword().length() > 50) { |
|
|
|
String confirmNewPassWord = RSASignature.decryptByPrivateKey(dto.getPassword(), privateKey); |
|
|
|
String newPassword = RSASignature.decryptByPrivateKey(dto.getNewPassword(), privateKey); |
|
|
|
dto.setPassword(confirmNewPassWord); |
|
|
|
dto.setNewPassword(newPassword); |
|
|
|
if (StringUtils.isNotBlank(dto.getOldPassword())){ |
|
|
|
String oldPassWord = RSASignature.decryptByPrivateKey(dto.getOldPassword(), privateKey); |
|
|
|
dto.setOldPassword(oldPassWord); |
|
|
|
} |
|
|
|
} |
|
|
|
//校验长度和 密码是否一致。
|
|
|
|
operUserService.updatePwd(tokenDto.getUserId(),dto); |
|
|
|
return new Result(); |
|
|
|
} |
|
|
|