| | |
| | | import com.sandu.common.domain.ResponseVO; |
| | | import com.sandu.common.enums.AdminStatusStatus; |
| | | import com.sandu.common.enums.ResponseStatusEnums; |
| | | import com.sandu.common.log.Log; |
| | | import com.sandu.common.object.BaseConditionVO; |
| | | import com.sandu.common.security.LoginUserInfo; |
| | | import com.sandu.common.security.annotation.AnonymousAccess; |
| | |
| | | private final TokenProvider tokenProvider; |
| | | private final AdminRoleRelationService adminRoleRelationService; |
| | | |
| | | |
| | | @Log("后台用户登录") |
| | | @AnonymousAccess |
| | | @PostMapping(value = "/login") |
| | | public ResponseVO<Object> login(@RequestBody AdminLoginParam loginParam) { |
| | |
| | | loginUserInfo.setName(admin.getNickName()); |
| | | loginUserInfo.setAccount(admin.getUsername()); |
| | | loginUserInfo.setStatus(admin.getStatus()); |
| | | loginUserInfo.setIcon(admin.getIcon()); |
| | | loginUserInfo.setIp(IpUtil.getRealIp()); |
| | | loginUserInfo.setAdministratorType(AdministratorEnums.ADMIN.getCode()); |
| | | loginUserInfo.setPermission(grantedAuthorities.stream().map(GrantedAuthority::getAuthority).collect(Collectors.joining(","))); |
| | |
| | | return ResponseUtil.success(authInfo); |
| | | } |
| | | |
| | | // @Log("后台用户信息") |
| | | @GetMapping(value = "/info") |
| | | public ResponseVO<Object> getUserInfo() { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | List<Role> roles; |
| | | MapBuilder<Object, Object> builder; |
| | | if (AdministratorEnums.ADMIN.equals(SecurityUtils.getAdministratorIdentity()) |
| | | || AdministratorEnums.CUSTOMER.equals(SecurityUtils.getAdministratorIdentity())) { |
| | | if (AdministratorEnums.ADMIN.getCode().equals(SecurityUtils.getAdministratorIdentity()) |
| | | || AdministratorEnums.CUSTOMER.getCode().equals(SecurityUtils.getAdministratorIdentity())) { |
| | | Admin admin = adminService.getById(userId); |
| | | roles = roleService.listByAdminId(admin.getId()); |
| | | builder = MapUtil.builder().put("admin", admin); |
| | |
| | | return ResponseUtil.success(builder.build()); |
| | | } |
| | | |
| | | @Log("后台用户列表") |
| | | @GetMapping(value = "/list") |
| | | public ResponseVO<Object> listAdmin(BaseConditionVO baseConditionVO, @RequestParam(value = "keyword", required = false) String keyword) { |
| | | PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize()); |
| | |
| | | return ResponseUtil.successPage(adminDtoList); |
| | | } |
| | | |
| | | @Log("后台用户注册") |
| | | @PostMapping("/register") |
| | | public ResponseVO<Object> register(@Validated @RequestBody AdminParam param) { |
| | | boolean result = adminService.register(param); |
| | |
| | | /** |
| | | * 修改管理员信息 |
| | | */ |
| | | @Log("后台用户修改信息") |
| | | @PostMapping("/update/{adminId}") |
| | | public ResponseVO<Object> updateAdmin(@RequestBody AdminParam param, @PathVariable Long adminId) { |
| | | boolean result = adminService.updateAdmin(adminId, param); |
| | |
| | | /** |
| | | * 修改我的密码 |
| | | */ |
| | | @Log("后台用户修改密码") |
| | | @PutMapping("/updateMyPassword") |
| | | public ResponseVO<Object> updateMyPassword(@Validated @RequestBody PwdParam param) { |
| | | boolean result = adminService.updateMyPassword(param); |
| | |
| | | // return ResponseUtil.success(null); |
| | | // } |
| | | |
| | | @Log("后台用户删除") |
| | | @PostMapping("/del/{adminId}") |
| | | public ResponseVO<Object> deleteAdmin(@PathVariable Long adminId) { |
| | | boolean result = adminService.deleteAdmin(adminId); |
| | |
| | | } |
| | | } |
| | | |
| | | @Log("用户修改头像") |
| | | @PostMapping("/updateIcon") |
| | | public ResponseVO<Object> updateIcon(@RequestBody String IconUrl) { |
| | | boolean result; |
| | | //普通用户修改头像 |
| | | if (SecurityUtils.getAdministratorIdentity().equals(AdministratorEnums.NORMAL.getCode())) { |
| | | result= clientService.updateIcon(SecurityUtils.getUserId(), IconUrl); |
| | | }else{ |
| | | //超级管理员、管理员修改头像 |
| | | result= adminService.updateIcon(SecurityUtils.getUserId(), IconUrl); |
| | | } |
| | | |
| | | if (result) { |
| | | return ResponseUtil.success("修改成功"); |
| | | } else { |
| | | return ResponseUtil.fail("修改失败"); |
| | | } |
| | | } |
| | | |
| | | // /** |
| | | // * 给管理员分配角色 |
| | | // * |