|
@@ -2,13 +2,13 @@ package com.sf.admin.controller;
|
|
|
|
|
|
import com.sf.admin.dto.CommonResult;
|
|
|
import com.sf.admin.entity.UmsRole;
|
|
|
+import com.sf.admin.service.IUmsAdminRoleRelationService;
|
|
|
import com.sf.admin.service.IUmsRoleService;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
-import org.springframework.web.bind.annotation.GetMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
@@ -24,11 +24,36 @@ import java.util.List;
|
|
|
public class UmsRoleController {
|
|
|
|
|
|
private final IUmsRoleService roleService;
|
|
|
+ private final IUmsAdminRoleRelationService adminRoleRelationService;
|
|
|
|
|
|
+
|
|
|
|
|
|
@GetMapping("/role/listAll")
|
|
|
- public CommonResult<List<UmsRole>> listAll(){
|
|
|
+ public CommonResult<List<UmsRole>> listAll() {
|
|
|
List<UmsRole> umsRoles = roleService.list();
|
|
|
return CommonResult.success(umsRoles);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @GetMapping("/admin/role/{id}")
|
|
|
+ public CommonResult<List<UmsRole>> getRolesByAdminId(@PathVariable("id") Long adminId) {
|
|
|
+ List<UmsRole> roles = adminRoleRelationService.getRolesByUserId(adminId);
|
|
|
+ return CommonResult.success(roles);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @PostMapping("/admin/role/update")
|
|
|
+ public CommonResult updateRole(
|
|
|
+ @RequestParam("adminId") Long adminId, @RequestParam("roleIds") String roleIds) {
|
|
|
+ String[] roleIdArr = roleIds.split(",");
|
|
|
+ List<Long> roleIdList = Arrays.stream(roleIdArr).map(
|
|
|
+ roleId -> Long.parseLong(roleId)).toList();
|
|
|
+
|
|
|
+ adminRoleRelationService.updateRole(adminId, roleIdList);
|
|
|
+ return CommonResult.success(null);
|
|
|
+ }
|
|
|
+
|
|
|
}
|