更新
This commit is contained in:
parent
c76f1dbf0a
commit
4d5707e2ad
File diff suppressed because one or more lines are too long
@ -89,6 +89,19 @@ export function dataPermissions(data:any){
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function orgList(roleId:String){
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
request({
|
||||||
|
url: '/tansci/sysrole/orgList/' + roleId,
|
||||||
|
method: 'get'
|
||||||
|
}).then((res:any) => {
|
||||||
|
resolve(res.data)
|
||||||
|
}).catch((e:any) => {
|
||||||
|
reject(e)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// 菜单权限
|
// 菜单权限
|
||||||
export function menuPermissions(data:any){
|
export function menuPermissions(data:any){
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
@ -103,3 +116,16 @@ export function menuPermissions(data:any){
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function menuList(roleId:String){
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
request({
|
||||||
|
url: '/tansci/sysrole/menuList/' + roleId,
|
||||||
|
method: 'get'
|
||||||
|
}).then((res:any) => {
|
||||||
|
resolve(res.data)
|
||||||
|
}).catch((e:any) => {
|
||||||
|
reject(e)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@ -19,9 +19,12 @@
|
|||||||
type: Array,
|
type: Array,
|
||||||
default: []
|
default: []
|
||||||
},
|
},
|
||||||
operation: { // 操作列,自定义插槽
|
operation: {
|
||||||
type: Boolean,
|
type: Object,
|
||||||
default: false
|
default: {
|
||||||
|
isShow: false,
|
||||||
|
width: '220'
|
||||||
|
}
|
||||||
},
|
},
|
||||||
tableHeight: {
|
tableHeight: {
|
||||||
type: Number,
|
type: Number,
|
||||||
@ -29,7 +32,7 @@
|
|||||||
},
|
},
|
||||||
headerCellStyle: {
|
headerCellStyle: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default:{color:'#606266', fontWeight: 700, background:'var(--bg1)'}
|
default:{color:'#606266', fontWeight: 700}
|
||||||
},
|
},
|
||||||
data: {
|
data: {
|
||||||
type: Array,
|
type: Array,
|
||||||
@ -67,7 +70,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 根据属性获取对象值
|
// 根据属性获取对象值
|
||||||
function onFind(arr,val){
|
function onFind(arr:any,val:any){
|
||||||
if(!arr) return 'info';
|
if(!arr) return 'info';
|
||||||
|
|
||||||
let temp = arr.find(v=>{ return v.value == val});
|
let temp = arr.find(v=>{ return v.value == val});
|
||||||
@ -174,7 +177,7 @@
|
|||||||
</el-table-column>
|
</el-table-column>
|
||||||
</template>
|
</template>
|
||||||
<!-- 自定义插槽 -->
|
<!-- 自定义插槽 -->
|
||||||
<el-table-column v-if="operation" fixed="right" label="操作" align="center" width="220">
|
<el-table-column v-if="operation.isShow" fixed="right" label="操作" align="center" :width="operation.width">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<slot name="column" v-bind:column="scope"></slot>
|
<slot name="column" v-bind:column="scope"></slot>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@ -7,7 +7,10 @@
|
|||||||
|
|
||||||
// 局部背景
|
// 局部背景
|
||||||
// --el-bg-color: radial-gradient( white 0%, #FAFDFE 10%, #ddf8e7 50%, #FAFDFE 90%, white 100%);
|
// --el-bg-color: radial-gradient( white 0%, #FAFDFE 10%, #ddf8e7 50%, #FAFDFE 90%, white 100%);
|
||||||
--el-bg-color: radial-gradient(#d9f8e5 0%, #FAFDFE 80%, #e7fcef 100%);
|
// --el-bg-color: radial-gradient(#d9f8e5 0%, #FAFDFE 80%, #e7fcef 100%);
|
||||||
|
--el-bg-color: #FAFDFE;
|
||||||
|
// 背景色
|
||||||
|
--bg1: #FAFAFA;
|
||||||
|
|
||||||
// 操作颜色
|
// 操作颜色
|
||||||
--delete: #f56c6c;
|
--delete: #f56c6c;
|
||||||
@ -29,6 +32,15 @@ body {
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dialog 对话框
|
||||||
|
*/
|
||||||
|
.el-dialog__header{
|
||||||
|
background-color: var(--el-color-primary);
|
||||||
|
margin-right: 0;
|
||||||
|
padding: 0.5rem 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* table组件样式
|
* table组件样式
|
||||||
*/
|
*/
|
||||||
@ -36,7 +48,7 @@ body {
|
|||||||
.search-wrap{
|
.search-wrap{
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
background: var(--bg1);
|
// background: var(--bg1);
|
||||||
}
|
}
|
||||||
.search-wrap>div{
|
.search-wrap>div{
|
||||||
line-height: 40px;
|
line-height: 40px;
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
import {onMounted, reactive, ref, unref} from 'vue'
|
import {onMounted, reactive, ref, unref} from 'vue'
|
||||||
import {ElMessage, ElMessageBox} from 'element-plus'
|
import {ElMessage, ElMessageBox} from 'element-plus'
|
||||||
import type {FormInstance} from 'element-plus'
|
import type {FormInstance} from 'element-plus'
|
||||||
import {page,save,update,del} from '@/api/system/role'
|
import {page,save,update,del,dataPermissions,orgList,menuPermissions,menuList} from '@/api/system/role'
|
||||||
import Table from '@/components/Table.vue'
|
import Table from '@/components/Table.vue'
|
||||||
|
|
||||||
const searchForm = reactive({
|
const searchForm = reactive({
|
||||||
@ -16,6 +16,10 @@
|
|||||||
size: 10,
|
size: 10,
|
||||||
total: 1,
|
total: 1,
|
||||||
},
|
},
|
||||||
|
operation:{
|
||||||
|
isShow: true,
|
||||||
|
width: '240'
|
||||||
|
},
|
||||||
tableTitle: [
|
tableTitle: [
|
||||||
{prop:'',label:'',fixed:'left'},
|
{prop:'',label:'',fixed:'left'},
|
||||||
{prop:'code',label:'角色编码'},
|
{prop:'code',label:'角色编码'},
|
||||||
@ -28,18 +32,6 @@
|
|||||||
tableData:[],
|
tableData:[],
|
||||||
})
|
})
|
||||||
|
|
||||||
const formRef = ref<FormInstance>();
|
|
||||||
const form = reactive({
|
|
||||||
roleVisible: false,
|
|
||||||
operate: 0,
|
|
||||||
roleForm:{
|
|
||||||
id:'',
|
|
||||||
name:'',
|
|
||||||
status: 0,
|
|
||||||
remarks: ''
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
onMounted(()=>{
|
onMounted(()=>{
|
||||||
onRolePage()
|
onRolePage()
|
||||||
})
|
})
|
||||||
@ -73,11 +65,49 @@
|
|||||||
onRolePage();
|
onRolePage();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 编辑
|
const formRef = ref<FormInstance>();
|
||||||
function onEdit(val){
|
const form = reactive({
|
||||||
|
roleVisible: false,
|
||||||
}
|
operate: 0,
|
||||||
|
permissionList :[
|
||||||
|
{label: '全部', value: '0'},
|
||||||
|
{label: '自定义', value: '1'},
|
||||||
|
{label: '本级级子级', value: '2'},
|
||||||
|
{label: '本级', value: '3'}
|
||||||
|
],
|
||||||
|
roleForm:{
|
||||||
|
id:'',
|
||||||
|
name:'',
|
||||||
|
permission: '',
|
||||||
|
sort: 0,
|
||||||
|
remarks: ''
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
// 添加信息
|
||||||
|
function onAddRole(){
|
||||||
|
form.roleVisible = true
|
||||||
|
form.operate = 0
|
||||||
|
form.roleForm = {
|
||||||
|
id:'',
|
||||||
|
name:'',
|
||||||
|
permission: '',
|
||||||
|
sort: 0,
|
||||||
|
remarks: ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 编辑
|
||||||
|
function onEdit(val:any){
|
||||||
|
form.operate = 1
|
||||||
|
form.roleForm = {
|
||||||
|
id: val.column.row.id,
|
||||||
|
name: val.column.row.name,
|
||||||
|
permission: val.column.row.permission,
|
||||||
|
sort: val.column.row.sort,
|
||||||
|
remarks: val.column.row.remarks
|
||||||
|
}
|
||||||
|
form.roleVisible = true
|
||||||
|
}
|
||||||
// 删除
|
// 删除
|
||||||
function onDelete(val:any){
|
function onDelete(val:any){
|
||||||
ElMessageBox.confirm('此操作将永久删除, 是否继续?', '提示', {
|
ElMessageBox.confirm('此操作将永久删除, 是否继续?', '提示', {
|
||||||
@ -95,26 +125,94 @@
|
|||||||
console.log(e)
|
console.log(e)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
const onSubmit = async (formEl: FormInstance | undefined) => {
|
||||||
// 添加信息
|
if (!formEl) return;
|
||||||
function onAddRole(){
|
await formEl.validate((valid)=>{
|
||||||
|
if(valid){
|
||||||
|
if(form.operate == 0){
|
||||||
|
save(form.roleForm).then(res=>{
|
||||||
|
if(res){
|
||||||
|
ElMessage.success("添加成功!");
|
||||||
|
onRolePage()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
update(form.roleForm).then(res=>{
|
||||||
|
if(res){
|
||||||
|
ElMessage.success("更新成功!");
|
||||||
|
onRolePage()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
form.operate = 0
|
||||||
|
form.roleVisible = false
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onSubmit (){
|
// 数据、菜单权限
|
||||||
const form = unref(formRef);
|
const menuRef = ref()
|
||||||
if (!form) return;
|
const orgRef = ref()
|
||||||
await form.validate();
|
const auth = reactive({
|
||||||
|
authVisible: false,
|
||||||
|
type: '',
|
||||||
|
menuList: [],
|
||||||
|
orgList: [],
|
||||||
|
selected: [],
|
||||||
|
roleId: ''
|
||||||
|
})
|
||||||
|
|
||||||
|
function onAuth(val:any, type:string){
|
||||||
|
auth.type = type
|
||||||
|
auth.roleId = val.column.row.id
|
||||||
|
if(auth.type == 'menu'){
|
||||||
|
menuList(val.column.row.id).then((res:any)=>{
|
||||||
|
auth.menuList = res.result.list
|
||||||
|
auth.selected = res.result.selected
|
||||||
|
})
|
||||||
|
} else{
|
||||||
|
orgList(val.column.row.id).then((res:any)=>{
|
||||||
|
auth.orgList = res.result.list
|
||||||
|
auth.selected = res.result.selected
|
||||||
|
})
|
||||||
|
}
|
||||||
|
auth.authVisible = true
|
||||||
|
}
|
||||||
|
|
||||||
|
function onAuthSubmit(){
|
||||||
|
if(auth.type == 'menu'){
|
||||||
|
const keys = unref(menuRef);
|
||||||
|
if(keys.getCheckedKeys().length == 0){
|
||||||
|
ElMessage.error("请先选择菜单!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
menuPermissions({id: auth.roleId, menuIds: keys.getCheckedKeys()}).then(res=>{
|
||||||
|
if(res){
|
||||||
|
ElMessage.success("操作成功!");
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
const keys = unref(orgRef);
|
||||||
|
if(keys.getCheckedKeys().length == 0){
|
||||||
|
ElMessage.error("请先选择组织!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
dataPermissions({id: auth.roleId, orgIds: keys.getCheckedKeys()}).then(res=>{
|
||||||
|
if(res){
|
||||||
|
ElMessage.success("操作成功!");
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
auth.authVisible = false
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<el-card class="role-container" shadow="always">
|
<el-card class="role-container" shadow="always">
|
||||||
<Table :data="table.tableData" :column="table.tableTitle" :operation="true" :page="table.page" :loading="table.loading"
|
<Table :data="table.tableData" :column="table.tableTitle" :operation="table.operation" :page="table.page" :loading="table.loading"
|
||||||
@onSizeChange="onSizeChange" @onCurrentChange="onCurrentChange" @onSwitchChange="onSwitchChange">
|
@onSizeChange="onSizeChange" @onCurrentChange="onCurrentChange" @onSwitchChange="onSwitchChange">
|
||||||
<template #search>
|
<template #search>
|
||||||
<div><el-button type="info" @click="onAddRole">添加</el-button></div>
|
<div><el-button type="primary" @click="onAddRole">添加</el-button></div>
|
||||||
<div><el-input v-model="name" placeholder="请输入名称"></el-input></div>
|
<div><el-input v-model="name" placeholder="请输入名称"></el-input></div>
|
||||||
<div><el-button @click="onRefresh" icon="RefreshRight" circle></el-button></div>
|
<div><el-button @click="onRefresh" icon="RefreshRight" circle></el-button></div>
|
||||||
<div><el-button @click="onSearch" type="primary" icon="Search">查询</el-button></div>
|
<div><el-button @click="onSearch" type="primary" icon="Search">查询</el-button></div>
|
||||||
@ -122,19 +220,48 @@
|
|||||||
<template #column="scope">
|
<template #column="scope">
|
||||||
<el-button @click="onEdit(scope)" type='primary' text='primary' style="color:var(--edit); padding:0;">编辑</el-button>
|
<el-button @click="onEdit(scope)" type='primary' text='primary' style="color:var(--edit); padding:0;">编辑</el-button>
|
||||||
<el-button @click="onDelete(scope)" type='primary' text='primary' style="color:var(--delete); padding:0;">删除</el-button>
|
<el-button @click="onDelete(scope)" type='primary' text='primary' style="color:var(--delete); padding:0;">删除</el-button>
|
||||||
<el-button @click="onMenuRole(scope)" type='primary' text='primary' style="color:var(--role); padding:0;">菜单权限</el-button>
|
<el-button @click="onAuth(scope, 'menu')" type='primary' text='primary' style="color:var(--add); padding:0;">菜单权限</el-button>
|
||||||
<el-button @click="onMenuRole(scope)" type='primary' text='primary' style="color:var(--role); padding:0;">权限</el-button>
|
<el-button @click="onAuth(scope, 'org')" type='primary' text='primary' style="color:var(--role); padding:0;">数据权限</el-button>
|
||||||
</template>
|
</template>
|
||||||
</Table>
|
</Table>
|
||||||
<el-dialog title="权限信息" v-model="form.roleVisible" :show-close="false" width="40%">
|
<el-dialog title="角色信息" v-model="form.roleVisible" :show-close="false" width="40%">
|
||||||
|
<el-form :model="form.roleForm" ref="formRef" :rules="rules" label-width="80px" status-icon>
|
||||||
|
<el-form-item label="名称" prop="name" :rules="[{required: true,message:'请输入名称',trigger: 'blur'}]">
|
||||||
|
<el-input v-model="form.roleForm.name" placeholder="请输入名称" style="width: 100%"/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="权限" prop="permission" :rules="[{required: true,message:'请选择权限',trigger: 'change'}]">
|
||||||
|
<el-select v-model="form.roleForm.permission" placeholder="请选择权限" style="width: 100%">
|
||||||
|
<el-option v-for="item in form.permissionList" :key="item" :label="item.label" :value="item.value" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="排序" prop="sort">
|
||||||
|
<el-input-number v-model="form.roleForm.sort" :min="0" :max="999" controls-position="right" style="width: 100%"/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="描述" prop="remarks">
|
||||||
|
<el-input v-model="form.roleForm.remarks" type="textarea" placeholder="请输入描述" style="width: 100%"/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<span class="dialog-footer">
|
<span class="dialog-footer">
|
||||||
<el-button @click="roleVisible = false">取消</el-button>
|
<el-button @click="form.roleVisible = false">取消</el-button>
|
||||||
<el-button type="primary" @click="onSubmit(formRef)">提交</el-button>
|
<el-button type="primary" @click="onSubmit(formRef)">提交</el-button>
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
<el-dialog title="权限信息" v-model="auth.authVisible" :show-close="false" width="30%">
|
||||||
|
<el-scrollbar height="400px">
|
||||||
|
<el-tree v-if="auth.type == 'menu'" :data="auth.menuList" node-key="id" ref="menuRef" :default-expand-all="true"
|
||||||
|
:props="{children: 'children',label: 'chineseName'}" :default-checked-keys="auth.selected" multiple show-checkbox />
|
||||||
|
<el-tree v-if="auth.type == 'org'" :data="auth.orgList" node-key="id" ref="orgRef" :default-expand-all="true"
|
||||||
|
:props="{children: 'children',label: 'name'}" :default-checked-keys="auth.selected" multiple show-checkbox />
|
||||||
|
</el-scrollbar>
|
||||||
|
<template #footer>
|
||||||
|
<span class="dialog-footer">
|
||||||
|
<el-button @click="auth.authVisible = false">取消</el-button>
|
||||||
|
<el-button type="primary" @click="onAuthSubmit(authRef)">提交</el-button>
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
</el-card>
|
</el-card>
|
||||||
</template>
|
</template>
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
|
|||||||
@ -80,6 +80,14 @@ public class SysRoleController {
|
|||||||
return WrapMapper.wrap(Wrapper.SUCCESS_CODE, Wrapper.SUCCESS_MESSAGE, sysRoleService.dataPermissions(role));
|
return WrapMapper.wrap(Wrapper.SUCCESS_CODE, Wrapper.SUCCESS_MESSAGE, sysRoleService.dataPermissions(role));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "获取权限组织", notes = "获取权限组织")
|
||||||
|
@Log(modul = "角色管理-获取权限组织", type = Constants.UPDATE, desc = "获取权限组织")
|
||||||
|
@GetMapping("/orgList/{roleId}")
|
||||||
|
@SaCheckPermission("role:data")
|
||||||
|
public Wrapper<Object> orgList(@PathVariable String roleId) {
|
||||||
|
return WrapMapper.wrap(Wrapper.SUCCESS_CODE, Wrapper.SUCCESS_MESSAGE, sysRoleService.orgList(roleId));
|
||||||
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "菜单权限", notes = "菜单权限")
|
@ApiOperation(value = "菜单权限", notes = "菜单权限")
|
||||||
@Log(modul = "角色管理-菜单权限", type = Constants.UPDATE, desc = "菜单权限")
|
@Log(modul = "角色管理-菜单权限", type = Constants.UPDATE, desc = "菜单权限")
|
||||||
@PostMapping("/menuPermissions")
|
@PostMapping("/menuPermissions")
|
||||||
@ -88,4 +96,12 @@ public class SysRoleController {
|
|||||||
return WrapMapper.wrap(Wrapper.SUCCESS_CODE, Wrapper.SUCCESS_MESSAGE, sysRoleService.menuPermissions(role));
|
return WrapMapper.wrap(Wrapper.SUCCESS_CODE, Wrapper.SUCCESS_MESSAGE, sysRoleService.menuPermissions(role));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "获取权限菜单", notes = "获取权限菜单")
|
||||||
|
@Log(modul = "角色管理-获取权限菜单", type = Constants.UPDATE, desc = "获取权限菜单")
|
||||||
|
@GetMapping("/menuList/{roleId}")
|
||||||
|
@SaCheckPermission("role:menu")
|
||||||
|
public Wrapper<Object> menuList(@PathVariable String roleId) {
|
||||||
|
return WrapMapper.wrap(Wrapper.SUCCESS_CODE, Wrapper.SUCCESS_MESSAGE, sysRoleService.menuList(roleId));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -28,6 +28,10 @@ public interface SysRoleService extends IService<SysRole> {
|
|||||||
|
|
||||||
Object dataPermissions(SysRole role);
|
Object dataPermissions(SysRole role);
|
||||||
|
|
||||||
|
Object orgList(String roleId);
|
||||||
|
|
||||||
Object menuPermissions(SysRole role);
|
Object menuPermissions(SysRole role);
|
||||||
|
|
||||||
|
Object menuList(String roleId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,22 +6,17 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.tansci.common.constant.Constants;
|
import com.tansci.common.constant.Constants;
|
||||||
import com.tansci.domain.SysRole;
|
import com.tansci.domain.*;
|
||||||
import com.tansci.domain.SysRoleMenu;
|
|
||||||
import com.tansci.domain.SysRoleOrg;
|
|
||||||
import com.tansci.mapper.SysRoleMapper;
|
import com.tansci.mapper.SysRoleMapper;
|
||||||
import com.tansci.service.SysRoleMenuService;
|
import com.tansci.service.*;
|
||||||
import com.tansci.service.SysRoleOrgService;
|
|
||||||
import com.tansci.service.SysRoleService;
|
|
||||||
import com.tansci.utils.UUIDUtils;
|
import com.tansci.utils.UUIDUtils;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.List;
|
import java.util.stream.Collectors;
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ClassName: SysRoleServiceImpl.java
|
* @ClassName: SysRoleServiceImpl.java
|
||||||
@ -37,7 +32,11 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
|||||||
@Autowired
|
@Autowired
|
||||||
private SysRoleMenuService sysRoleMenuService;
|
private SysRoleMenuService sysRoleMenuService;
|
||||||
@Autowired
|
@Autowired
|
||||||
|
private SysMenuService sysMenuService;
|
||||||
|
@Autowired
|
||||||
private SysRoleOrgService sysRoleOrgService;
|
private SysRoleOrgService sysRoleOrgService;
|
||||||
|
@Autowired
|
||||||
|
private SysOrgService sysOrgService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IPage<SysRole> page(Page page, SysRole role) {
|
public IPage<SysRole> page(Page page, SysRole role) {
|
||||||
@ -64,7 +63,7 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
|||||||
@Override
|
@Override
|
||||||
public Object insert(SysRole role) {
|
public Object insert(SysRole role) {
|
||||||
role.setCreator(String.valueOf(StpUtil.getLoginId()));
|
role.setCreator(String.valueOf(StpUtil.getLoginId()));
|
||||||
role.setCode(UUIDUtils.getUUID(10));
|
role.setCode("SR"+UUIDUtils.getUUID(10).toUpperCase());
|
||||||
role.setIsDel(Constants.NOT_DEL_FALG);
|
role.setIsDel(Constants.NOT_DEL_FALG);
|
||||||
role.setUpdateTime(LocalDateTime.now());
|
role.setUpdateTime(LocalDateTime.now());
|
||||||
role.setCreateTime(LocalDateTime.now());
|
role.setCreateTime(LocalDateTime.now());
|
||||||
@ -97,14 +96,37 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
|||||||
return sysRoleOrgService.saveBatch(orgs);
|
return sysRoleOrgService.saveBatch(orgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object orgList(String roleId) {
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
map.put("list", sysOrgService.list(SysOrg.builder().build()));
|
||||||
|
|
||||||
|
List<SysRoleOrg> orgs = sysRoleOrgService.list(Wrappers.<SysRoleOrg>lambdaQuery().eq(SysRoleOrg::getRoleId, roleId));
|
||||||
|
if (Objects.nonNull(orgs) && orgs.size() > 0) {
|
||||||
|
map.put("selected", orgs.stream().map(SysRoleOrg::getOrgId).collect(Collectors.toList()));
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object menuPermissions(SysRole role) {
|
public Object menuPermissions(SysRole role) {
|
||||||
sysRoleMenuService.remove(Wrappers.<SysRoleMenu>lambdaQuery().eq(SysRoleMenu::getRoleId, role.getId()));
|
sysRoleMenuService.remove(Wrappers.<SysRoleMenu>lambdaQuery().eq(SysRoleMenu::getRoleId, role.getId()));
|
||||||
List<SysRoleMenu> menus = new ArrayList<>();
|
List<SysRoleMenu> menus = new ArrayList<>();
|
||||||
role.getOrgIds().forEach(item -> {
|
role.getMenuIds().forEach(item -> {
|
||||||
menus.add(SysRoleMenu.builder().roleId(role.getId()).menuId(item).build());
|
menus.add(SysRoleMenu.builder().roleId(role.getId()).menuId(item).build());
|
||||||
});
|
});
|
||||||
return sysRoleMenuService.saveBatch(menus);
|
return sysRoleMenuService.saveBatch(menus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object menuList(String roleId) {
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
map.put("list", sysMenuService.tree(SysMenu.builder().build()));
|
||||||
|
|
||||||
|
List<SysRoleMenu> menus = sysRoleMenuService.list(Wrappers.<SysRoleMenu>lambdaQuery().eq(SysRoleMenu::getRoleId, roleId));
|
||||||
|
if (Objects.nonNull(menus) && menus.size() > 0) {
|
||||||
|
map.put("selected", menus.stream().map(SysRoleMenu::getMenuId).collect(Collectors.toList()));
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user