| | |
| | | import com.sandu.common.object.BaseConditionVO; |
| | | import com.sandu.common.redis.RedisService; |
| | | import com.sandu.common.security.LoginUserInfo; |
| | | import com.sandu.common.security.annotation.AnonymousAccess; |
| | | import com.sandu.common.security.config.SecurityProperties; |
| | | import com.sandu.common.security.token.TokenProvider; |
| | | import com.sandu.common.util.IpUtil; |
| | |
| | | private PermissionConfig permissionConfig; |
| | | private final RedisService redisService; |
| | | |
| | | @Log("后台用户登录") |
| | | @AnonymousAccess |
| | | @PostMapping(value = "/login") |
| | | public ResponseVO<Object> login(HttpServletRequest request, @RequestBody AdminLoginParam loginParam) { |
| | | public ResponseVO<Object> login(HttpServletRequest request, AdminLoginParam loginParam) { |
| | | Admin admin = adminService.getOne(Wrappers.lambdaQuery(Admin.class).eq(Admin::getUsername, loginParam.getUsername()).last("limit 1")); |
| | | if (admin == null) { |
| | | return ResponseUtil.error(ResponseStatusEnums.BAD_CREDENTIALS.getCode(), ResponseStatusEnums.BAD_CREDENTIALS.getMessage()); |
| | |
| | | // 返回 token 与 用户信息 |
| | | Map<String, Object> authInfo = new HashMap<String, Object>(2) {{ |
| | | put("token", properties.getTokenStartWith() + token); |
| | | put("user", admin); |
| | | put("admin", admin); |
| | | put("client", null); |
| | | }}; |
| | | |
| | | |
| | |
| | | |
| | | @Log("后台用户列表") |
| | | @GetMapping(value = "/list") |
| | | public ResponseVO<Object> listAdmin(BaseConditionVO baseConditionVO, @RequestParam(value = "keyword", required = false) String keyword) { |
| | | public ResponseVO<Object> listAdmin(BaseConditionVO baseConditionVO, |
| | | @RequestParam(value = "keyword", required = false) String keyword, |
| | | @RequestParam(value = "order", required = false) Integer order, |
| | | @RequestParam(value = "seq", required = false) Integer seq) { |
| | | if (!permissionConfig.check(MenuEnum.ADMIN_LIST.getCode())) { |
| | | return ResponseUtil.fail("缺少对应用户权限"); |
| | | } |
| | | return ResponseUtil.successPage(adminService.listAdmin(baseConditionVO, keyword)); |
| | | return ResponseUtil.successPage(adminService.listAdmin(baseConditionVO, keyword, order, seq)); |
| | | } |
| | | |
| | | @Log("后台用户注册") |
| | |
| | | } |
| | | } |
| | | |
| | | @Log("后台用户删除") |
| | | @PostMapping("/del/{adminId}") |
| | | @GetMapping("/del/{adminId}") |
| | | public ResponseVO<Object> deleteAdmin(@PathVariable Long adminId) { |
| | | if (!permissionConfig.check(MenuEnum.ADMIN_DELETE.getCode())) { |
| | | return ResponseUtil.fail("缺少对应用户权限"); |
| | | } |
| | | boolean result = adminService.deleteAdmin(adminId); |
| | | if (result) { |
| | | return ResponseUtil.success("修改成功"); |
| | | return ResponseUtil.success("删除管理员成功!"); |
| | | } else { |
| | | return ResponseUtil.fail("修改失败"); |
| | | return ResponseUtil.fail("删除管理员失败!"); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | return ResponseUtil.success(userPermissionList); |
| | | } |
| | | |
| | | |
| | | @GetMapping("/creatUserKey") |
| | | public ResponseVO<Object> creatUserKey(@RequestParam(required = false, value = "userId") Long userId, |
| | | @RequestParam(required = false, value = "requstType") Integer requstType) { |
| | | if (!AdministratorEnums.ADMIN.getCode().equals(SecurityUtils.getAdministratorIdentity())) { |
| | | throw new BusinessException("非超级管理员无法操作!"); |
| | | } |
| | | return ResponseUtil.success(adminService.creatUserKey(userId, requstType)); |
| | | } |
| | | } |