大屏页面初始化
This commit is contained in:
@@ -9,5 +9,8 @@ import java.util.List;
|
||||
public class RoleAssignPerm implements Serializable {
|
||||
|
||||
private String roleId;
|
||||
private List<String> permissionIds;
|
||||
|
||||
private String roleName;
|
||||
|
||||
private List<String> menuIds;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,20 @@
|
||||
package com.mini.mybigscreen.biz.controller;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.mini.mybigscreen.Model.Message;
|
||||
import com.mini.mybigscreen.Model.Result;
|
||||
import com.mini.mybigscreen.Model.RoleAssignPerm;
|
||||
import com.mini.mybigscreen.biz.domain.ErpCategory;
|
||||
import com.mini.mybigscreen.biz.domain.HomeRole;
|
||||
import com.mini.mybigscreen.biz.domain.HomeRoleMenu;
|
||||
import com.mini.mybigscreen.biz.service.HomeRoleMenuService;
|
||||
import com.mini.mybigscreen.biz.service.HomeRoleService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -20,16 +28,54 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@RequestMapping("/biz/homeRole")
|
||||
public class HomeRoleController {
|
||||
|
||||
@Resource
|
||||
private HomeRoleMenuService roleMenuService;
|
||||
|
||||
@Resource
|
||||
private HomeRoleService roleService;
|
||||
|
||||
|
||||
@GetMapping("list")
|
||||
public Result<?> getList(){
|
||||
public Result<?> getList() {
|
||||
return Result.success(roleService.list());
|
||||
}
|
||||
|
||||
/**
|
||||
* 角色授权
|
||||
*/
|
||||
@PostMapping("assign")
|
||||
public Result<Message> getRoleAssign(@RequestBody RoleAssignPerm assignPerm) {
|
||||
HomeRole role = roleService.getById(assignPerm.getRoleId());
|
||||
role.setRoleName(assignPerm.getRoleName());
|
||||
roleService.updateById(role);
|
||||
roleMenuService.remove(new LambdaQueryWrapper<HomeRoleMenu>()
|
||||
.eq(HomeRoleMenu::getRoleId, assignPerm.getRoleId()));
|
||||
List<HomeRoleMenu> newRoleMenus = assignPerm.getMenuIds().stream()
|
||||
.map(menuId -> {
|
||||
HomeRoleMenu roleMenu = new HomeRoleMenu();
|
||||
roleMenu.setRoleId(assignPerm.getRoleId());
|
||||
roleMenu.setMenuId(menuId);
|
||||
roleMenu.setUstatus("1");
|
||||
return roleMenu;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
roleMenuService.saveBatch(newRoleMenus);
|
||||
return Result.success(new Message("角色菜单分配成功", 200));
|
||||
}
|
||||
|
||||
@GetMapping("userMenus")
|
||||
public Result<Message> getUserMenus() {
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("roleMenus")
|
||||
public Result<List<HomeRoleMenu>> getRoleMenus(String roleId) {
|
||||
LambdaQueryWrapper<HomeRoleMenu> query = new LambdaQueryWrapper<HomeRoleMenu>()
|
||||
.eq(StrUtil.isNotBlank(roleId), HomeRoleMenu::getRoleId, roleId)
|
||||
.orderByDesc(HomeRoleMenu::getCreateTime);
|
||||
return Result.success(roleMenuService.list(query));
|
||||
}
|
||||
|
||||
|
||||
public Result<Message> save() {
|
||||
|
||||
@@ -48,5 +48,5 @@ public class HomeRoleMenu extends BaseEntity implements Serializable {
|
||||
private String menuId;
|
||||
|
||||
@TableField("ustatus")
|
||||
private Integer ustatus;
|
||||
private String ustatus;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user