代码更新

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,21 +57,12 @@ 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);
}
@@ -111,7 +76,7 @@ public class RoleController {
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

View File

@@ -23,13 +23,6 @@ export function getMenusByRole(params) {
})
}
export function getSelectList() {
return request({
url: 'api/menus/getSelectList',
method: 'get'
})
}
export function getMenuSuperior(ids) {
// const data = ids.length || ids.length === 0 ? ids : Array.of(ids)
const data = {
@@ -80,4 +73,4 @@ export function edit(data) {
})
}
export default { add, edit, del, getMenusTree, getMenuSuperior, getMenus, getChild, getSelectList, getMenusByRole }
export default { add, edit, del, getMenusTree, getMenuSuperior, getMenus, getChild, getMenusByRole }

View File

@@ -50,7 +50,7 @@ function CRUD(options) {
// 主页操作栏显示哪些按钮
optShow: {
add: true,
edit: true,
edit: false,
del: true,
download: false,
reset: true
@@ -160,6 +160,16 @@ function CRUD(options) {
})
})
},
/**
* 格式化是否1-是0-否
*/
formatIsOrNot(row, column) {
if (!row[column.property]) {
return '否'
}
return row[column.property] == '1' ? '是' : '否'
},
/**
* 格式化数据保留0位小数
*/

View File

@@ -137,44 +137,25 @@
@selection-change="crud.selectionChangeHandler"
>
<el-table-column type="selection" width="55" />
<el-table-column show-overflow-tooltip label="菜单标题" width="125px" prop="title" />
<el-table-column show-overflow-tooltip label="子系统" width="125px" prop="system_type" />
<el-table-column show-overflow-tooltip label="菜单类别" width="125px" prop="category" />
<el-table-column prop="icon" label="图标" align="center" width="60px">
<el-table-column label="菜单标题" prop="title" :min-width="flexWidth('title',crud.data,'菜单标题')" />
<el-table-column label="子系统" prop="system_type" :min-width="flexWidth('system_type',crud.data,'子系统')" />
<el-table-column prop="icon" label="图标" align="center" :min-width="flexWidth('icon',crud.data,'图标')">
<template slot-scope="scope">
<svg-icon :icon-class="scope.row.icon ? scope.row.icon : ''" />
</template>
</el-table-column>
<el-table-column prop="menuSort" align="center" label="排序">
<el-table-column prop="menuSort" align="center" label="排序" :min-width="flexWidth('menuSort',crud.data,'排序')">
<template slot-scope="scope">
{{ scope.row.menuSort }}
</template>
</el-table-column>
<el-table-column show-overflow-tooltip prop="permission" label="权限标识" />
<el-table-column show-overflow-tooltip prop="component" label="组件路径" />
<el-table-column prop="i_frame" label="外链" width="75px">
<template slot-scope="scope">
<span v-if="scope.row.i_frame=='1'">是</span>
<span v-else>否</span>
</template>
</el-table-column>
<el-table-column prop="cache" label="缓存" width="75px">
<template slot-scope="scope">
<span v-if="scope.row.cache=='1'">是</span>
<span v-else>否</span>
</template>
</el-table-column>
<el-table-column prop="hidden" label="可见" width="75px">
<template slot-scope="scope">
<span v-if="scope.row.hidden=='0'">否</span>
<span v-else>是</span>
</template>
</el-table-column>
<el-table-column prop="createTime" label="创建日期" width="135px">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime) }}</span>
</template>
</el-table-column>
<el-table-column prop="permission" label="权限标识" :min-width="flexWidth('permission',crud.data,'权限标识')" />
<el-table-column prop="component" label="组件路径" :min-width="flexWidth('component',crud.data,'组件路径')" />
<el-table-column prop="i_frame" label="外链" :formatter="crud.formatIsOrNot" :min-width="flexWidth('i_frame',crud.data,'外链')" />
<el-table-column prop="cache" label="缓存" :formatter="crud.formatIsOrNot" :min-width="flexWidth('cache',crud.data,'缓存')" />
<el-table-column prop="hidden" label="可见" :formatter="crud.formatIsOrNot" :min-width="flexWidth('hidden',crud.data,'可见')" />
<el-table-column prop="createTime" label="创建日期" :min-width="flexWidth('createTime',crud.data,'创建日期')" />
<el-table-column
v-permission="['admin','menu:edit','menu:del']"
label="操作"

View File

@@ -102,13 +102,6 @@
</el-button>
</div>
<el-cascader
:options="options"
:props="{ checkStrictly: true }"
clearable
@change="getMenusByRole"
/>
<el-tree
ref="menu"
lazy
@@ -152,7 +145,6 @@ export default {
defaultProps: { children: 'children', label: 'title', isLeaf: 'leaf' },
currentId: 0, menuLoading: false, showButton: false,
menus: [], menuIds: [], // 多选时使用
options: [],
permission: {
add: ['admin', 'roles:add'],
edit: ['admin', 'roles:edit'],
@@ -169,9 +161,6 @@ export default {
}
},
created() {
crudMenu.getSelectList().then(res => {
this.options = res
})
},
methods: {
getMenuDatas(node, resolve) {

View File

@@ -2,7 +2,7 @@
<div class="app-container">
<el-row :gutter="20">
<!--侧边部门数据-->
<el-col :xs="9" :sm="6" :md="5" :lg="5" :xl="4">
<el-col :span="4">
<div class="head-container">
<el-input
v-model="deptName"
@@ -21,7 +21,7 @@
/>
</el-col>
<!--用户数据-->
<el-col :xs="15" :sm="18" :md="19" :lg="19" :xl="20">
<el-col :span="20">
<!--工具栏-->
<div class="head-container">
<div v-if="crud.props.searchToggle">
@@ -143,52 +143,43 @@
@selection-change="crud.selectionChangeHandler"
>
<el-table-column :selectable="checkboxT" type="selection" width="55" />
<el-table-column show-overflow-tooltip prop="username" label="用户名" />
<el-table-column show-overflow-tooltip prop="person_name" label="姓名" />
<el-table-column prop="gender" label="性别" />
<el-table-column show-overflow-tooltip prop="phone" width="100" label="电话" />
<el-table-column show-overflow-tooltip width="135" prop="email" label="邮箱" />
<el-table-column show-overflow-tooltip prop="deptnames" label="部门" />
<el-table-column label="状态" align="center" prop="is_used">
<template slot-scope="scope">
<el-switch
v-model="scope.row.is_used"
:disabled="scope.row.id === 1"
active-color="#409EFF"
inactive-color="#F56C6C"
active-value="1"
inactive-value="0"
@change="changeEnabled(scope.row, scope.row.is_used)"
/>
</template>
</el-table-column>
<el-table-column show-overflow-tooltip prop="create_time" width="135" label="创建日期">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.create_time) }}</span>
</template>
</el-table-column>
<el-table-column prop="username" label="用户名" :min-width="flexWidth('username',crud.data,'用户名')" />
<el-table-column
v-permission="['admin','user:edit','user:del']"
label="操作"
width="200"
align="center"
fixed="right"
>
<template slot-scope="scope">
<udOperation
style="display:inline;"
:data="scope.row"
:permission="permission"
prop="person_name"
label="姓名"
:min-width="flexWidth('person_name',crud.data,'姓名')"
/>
<el-button
slot="left"
v-permission="permission.edit"
type="text"
icon="el-icon-refresh-left"
@click="resetPassword(scope.row)"
<el-table-column prop="gender" label="性别" :min-width="flexWidth('person_name',crud.data,'性别')" />
<el-table-column prop="phone" label="电话" :min-width="flexWidth('phone',crud.data,'电话')" />
<el-table-column prop="email" label="邮箱" :min-width="flexWidth('email',crud.data,'邮箱')" />
<el-table-column show-overflow-tooltip prop="deptnames" label="部门" />
<el-table-column
label="启用"
align="center"
prop="is_used"
:formatter="crud.formatIsOrNot"
:min-width="flexWidth('is_used',crud.data,'启用')"
/>
<el-table-column prop="create_time" label="创建日期" :min-width="flexWidth('create_time',crud.data,'创建日期')" />
<el-table-column
label="操作"
fixed="right"
align="center"
width="200"
>
重置密码
</el-button>
<template v-if="scope.row.userId !== 1" slot-scope="scope">
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)">修改</el-button>
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)">删除</el-button>
<el-dropdown v-hasPermi="['system:user:resetPwd', 'system:user:edit']" size="mini" @command="(command) => handleCommand(command, scope.row)">
<el-button size="mini" type="text" icon="el-icon-d-arrow-right">更多</el-button>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="handleResetPwd" icon="el-icon-key">重置密码</el-dropdown-item>
<el-dropdown-item command="handleResetPwd" icon="el-icon-key">部门权限</el-dropdown-item>
<el-dropdown-item command="handleResetPwd" icon="el-icon-key">数据权限</el-dropdown-item>
<el-dropdown-item command="handleResetPwd" icon="el-icon-key">锁定账号</el-dropdown-item>
<el-dropdown-item command="handleAuthRole" icon="el-icon-circle-check">分配角色</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</template>
</el-table-column>
</el-table>
@@ -280,7 +271,7 @@ export default {
},
methods: {
changeRole(value) {
userRoles = [],
userRoles = []
value.forEach(function(data, index) {
const role = { id: data }
userRoles.push(role)