代码更新

This commit is contained in:
ludj
2022-12-02 17:16:27 +08:00
parent 06cd3b453c
commit 1840ceec58
10 changed files with 76 additions and 217 deletions

View File

@@ -64,14 +64,6 @@ public class MenuController {
public ResponseEntity<Object> query(@RequestParam String pid) {
return new ResponseEntity<>(menuService.getMenus(pid), HttpStatus.OK);
}
@ApiOperation("菜单子系统级联选择")
@GetMapping(value = "/getSelectList")
@SaCheckPermission(value = {"menu:list", "roles:list"}, mode = SaMode.AND)
public ResponseEntity<Object> getSelectList() {
return new ResponseEntity<>(menuService.getSelectList(), HttpStatus.OK);
}
@ApiOperation("获取菜单列表")
@PostMapping(value = "/getMenusByRole")
@SaCheckPermission(value = {"menu:list", "roles:list"}, mode = SaMode.AND)

View File

@@ -1,37 +1,15 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.nl.modules.system.rest;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.dev33.satoken.annotation.SaMode;
import cn.dev33.satoken.stp.StpUtil;
import cn.hutool.core.lang.Dict;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.nl.modules.common.exception.BadRequestException;
import org.nl.modules.logging.annotation.Log;
import org.nl.modules.system.domain.Role;
import org.nl.modules.system.domain.vo.RoleVo;
import org.nl.modules.system.service.RoleService;
import org.nl.modules.system.service.dto.RoleDto;
import org.nl.modules.system.service.dto.RoleQueryCriteria;
import org.nl.modules.system.service.dto.RoleSmallDto;
import org.nl.modules.wql.core.bean.WQLObject;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
@@ -39,13 +17,9 @@ import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
/**
* @author Zheng Jie
@@ -83,35 +57,26 @@ public class RoleController {
return new ResponseEntity<>(roleService.queryAll(criteria, pageable), HttpStatus.OK);
}
@ApiOperation("获取用户级别")
@GetMapping(value = "/level")
public ResponseEntity<Object> getLevel() {
return new ResponseEntity<>(Dict.create().set("level", getLevels(null)), HttpStatus.OK);
}
@Log("新增角色")
@ApiOperation("新增角色")
@PostMapping
@SaCheckPermission("roles:add")
public ResponseEntity<Object> create(@Validated @RequestBody Role resources) {
if (resources.getId() != null) {
throw new BadRequestException("A new " + ENTITY_NAME + " cannot already have an ID");
}
getLevels(resources.getLevel());
// roleService.create(resources);
return new ResponseEntity<>(HttpStatus.CREATED);
}
/* @Log("修改角色")
@ApiOperation("修改角色")
@PutMapping
@SaCheckPermission("roles:edit")
public ResponseEntity<Object> update(@Validated(Role.Update.class) @RequestBody Role resources) {
getLevels(resources.getLevel());
roleService.update(resources);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
*/
/* @Log("修改角色")
@ApiOperation("修改角色")
@PutMapping
@SaCheckPermission("roles:edit")
public ResponseEntity<Object> update(@Validated(Role.Update.class) @RequestBody Role resources) {
getLevels(resources.getLevel());
roleService.update(resources);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
*/
@Log("修改角色菜单")
@ApiOperation("修改角色菜单")
@PutMapping(value = "/menu")
@@ -140,20 +105,4 @@ public class RoleController {
roleService.delete(ids);
return new ResponseEntity<>(HttpStatus.OK);
}
/**
* 获取用户的角色级别
*
* @return /
*/
private int getLevels(Integer level) {
/* List<Integer> levels = roleService.findByUsersId(StpUtil.getLoginIdAsLong()).stream().map(Role::getLevel).collect(Collectors.toList());
int min = Collections.min(levels);
if(level != null){
if(level < min){
throw new BadRequestException("权限不足,你的角色级别:" + min + ",低于操作的角色级别:" + level);
}
}*/
return 2;
}
}

View File

@@ -41,13 +41,6 @@ public interface MenuService {
JSONObject queryAll(JSONObject param, Pageable page) throws Exception;
/**
* 构建菜单子系统与菜单类类别的级联选择下拉框
*
* @return
*/
JSONArray getSelectList();
/**
* 1、根据子系统、菜单类别获取菜单列表,并判断对应的角色ID是否拥有该菜单
*

View File

@@ -35,7 +35,7 @@ public class MenuServiceImpl implements MenuService {
@Override
public JSONObject queryAll(JSONObject param, Pageable page) throws Exception {
JSONObject json = WQL.getWO("QSYS_MENU01").addParam("flag", "0").addParam("pid", param.getString("pid")).pageQuery(WqlUtil.getHttpContext(page), "");
JSONObject json = WQL.getWO("QSYS_MENU01").addParam("flag", "1").addParam("pid", param.getString("pid")).pageQuery(WqlUtil.getHttpContext(page), "");
JSONArray content = json.getJSONArray("content");
JSONArray res = new JSONArray();
@@ -60,37 +60,6 @@ public class MenuServiceImpl implements MenuService {
return json;
}
@Override
public JSONArray getSelectList() {
JSONArray arr = WQL.getWO("QSYS_MENU01").addParam("flag", "1").process().getResultJSONArray(0);
JSONArray result = new JSONArray();
for (int i = 0; i < arr.size(); i++) {
JSONObject json = arr.getJSONObject(i);
JSONObject item = new JSONObject();
String system_type = json.getString("system_type");
item.put("label", system_type);
item.put("value", system_type);
//构建字级节点
JSONArray children = WQL.getWO("QSYS_MENU01").addParam("flag", "2").addParam("system_type", system_type).process().getResultJSONArray(0);
if (ObjectUtil.isNotEmpty(children)) {
JSONArray childNodes = new JSONArray();
for (int j = 0; j < children.size(); j++) {
JSONObject childJson = children.getJSONObject(j);
JSONObject childItem = new JSONObject();
String category = childJson.getString("category");
childItem.put("label", category);
childItem.put("value", category);
childNodes.add(childItem);
}
item.put("children", childNodes);
}
result.add(item);
}
return result;
}
@Override
public JSONArray getMenusByRole(String role_id, String system_type, String category) {

View File

@@ -43,7 +43,7 @@
# 3、业务主过程 #
##########################################
IF 输入.flag = "0"
IF 输入.flag = "1"
PAGEQUERY
SELECT
* ,
@@ -62,14 +62,6 @@
ENDIF
IF 输入.flag = "1"
QUERY
SELECT system_type from sys_menu GROUP BY system_type
ENDSELECT
ENDQUERY
ENDIF
IF 输入.flag = "2"
QUERY
SELECT category from sys_menu