添加护理单元菜单权限功能及员工对应权限功能
This commit is contained in:
parent
16b7f90c5a
commit
816b8c7e59
|
|
@ -0,0 +1,280 @@
|
|||
package com.nu.modules.appConfig.controller;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.nu.modules.appConfig.entity.AppPermissionTree;
|
||||
import com.nu.modules.appConfig.utils.AppPermissionDataUtil;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.common.system.query.QueryRuleEnum;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import com.nu.modules.appConfig.entity.NuAppPermission;
|
||||
import com.nu.modules.appConfig.service.INuAppPermissionService;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
||||
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
||||
import org.jeecgframework.poi.excel.entity.ExportParams;
|
||||
import org.jeecgframework.poi.excel.entity.ImportParams;
|
||||
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
||||
import org.jeecg.common.system.base.controller.JeecgController;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
|
||||
/**
|
||||
* @Description: 菜单表
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2025-12-31
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Api(tags="菜单表")
|
||||
@RestController
|
||||
@RequestMapping("/appConfig/nuAppPermission")
|
||||
@Slf4j
|
||||
public class NuAppPermissionController extends JeecgController<NuAppPermission, INuAppPermissionService> {
|
||||
@Autowired
|
||||
private INuAppPermissionService nuAppPermissionService;
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
* @param nuAppPermission
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
//@AutoLog(value = "菜单表-分页列表查询")
|
||||
@ApiOperation(value="菜单表-分页列表查询", notes="菜单表-分页列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<List<AppPermissionTree>> queryPageList(NuAppPermission nuAppPermission,
|
||||
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
||||
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
long start = System.currentTimeMillis();
|
||||
Result<List<AppPermissionTree>> result = new Result<>();
|
||||
try {
|
||||
LambdaQueryWrapper<NuAppPermission> query = new LambdaQueryWrapper<NuAppPermission>();
|
||||
query.eq(NuAppPermission::getDelFlag, CommonConstant.DEL_FLAG_0);
|
||||
query.orderByAsc(NuAppPermission::getSortNo);
|
||||
|
||||
//支持通过菜单名字,模糊查询
|
||||
if(oConvertUtils.isNotEmpty(nuAppPermission.getName())){
|
||||
query.like(NuAppPermission::getName, nuAppPermission.getName());
|
||||
}
|
||||
List<NuAppPermission> list = nuAppPermissionService.list(query);
|
||||
List<AppPermissionTree> treeList = new ArrayList<>();
|
||||
|
||||
//如果有菜单名查询条件,则平铺数据 不做上下级
|
||||
if(oConvertUtils.isNotEmpty(nuAppPermission.getName())){
|
||||
if(list!=null && list.size()>0){
|
||||
treeList = list.stream().map(e -> {
|
||||
e.setLeaf(true);
|
||||
return new AppPermissionTree(e);
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
}else{
|
||||
getTreeList(treeList, list, null);
|
||||
}
|
||||
result.setResult(treeList);
|
||||
result.setSuccess(true);
|
||||
log.info("======获取全部菜单数据=====耗时:" + (System.currentTimeMillis() - start) + "毫秒");
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
* @param permission
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "菜单表-添加")
|
||||
@ApiOperation(value="菜单表-添加", notes="菜单表-添加")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<NuAppPermission> add(@RequestBody NuAppPermission permission) {
|
||||
Result<NuAppPermission> result = new Result<NuAppPermission>();
|
||||
try {
|
||||
permission = AppPermissionDataUtil.intelligentProcessData(permission);
|
||||
nuAppPermissionService.addPermission(permission);
|
||||
result.success("添加成功!");
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
result.error500("操作失败");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param permission
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "菜单表-编辑")
|
||||
@ApiOperation(value="菜单表-编辑", notes="菜单表-编辑")
|
||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
|
||||
public Result<NuAppPermission> edit(@RequestBody NuAppPermission permission) {
|
||||
Result<NuAppPermission> result = new Result<>();
|
||||
try {
|
||||
permission = AppPermissionDataUtil.intelligentProcessData(permission);
|
||||
nuAppPermissionService.editPermission(permission);
|
||||
result.success("修改成功!");
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
result.error500("操作失败");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "菜单表-通过id删除")
|
||||
@ApiOperation(value="菜单表-通过id删除", notes="菜单表-通过id删除")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<String> delete(@RequestParam(name="id",required=true) String id) {
|
||||
nuAppPermissionService.removeById(id);
|
||||
return Result.OK("删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "菜单表-批量删除")
|
||||
@ApiOperation(value="菜单表-批量删除", notes="菜单表-批量删除")
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
||||
this.nuAppPermissionService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
return Result.OK("批量删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
//@AutoLog(value = "菜单表-通过id查询")
|
||||
@ApiOperation(value="菜单表-通过id查询", notes="菜单表-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<NuAppPermission> queryById(@RequestParam(name="id",required=true) String id) {
|
||||
NuAppPermission nuAppPermission = nuAppPermissionService.getById(id);
|
||||
if(nuAppPermission==null) {
|
||||
return Result.error("未找到对应数据");
|
||||
}
|
||||
return Result.OK(nuAppPermission);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel
|
||||
*
|
||||
* @param request
|
||||
* @param nuAppPermission
|
||||
*/
|
||||
@RequiresPermissions("appConfig:nu_app_permission:exportXls")
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, NuAppPermission nuAppPermission) {
|
||||
return super.exportXls(request, nuAppPermission, NuAppPermission.class, "菜单表");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过excel导入数据
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@RequiresPermissions("appConfig:nu_app_permission:importExcel")
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
return super.importExcel(request, response, NuAppPermission.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验角色编码唯一
|
||||
*/
|
||||
@RequestMapping(value = "/checkRoleCode", method = RequestMethod.GET)
|
||||
public Result<Boolean> checkUsername(String id,String roleCode) {
|
||||
Result<Boolean> result = new Result<>();
|
||||
//如果此参数为false则程序发生异常
|
||||
result.setResult(true);
|
||||
log.info("--验证角色编码是否唯一---id:"+id+"--roleCode:"+roleCode);
|
||||
try {
|
||||
NuAppPermission role = null;
|
||||
if(oConvertUtils.isNotEmpty(id)) {
|
||||
role = nuAppPermissionService.getById(id);
|
||||
}
|
||||
//SysRole newRole = sysRoleService.getOne(new QueryWrapper<SysRole>().lambda().eq(SysRole::getRoleCode, roleCode));
|
||||
NuAppPermission newRole = nuAppPermissionService.getRoleNoTenant(roleCode);
|
||||
if(newRole!=null) {
|
||||
//如果根据传入的roleCode查询到信息了,那么就需要做校验了。
|
||||
if(role==null) {
|
||||
//role为空=>新增模式=>只要roleCode存在则返回false
|
||||
result.setSuccess(false);
|
||||
result.setMessage("角色编码已存在");
|
||||
return result;
|
||||
}else if(!id.equals(newRole.getId())) {
|
||||
//否则=>编辑模式=>判断两者ID是否一致-
|
||||
result.setSuccess(false);
|
||||
result.setMessage("角色编码已存在");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
result.setSuccess(false);
|
||||
result.setResult(false);
|
||||
result.setMessage(e.getMessage());
|
||||
return result;
|
||||
}
|
||||
result.setSuccess(true);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
private void getTreeList(List<AppPermissionTree> treeList, List<NuAppPermission> metaList, AppPermissionTree temp) {
|
||||
for (NuAppPermission permission : metaList) {
|
||||
String tempPid = permission.getParentId();
|
||||
AppPermissionTree tree = new AppPermissionTree(permission);
|
||||
if (temp == null && oConvertUtils.isEmpty(tempPid)) {
|
||||
treeList.add(tree);
|
||||
if (!tree.getIsLeaf()) {
|
||||
getTreeList(treeList, metaList, tree);
|
||||
}
|
||||
} else if (temp != null && tempPid != null && tempPid.equals(temp.getId())) {
|
||||
temp.getChildren().add(tree);
|
||||
if (!tree.getIsLeaf()) {
|
||||
getTreeList(treeList, metaList, tree);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,439 @@
|
|||
package com.nu.modules.appConfig.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 菜单树,封装树结构
|
||||
* @author: jeecg-boot
|
||||
*/
|
||||
public class AppPermissionTree implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private String id;
|
||||
|
||||
private String key;
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 父id
|
||||
*/
|
||||
private String parentId;
|
||||
|
||||
/**
|
||||
* 菜单名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 菜单权限编码
|
||||
*/
|
||||
private String perms;
|
||||
/**
|
||||
* 权限策略1显示2禁用
|
||||
*/
|
||||
private String permsType;
|
||||
|
||||
/**
|
||||
* 菜单图标
|
||||
*/
|
||||
private String icon;
|
||||
|
||||
/**
|
||||
* 组件
|
||||
*/
|
||||
private String component;
|
||||
|
||||
/**
|
||||
* 组件名字
|
||||
*/
|
||||
private String componentName;
|
||||
|
||||
/**
|
||||
* 跳转网页链接
|
||||
*/
|
||||
private String url;
|
||||
|
||||
/**
|
||||
* 一级菜单跳转地址
|
||||
*/
|
||||
private String redirect;
|
||||
|
||||
/**
|
||||
* 菜单排序
|
||||
*/
|
||||
private Double sortNo;
|
||||
|
||||
/**
|
||||
* 类型(0:一级菜单;1:子菜单 ;2:按钮权限)
|
||||
*/
|
||||
private Integer menuType;
|
||||
|
||||
/**
|
||||
* 是否叶子节点: 1:是 0:不是
|
||||
*/
|
||||
private boolean isLeaf;
|
||||
|
||||
/**
|
||||
* 是否路由菜单: 0:不是 1:是(默认值1)
|
||||
*/
|
||||
private boolean route;
|
||||
|
||||
|
||||
/**
|
||||
* 是否路缓存页面: 0:不是 1:是(默认值1)
|
||||
*/
|
||||
private boolean keepAlive;
|
||||
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 删除状态 0正常 1已删除
|
||||
*/
|
||||
private Integer delFlag;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
/**alwaysShow*/
|
||||
private boolean alwaysShow;
|
||||
/**是否隐藏路由菜单: 0否,1是(默认值0)*/
|
||||
private boolean hidden;
|
||||
|
||||
/**按钮权限状态(0无效1有效)*/
|
||||
private String status;
|
||||
|
||||
/*update_begin author:wuxianquan date:20190908 for:model增加字段 */
|
||||
/** 外链菜单打开方式 0/内部打开 1/外部打开 */
|
||||
private boolean internalOrExternal;
|
||||
/*update_end author:wuxianquan date:20190908 for:model增加字段 */
|
||||
|
||||
/*update_begin author:liusq date:20230601 for:【issues/4986】model增加hideTab字段 */
|
||||
/**
|
||||
* 是否隐藏Tab: 0否,1是(默认值0)
|
||||
*/
|
||||
private boolean hideTab;
|
||||
/*update_end author:liusq date:20230601 for:【issues/4986】model增加hideTab字段 */
|
||||
|
||||
private String menuCode;
|
||||
|
||||
public AppPermissionTree() {
|
||||
}
|
||||
|
||||
public AppPermissionTree(NuAppPermission permission) {
|
||||
this.key = permission.getId();
|
||||
this.id = permission.getId();
|
||||
this.perms = permission.getPerms();
|
||||
this.permsType = permission.getPermsType();
|
||||
this.component = permission.getComponent();
|
||||
this.componentName = permission.getComponentName();
|
||||
this.createBy = permission.getCreateBy();
|
||||
this.createTime = permission.getCreateTime();
|
||||
this.delFlag = permission.getDelFlag();
|
||||
this.description = permission.getDescription();
|
||||
this.icon = permission.getIcon();
|
||||
this.isLeaf = permission.isLeaf();
|
||||
this.menuType = permission.getMenuType();
|
||||
this.name = permission.getName();
|
||||
this.parentId = permission.getParentId();
|
||||
this.sortNo = permission.getSortNo();
|
||||
this.updateBy = permission.getUpdateBy();
|
||||
this.updateTime = permission.getUpdateTime();
|
||||
this.redirect = permission.getRedirect();
|
||||
this.url = permission.getUrl();
|
||||
this.hidden = permission.isHidden();
|
||||
this.route = permission.isRoute();
|
||||
this.keepAlive = permission.isKeepAlive();
|
||||
this.alwaysShow= permission.isAlwaysShow();
|
||||
/*update_begin author:wuxianquan date:20190908 for:赋值 */
|
||||
this.internalOrExternal = permission.isInternalOrExternal();
|
||||
/*update_end author:wuxianquan date:20190908 for:赋值 */
|
||||
this.title=permission.getName();
|
||||
/*update_end author:liusq date:20230601 for:【issues/4986】model增加hideTab字段 */
|
||||
this.hideTab = permission.isHideTab();
|
||||
/*update_end author:liusq date:20230601 for:【issues/4986】model增加hideTab字段 */
|
||||
if (!permission.isLeaf()) {
|
||||
this.children = new ArrayList<AppPermissionTree>();
|
||||
}
|
||||
this.status = permission.getStatus();
|
||||
this.menuCode = permission.getMenuCode();
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
private List<AppPermissionTree> children;
|
||||
|
||||
public boolean isLeaf() {
|
||||
return isLeaf;
|
||||
}
|
||||
|
||||
public void setLeaf(boolean leaf) {
|
||||
isLeaf = leaf;
|
||||
}
|
||||
|
||||
public boolean isKeepAlive() {
|
||||
return keepAlive;
|
||||
}
|
||||
|
||||
public void setKeepAlive(boolean keepAlive) {
|
||||
this.keepAlive = keepAlive;
|
||||
}
|
||||
|
||||
public boolean isAlwaysShow() {
|
||||
return alwaysShow;
|
||||
}
|
||||
|
||||
public void setAlwaysShow(boolean alwaysShow) {
|
||||
this.alwaysShow = alwaysShow;
|
||||
}
|
||||
public List<AppPermissionTree> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setChildren(List<AppPermissionTree> children) {
|
||||
this.children = children;
|
||||
}
|
||||
|
||||
public String getRedirect() {
|
||||
return redirect;
|
||||
}
|
||||
|
||||
public void setRedirect(String redirect) {
|
||||
this.redirect = redirect;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getParentId() {
|
||||
return parentId;
|
||||
}
|
||||
|
||||
public void setParentId(String parentId) {
|
||||
this.parentId = parentId;
|
||||
}
|
||||
|
||||
public boolean isHidden() {
|
||||
return hidden;
|
||||
}
|
||||
|
||||
public void setHidden(boolean hidden) {
|
||||
this.hidden = hidden;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
public void setIcon(String icon) {
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
public String getComponent() {
|
||||
return component;
|
||||
}
|
||||
|
||||
public void setComponent(String component) {
|
||||
this.component = component;
|
||||
}
|
||||
|
||||
public String getComponentName() {
|
||||
return componentName;
|
||||
}
|
||||
|
||||
public void setComponentName(String componentName) {
|
||||
this.componentName = componentName;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public Double getSortNo() {
|
||||
return sortNo;
|
||||
}
|
||||
|
||||
public void setSortNo(Double sortNo) {
|
||||
this.sortNo = sortNo;
|
||||
}
|
||||
|
||||
public Integer getMenuType() {
|
||||
return menuType;
|
||||
}
|
||||
|
||||
public void setMenuType(Integer menuType) {
|
||||
this.menuType = menuType;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public boolean isRoute() {
|
||||
return route;
|
||||
}
|
||||
|
||||
public void setRoute(boolean route) {
|
||||
this.route = route;
|
||||
}
|
||||
|
||||
public Integer getDelFlag() {
|
||||
return delFlag;
|
||||
}
|
||||
|
||||
public void setDelFlag(Integer delFlag) {
|
||||
this.delFlag = delFlag;
|
||||
}
|
||||
|
||||
public String getCreateBy() {
|
||||
return createBy;
|
||||
}
|
||||
|
||||
public void setCreateBy(String createBy) {
|
||||
this.createBy = createBy;
|
||||
}
|
||||
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public String getUpdateBy() {
|
||||
return updateBy;
|
||||
}
|
||||
|
||||
public void setUpdateBy(String updateBy) {
|
||||
this.updateBy = updateBy;
|
||||
}
|
||||
|
||||
public Date getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
public void setUpdateTime(Date updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public String getPerms() {
|
||||
return perms;
|
||||
}
|
||||
|
||||
public void setPerms(String perms) {
|
||||
this.perms = perms;
|
||||
}
|
||||
|
||||
public boolean getIsLeaf() {
|
||||
return isLeaf;
|
||||
}
|
||||
|
||||
public void setIsLeaf(boolean isLeaf) {
|
||||
this.isLeaf = isLeaf;
|
||||
}
|
||||
|
||||
public String getPermsType() {
|
||||
return permsType;
|
||||
}
|
||||
|
||||
public void setPermsType(String permsType) {
|
||||
this.permsType = permsType;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
/*update_begin author:wuxianquan date:20190908 for:get set方法 */
|
||||
public boolean isInternalOrExternal() {
|
||||
return internalOrExternal;
|
||||
}
|
||||
|
||||
public void setInternalOrExternal(boolean internalOrExternal) {
|
||||
this.internalOrExternal = internalOrExternal;
|
||||
}
|
||||
/*update_end author:wuxianquan date:20190908 for:get set 方法 */
|
||||
|
||||
public boolean isHideTab() {
|
||||
return hideTab;
|
||||
}
|
||||
|
||||
public void setHideTab(boolean hideTab) {
|
||||
this.hideTab = hideTab;
|
||||
}
|
||||
|
||||
public String getMenuCode() {
|
||||
return menuCode;
|
||||
}
|
||||
|
||||
public void setMenuCode(String menuCode) {
|
||||
this.menuCode = menuCode;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
package com.nu.modules.appConfig.entity;
|
||||
|
||||
/**
|
||||
* 默认首页常量
|
||||
*/
|
||||
public interface DefIndexConst {
|
||||
|
||||
/**
|
||||
* 默认首页的roleCode
|
||||
*/
|
||||
String DEF_INDEX_ALL = "DEF_INDEX_ALL";
|
||||
|
||||
/**
|
||||
* 默认首页的缓存key
|
||||
*/
|
||||
String CACHE_KEY = "sys:cache:def_index";
|
||||
|
||||
/**
|
||||
* 默认首页的初始值
|
||||
*/
|
||||
String DEF_INDEX_NAME = "首页";
|
||||
String DEF_INDEX_URL = "/dashboard/analysis";
|
||||
String DEF_INDEX_COMPONENT = "dashboard/Analysis";
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,196 @@
|
|||
package com.nu.modules.appConfig.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Date;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import org.jeecg.common.constant.ProvinceCityArea;
|
||||
import org.jeecg.common.util.SpringContextUtils;
|
||||
import lombok.Data;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import org.jeecg.common.aspect.annotation.Dict;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* @Description: 菜单表
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2025-12-31
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Data
|
||||
@TableName("nu_app_permission")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value="nu_app_permission对象", description="菜单表")
|
||||
public class NuAppPermission implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 父id
|
||||
*/
|
||||
private String parentId;
|
||||
|
||||
/**
|
||||
* 菜单名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 菜单权限编码,例如:“sys:schedule:list,sys:schedule:info”,多个逗号隔开
|
||||
*/
|
||||
private String perms;
|
||||
/**
|
||||
* 权限策略1显示2禁用
|
||||
*/
|
||||
private String permsType;
|
||||
|
||||
/**
|
||||
* 菜单图标
|
||||
*/
|
||||
private String icon;
|
||||
|
||||
/**
|
||||
* 组件
|
||||
*/
|
||||
private String component;
|
||||
|
||||
/**
|
||||
* 组件名字
|
||||
*/
|
||||
private String componentName;
|
||||
|
||||
/**
|
||||
* 路径
|
||||
*/
|
||||
private String url;
|
||||
/**
|
||||
* 一级菜单跳转地址
|
||||
*/
|
||||
private String redirect;
|
||||
|
||||
/**
|
||||
* 菜单排序
|
||||
*/
|
||||
private Double sortNo;
|
||||
|
||||
/**
|
||||
* 类型(0:一级菜单;1:子菜单 ;2:按钮权限)
|
||||
*/
|
||||
@Dict(dicCode = "menu_type")
|
||||
private Integer menuType;
|
||||
|
||||
/**
|
||||
* 是否叶子节点: 1:是 0:不是
|
||||
*/
|
||||
@TableField(value="is_leaf")
|
||||
private boolean leaf;
|
||||
|
||||
/**
|
||||
* 是否路由菜单: 0:不是 1:是(默认值1)
|
||||
*/
|
||||
@TableField(value="is_route")
|
||||
private boolean route;
|
||||
|
||||
|
||||
/**
|
||||
* 是否缓存页面: 0:不是 1:是(默认值1)
|
||||
*/
|
||||
@TableField(value="keep_alive")
|
||||
private boolean keepAlive;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 删除状态 0正常 1已删除
|
||||
*/
|
||||
private Integer delFlag;
|
||||
|
||||
/**
|
||||
* 是否配置菜单的数据权限 1是0否 默认0
|
||||
*/
|
||||
private Integer ruleFlag;
|
||||
|
||||
/**
|
||||
* 是否隐藏路由菜单: 0否,1是(默认值0)
|
||||
*/
|
||||
private boolean hidden;
|
||||
|
||||
/**
|
||||
* 是否隐藏Tab: 0否,1是(默认值0)
|
||||
*/
|
||||
private boolean hideTab;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
/**按钮权限状态(0无效1有效)*/
|
||||
private java.lang.String status;
|
||||
|
||||
/**alwaysShow*/
|
||||
private boolean alwaysShow;
|
||||
|
||||
private String menuCode;
|
||||
|
||||
/*update_begin author:wuxianquan date:20190908 for:实体增加字段 */
|
||||
/** 外链菜单打开方式 0/内部打开 1/外部打开 */
|
||||
private boolean internalOrExternal;
|
||||
/*update_end author:wuxianquan date:20190908 for:实体增加字段 */
|
||||
|
||||
public NuAppPermission() {
|
||||
|
||||
}
|
||||
public NuAppPermission(boolean index) {
|
||||
if(index) {
|
||||
this.id = "9502685863ab87f0ad1134142788a385";
|
||||
this.name = DefIndexConst.DEF_INDEX_NAME;
|
||||
this.component = DefIndexConst.DEF_INDEX_COMPONENT;
|
||||
this.componentName = "dashboard-analysis";
|
||||
this.url = DefIndexConst.DEF_INDEX_URL;
|
||||
this.icon="home";
|
||||
this.menuType=0;
|
||||
this.sortNo=0.0;
|
||||
this.ruleFlag=0;
|
||||
this.delFlag=0;
|
||||
this.alwaysShow=false;
|
||||
this.route=true;
|
||||
this.keepAlive=true;
|
||||
this.leaf=true;
|
||||
this.hidden=false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,183 @@
|
|||
package com.nu.modules.appConfig.entity;
|
||||
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 树形列表用到
|
||||
* @author: jeecg-boot
|
||||
*/
|
||||
public class TreeModel implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 4013193970046502756L;
|
||||
|
||||
private String key;
|
||||
|
||||
private String title;
|
||||
|
||||
private String slotTitle;
|
||||
|
||||
private boolean isLeaf;
|
||||
|
||||
private String icon;
|
||||
|
||||
private Integer ruleFlag;
|
||||
|
||||
private Map<String,String> scopedSlots;
|
||||
|
||||
public Map<String, String> getScopedSlots() {
|
||||
return scopedSlots;
|
||||
}
|
||||
|
||||
public void setScopedSlots(Map<String, String> scopedSlots) {
|
||||
this.scopedSlots = scopedSlots;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public boolean getIsLeaf() {
|
||||
return isLeaf;
|
||||
}
|
||||
|
||||
public void setIsLeaf(boolean isLeaf) {
|
||||
this.isLeaf = isLeaf;
|
||||
}
|
||||
|
||||
public String getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
public void setIcon(String icon) {
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
private List<TreeModel> children;
|
||||
|
||||
public List<TreeModel> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setChildren(List<TreeModel> children) {
|
||||
this.children = children;
|
||||
}
|
||||
|
||||
public TreeModel() {
|
||||
|
||||
}
|
||||
|
||||
public TreeModel(NuAppPermission permission) {
|
||||
this.key = permission.getId();
|
||||
this.icon = permission.getIcon();
|
||||
this.parentId = permission.getParentId();
|
||||
this.title = permission.getName();
|
||||
this.slotTitle = permission.getName();
|
||||
this.value = permission.getId();
|
||||
this.isLeaf = permission.isLeaf();
|
||||
this.label = permission.getName();
|
||||
if(!permission.isLeaf()) {
|
||||
this.children = new ArrayList<TreeModel>();
|
||||
}
|
||||
}
|
||||
|
||||
public TreeModel(String key, String parentId, String slotTitle, Integer ruleFlag, boolean isLeaf,String code) {
|
||||
this.key = key;
|
||||
this.parentId = parentId;
|
||||
this.ruleFlag=ruleFlag;
|
||||
this.slotTitle = slotTitle;
|
||||
Map<String,String> map = new HashMap(5);
|
||||
map.put("title", "hasDatarule");
|
||||
this.scopedSlots = map;
|
||||
this.isLeaf = isLeaf;
|
||||
this.value = key;
|
||||
this.code = code;
|
||||
if(!isLeaf) {
|
||||
this.children = new ArrayList<TreeModel>();
|
||||
}
|
||||
}
|
||||
|
||||
private String parentId;
|
||||
|
||||
private String label;
|
||||
|
||||
private String value;
|
||||
private String code;
|
||||
|
||||
|
||||
public String getParentId() {
|
||||
return parentId;
|
||||
}
|
||||
|
||||
public void setParentId(String parentId) {
|
||||
this.parentId = parentId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the label
|
||||
*/
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param label the label to set
|
||||
*/
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the value
|
||||
*/
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param value the value to set
|
||||
*/
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getSlotTitle() {
|
||||
return slotTitle;
|
||||
}
|
||||
|
||||
public void setSlotTitle(String slotTitle) {
|
||||
this.slotTitle = slotTitle;
|
||||
}
|
||||
|
||||
public Integer getRuleFlag() {
|
||||
return ruleFlag;
|
||||
}
|
||||
|
||||
public void setRuleFlag(Integer ruleFlag) {
|
||||
this.ruleFlag = ruleFlag;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
package com.nu.modules.appConfig.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.nu.modules.appConfig.entity.NuAppPermission;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
|
||||
/**
|
||||
* @Description: 菜单表
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2025-12-31
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface NuAppPermissionMapper extends BaseMapper<NuAppPermission> {
|
||||
|
||||
NuAppPermission getRoleNoTenant(@Param("roleCode") String roleCode);
|
||||
|
||||
@Update("update nu_app_permission set is_leaf=#{leaf} where id = #{id}")
|
||||
public int setMenuLeaf(@Param("id") String id,@Param("leaf") int leaf);
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.nu.modules.appConfig.mapper.NuAppPermissionMapper">
|
||||
|
||||
<select id="getRoleNoTenant" resultType="com.nu.modules.appConfig.entity.NuAppPermission">
|
||||
SELECT * from nu_app_permission
|
||||
WHERE menu_code = #{roleCode}
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
package com.nu.modules.appConfig.service;
|
||||
|
||||
import com.nu.modules.appConfig.entity.NuAppPermission;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* @Description: 菜单表
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2025-12-31
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface INuAppPermissionService extends IService<NuAppPermission> {
|
||||
|
||||
NuAppPermission getRoleNoTenant(String roleCode);
|
||||
|
||||
void addPermission(NuAppPermission permission);
|
||||
|
||||
void editPermission(NuAppPermission permission);
|
||||
}
|
||||
|
|
@ -0,0 +1,88 @@
|
|||
package com.nu.modules.appConfig.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.nu.modules.appConfig.entity.NuAppPermission;
|
||||
import com.nu.modules.appConfig.mapper.NuAppPermissionMapper;
|
||||
import com.nu.modules.appConfig.service.INuAppPermissionService;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.exception.JeecgBootException;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Description: 菜单表
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2025-12-31
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Service
|
||||
public class NuAppPermissionServiceImpl extends ServiceImpl<NuAppPermissionMapper, NuAppPermission> implements INuAppPermissionService {
|
||||
|
||||
@Override
|
||||
public NuAppPermission getRoleNoTenant(String roleCode) {
|
||||
return baseMapper.getRoleNoTenant(roleCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPermission(NuAppPermission sysPermission) {
|
||||
//----------------------------------------------------------------------
|
||||
//判断是否是一级菜单,是的话清空父菜单
|
||||
if(CommonConstant.MENU_TYPE_0.equals(sysPermission.getMenuType())) {
|
||||
sysPermission.setParentId(null);
|
||||
}
|
||||
//----------------------------------------------------------------------
|
||||
String pid = sysPermission.getParentId();
|
||||
if(oConvertUtils.isNotEmpty(pid)) {
|
||||
//设置父节点不为叶子节点
|
||||
this.baseMapper.setMenuLeaf(pid, 0);
|
||||
}
|
||||
sysPermission.setCreateTime(new Date());
|
||||
sysPermission.setDelFlag(0);
|
||||
sysPermission.setLeaf(true);
|
||||
this.save(sysPermission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void editPermission(NuAppPermission sysPermission) {
|
||||
NuAppPermission p = this.getById(sysPermission.getId());
|
||||
//TODO 该节点判断是否还有子节点
|
||||
if(p==null) {
|
||||
throw new JeecgBootException("未找到菜单信息");
|
||||
}else {
|
||||
sysPermission.setUpdateTime(new Date());
|
||||
//----------------------------------------------------------------------
|
||||
//Step1.判断是否是一级菜单,是的话清空父菜单ID
|
||||
if(CommonConstant.MENU_TYPE_0.equals(sysPermission.getMenuType())) {
|
||||
sysPermission.setParentId("");
|
||||
}
|
||||
//Step2.判断菜单下级是否有菜单,无则设置为叶子节点
|
||||
Long count = this.count(new QueryWrapper<NuAppPermission>().lambda().eq(NuAppPermission::getParentId, sysPermission.getId()));
|
||||
if(count==0) {
|
||||
sysPermission.setLeaf(true);
|
||||
}
|
||||
//----------------------------------------------------------------------
|
||||
this.updateById(sysPermission);
|
||||
|
||||
//如果当前菜单的父菜单变了,则需要修改新父菜单和老父菜单的,叶子节点状态
|
||||
String pid = sysPermission.getParentId();
|
||||
boolean flag = (oConvertUtils.isNotEmpty(pid) && !pid.equals(p.getParentId())) || oConvertUtils.isEmpty(pid)&&oConvertUtils.isNotEmpty(p.getParentId());
|
||||
if (flag) {
|
||||
//a.设置新的父菜单不为叶子节点
|
||||
this.baseMapper.setMenuLeaf(pid, 0);
|
||||
//b.判断老的菜单下是否还有其他子菜单,没有的话则设置为叶子节点
|
||||
Long cc = this.count(new QueryWrapper<NuAppPermission>().lambda().eq(NuAppPermission::getParentId, p.getParentId()));
|
||||
if(cc==0) {
|
||||
if(oConvertUtils.isNotEmpty(p.getParentId())) {
|
||||
this.baseMapper.setMenuLeaf(p.getParentId(), 1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,136 @@
|
|||
package com.nu.modules.appConfig.utils;
|
||||
|
||||
import com.nu.modules.appConfig.entity.NuAppPermission;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.constant.SymbolConstant;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: scott
|
||||
* @Date: 2019-04-03
|
||||
*/
|
||||
public class AppPermissionDataUtil {
|
||||
|
||||
/**
|
||||
* 路径:views/
|
||||
*/
|
||||
private static final String PATH_VIEWS = "views/";
|
||||
|
||||
/**
|
||||
* 路径:src/views/
|
||||
*/
|
||||
private static final String PATH_SRC_VIEWS = "src/views/";
|
||||
|
||||
/**
|
||||
* .vue后缀
|
||||
*/
|
||||
private static final String VUE_SUFFIX = ".vue";
|
||||
|
||||
/**
|
||||
* 智能处理错误数据,简化用户失误操作
|
||||
*
|
||||
* @param permission
|
||||
*/
|
||||
public static NuAppPermission intelligentProcessData(NuAppPermission permission) {
|
||||
if (permission == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 组件
|
||||
if (oConvertUtils.isNotEmpty(permission.getComponent())) {
|
||||
String component = permission.getComponent();
|
||||
if (component.startsWith(SymbolConstant.SINGLE_SLASH)) {
|
||||
component = component.substring(1);
|
||||
}
|
||||
if (component.startsWith(PATH_VIEWS)) {
|
||||
component = component.replaceFirst(PATH_VIEWS, "");
|
||||
}
|
||||
if (component.startsWith(PATH_SRC_VIEWS)) {
|
||||
component = component.replaceFirst(PATH_SRC_VIEWS, "");
|
||||
}
|
||||
if (component.endsWith(VUE_SUFFIX)) {
|
||||
component = component.replace(VUE_SUFFIX, "");
|
||||
}
|
||||
permission.setComponent(component);
|
||||
}
|
||||
|
||||
// 请求URL
|
||||
if (oConvertUtils.isNotEmpty(permission.getUrl())) {
|
||||
String url = permission.getUrl();
|
||||
if (url.endsWith(VUE_SUFFIX)) {
|
||||
url = url.replace(VUE_SUFFIX, "");
|
||||
}
|
||||
if (!url.startsWith(CommonConstant.STR_HTTP) && !url.startsWith(SymbolConstant.SINGLE_SLASH)&&!url.trim().startsWith(SymbolConstant.DOUBLE_LEFT_CURLY_BRACKET)) {
|
||||
url = SymbolConstant.SINGLE_SLASH + url;
|
||||
}
|
||||
permission.setUrl(url);
|
||||
}
|
||||
|
||||
// 一级菜单默认组件
|
||||
if (0 == permission.getMenuType() && oConvertUtils.isEmpty(permission.getComponent())) {
|
||||
// 一级菜单默认组件
|
||||
permission.setComponent("layouts/RouteView");
|
||||
}
|
||||
return permission;
|
||||
}
|
||||
|
||||
/**
|
||||
* 如果没有index页面 需要new 一个放到list中
|
||||
* @param metaList
|
||||
*/
|
||||
// public static void addIndexPage(List<NuAppPermission> metaList) {
|
||||
// boolean hasIndexMenu = false;
|
||||
// SysRoleIndex defIndexCfg = PermissionDataUtil.getDefIndexConfig();
|
||||
// for (SysPermission sysPermission : metaList) {
|
||||
// if(defIndexCfg.getUrl().equals(sysPermission.getUrl())) {
|
||||
// hasIndexMenu = true;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// if(!hasIndexMenu) {
|
||||
// metaList.add(0,new SysPermission(true));
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* 判断是否授权首页
|
||||
* @param metaList
|
||||
* @return
|
||||
*/
|
||||
// public static boolean hasIndexPage(List<NuAppPermission> metaList, SysRoleIndex defIndexCfg){
|
||||
// boolean hasIndexMenu = false;
|
||||
// for (NuAppPermission sysPermission : metaList) {
|
||||
// if(defIndexCfg.getUrl().equals(sysPermission.getUrl())) {
|
||||
// hasIndexMenu = true;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// return hasIndexMenu;
|
||||
// }
|
||||
|
||||
/**
|
||||
* 通过id判断是否授权某个页面
|
||||
*
|
||||
* @param metaList
|
||||
* @return
|
||||
*/
|
||||
public static boolean hasMenuById(List<NuAppPermission> metaList, String id) {
|
||||
for (NuAppPermission sysPermission : metaList) {
|
||||
if (id.equals(sysPermission.getId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取默认首页配置
|
||||
*/
|
||||
// public static SysRoleIndex getDefIndexConfig() {
|
||||
// ISysRoleIndexService sysRoleIndexService = SpringContextUtils.getBean(ISysRoleIndexService.class);
|
||||
// return sysRoleIndexService.queryDefaultIndex();
|
||||
// }
|
||||
|
||||
}
|
||||
|
|
@ -69,5 +69,11 @@
|
|||
<version>2.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.nursingunit.boot</groupId>
|
||||
<artifactId>nu-employee-local-api</artifactId>
|
||||
<version>2.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,44 @@
|
|||
package com.nu.modules.employess;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.nu.modules.IEmployeesInfoApi;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.system.api.ISysBaseAPI;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 获取常用信息(不涉及安全信息)
|
||||
* @author zmy
|
||||
* @date 2025-5-22 08:43:05
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/employessInfo")
|
||||
public class EmployessApi {
|
||||
|
||||
@Lazy
|
||||
@Autowired
|
||||
private IEmployeesInfoApi employeesInfoApi;
|
||||
|
||||
/**
|
||||
* 返回机构信息配置的"协议域名"
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getPermissionList")
|
||||
public Result<?> getPermissionList(String employessId){
|
||||
if (StringUtils.isBlank(employessId)){
|
||||
return Result.error("参数错误");
|
||||
}
|
||||
List<Map<String ,String>> result = employeesInfoApi.getPermissionList(employessId);
|
||||
return Result.ok(result);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -93,6 +93,7 @@ public class ShiroConfig {
|
|||
filterChainDefinitionMap.put("/api/tplink/videoStorage/**", "anon"); //视频缓存存储接口
|
||||
filterChainDefinitionMap.put("/api/pad/invoicing/getShareInfoByCgdId", "anon"); //查询采购单信息(分享接口使用)
|
||||
// filterChainDefinitionMap.put("/api/pad/invoicing/pdd/**", "anon"); //查询盘点单
|
||||
filterChainDefinitionMap.put("/api/employessInfo/**", "anon"); //测试员工接口
|
||||
// filterChainDefinitionMap.put("/api/pad/invoicing/**", "anon"); //测试进销存对应的接口
|
||||
// filterChainDefinitionMap.put("/api/pad/qingling/**", "anon"); //测试请领对应的接口
|
||||
// filterChainDefinitionMap.put("/api/pad/care/**", "anon"); //服务指令
|
||||
|
|
|
|||
|
|
@ -85,6 +85,8 @@ public class NuBaseInfoEntity implements Serializable {
|
|||
private List<HumidDeviceEntity> humidDeviceList;
|
||||
//长者信息
|
||||
private ElderInfoEntity elderInfo;
|
||||
|
||||
private List<NuidPermissionEntity> permissionList;
|
||||
|
||||
private java.lang.String fzr;
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,71 @@
|
|||
package com.nu.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Description: nu_app_nuid_permission
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2026-01-04
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Data
|
||||
@TableName("nu_app_nuid_permission")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value="nu_app_nuid_permission对象", description="nu_app_nuid_permission")
|
||||
public class NuidPermissionEntity implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**id*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@ApiModelProperty(value = "id")
|
||||
private String id;
|
||||
/**角色id*/
|
||||
@Excel(name = "角色id", width = 15)
|
||||
@ApiModelProperty(value = "角色id")
|
||||
private String roleId;
|
||||
/**权限id*/
|
||||
@Excel(name = "权限id", width = 15)
|
||||
@ApiModelProperty(value = "权限id")
|
||||
private String permissionId;
|
||||
/**数据权限ids*/
|
||||
@Excel(name = "数据权限ids", width = 15)
|
||||
@ApiModelProperty(value = "数据权限ids")
|
||||
private String dataRuleIds;
|
||||
/**操作时间*/
|
||||
@Excel(name = "操作时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "操作时间")
|
||||
private Date operateDate;
|
||||
/**操作ip*/
|
||||
@Excel(name = "操作ip", width = 15)
|
||||
@ApiModelProperty(value = "操作ip")
|
||||
private String operateIp;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String menuName;
|
||||
@TableField(exist = false)
|
||||
private String menuCode;
|
||||
|
||||
|
||||
|
||||
public NuidPermissionEntity(String roleId, String permissionId) {
|
||||
this.roleId = roleId;
|
||||
this.permissionId = permissionId;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
package com.nu.modules;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface IEmployeesInfoApi {
|
||||
List<Map<String ,String>> getPermissionList(String employessId);
|
||||
}
|
||||
|
|
@ -45,6 +45,18 @@
|
|||
<version>2.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.nursingunit.boot</groupId>
|
||||
<artifactId>nu-admin-biz</artifactId>
|
||||
<version>2.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.nursingunit.boot</groupId>
|
||||
<artifactId>nu-nu-biz</artifactId>
|
||||
<version>2.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,24 @@
|
|||
package com.nu.modules.employeesInfo.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.nu.modules.IEmployeesInfoApi;
|
||||
import com.nu.modules.employeesInfo.entity.BizEmployeesInfo;
|
||||
import com.nu.modules.employeesInfo.mapper.BizEmployeesInfoMapper;
|
||||
import com.nu.modules.employeesInfo.service.IBizEmployeesInfoService;
|
||||
import com.nu.modules.employessPermission.entity.NuAppEmployessPermission;
|
||||
import com.nu.modules.employessPermission.service.INuAppEmployessPermissionService;
|
||||
import com.nu.modules.nuidPermission.entity.NuAppNuidPermission;
|
||||
import com.nu.modules.nuidPermission.service.INuAppNuidPermissionService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Description: 员工信息
|
||||
* @Author: jeecg-boot
|
||||
|
|
@ -14,6 +26,21 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|||
* @Version: V1.0
|
||||
*/
|
||||
@Service
|
||||
public class BizEmployeesInfoServiceImpl extends ServiceImpl<BizEmployeesInfoMapper, BizEmployeesInfo> implements IBizEmployeesInfoService {
|
||||
public class BizEmployeesInfoServiceImpl extends ServiceImpl<BizEmployeesInfoMapper, BizEmployeesInfo> implements IBizEmployeesInfoService, IEmployeesInfoApi {
|
||||
|
||||
@Autowired
|
||||
private INuAppEmployessPermissionService nuAppEmployessPermissionService;
|
||||
|
||||
@Override
|
||||
public List<Map<String ,String>> getPermissionList(String employessId) {
|
||||
List<Map<String ,String>> mapList = new ArrayList<>();
|
||||
List<NuAppEmployessPermission> permissionList = nuAppEmployessPermissionService.listByEmployessId(employessId);
|
||||
for(NuAppEmployessPermission par:permissionList){
|
||||
Map<String,String> map = new HashMap<>();
|
||||
map.put("menuName", par.getMenuName());
|
||||
map.put("menuCode", par.getMenuCode());
|
||||
mapList.add(map);
|
||||
}
|
||||
return mapList;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,288 @@
|
|||
package com.nu.modules.employessPermission.controller;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.nu.modules.appConfig.entity.NuAppPermission;
|
||||
import com.nu.modules.appConfig.entity.TreeModel;
|
||||
import com.nu.modules.appConfig.service.INuAppPermissionService;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.common.system.query.QueryRuleEnum;
|
||||
import org.jeecg.common.system.vo.LoginUser;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import com.nu.modules.employessPermission.entity.NuAppEmployessPermission;
|
||||
import com.nu.modules.employessPermission.service.INuAppEmployessPermissionService;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.jeecg.modules.base.service.BaseCommonService;
|
||||
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
||||
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
||||
import org.jeecgframework.poi.excel.entity.ExportParams;
|
||||
import org.jeecgframework.poi.excel.entity.ImportParams;
|
||||
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
||||
import org.jeecg.common.system.base.controller.JeecgController;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
|
||||
/**
|
||||
* @Description: nu_app_employess_permission
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2026-01-04
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Api(tags="nu_app_employess_permission")
|
||||
@RestController
|
||||
@RequestMapping("/employessPermission/nuAppEmployessPermission")
|
||||
@Slf4j
|
||||
public class NuAppEmployessPermissionController extends JeecgController<NuAppEmployessPermission, INuAppEmployessPermissionService> {
|
||||
@Autowired
|
||||
private INuAppEmployessPermissionService nuAppEmployessPermissionService;
|
||||
|
||||
@Autowired
|
||||
private INuAppPermissionService nuAppPermissionService;
|
||||
@Autowired
|
||||
private BaseCommonService baseCommonService;
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
* @param nuAppEmployessPermission
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
//@AutoLog(value = "nu_app_employess_permission-分页列表查询")
|
||||
@ApiOperation(value="nu_app_employess_permission-分页列表查询", notes="nu_app_employess_permission-分页列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<IPage<NuAppEmployessPermission>> queryPageList(NuAppEmployessPermission nuAppEmployessPermission,
|
||||
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
||||
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
QueryWrapper<NuAppEmployessPermission> queryWrapper = QueryGenerator.initQueryWrapper(nuAppEmployessPermission, req.getParameterMap());
|
||||
Page<NuAppEmployessPermission> page = new Page<NuAppEmployessPermission>(pageNo, pageSize);
|
||||
IPage<NuAppEmployessPermission> pageList = nuAppEmployessPermissionService.page(page, queryWrapper);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @param nuAppEmployessPermission
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "nu_app_employess_permission-添加")
|
||||
@ApiOperation(value="nu_app_employess_permission-添加", notes="nu_app_employess_permission-添加")
|
||||
@RequiresPermissions("employessPermission:nu_app_employess_permission:add")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<String> add(@RequestBody NuAppEmployessPermission nuAppEmployessPermission) {
|
||||
nuAppEmployessPermissionService.save(nuAppEmployessPermission);
|
||||
return Result.OK("添加成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param nuAppEmployessPermission
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "nu_app_employess_permission-编辑")
|
||||
@ApiOperation(value="nu_app_employess_permission-编辑", notes="nu_app_employess_permission-编辑")
|
||||
@RequiresPermissions("employessPermission:nu_app_employess_permission:edit")
|
||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
|
||||
public Result<String> edit(@RequestBody NuAppEmployessPermission nuAppEmployessPermission) {
|
||||
nuAppEmployessPermissionService.updateById(nuAppEmployessPermission);
|
||||
return Result.OK("编辑成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "nu_app_employess_permission-通过id删除")
|
||||
@ApiOperation(value="nu_app_employess_permission-通过id删除", notes="nu_app_employess_permission-通过id删除")
|
||||
@RequiresPermissions("employessPermission:nu_app_employess_permission:delete")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<String> delete(@RequestParam(name="id",required=true) String id) {
|
||||
nuAppEmployessPermissionService.removeById(id);
|
||||
return Result.OK("删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "nu_app_employess_permission-批量删除")
|
||||
@ApiOperation(value="nu_app_employess_permission-批量删除", notes="nu_app_employess_permission-批量删除")
|
||||
@RequiresPermissions("employessPermission:nu_app_employess_permission:deleteBatch")
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
||||
this.nuAppEmployessPermissionService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
return Result.OK("批量删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
//@AutoLog(value = "nu_app_employess_permission-通过id查询")
|
||||
@ApiOperation(value="nu_app_employess_permission-通过id查询", notes="nu_app_employess_permission-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<NuAppEmployessPermission> queryById(@RequestParam(name="id",required=true) String id) {
|
||||
NuAppEmployessPermission nuAppEmployessPermission = nuAppEmployessPermissionService.getById(id);
|
||||
if(nuAppEmployessPermission==null) {
|
||||
return Result.error("未找到对应数据");
|
||||
}
|
||||
return Result.OK(nuAppEmployessPermission);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel
|
||||
*
|
||||
* @param request
|
||||
* @param nuAppEmployessPermission
|
||||
*/
|
||||
@RequiresPermissions("employessPermission:nu_app_employess_permission:exportXls")
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, NuAppEmployessPermission nuAppEmployessPermission) {
|
||||
return super.exportXls(request, nuAppEmployessPermission, NuAppEmployessPermission.class, "nu_app_employess_permission");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过excel导入数据
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@RequiresPermissions("employessPermission:nu_app_employess_permission:importExcel")
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
return super.importExcel(request, response, NuAppEmployessPermission.class);
|
||||
}
|
||||
/**
|
||||
* 用户角色授权功能,查询菜单权限树
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/queryTreeList", method = RequestMethod.GET)
|
||||
public Result<Map<String,Object>> queryTreeList(HttpServletRequest request) {
|
||||
Result<Map<String,Object>> result = new Result<>();
|
||||
//全部权限ids
|
||||
List<String> ids = new ArrayList<>();
|
||||
try {
|
||||
LambdaQueryWrapper<NuAppPermission> query = new LambdaQueryWrapper<NuAppPermission>();
|
||||
query.eq(NuAppPermission::getDelFlag, CommonConstant.DEL_FLAG_0);
|
||||
query.orderByAsc(NuAppPermission::getSortNo);
|
||||
List<NuAppPermission> list = nuAppPermissionService.list(query);
|
||||
for(NuAppPermission sysPer : list) {
|
||||
ids.add(sysPer.getId());
|
||||
}
|
||||
List<TreeModel> treeList = new ArrayList<>();
|
||||
getTreeModelList(treeList, list, null);
|
||||
Map<String,Object> resMap = new HashMap(5);
|
||||
//全部树节点数据
|
||||
resMap.put("treeList", treeList);
|
||||
//全部树ids
|
||||
resMap.put("ids", ids);
|
||||
result.setResult(resMap);
|
||||
result.setSuccess(true);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private void getTreeModelList(List<TreeModel> treeList, List<NuAppPermission> metaList, TreeModel temp) {
|
||||
for (NuAppPermission permission : metaList) {
|
||||
String tempPid = permission.getParentId();
|
||||
TreeModel tree = new TreeModel(permission.getId(), tempPid, permission.getName(),permission.getRuleFlag(), permission.isLeaf(),permission.getMenuCode());
|
||||
if(temp==null && oConvertUtils.isEmpty(tempPid)) {
|
||||
treeList.add(tree);
|
||||
if(!tree.getIsLeaf()) {
|
||||
getTreeModelList(treeList, metaList, tree);
|
||||
}
|
||||
}else if(temp!=null && tempPid!=null && tempPid.equals(temp.getKey())){
|
||||
temp.getChildren().add(tree);
|
||||
if(!tree.getIsLeaf()) {
|
||||
getTreeModelList(treeList, metaList, tree);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询角色授权
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/queryEmployessPermission", method = RequestMethod.GET)
|
||||
public Result<List<String>> queryEmployessPermission(@RequestParam(name = "employessId", required = true) String employessId) {
|
||||
Result<List<String>> result = new Result<>();
|
||||
try {
|
||||
List<NuAppEmployessPermission> list = nuAppEmployessPermissionService.list(new QueryWrapper<NuAppEmployessPermission>().lambda().eq(NuAppEmployessPermission::getRoleId, employessId));
|
||||
result.setResult(list.stream().map(sysRolePermission -> String.valueOf(sysRolePermission.getPermissionId())).collect(Collectors.toList()));
|
||||
result.setSuccess(true);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存角色授权
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/saveRolePermission", method = RequestMethod.POST)
|
||||
// @RequiresPermissions("system:permission:saveRole")
|
||||
public Result<String> saveRolePermission(@RequestBody JSONObject json) {
|
||||
long start = System.currentTimeMillis();
|
||||
Result<String> result = new Result<>();
|
||||
try {
|
||||
String roleId = json.getString("roleId");
|
||||
String permissionIds = json.getString("permissionIds");
|
||||
String lastPermissionIds = json.getString("lastpermissionIds");
|
||||
this.nuAppEmployessPermissionService.saveRolePermission(roleId, permissionIds, lastPermissionIds);
|
||||
//update-begin---author:wangshuai ---date:20220316 for:[VUEN-234]用户管理角色授权添加敏感日志------------
|
||||
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
baseCommonService.addLog("修改角色ID: "+roleId+" 的权限配置,操作人: " +loginUser.getUsername() ,CommonConstant.LOG_TYPE_2, 2);
|
||||
//update-end---author:wangshuai ---date:20220316 for:[VUEN-234]用户管理角色授权添加敏感日志------------
|
||||
result.success("保存成功!");
|
||||
log.info("======角色授权成功=====耗时:" + (System.currentTimeMillis() - start) + "毫秒");
|
||||
|
||||
} catch (Exception e) {
|
||||
result.error500("授权失败!");
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
package com.nu.modules.employessPermission.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Date;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import org.jeecg.common.constant.ProvinceCityArea;
|
||||
import org.jeecg.common.util.SpringContextUtils;
|
||||
import lombok.Data;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import org.jeecg.common.aspect.annotation.Dict;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* @Description: nu_app_employess_permission
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2026-01-04
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Data
|
||||
@TableName("nu_app_employess_permission")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value="nu_app_employess_permission对象", description="nu_app_employess_permission")
|
||||
public class NuAppEmployessPermission implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**id*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@ApiModelProperty(value = "id")
|
||||
private java.lang.String id;
|
||||
/**角色id*/
|
||||
@Excel(name = "角色id", width = 15)
|
||||
@ApiModelProperty(value = "角色id")
|
||||
private java.lang.String roleId;
|
||||
/**权限id*/
|
||||
@Excel(name = "权限id", width = 15)
|
||||
@ApiModelProperty(value = "权限id")
|
||||
private java.lang.String permissionId;
|
||||
/**数据权限ids*/
|
||||
@Excel(name = "数据权限ids", width = 15)
|
||||
@ApiModelProperty(value = "数据权限ids")
|
||||
private java.lang.String dataRuleIds;
|
||||
/**操作时间*/
|
||||
@Excel(name = "操作时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "操作时间")
|
||||
private java.util.Date operateDate;
|
||||
/**操作ip*/
|
||||
@Excel(name = "操作ip", width = 15)
|
||||
@ApiModelProperty(value = "操作ip")
|
||||
private java.lang.String operateIp;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String menuName;
|
||||
@TableField(exist = false)
|
||||
private String menuCode;
|
||||
|
||||
|
||||
public NuAppEmployessPermission(String roleId, String permissionId) {
|
||||
this.roleId = roleId;
|
||||
this.permissionId = permissionId;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
package com.nu.modules.employessPermission.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.nu.modules.nuidPermission.entity.NuAppNuidPermission;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.nu.modules.employessPermission.entity.NuAppEmployessPermission;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @Description: nu_app_employess_permission
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2026-01-04
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface NuAppEmployessPermissionMapper extends BaseMapper<NuAppEmployessPermission> {
|
||||
|
||||
List<NuAppEmployessPermission> listByEmployessId(@Param("roleId") String employessId);
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.nu.modules.employessPermission.mapper.NuAppEmployessPermissionMapper">
|
||||
<select id="listByEmployessId" resultType="com.nu.modules.employessPermission.entity.NuAppEmployessPermission">
|
||||
select a.*,b.name as menu_name,b.menu_code from nu_app_employess_permission a
|
||||
left join nu_app_permission b on a.permission_id = b.id
|
||||
<where>
|
||||
<if test="roleId != null and roleId !=''">
|
||||
and a.role_id = #{roleId}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package com.nu.modules.employessPermission.service;
|
||||
|
||||
import com.nu.modules.employessPermission.entity.NuAppEmployessPermission;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.nu.modules.nuidPermission.entity.NuAppNuidPermission;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: nu_app_employess_permission
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2026-01-04
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface INuAppEmployessPermissionService extends IService<NuAppEmployessPermission> {
|
||||
|
||||
void saveRolePermission(String roleId, String permissionIds, String lastPermissionIds);
|
||||
|
||||
List<NuAppEmployessPermission> listByEmployessId(String employessId);
|
||||
}
|
||||
|
|
@ -0,0 +1,93 @@
|
|||
package com.nu.modules.employessPermission.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.nu.modules.employessPermission.entity.NuAppEmployessPermission;
|
||||
import com.nu.modules.employessPermission.mapper.NuAppEmployessPermissionMapper;
|
||||
import com.nu.modules.employessPermission.service.INuAppEmployessPermissionService;
|
||||
import com.nu.modules.nuidPermission.entity.NuAppNuidPermission;
|
||||
import org.jeecg.common.util.IpUtils;
|
||||
import org.jeecg.common.util.SpringContextUtils;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @Description: nu_app_employess_permission
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2026-01-04
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Service
|
||||
public class NuAppEmployessPermissionServiceImpl extends ServiceImpl<NuAppEmployessPermissionMapper, NuAppEmployessPermission> implements INuAppEmployessPermissionService {
|
||||
|
||||
@Override
|
||||
public void saveRolePermission(String roleId, String permissionIds, String lastPermissionIds) {
|
||||
String ip = "";
|
||||
try {
|
||||
//获取request
|
||||
HttpServletRequest request = SpringContextUtils.getHttpServletRequest();
|
||||
//获取IP地址
|
||||
ip = IpUtils.getIpAddr(request);
|
||||
} catch (Exception e) {
|
||||
ip = "127.0.0.1";
|
||||
}
|
||||
List<String> add = getDiff(lastPermissionIds,permissionIds);
|
||||
if(add!=null && add.size()>0) {
|
||||
List<NuAppEmployessPermission> list = new ArrayList<NuAppEmployessPermission>();
|
||||
for (String p : add) {
|
||||
if(oConvertUtils.isNotEmpty(p)) {
|
||||
NuAppEmployessPermission rolepms = new NuAppEmployessPermission(roleId, p);
|
||||
rolepms.setOperateDate(new Date());
|
||||
rolepms.setOperateIp(ip);
|
||||
list.add(rolepms);
|
||||
}
|
||||
}
|
||||
this.saveBatch(list);
|
||||
}
|
||||
|
||||
List<String> delete = getDiff(permissionIds,lastPermissionIds);
|
||||
if(delete!=null && delete.size()>0) {
|
||||
for (String permissionId : delete) {
|
||||
this.remove(new QueryWrapper<NuAppEmployessPermission>().lambda().eq(NuAppEmployessPermission::getRoleId, roleId).eq(NuAppEmployessPermission::getPermissionId, permissionId));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NuAppEmployessPermission> listByEmployessId(String employessId) {
|
||||
return baseMapper.listByEmployessId(employessId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 从diff中找出main中没有的元素
|
||||
* @param main
|
||||
* @param diff
|
||||
* @return
|
||||
*/
|
||||
private List<String> getDiff(String main,String diff){
|
||||
if(oConvertUtils.isEmpty(diff)) {
|
||||
return null;
|
||||
}
|
||||
if(oConvertUtils.isEmpty(main)) {
|
||||
return Arrays.asList(diff.split(","));
|
||||
}
|
||||
|
||||
String[] mainArr = main.split(",");
|
||||
String[] diffArr = diff.split(",");
|
||||
Map<String, Integer> map = new HashMap(5);
|
||||
for (String string : mainArr) {
|
||||
map.put(string, 1);
|
||||
}
|
||||
List<String> res = new ArrayList<String>();
|
||||
for (String key : diffArr) {
|
||||
if(oConvertUtils.isNotEmpty(key) && !map.containsKey(key)) {
|
||||
res.add(key);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
|
@ -47,7 +47,19 @@
|
|||
<version>2.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.nursingunit.boot</groupId>
|
||||
<artifactId>nu-admin-biz</artifactId>
|
||||
<version>2.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.nursingunit.boot</groupId>
|
||||
<artifactId>nu-admin-biz</artifactId>
|
||||
<version>2.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -2,7 +2,11 @@ package com.nu.modules.nubaseinfo.entity;
|
|||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.nu.entity.*;
|
||||
import com.nu.entity.CameraInfoEntity;
|
||||
import com.nu.entity.ElderInfoEntity;
|
||||
import com.nu.entity.ElderServerEntity;
|
||||
import com.nu.entity.HumidDeviceEntity;
|
||||
import com.nu.modules.nuidPermission.entity.NuAppNuidPermission;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
|
@ -172,5 +176,8 @@ public class NuBaseInfo implements Serializable {
|
|||
//温湿度计
|
||||
@TableField(exist = false)
|
||||
private List<HumidDeviceEntity> humidDeviceList;
|
||||
//单元对应外挂
|
||||
@TableField(exist = false)
|
||||
private List<NuAppNuidPermission> permissionList;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.nu.entity.*;
|
||||
import com.nu.modules.appConfig.entity.NuAppPermission;
|
||||
import com.nu.modules.camerainfo.api.CameraInfoApi;
|
||||
import com.nu.modules.elder.api.IElderInfoApi;
|
||||
import com.nu.modules.humiddevice.api.IHumidAlarmApi;
|
||||
|
|
@ -17,6 +18,8 @@ import com.nu.modules.nubaseinfo.entity.NuBaseInfo;
|
|||
import com.nu.modules.nubaseinfo.mapper.NuBaseInfoMapper;
|
||||
import com.nu.modules.nubaseinfo.service.INuBaseInfoService;
|
||||
import com.nu.modules.nubaseinfo.api.INuBaseInfoApi;
|
||||
import com.nu.modules.nuidPermission.entity.NuAppNuidPermission;
|
||||
import com.nu.modules.nuidPermission.service.INuAppNuidPermissionService;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.jeecg.common.system.api.ISysBaseAPI;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
|
|
@ -54,6 +57,8 @@ public class NuBaseInfoServiceImpl extends ServiceImpl<NuBaseInfoMapper, NuBaseI
|
|||
@Autowired
|
||||
private IHumidDeviceApi humidDeviceApi;
|
||||
|
||||
@Autowired
|
||||
private INuAppNuidPermissionService nuAppNuidPermissionService;
|
||||
|
||||
@Override
|
||||
public void setNuId(NuBaseInfo nuBaseInfo) {
|
||||
|
|
@ -142,6 +147,10 @@ public class NuBaseInfoServiceImpl extends ServiceImpl<NuBaseInfoMapper, NuBaseI
|
|||
|
||||
List<HumidDeviceEntity> humidDeviceList = humidDeviceApi.listAll();
|
||||
|
||||
//查询护理单元对应菜单权限
|
||||
List<NuAppNuidPermission> permissionList = nuAppNuidPermissionService.listByNuId(null);
|
||||
|
||||
|
||||
//查找list集合里的nuid等于cameraList集合中nuid的就给list集合赋值
|
||||
list.getRecords().forEach(ni -> {
|
||||
//赋值摄像头信息
|
||||
|
|
@ -179,6 +188,17 @@ public class NuBaseInfoServiceImpl extends ServiceImpl<NuBaseInfoMapper, NuBaseI
|
|||
ni.setHumidDeviceList(humidDtoList);
|
||||
}
|
||||
});
|
||||
//赋值温湿度信息
|
||||
permissionList.forEach(humidDto -> {
|
||||
if (StringUtils.equals(ni.getNuId(), humidDto.getRoleId())) {
|
||||
List<NuAppNuidPermission> permissionDtoList = ni.getPermissionList();
|
||||
if (permissionDtoList == null) {
|
||||
permissionDtoList = new ArrayList<>();
|
||||
}
|
||||
permissionDtoList.add(humidDto);
|
||||
ni.setPermissionList(permissionDtoList);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
IPage<NuBaseInfoEntity> entityPage = new Page<>(page.getCurrent(), page.getSize(), page.getTotal());
|
||||
|
|
|
|||
|
|
@ -0,0 +1,291 @@
|
|||
package com.nu.modules.nuidPermission.controller;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.nu.modules.appConfig.entity.NuAppPermission;
|
||||
import com.nu.modules.appConfig.entity.TreeModel;
|
||||
import com.nu.modules.appConfig.service.INuAppPermissionService;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.apache.shiro.subject.Subject;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.common.system.query.QueryRuleEnum;
|
||||
import org.jeecg.common.system.vo.LoginUser;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import com.nu.modules.nuidPermission.entity.NuAppNuidPermission;
|
||||
import com.nu.modules.nuidPermission.service.INuAppNuidPermissionService;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.jeecg.modules.base.service.BaseCommonService;
|
||||
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
||||
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
||||
import org.jeecgframework.poi.excel.entity.ExportParams;
|
||||
import org.jeecgframework.poi.excel.entity.ImportParams;
|
||||
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
||||
import org.jeecg.common.system.base.controller.JeecgController;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
|
||||
/**
|
||||
* @Description: nu_app_nuid_permission
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2026-01-04
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Api(tags="nu_app_nuid_permission")
|
||||
@RestController
|
||||
@RequestMapping("/nuidPermission/nuAppNuidPermission")
|
||||
@Slf4j
|
||||
public class NuAppNuidPermissionController extends JeecgController<NuAppNuidPermission, INuAppNuidPermissionService> {
|
||||
@Autowired
|
||||
private INuAppNuidPermissionService nuAppNuidPermissionService;
|
||||
@Autowired
|
||||
private INuAppPermissionService nuAppPermissionService;
|
||||
@Autowired
|
||||
private BaseCommonService baseCommonService;
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
* @param nuAppNuidPermission
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
//@AutoLog(value = "nu_app_nuid_permission-分页列表查询")
|
||||
@ApiOperation(value="nu_app_nuid_permission-分页列表查询", notes="nu_app_nuid_permission-分页列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<IPage<NuAppNuidPermission>> queryPageList(NuAppNuidPermission nuAppNuidPermission,
|
||||
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
||||
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
QueryWrapper<NuAppNuidPermission> queryWrapper = QueryGenerator.initQueryWrapper(nuAppNuidPermission, req.getParameterMap());
|
||||
Page<NuAppNuidPermission> page = new Page<NuAppNuidPermission>(pageNo, pageSize);
|
||||
IPage<NuAppNuidPermission> pageList = nuAppNuidPermissionService.page(page, queryWrapper);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @param nuAppNuidPermission
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "nu_app_nuid_permission-添加")
|
||||
@ApiOperation(value="nu_app_nuid_permission-添加", notes="nu_app_nuid_permission-添加")
|
||||
@RequiresPermissions("nuidPermission:nu_app_nuid_permission:add")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<String> add(@RequestBody NuAppNuidPermission nuAppNuidPermission) {
|
||||
nuAppNuidPermissionService.save(nuAppNuidPermission);
|
||||
return Result.OK("添加成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param nuAppNuidPermission
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "nu_app_nuid_permission-编辑")
|
||||
@ApiOperation(value="nu_app_nuid_permission-编辑", notes="nu_app_nuid_permission-编辑")
|
||||
@RequiresPermissions("nuidPermission:nu_app_nuid_permission:edit")
|
||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
|
||||
public Result<String> edit(@RequestBody NuAppNuidPermission nuAppNuidPermission) {
|
||||
nuAppNuidPermissionService.updateById(nuAppNuidPermission);
|
||||
return Result.OK("编辑成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "nu_app_nuid_permission-通过id删除")
|
||||
@ApiOperation(value="nu_app_nuid_permission-通过id删除", notes="nu_app_nuid_permission-通过id删除")
|
||||
@RequiresPermissions("nuidPermission:nu_app_nuid_permission:delete")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<String> delete(@RequestParam(name="id",required=true) String id) {
|
||||
nuAppNuidPermissionService.removeById(id);
|
||||
return Result.OK("删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "nu_app_nuid_permission-批量删除")
|
||||
@ApiOperation(value="nu_app_nuid_permission-批量删除", notes="nu_app_nuid_permission-批量删除")
|
||||
@RequiresPermissions("nuidPermission:nu_app_nuid_permission:deleteBatch")
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
||||
this.nuAppNuidPermissionService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
return Result.OK("批量删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
//@AutoLog(value = "nu_app_nuid_permission-通过id查询")
|
||||
@ApiOperation(value="nu_app_nuid_permission-通过id查询", notes="nu_app_nuid_permission-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<NuAppNuidPermission> queryById(@RequestParam(name="id",required=true) String id) {
|
||||
NuAppNuidPermission nuAppNuidPermission = nuAppNuidPermissionService.getById(id);
|
||||
if(nuAppNuidPermission==null) {
|
||||
return Result.error("未找到对应数据");
|
||||
}
|
||||
return Result.OK(nuAppNuidPermission);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel
|
||||
*
|
||||
* @param request
|
||||
* @param nuAppNuidPermission
|
||||
*/
|
||||
@RequiresPermissions("nuidPermission:nu_app_nuid_permission:exportXls")
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, NuAppNuidPermission nuAppNuidPermission) {
|
||||
return super.exportXls(request, nuAppNuidPermission, NuAppNuidPermission.class, "nu_app_nuid_permission");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过excel导入数据
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@RequiresPermissions("nuidPermission:nu_app_nuid_permission:importExcel")
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
return super.importExcel(request, response, NuAppNuidPermission.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户角色授权功能,查询菜单权限树
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/queryTreeList", method = RequestMethod.GET)
|
||||
public Result<Map<String,Object>> queryTreeList(HttpServletRequest request) {
|
||||
Result<Map<String,Object>> result = new Result<>();
|
||||
//全部权限ids
|
||||
List<String> ids = new ArrayList<>();
|
||||
try {
|
||||
LambdaQueryWrapper<NuAppPermission> query = new LambdaQueryWrapper<NuAppPermission>();
|
||||
query.eq(NuAppPermission::getDelFlag, CommonConstant.DEL_FLAG_0);
|
||||
query.orderByAsc(NuAppPermission::getSortNo);
|
||||
List<NuAppPermission> list = nuAppPermissionService.list(query);
|
||||
for(NuAppPermission sysPer : list) {
|
||||
ids.add(sysPer.getId());
|
||||
}
|
||||
List<TreeModel> treeList = new ArrayList<>();
|
||||
getTreeModelList(treeList, list, null);
|
||||
Map<String,Object> resMap = new HashMap(5);
|
||||
//全部树节点数据
|
||||
resMap.put("treeList", treeList);
|
||||
//全部树ids
|
||||
resMap.put("ids", ids);
|
||||
result.setResult(resMap);
|
||||
result.setSuccess(true);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private void getTreeModelList(List<TreeModel> treeList, List<NuAppPermission> metaList, TreeModel temp) {
|
||||
for (NuAppPermission permission : metaList) {
|
||||
String tempPid = permission.getParentId();
|
||||
TreeModel tree = new TreeModel(permission.getId(), tempPid, permission.getName(),permission.getRuleFlag(), permission.isLeaf(),permission.getMenuCode());
|
||||
if(temp==null && oConvertUtils.isEmpty(tempPid)) {
|
||||
treeList.add(tree);
|
||||
if(!tree.getIsLeaf()) {
|
||||
getTreeModelList(treeList, metaList, tree);
|
||||
}
|
||||
}else if(temp!=null && tempPid!=null && tempPid.equals(temp.getKey())){
|
||||
temp.getChildren().add(tree);
|
||||
if(!tree.getIsLeaf()) {
|
||||
getTreeModelList(treeList, metaList, tree);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询角色授权
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/queryNuidPermission", method = RequestMethod.GET)
|
||||
public Result<List<String>> queryNuidPermission(@RequestParam(name = "nuId", required = true) String nuId) {
|
||||
Result<List<String>> result = new Result<>();
|
||||
try {
|
||||
List<NuAppNuidPermission> list = nuAppNuidPermissionService.list(new QueryWrapper<NuAppNuidPermission>().lambda().eq(NuAppNuidPermission::getRoleId, nuId));
|
||||
result.setResult(list.stream().map(sysRolePermission -> String.valueOf(sysRolePermission.getPermissionId())).collect(Collectors.toList()));
|
||||
result.setSuccess(true);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 保存角色授权
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/saveRolePermission", method = RequestMethod.POST)
|
||||
// @RequiresPermissions("system:permission:saveRole")
|
||||
public Result<String> saveRolePermission(@RequestBody JSONObject json) {
|
||||
long start = System.currentTimeMillis();
|
||||
Result<String> result = new Result<>();
|
||||
try {
|
||||
String roleId = json.getString("roleId");
|
||||
String permissionIds = json.getString("permissionIds");
|
||||
String lastPermissionIds = json.getString("lastpermissionIds");
|
||||
this.nuAppNuidPermissionService.saveRolePermission(roleId, permissionIds, lastPermissionIds);
|
||||
//update-begin---author:wangshuai ---date:20220316 for:[VUEN-234]用户管理角色授权添加敏感日志------------
|
||||
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
baseCommonService.addLog("修改角色ID: "+roleId+" 的权限配置,操作人: " +loginUser.getUsername() ,CommonConstant.LOG_TYPE_2, 2);
|
||||
//update-end---author:wangshuai ---date:20220316 for:[VUEN-234]用户管理角色授权添加敏感日志------------
|
||||
result.success("保存成功!");
|
||||
log.info("======角色授权成功=====耗时:" + (System.currentTimeMillis() - start) + "毫秒");
|
||||
|
||||
} catch (Exception e) {
|
||||
result.error500("授权失败!");
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,73 @@
|
|||
package com.nu.modules.nuidPermission.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Date;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import org.jeecg.common.constant.ProvinceCityArea;
|
||||
import org.jeecg.common.util.SpringContextUtils;
|
||||
import lombok.Data;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import org.jeecg.common.aspect.annotation.Dict;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* @Description: nu_app_nuid_permission
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2026-01-04
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Data
|
||||
@TableName("nu_app_nuid_permission")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value="nu_app_nuid_permission对象", description="nu_app_nuid_permission")
|
||||
public class NuAppNuidPermission implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**id*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@ApiModelProperty(value = "id")
|
||||
private java.lang.String id;
|
||||
/**角色id*/
|
||||
@Excel(name = "角色id", width = 15)
|
||||
@ApiModelProperty(value = "角色id")
|
||||
private java.lang.String roleId;
|
||||
/**权限id*/
|
||||
@Excel(name = "权限id", width = 15)
|
||||
@ApiModelProperty(value = "权限id")
|
||||
private java.lang.String permissionId;
|
||||
/**数据权限ids*/
|
||||
@Excel(name = "数据权限ids", width = 15)
|
||||
@ApiModelProperty(value = "数据权限ids")
|
||||
private java.lang.String dataRuleIds;
|
||||
/**操作时间*/
|
||||
@Excel(name = "操作时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "操作时间")
|
||||
private java.util.Date operateDate;
|
||||
/**操作ip*/
|
||||
@Excel(name = "操作ip", width = 15)
|
||||
@ApiModelProperty(value = "操作ip")
|
||||
private java.lang.String operateIp;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String menuName;
|
||||
@TableField(exist = false)
|
||||
private String menuCode;
|
||||
|
||||
|
||||
|
||||
public NuAppNuidPermission(String roleId, String permissionId) {
|
||||
this.roleId = roleId;
|
||||
this.permissionId = permissionId;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package com.nu.modules.nuidPermission.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.nu.modules.nuidPermission.entity.NuAppNuidPermission;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @Description: nu_app_nuid_permission
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2026-01-04
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface NuAppNuidPermissionMapper extends BaseMapper<NuAppNuidPermission> {
|
||||
|
||||
List<NuAppNuidPermission> listByNuId(@Param("roleId") String nuId);
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.nu.modules.nuidPermission.mapper.NuAppNuidPermissionMapper">
|
||||
|
||||
<select id="listByNuId" resultType="com.nu.modules.nuidPermission.entity.NuAppNuidPermission">
|
||||
select a.*,b.name as menu_name,b.menu_code from nu_app_nuid_permission a
|
||||
left join nu_app_permission b on a.permission_id = b.id
|
||||
<where>
|
||||
<if test="roleId != null and roleId !=''">
|
||||
and a.role_id = #{roleId}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
package com.nu.modules.nuidPermission.service;
|
||||
|
||||
import com.nu.modules.nuidPermission.entity.NuAppNuidPermission;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: nu_app_nuid_permission
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2026-01-04
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface INuAppNuidPermissionService extends IService<NuAppNuidPermission> {
|
||||
|
||||
void saveRolePermission(String roleId, String permissionIds, String lastPermissionIds);
|
||||
|
||||
List<NuAppNuidPermission> listByNuId(String nuId);
|
||||
}
|
||||
|
|
@ -0,0 +1,92 @@
|
|||
package com.nu.modules.nuidPermission.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.nu.modules.nuidPermission.entity.NuAppNuidPermission;
|
||||
import com.nu.modules.nuidPermission.mapper.NuAppNuidPermissionMapper;
|
||||
import com.nu.modules.nuidPermission.service.INuAppNuidPermissionService;
|
||||
import org.jeecg.common.util.IpUtils;
|
||||
import org.jeecg.common.util.SpringContextUtils;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @Description: nu_app_nuid_permission
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2026-01-04
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Service
|
||||
public class NuAppNuidPermissionServiceImpl extends ServiceImpl<NuAppNuidPermissionMapper, NuAppNuidPermission> implements INuAppNuidPermissionService {
|
||||
|
||||
@Override
|
||||
public void saveRolePermission(String roleId, String permissionIds, String lastPermissionIds) {
|
||||
String ip = "";
|
||||
try {
|
||||
//获取request
|
||||
HttpServletRequest request = SpringContextUtils.getHttpServletRequest();
|
||||
//获取IP地址
|
||||
ip = IpUtils.getIpAddr(request);
|
||||
} catch (Exception e) {
|
||||
ip = "127.0.0.1";
|
||||
}
|
||||
List<String> add = getDiff(lastPermissionIds,permissionIds);
|
||||
if(add!=null && add.size()>0) {
|
||||
List<NuAppNuidPermission> list = new ArrayList<NuAppNuidPermission>();
|
||||
for (String p : add) {
|
||||
if(oConvertUtils.isNotEmpty(p)) {
|
||||
NuAppNuidPermission rolepms = new NuAppNuidPermission(roleId, p);
|
||||
rolepms.setOperateDate(new Date());
|
||||
rolepms.setOperateIp(ip);
|
||||
list.add(rolepms);
|
||||
}
|
||||
}
|
||||
this.saveBatch(list);
|
||||
}
|
||||
|
||||
List<String> delete = getDiff(permissionIds,lastPermissionIds);
|
||||
if(delete!=null && delete.size()>0) {
|
||||
for (String permissionId : delete) {
|
||||
this.remove(new QueryWrapper<NuAppNuidPermission>().lambda().eq(NuAppNuidPermission::getRoleId, roleId).eq(NuAppNuidPermission::getPermissionId, permissionId));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NuAppNuidPermission> listByNuId(String nuId) {
|
||||
return baseMapper.listByNuId(nuId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 从diff中找出main中没有的元素
|
||||
* @param main
|
||||
* @param diff
|
||||
* @return
|
||||
*/
|
||||
private List<String> getDiff(String main,String diff){
|
||||
if(oConvertUtils.isEmpty(diff)) {
|
||||
return null;
|
||||
}
|
||||
if(oConvertUtils.isEmpty(main)) {
|
||||
return Arrays.asList(diff.split(","));
|
||||
}
|
||||
|
||||
String[] mainArr = main.split(",");
|
||||
String[] diffArr = diff.split(",");
|
||||
Map<String, Integer> map = new HashMap(5);
|
||||
for (String string : mainArr) {
|
||||
map.put(string, 1);
|
||||
}
|
||||
List<String> res = new ArrayList<String>();
|
||||
for (String key : diffArr) {
|
||||
if(oConvertUtils.isNotEmpty(key) && !map.containsKey(key)) {
|
||||
res.add(key);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue