package com.epmet.controller; import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.dto.form.*; import com.epmet.dto.result.StaffOrgsResultDTO; import com.epmet.dto.result.UserTokenResultDTO; import com.epmet.service.GovLoginService; import org.springframework.beans.factory.annotation.Autowired; 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; import java.util.HashMap; import java.util.List; /** * @Description 政府端登录 * @Author yinzuomei * @Date 2020/4/20 10:54 */ @RestController @RequestMapping("gov") public class GovLoginController { @Autowired private GovLoginService govLoginService; /** * @param formDTO * @return com.epmet.commons.tools.utils.Result * @Author yinzuomei * @Description 1、政府端小程序根据wxCode获取上一次登录信息,返回token * @Date 2020/4/20 11:22 **/ @PostMapping(value = "/loginwxmp/loginbywxcode") public Result loginByWxCode(@RequestBody GovWxmpFormDTO formDTO) { ValidatorUtils.validateEntity(formDTO,LoginCommonFormDTO.AddUserInternalGroup.class); UserTokenResultDTO userTokenResultDTO=govLoginService.loginByWxCode(formDTO); return new Result().ok(userTokenResultDTO); } /** * @param formDTO 手机号 * @return com.epmet.commons.tools.utils.Result * @Author yinzuomei * @Description 2、政府端微信小程序登录-发送验证码 * @Date 2020/4/18 10:58 **/ @PostMapping(value = "/loginwxmp/sendsmscode") public Result sendSmsCode(@RequestBody SendSmsCodeFormDTO formDTO) { ValidatorUtils.validateEntity(formDTO,SendSmsCodeFormDTO.AddUserShowGroup.class); govLoginService.sendSmsCode(formDTO); return new Result(); } /** * @param formDTO * @return com.epmet.commons.tools.utils.Result * @Author yinzuomei * @Description 3、手机验证码获取组织 * @Date 2020/4/18 21:14 **/ @PostMapping(value = "/loginwxmp/getmyorg") public Result> getmyorg(@RequestBody StaffOrgsFormDTO formDTO) { ValidatorUtils.validateEntity(formDTO,StaffOrgsFormDTO.AddUserShowGroup.class, StaffOrgsFormDTO.GetMyOrgByLoginWxmp.class); List staffOrgs=govLoginService.getMyOrg(formDTO); return new Result>().ok(staffOrgs); } /** * @param formDTO * @return com.epmet.commons.tools.utils.Result * @Author yinzuomei * @Description 4、选择组织,进入首页 * @Date 2020/4/20 13:07 **/ @PostMapping(value = "/loginwxmp/enterorg") public Result enterOrg(@RequestBody GovWxmpEnteOrgFormDTO formDTO) { ValidatorUtils.validateEntity(formDTO,GovWxmpEnteOrgFormDTO.AddUserShowGroup.class,GovWxmpEnteOrgFormDTO.AddUserInternalGroup.class); UserTokenResultDTO userTokenResultDTO=govLoginService.enterOrg(formDTO); return new Result().ok(userTokenResultDTO); } /** * @param tokenDto * @return com.epmet.commons.tools.utils.Result * @Author yinzuomei * @Description 政府端小程序退出 * @Date 2020/4/21 22:22 **/ @PostMapping("/loginwxmp/loginout") public Result loginOut(@LoginUser TokenDto tokenDto) { govLoginService.loginOut(tokenDto); return new Result(); } /** * 更新缓存的角色列表 * @param form * @return */ @PostMapping("/updatecachedroles") public Result updateCachedRoles(@RequestBody UpdateCachedRolesFormDTO form) { ValidatorUtils.validateEntity(form); govLoginService.updateCachedRoles(form.getStaffId(), form.getOrgId(), form.getRoleIds()); return new Result(); } /** * @param formDTO * @return com.epmet.commons.tools.utils.Result> * @author yinzuomei * @description 6、手机号密码获取组织 * @Date 2020/6/30 22:43 **/ @PostMapping(value = "/getmyorgbypassword") public Result> getMyOrgByPassword(@RequestBody StaffOrgsFormDTO formDTO) { ValidatorUtils.validateEntity(formDTO, StaffOrgsFormDTO.AddUserShowGroup.class, StaffOrgsFormDTO.GetMyOrgByPassWordGroup.class); List staffOrgs = govLoginService.getMyOrgByPassword(formDTO); return new Result>().ok(staffOrgs); } /** * 区块链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(); String userId = govLoginService.blockChainStaffAuthenticationByPwd(customerId, mobile, password); HashMap m = new HashMap<>(); m.put("userId", userId); return new Result().ok(m); } }