puzhibing
2025-01-15 e5a94c9d747fa73ec7eb16b284ed5bc4b057bacc
ruoyi-auth/src/main/java/com/ruoyi/auth/controller/TokenController.java
@@ -64,6 +64,27 @@
      userClient.updateSysUser(sysUser);
      return R.ok(map);
   }
   @PostMapping("loginShop")
   public R<?> loginShop(@RequestBody LoginBody form, HttpServletRequest request) {
      // 用户登录
      LoginUser userInfo = sysLoginService.loginShop(form.getUsername(), form.getPassword(), request);
      HashMap<String, Object> map = new HashMap<>();
      map.put("token", tokenService.createToken(userInfo));
      List<SysRole> roles = userInfo.getSysUser().getRoles();
        if(CollectionUtils.isEmpty(roles)){
            return R.fail("请关联角色!");
        }
        map.put("roleName",roles.get(0).getRoleName());
      map.put("info", userInfo);
      // 修改用户最后登录时间
      SysUser sysUser = new SysUser();
      sysUser.setUserId(userInfo.getSysUser().getUserId());
      sysUser.setLoginDate(new Date());
      System.out.println("修改用户登录时间" + sysUser);
      userClient.updateSysUser(sysUser);
      return R.ok(map);
   }
   
   @DeleteMapping("logout")
   public R<?> logout(HttpServletRequest request) {