package com.epmet.controller; import com.epmet.auth.dto.result.BlockChainStaffAuthResultDTO; 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.BcStaffAuthenticationFormDTO; 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 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().ok(govWebService.login(formDTO)); } /** * desc: 获取前端密码加密 公钥 * * @return com.epmet.commons.tools.utils.Result * @author LiuJanJun * @date 2021/3/8 5:07 下午 */ @PostMapping("getKey") public Result getPubKey() { return new Result().ok(publicKey); } /** * 区块链web 系统身份认证 * @param input * @return */ @PostMapping("/blockchain/authentication") public Result blockChainGetStaffInfoByPwd(@RequestBody BcStaffAuthenticationFormDTO input) { ValidatorUtils.validateEntity(input); String customerId = input.getCustomerId(); String mobile = input.getMobile(); String password = input.getPassword(); BlockChainStaffAuthResultDTO r = govWebService.blockChainStaffAuthenticationByPwd(customerId, mobile, password); return new Result().ok(r); } }