| | |
| | | import com.whyc.service.LoginService; |
| | | import com.whyc.service.UserService; |
| | | import com.whyc.util.CommonUtil; |
| | | import com.whyc.util.UserUtil; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | @Autowired |
| | | private UserService userService; |
| | | |
| | | @PostMapping("login") |
| | | @ApiOperation(value ="登录-账号密码") |
| | | public Response login(@RequestParam String name, String pwd,HttpServletRequest request){ |
| | | return service.login(name,pwd,request); |
| | | } |
| | | @PostMapping("loginByRSA") |
| | | @ApiOperation(value ="登录-账号密码加密") |
| | | public Response loginByRSA(@RequestParam String userName, String password,String deliveredCode,HttpServletRequest request,Integer validCode){ |
| | | return service.loginByRSA(userName,password,deliveredCode,request,validCode); |
| | | } |
| | | |
| | | /*@GetMapping("/getRandom") |
| | | @ApiOperation(value = "uKey校验前生成随机数") |
| | | public Response getRandom() throws NoSuchAlgorithmException { |
| | | //int randomNum = (int)((Math.random()*9+1)*10000); |
| | | SecureRandom random = SecureRandom.getInstance("SHA1PRNG"); |
| | | int randomNum = random.nextInt(100000); |
| | | ActionUtil.getSession().setAttribute("uKeyRandom",String.valueOf(randomNum)); |
| | | return new Response().set(1,randomNum); |
| | | }*/ |
| | | |
| | | @PostMapping("logout") |
| | | @ApiOperation(value ="退出登录") |
| | |
| | | } |
| | | |
| | | |
| | | /**拦截登录*/ |
| | | @GetMapping("unauthorized") |
| | | @ApiIgnore |
| | | public void unauthorized(HttpServletRequest request,HttpServletResponse response) throws IOException { |
| | | response.setContentType("text/html;charset=utf-8"); |
| | | response.getWriter().write("您未获取到接口的调用授权,拒绝访问!"); |
| | | |
| | | |
| | | @ApiOperation(value = "修改密码") |
| | | @GetMapping("changeSnId") |
| | | public Response changeSnId(@RequestParam String oldSnId,@RequestParam String newSnId){ |
| | | User uinf= UserUtil.getUser(); |
| | | return userService.changeSnId(uinf.getName(),oldSnId,newSnId); |
| | | } |
| | | |
| | | @PostMapping("/check") |
| | | @ApiOperation(value = "判断是否有另一同一账号登录的用户") |
| | | public Response check(){ |
| | | Response response = service.checkUser(); |
| | | //当前用户 |
| | | HttpSession session = CommonUtil.getSession(); |
| | | User uinf=(User) session.getAttribute("user"); |
| | | if(response.getCode() == 1){ |
| | | session.invalidate(); //清除当前的session; //清除session |
| | | } |
| | | return response; |
| | | } |
| | | |
| | | @GetMapping("loginNoPass") |
| | | @ApiOperation(value = "免密登录") |
| | | public Response loginNoPass(@RequestParam int uId,HttpServletRequest request){ |
| | | return service.loginNoPass(uId,request); |
| | | @ApiOperation(value = "校验密码") |
| | | @GetMapping("checkSnId") |
| | | public Response checkSnId(@RequestParam String checksnId){ |
| | | User uinf= UserUtil.getUser(); |
| | | return userService.checkSnId(uinf.getName(),checksnId); |
| | | } |
| | | |
| | | } |