You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

69 lines
2.0 KiB

package com.epmet.controller;
import com.epmet.commons.tools.utils.RSASignature;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.dto.form.GovWebLoginFormDTO;
import com.epmet.dto.result.UserTokenResultDTO;
import com.epmet.service.GovWebService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
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;
/**
* @author sun
* @Description PC工作端-登陆服务
*/
@Slf4j
@RestController
@RequestMapping("govweb")
public class GovWebController {
@Autowired
private GovWebService govWebService;
@Value("${epmet.login.publicKey}")
private String publicKey;
@Value("${epmet.login.privateKey}")
private String privateKey;
/**
* @param formDTO
* @return
* @Author sun
* @Description PC工作端-工作人员登录
**/
@PostMapping("login")
public Result<UserTokenResultDTO> workLogin(@RequestBody GovWebLoginFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO);
try {
if (formDTO.getPassword().length() > 50) {
String newPassword = RSASignature.decryptByPrivateKey(formDTO.getPassword(), privateKey);
formDTO.setPassword(newPassword);
}
} catch (Exception e) {
log.error("method exception", e);
}
return new Result<UserTokenResultDTO>().ok(govWebService.login(formDTO));
}
/**
* desc: 获取前端密码加密 公钥
*
* @return com.epmet.commons.tools.utils.Result
* @author LiuJanJun
* @date 2021/3/8 5:07 下午
*/
@PostMapping("getKey")
public Result<String> getPubKey() {
return new Result().ok(publicKey);
}
}