新增:新增系统管理/角色管理(分页、查看详情、创建、修改、删除)

This commit is contained in:
Charles7c 2023-02-09 23:15:16 +08:00
parent 4171fe0597
commit 5251a484f2
22 changed files with 1564 additions and 12 deletions

View File

@ -272,6 +272,7 @@ continew-admin
│ │ │ └─ online # 在线用户
│ │ └─ system # 系统管理模块
│ │ ├─ dept # 部门管理
│ │ ├─ role # 角色管理
│ │ └─ user # 用户模块
│ │ └─ center # 个人中心
│ ├─ App.vue # 视图入口

View File

@ -0,0 +1,35 @@
/*
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
*
* 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 top.charles7c.cnadmin.common.consts;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
/**
* 系统常量
*
* @author Charles7c
* @since 2023/2/9 22:11
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class Constants {
/**
* 超级管理员角色编码
*/
public static final String ADMIN_ROLE_CODE = "admin";
}

View File

@ -0,0 +1,51 @@
/*
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
*
* 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 top.charles7c.cnadmin.common.enums;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import top.charles7c.cnadmin.common.base.BaseEnum;
/**
* 数据权限枚举
*
* @author Charles7c
* @since 2023/2/8 22:58
*/
@Getter
@RequiredArgsConstructor
public enum DataScopeEnum implements BaseEnum<Integer, String> {
/** 全部数据权限 */
ALL(1, "全部数据权限"),
/** 本部门及以下数据权限 */
DEPT_AND_CHILD(2, "本部门及以下数据权限"),
/** 本部门数据权限 */
DEPT(3, "本部门数据权限"),
/** 仅本人数据权限 */
SELF(4, "仅本人数据权限"),
/** 自定数据权限 */
CUSTOM(5, "自定数据权限"),;
private final Integer value;
private final String description;
}

View File

@ -0,0 +1,29 @@
/*
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
*
* 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 top.charles7c.cnadmin.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import top.charles7c.cnadmin.system.model.entity.RoleDO;
/**
* 角色 Mapper
*
* @author Charles7c
* @since 2023/2/8 23:17
*/
public interface RoleMapper extends BaseMapper<RoleDO> {}

View File

@ -0,0 +1,85 @@
/*
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
*
* 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 top.charles7c.cnadmin.system.model.entity;
import java.util.List;
import lombok.Data;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import top.charles7c.cnadmin.common.base.BaseDO;
import top.charles7c.cnadmin.common.enums.DataScopeEnum;
import top.charles7c.cnadmin.common.enums.DisEnableStatusEnum;
/**
* 角色实体
*
* @author Charles7c
* @since 2023/2/8 22:54
*/
@Data
@TableName(value = "sys_role", autoResultMap = true)
public class RoleDO extends BaseDO {
private static final long serialVersionUID = 1L;
/**
* 角色 ID
*/
@TableId
private Long roleId;
/**
* 角色名称
*/
private String roleName;
/**
* 角色编码
*/
private String roleCode;
/**
* 数据权限1全部数据权限 2本部门及以下数据权限 3本部门数据权限 4仅本人数据权限 5自定数据权限
*/
private DataScopeEnum dataScope;
/**
* 数据权限范围部门 ID 数组
*/
@TableField(typeHandler = JacksonTypeHandler.class)
private List<Long> dataScopeDeptIds;
/**
* 描述
*/
private String description;
/**
* 角色排序
*/
private Integer roleSort;
/**
* 状态1启用 2禁用
*/
private DisEnableStatusEnum status;
}

View File

@ -0,0 +1,55 @@
/*
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
*
* 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 top.charles7c.cnadmin.system.model.query;
import java.io.Serializable;
import lombok.Data;
import io.swagger.v3.oas.annotations.media.Schema;
import org.springdoc.api.annotations.ParameterObject;
import top.charles7c.cnadmin.common.annotation.Query;
/**
* 角色查询条件
*
* @author Charles7c
* @since 2023/2/8 23:04
*/
@Data
@ParameterObject
@Schema(description = "角色查询条件")
public class RoleQuery implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 角色名称
*/
@Schema(description = "角色名称")
@Query(type = Query.Type.INNER_LIKE)
private String roleName;
/**
* 状态1启用 2禁用
*/
@Schema(description = "状态1启用 2禁用")
@Query
private Integer status;
}

View File

@ -0,0 +1,100 @@
/*
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
*
* 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 top.charles7c.cnadmin.system.model.request;
import java.util.List;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;
import lombok.Data;
import io.swagger.v3.oas.annotations.media.Schema;
import org.hibernate.validator.constraints.Length;
import top.charles7c.cnadmin.common.base.BaseRequest;
import top.charles7c.cnadmin.common.enums.DataScopeEnum;
import top.charles7c.cnadmin.common.enums.DisEnableStatusEnum;
/**
* 创建或修改角色信息
*
* @author Charles7c
* @since 2023/2/8 23:12
*/
@Data
@Schema(description = "创建或修改角色信息")
public class RoleRequest extends BaseRequest {
private static final long serialVersionUID = 1L;
/**
* 角色 ID
*/
@Schema(description = "角色 ID")
@Null(message = "新增时ID 必须为空", groups = Create.class)
@NotNull(message = "修改时ID 不能为空", groups = Update.class)
private Long roleId;
/**
* 角色名称
*/
@Schema(description = "角色名称")
@NotBlank(message = "角色名称不能为空")
private String roleName;
/**
* 角色编码
*/
@Schema(description = "角色编码")
private String roleCode;
/**
* 数据权限1全部数据权限 2本部门及以下数据权限 3本部门数据权限 4仅本人数据权限 5自定数据权限
*/
@Schema(description = "数据权限1全部数据权限 2本部门及以下数据权限 3本部门数据权限 4仅本人数据权限 5自定数据权限", type = "Integer",
allowableValues = {"1", "2", "3", "4", "5"})
private DataScopeEnum dataScope;
/**
* 数据权限范围部门 ID 数组
*/
@Schema(description = "数据权限范围(部门 ID 数组)")
private List<Long> dataScopeDeptIds;
/**
* 描述
*/
@Schema(description = "描述")
@Length(max = 200, message = "描述长度不能超过 200 个字符")
private String description;
/**
* 角色排序
*/
@Schema(description = "角色排序")
@NotNull(message = "角色排序不能为空")
private Integer roleSort;
/**
* 状态1启用 2禁用
*/
@Schema(description = "状态1启用 2禁用", type = "Integer", allowableValues = {"1", "2"})
private DisEnableStatusEnum status;
}

View File

@ -0,0 +1,100 @@
/*
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
*
* 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 top.charles7c.cnadmin.system.model.vo;
import java.util.List;
import lombok.Data;
import io.swagger.v3.oas.annotations.media.Schema;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import top.charles7c.cnadmin.common.base.BaseDetailVO;
import top.charles7c.cnadmin.common.config.easyexcel.ExcelBaseEnumConverter;
import top.charles7c.cnadmin.common.enums.DataScopeEnum;
import top.charles7c.cnadmin.common.enums.DisEnableStatusEnum;
/**
* 角色详情信息
*
* @author Charles7c
* @since 2023/2/1 22:19
*/
@Data
@ExcelIgnoreUnannotated
@Schema(description = "角色详情信息")
public class RoleDetailVO extends BaseDetailVO {
private static final long serialVersionUID = 1L;
/**
* 角色 ID
*/
@Schema(description = "角色 ID")
@ExcelProperty(value = "角色ID")
private Long roleId;
/**
* 角色名称
*/
@Schema(description = "角色名称")
@ExcelProperty(value = "角色名称")
private String roleName;
/**
* 角色编码
*/
@Schema(description = "角色编码")
@ExcelProperty(value = "角色编码")
private String roleCode;
/**
* 数据权限1全部数据权限 2本部门及以下数据权限 3本部门数据权限 4仅本人数据权限 5自定数据权限
*/
@Schema(description = "数据权限1全部数据权限 2本部门及以下数据权限 3本部门数据权限 4仅本人数据权限 5自定数据权限")
@ExcelProperty(value = "数据权限", converter = ExcelBaseEnumConverter.class)
private DataScopeEnum dataScope;
/**
* 数据权限范围部门 ID 数组
*/
@Schema(description = "数据权限范围(部门 ID 数组)")
private List<Long> dataScopeDeptIds;
/**
* 描述
*/
@Schema(description = "描述")
@ExcelProperty(value = "描述")
private String description;
/**
* 角色排序
*/
@Schema(description = "角色排序")
@ExcelProperty(value = "角色排序")
private Integer roleSort;
/**
* 状态1启用 2禁用
*/
@Schema(description = "状态1启用 2禁用")
@ExcelProperty(value = "状态", converter = ExcelBaseEnumConverter.class)
private DisEnableStatusEnum status;
}

View File

@ -0,0 +1,106 @@
/*
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
*
* 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 top.charles7c.cnadmin.system.model.vo;
import java.util.List;
import lombok.Data;
import lombok.experimental.Accessors;
import io.swagger.v3.oas.annotations.media.Schema;
import com.fasterxml.jackson.annotation.JsonInclude;
import top.charles7c.cnadmin.common.base.BaseVO;
import top.charles7c.cnadmin.common.consts.Constants;
import top.charles7c.cnadmin.common.enums.DataScopeEnum;
import top.charles7c.cnadmin.common.enums.DisEnableStatusEnum;
/**
* 角色信息
*
* @author Charles7c
* @since 2023/2/8 23:05
*/
@Data
@Accessors(chain = true)
@Schema(description = "角色信息")
public class RoleVO extends BaseVO {
private static final long serialVersionUID = 1L;
/**
* 角色 ID
*/
@Schema(description = "角色 ID")
private Long roleId;
/**
* 角色名称
*/
@Schema(description = "角色名称")
private String roleName;
/**
* 角色编码
*/
@Schema(description = "角色编码")
private String roleCode;
/**
* 数据权限1全部数据权限 2本部门及以下数据权限 3本部门数据权限 4仅本人数据权限 5自定数据权限
*/
@Schema(description = "数据权限1全部数据权限 2本部门及以下数据权限 3本部门数据权限 4仅本人数据权限 5自定数据权限")
private DataScopeEnum dataScope;
/**
* 数据权限范围部门 ID 数组
*/
@Schema(description = "数据权限范围(部门 ID 数组)")
private List<Long> dataScopeDeptIds;
/**
* 描述
*/
@Schema(description = "描述")
private String description;
/**
* 角色排序
*/
@Schema(description = "角色排序")
private Integer roleSort;
/**
* 状态1启用 2禁用
*/
@Schema(description = "状态1启用 2禁用")
private DisEnableStatusEnum status;
/**
* 是否禁用修改
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
private Boolean disabled;
public Boolean getDisabled() {
if (Constants.ADMIN_ROLE_CODE.equals(roleCode)) {
return true;
}
return disabled;
}
}

View File

@ -0,0 +1,31 @@
/*
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
*
* 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 top.charles7c.cnadmin.system.service;
import top.charles7c.cnadmin.common.base.BaseService;
import top.charles7c.cnadmin.system.model.query.RoleQuery;
import top.charles7c.cnadmin.system.model.request.RoleRequest;
import top.charles7c.cnadmin.system.model.vo.RoleDetailVO;
import top.charles7c.cnadmin.system.model.vo.RoleVO;
/**
* 角色业务接口
*
* @author Charles7c
* @since 2023/2/8 23:15
*/
public interface RoleService extends BaseService<RoleVO, RoleDetailVO, RoleQuery, RoleRequest> {}

View File

@ -0,0 +1,147 @@
/*
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
*
* 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 top.charles7c.cnadmin.system.service.impl;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import cn.hutool.core.bean.BeanUtil;
import top.charles7c.cnadmin.common.base.BaseDetailVO;
import top.charles7c.cnadmin.common.base.BaseServiceImpl;
import top.charles7c.cnadmin.common.base.BaseVO;
import top.charles7c.cnadmin.common.enums.DisEnableStatusEnum;
import top.charles7c.cnadmin.common.model.query.PageQuery;
import top.charles7c.cnadmin.common.model.vo.PageDataVO;
import top.charles7c.cnadmin.common.util.ExceptionUtils;
import top.charles7c.cnadmin.common.util.validate.CheckUtils;
import top.charles7c.cnadmin.system.mapper.RoleMapper;
import top.charles7c.cnadmin.system.model.entity.RoleDO;
import top.charles7c.cnadmin.system.model.query.RoleQuery;
import top.charles7c.cnadmin.system.model.request.RoleRequest;
import top.charles7c.cnadmin.system.model.vo.RoleDetailVO;
import top.charles7c.cnadmin.system.model.vo.RoleVO;
import top.charles7c.cnadmin.system.service.RoleService;
import top.charles7c.cnadmin.system.service.UserService;
/**
* 角色业务实现类
*
* @author Charles7c
* @since 2023/2/8 23:17
*/
@Service
@RequiredArgsConstructor
public class RoleServiceImpl extends BaseServiceImpl<RoleMapper, RoleDO, RoleVO, RoleDetailVO, RoleQuery, RoleRequest>
implements RoleService {
private final UserService userService;
@Override
public PageDataVO<RoleVO> page(RoleQuery query, PageQuery pageQuery) {
PageDataVO<RoleVO> pageDataVO = super.page(query, pageQuery);
pageDataVO.getList().forEach(this::fill);
return pageDataVO;
}
@Override
public RoleDetailVO get(Long id) {
RoleDetailVO roleDetailVO = super.get(id);
this.fillDetail(roleDetailVO);
return roleDetailVO;
}
@Override
@Transactional(rollbackFor = Exception.class)
public Long create(RoleRequest request) {
String roleName = request.getRoleName();
boolean isExist = this.checkNameExist(roleName, request.getRoleId());
CheckUtils.throwIf(() -> isExist, String.format("新增失败,'%s'已存在", roleName));
// 保存信息
RoleDO roleDO = BeanUtil.copyProperties(request, RoleDO.class);
roleDO.setStatus(DisEnableStatusEnum.ENABLE);
baseMapper.insert(roleDO);
return roleDO.getRoleId();
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(RoleRequest request) {
String roleName = request.getRoleName();
boolean isExist = this.checkNameExist(roleName, request.getRoleId());
CheckUtils.throwIf(() -> isExist, String.format("修改失败,'%s'已存在", roleName));
super.update(request);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(List<Long> ids) {
super.delete(ids);
}
/**
* 检查名称是否存在
*
* @param roleName
* 角色名称
* @param roleId
* 角色 ID
* @return 是否存在
*/
private boolean checkNameExist(String roleName, Long roleId) {
return baseMapper.exists(Wrappers.<RoleDO>lambdaQuery().eq(RoleDO::getRoleName, roleName).ne(roleId != null,
RoleDO::getRoleId, roleId));
}
/**
* 填充数据
*
* @param baseVO
* 待填充列表信息
*/
private void fill(BaseVO baseVO) {
Long createUser = baseVO.getCreateUser();
if (createUser == null) {
return;
}
baseVO.setCreateUserString(ExceptionUtils.exToNull(() -> userService.getById(createUser)).getNickname());
}
/**
* 填充详情数据
*
* @param detailVO
* 待填充详情信息
*/
private void fillDetail(BaseDetailVO detailVO) {
this.fill(detailVO);
Long updateUser = detailVO.getUpdateUser();
if (updateUser == null) {
return;
}
detailVO.setUpdateUserString(ExceptionUtils.exToNull(() -> userService.getById(updateUser)).getNickname());
}
}

View File

@ -0,0 +1,4 @@
<?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="top.charles7c.cnadmin.system.mapper.RoleMapper">
</mapper>

View File

@ -0,0 +1,58 @@
import axios from 'axios';
import qs from 'query-string';
const BASE_URL = '/system/role';
export interface RoleRecord {
roleId?: number;
roleName: string;
roleCode?: string;
dataScope: number;
dataScopeDeptIds?: string;
description?: string;
roleSort: number;
status?: number;
createUserString?: string;
createTime?: string;
updateUserString?: string;
updateTime?: string;
disabled?: boolean;
}
export interface RoleParam {
roleName?: string;
status?: number;
page: number;
size: number;
sort: Array<string>;
}
export interface RoleListRes {
list: RoleRecord[];
total: number;
}
export function listRole(params: RoleParam) {
return axios.get<RoleListRes>(`${BASE_URL}`, {
params,
paramsSerializer: (obj) => {
return qs.stringify(obj);
},
});
}
export function getRole(id: number) {
return axios.get<RoleRecord>(`${BASE_URL}/${id}`);
}
export function createRole(req: RoleRecord) {
return axios.post(BASE_URL, req);
}
export function updateRole(req: RoleRecord) {
return axios.put(BASE_URL, req);
}
export function deleteRole(ids: number | Array<number>) {
return axios.delete(`${BASE_URL}/${ids}`);
}

View File

@ -8,6 +8,7 @@ import localeMonitor from '@/views/dashboard/monitor/locale/en-US';
import localeDataAnalysis from '@/views/visualization/data-analysis/locale/en-US';
import localeMultiDAnalysis from '@/views/visualization/multi-dimension-data-analysis/locale/en-US';
import localeRole from '@/views/system/role/locale/en-US';
import localeDept from '@/views/system/dept/locale/en-US';
import localeOnlineUser from '@/views/monitor/online/locale/en-US';
@ -61,6 +62,7 @@ export default {
...localeDataAnalysis,
...localeMultiDAnalysis,
...localeRole,
...localeDept,
...localeOnlineUser,

View File

@ -8,6 +8,7 @@ import localeMonitor from '@/views/dashboard/monitor/locale/zh-CN';
import localeDataAnalysis from '@/views/visualization/data-analysis/locale/zh-CN';
import localeMultiDAnalysis from '@/views/visualization/multi-dimension-data-analysis/locale/zh-CN';
import localeRole from '@/views/system/role/locale/zh-CN';
import localeDept from '@/views/system/dept/locale/zh-CN';
import localeOnlineUser from '@/views/monitor/online/locale/zh-CN';
@ -61,6 +62,7 @@ export default {
...localeDataAnalysis,
...localeMultiDAnalysis,
...localeRole,
...localeDept,
...localeOnlineUser,

View File

@ -12,6 +12,16 @@ const System: AppRouteRecordRaw = {
order: 2,
},
children: [
{
path: '/system/role',
name: 'Role',
component: () => import('@/views/system/role/index.vue'),
meta: {
locale: 'menu.system.role.list',
requiresAuth: true,
roles: ['*'],
},
},
{
path: '/system/dept',
name: 'Dept',

View File

@ -0,0 +1,656 @@
<template>
<div class="app-container">
<Breadcrumb :items="['menu.system', 'menu.system.role.list']" />
<a-card class="general-card" :title="$t('menu.system.role.list')">
<!-- 头部区域 -->
<div class="header">
<!-- 搜索栏 -->
<div v-if="showQuery" class="header-query">
<a-form ref="queryRef" :model="queryParams" layout="inline">
<a-form-item field="roleName" hide-label>
<a-input
v-model="queryParams.roleName"
placeholder="输入角色名称搜索"
allow-clear
style="width: 150px"
@press-enter="handleQuery"
/>
</a-form-item>
<a-form-item field="status" hide-label>
<a-select
v-model="queryParams.status"
:options="statusOptions"
placeholder="状态搜索"
allow-clear
style="width: 150px"
/>
</a-form-item>
<a-form-item hide-label>
<a-space>
<a-button type="primary" @click="handleQuery">
<template #icon><icon-search /></template>查询
</a-button>
<a-button @click="resetQuery">
<template #icon><icon-refresh /></template>重置
</a-button>
</a-space>
</a-form-item>
</a-form>
</div>
<!-- 操作栏 -->
<div class="header-operation">
<a-row>
<a-col :span="12">
<a-space>
<a-button type="primary" @click="toCreate">
<template #icon><icon-plus /></template>新增
</a-button>
<a-button
type="primary"
status="success"
:disabled="single"
:title="single ? '请选择一条要修改的数据' : ''"
@click="toUpdate(ids[0])"
>
<template #icon><icon-edit /></template>修改
</a-button>
<a-button
type="primary"
status="danger"
:disabled="multiple"
:title="multiple ? '请选择要删除的数据' : ''"
@click="handleBatchDelete"
>
<template #icon><icon-delete /></template>删除
</a-button>
</a-space>
</a-col>
<a-col :span="12">
<right-toolbar
v-model:show-query="showQuery"
@refresh="getList"
/>
</a-col>
</a-row>
</div>
</div>
<!-- 列表区域 -->
<a-table
ref="tableRef"
:data="roleList"
:row-selection="{
type: 'checkbox',
showCheckedAll: true,
onlyCurrent: false,
}"
:pagination="{
showTotal: true,
showPageSize: true,
total: total,
current: queryParams.page,
}"
row-key="roleId"
:bordered="false"
:stripe="true"
:loading="loading"
size="large"
@page-change="handlePageChange"
@page-size-change="handlePageSizeChange"
@selection-change="handleSelectionChange"
>
<template #columns>
<a-table-column title="ID" data-index="roleId" />
<a-table-column title="角色名称" data-index="roleName">
<template #cell="{ record }">
<a-link @click="toDetail(record.roleId)">{{
record.roleName
}}</a-link>
</template>
</a-table-column>
<a-table-column title="角色编码" data-index="roleCode" />
<a-table-column title="数据权限">
<template #cell="{ record }">
<span v-if="record.dataScope === 1">全部数据权限</span>
<span v-else-if="record.dataScope === 2">本部门及以下数据权限</span>
<span v-else-if="record.dataScope === 3">本部门数据权限</span>
<span v-else-if="record.dataScope === 4">仅本人数据权限</span>
<span v-else>自定数据权限</span>
</template>
</a-table-column>
<a-table-column
title="角色排序"
align="center"
data-index="roleSort"
/>
<a-table-column title="状态" align="center" data-index="status">
<template #cell="{ record }">
<a-switch
v-model="record.status"
:checked-value="1"
:unchecked-value="2"
:disabled="record.disabled"
@change="handleChangeStatus(record)"
/>
</template>
</a-table-column>
<a-table-column title="描述" data-index="description" />
<a-table-column title="创建人" data-index="createUserString" />
<a-table-column title="创建时间" data-index="createTime" />
<a-table-column title="操作" align="center">
<template #cell="{ record }">
<a-button
v-permission="['admin']"
type="text"
size="small"
title="修改"
:disabled="record.disabled"
@click="toUpdate(record.roleId)"
>
<template #icon><icon-edit /></template>修改
</a-button>
<a-popconfirm
content="确定要删除当前选中的数据吗?"
type="warning"
@ok="handleDelete([record.roleId])"
>
<a-button
v-permission="['admin']"
type="text"
size="small"
title="删除"
:disabled="record.disabled"
>
<template #icon><icon-delete /></template>删除
</a-button>
</a-popconfirm>
</template>
</a-table-column>
</template>
</a-table>
<!-- 表单区域 -->
<a-modal
:title="title"
:visible="visible"
:width="570"
:mask-closable="false"
unmount-on-close
render-to-body
@ok="handleOk"
@cancel="handleCancel"
>
<a-form ref="formRef" :model="form" :rules="rules">
<a-form-item label="角色名称" field="roleName">
<a-input
v-model="form.roleName"
placeholder="请输入角色名称"
size="large"
/>
</a-form-item>
<a-form-item label="角色编码" field="roleCode">
<a-input
v-model="form.roleCode"
placeholder="请输入角色编码"
size="large"
/>
</a-form-item>
<a-form-item label="数据权限" field="dataScope">
<a-select
v-model="form.dataScope"
:options="dataScopeOptions"
placeholder="请选择数据权限"
size="large"
/>
</a-form-item>
<a-form-item
v-if="form.dataScope === 5"
label="数据范围"
field="dataScopeDeptIds"
>
<a-tree-select
v-model="form.dataScopeDeptIds"
:data="treeData"
placeholder="请选择数据范围"
allow-search
allow-clear
tree-checkable
tree-check-strictly
:filter-tree-node="filterDeptTree"
:fallback-option="false"
size="large"
/>
</a-form-item>
<a-form-item label="角色排序" field="roleSort">
<a-input-number
v-model="form.roleSort"
placeholder="请输入角色排序"
:min="1"
mode="button"
size="large"
/>
</a-form-item>
<a-form-item label="描述" field="description">
<a-textarea
v-model="form.description"
:max-length="200"
placeholder="请输入描述"
:auto-size="{
minRows: 3,
}"
show-word-limit
size="large"
/>
</a-form-item>
</a-form>
</a-modal>
<!-- 详情区域 -->
<a-drawer
title="部门详情"
:visible="detailVisible"
:width="570"
:footer="false"
unmount-on-close
render-to-body
@cancel="handleDetailCancel"
>
<a-descriptions title="基础信息" :column="2" bordered size="large">
<a-descriptions-item label="角色名称">
<a-skeleton v-if="detailLoading" :animation="true">
<a-skeleton-line :rows="1" />
</a-skeleton>
<span v-else>{{ role.roleName }}</span>
</a-descriptions-item>
<a-descriptions-item label="角色编码">
<a-skeleton v-if="detailLoading" :animation="true">
<a-skeleton-line :rows="1" />
</a-skeleton>
<span v-else>{{ role.roleCode }}</span>
</a-descriptions-item>
<a-descriptions-item label="状态">
<a-skeleton v-if="detailLoading" :animation="true">
<a-skeleton-line :rows="1" />
</a-skeleton>
<span v-else>
<a-tag v-if="role.status === 1" color="green">
<span class="circle pass"></span>启用
</a-tag>
<a-tag v-else color="red">
<span class="circle fail"></span>禁用
</a-tag>
</span>
</a-descriptions-item>
<a-descriptions-item label="数据权限">
<a-skeleton v-if="detailLoading" :animation="true">
<a-skeleton-line :rows="1" />
</a-skeleton>
<span v-else>
<span v-if="role.dataScope === 1">全部数据权限</span>
<span v-else-if="role.dataScope === 2">本部门及以下数据权限</span>
<span v-else-if="role.dataScope === 3">本部门数据权限</span>
<span v-else-if="role.dataScope === 4">仅本人数据权限</span>
<span v-else>自定数据权限</span>
</span>
</a-descriptions-item>
<a-descriptions-item label="创建人">
<a-skeleton v-if="detailLoading" :animation="true">
<a-skeleton-line :rows="1" />
</a-skeleton>
<span v-else>{{ role.createUserString }}</span>
</a-descriptions-item>
<a-descriptions-item label="创建时间">
<a-skeleton v-if="detailLoading" :animation="true">
<a-skeleton-line :rows="1" />
</a-skeleton>
<span v-else>{{ role.createTime }}</span>
</a-descriptions-item>
<a-descriptions-item label="修改人">
<a-skeleton v-if="detailLoading" :animation="true">
<a-skeleton-line :rows="1" />
</a-skeleton>
<span v-else>{{ role.updateUserString }}</span>
</a-descriptions-item>
<a-descriptions-item label="修改时间">
<a-skeleton v-if="detailLoading" :animation="true">
<a-skeleton-line :rows="1" />
</a-skeleton>
<span v-else>{{ role.updateTime }}</span>
</a-descriptions-item>
<a-descriptions-item label="描述">
<a-skeleton v-if="detailLoading" :animation="true">
<a-skeleton-line :rows="1" />
</a-skeleton>
<span v-else>{{ role.description }}</span>
</a-descriptions-item>
</a-descriptions>
<a-descriptions
v-if="role.dataScope === 5"
title="数据权限"
:column="2"
bordered
size="large"
style="margin-top: 25px"
>
<a-descriptions-item label="数据范围">
<a-tree-select
v-model="role.dataScopeDeptIds"
:data="treeData"
tree-checkable
disabled
/>
</a-descriptions-item>
</a-descriptions>
</a-drawer>
</a-card>
</div>
</template>
<script lang="ts" setup>
import { getCurrentInstance, ref, toRefs, reactive } from 'vue';
import { SelectOptionData, TreeNodeData } from '@arco-design/web-vue';
import {
RoleRecord,
RoleParam,
listRole,
getRole,
createRole,
updateRole,
deleteRole,
} from '@/api/system/role';
import listDeptTree from '@/api/common';
const { proxy } = getCurrentInstance() as any;
const roleList = ref<RoleRecord[]>([]);
const role = ref<RoleRecord>({
roleName: '',
roleCode: '',
dataScope: 1,
description: '',
roleSort: 0,
status: 1,
createUserString: '',
createTime: '',
updateUserString: '',
updateTime: '',
});
const total = ref(0);
const ids = ref<Array<number>>([]);
const title = ref('');
const single = ref(true);
const multiple = ref(true);
const showQuery = ref(true);
const loading = ref(false);
const detailLoading = ref(false);
const visible = ref(false);
const detailVisible = ref(false);
const statusOptions = ref<SelectOptionData[]>([
{ label: '启用', value: 1 },
{ label: '禁用', value: 2 },
]);
const dataScopeOptions = ref<SelectOptionData[]>([
{ label: '全部数据权限', value: 1 },
{ label: '本部门及以下数据权限', value: 2 },
{ label: '本部门数据权限', value: 3 },
{ label: '仅本人数据权限', value: 4 },
{ label: '自定数据权限', value: 5 },
]);
const treeData = ref<TreeNodeData[]>();
const data = reactive({
//
queryParams: {
roleName: undefined,
status: undefined,
page: 1,
size: 10,
sort: ['createTime,desc'],
},
//
form: {} as RoleRecord,
//
rules: {
roleName: [{ required: true, message: '请输入角色名称' }],
dataScope: [{ required: true, message: '请选择数据权限' }],
dataScopeDeptIds: [{ required: true, message: '请选择数据范围' }],
roleSort: [{ required: true, message: '请输入角色排序' }],
},
});
const { queryParams, form, rules } = toRefs(data);
/**
* 查询列表
*
* @param params 查询参数
*/
const getList = (params: RoleParam = { ...queryParams.value }) => {
loading.value = true;
listRole(params)
.then((res) => {
roleList.value = res.data.list;
total.value = res.data.total;
})
.finally(() => {
loading.value = false;
});
};
getList();
/**
* 打开新增对话框
*/
const toCreate = () => {
reset();
listDeptTree({ status: 1 }).then((res) => {
treeData.value = res.data;
});
title.value = '新增角色';
visible.value = true;
};
/**
* 打开修改对话框
*
* @param id ID
*/
const toUpdate = (id: number) => {
reset();
listDeptTree({}).then((res) => {
treeData.value = res.data;
});
getRole(id).then((res) => {
form.value = res.data;
title.value = '修改角色';
visible.value = true;
});
};
/**
* 重置表单
*/
const reset = () => {
form.value = {
roleId: undefined,
roleName: '',
roleCode: undefined,
dataScope: 4,
dataScopeDeptIds: undefined,
description: '',
roleSort: 999,
};
proxy.$refs.formRef?.resetFields();
};
/**
* 取消
*/
const handleCancel = () => {
visible.value = false;
proxy.$refs.formRef.resetFields();
};
/**
* 确定
*/
const handleOk = () => {
proxy.$refs.formRef.validate((valid: any) => {
if (!valid) {
if (form.value.roleId !== undefined) {
updateRole(form.value).then((res) => {
handleCancel();
getList();
proxy.$message.success(res.msg);
});
} else {
createRole(form.value).then((res) => {
handleCancel();
getList();
proxy.$message.success(res.msg);
});
}
}
});
};
/**
* 查看详情
*
* @param id ID
*/
const toDetail = async (id: number) => {
if (detailLoading.value) return;
detailLoading.value = true;
detailVisible.value = true;
getRole(id)
.then((res) => {
role.value = res.data;
})
.finally(() => {
detailLoading.value = false;
});
};
/**
* 关闭详情
*/
const handleDetailCancel = () => {
detailVisible.value = false;
};
/**
* 批量删除
*/
const handleBatchDelete = () => {
if (ids.value.length === 0) {
proxy.$message.info('请选择要删除的数据');
} else {
proxy.$modal.warning({
title: '警告',
titleAlign: 'start',
content: '确定要删除当前选中的数据吗?',
hideCancel: false,
onOk: () => {
handleDelete(ids.value);
},
});
}
};
/**
* 删除
*
* @param ids ID 列表
*/
const handleDelete = (ids: Array<number>) => {
deleteRole(ids).then((res) => {
proxy.$message.success(res.msg);
getList();
});
};
/**
* 多选
*
* @param rowKeys ID 列表
*/
const handleSelectionChange = (rowKeys: Array<any>) => {
ids.value = rowKeys;
single.value = rowKeys.length !== 1;
multiple.value = !rowKeys.length;
};
/**
* 修改状态
*
* @param record 记录信息
*/
const handleChangeStatus = (record: RoleRecord) => {
const tip = record.status === 1 ? '启用' : '禁用';
updateRole(record)
.then(() => {
proxy.$message.success(`${tip}成功`);
})
.catch(() => {
record.status = record.status === 1 ? 2 : 1;
});
};
/**
* 过滤部门树
*
* @param searchValue 搜索值
* @param nodeData 节点值
*/
const filterDeptTree = (searchValue: string, nodeData: TreeNodeData) => {
if (nodeData.title) {
return (
nodeData.title.toLowerCase().indexOf(searchValue.toLowerCase()) > -1
);
}
return false;
};
/**
* 查询
*/
const handleQuery = () => {
getList();
};
/**
* 重置
*/
const resetQuery = () => {
proxy.$refs.queryRef.resetFields();
handleQuery();
};
/**
* 切换页码
*
* @param current 页码
*/
const handlePageChange = (current: number) => {
queryParams.value.page = current;
getList();
};
/**
* 切换每页条数
*
* @param pageSize 每页条数
*/
const handlePageSizeChange = (pageSize: number) => {
queryParams.value.size = pageSize;
getList();
};
</script>
<script lang="ts">
export default {
name: 'Role',
};
</script>
<style scoped lang="less"></style>

View File

@ -0,0 +1,3 @@
export default {
'menu.system.role.list': 'Role management',
};

View File

@ -0,0 +1,3 @@
export default {
'menu.system.role.list': '角色管理',
};

View File

@ -0,0 +1,42 @@
/*
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
*
* 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 top.charles7c.cnadmin.webapi.controller.system;
import static top.charles7c.cnadmin.common.annotation.CrudRequestMapping.Api;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.RestController;
import top.charles7c.cnadmin.common.annotation.CrudRequestMapping;
import top.charles7c.cnadmin.common.base.BaseController;
import top.charles7c.cnadmin.system.model.query.RoleQuery;
import top.charles7c.cnadmin.system.model.request.RoleRequest;
import top.charles7c.cnadmin.system.model.vo.RoleDetailVO;
import top.charles7c.cnadmin.system.model.vo.RoleVO;
import top.charles7c.cnadmin.system.service.RoleService;
/**
* 角色管理 API
*
* @author Charles7c
* @since 2023/2/8 23:11
*/
@Tag(name = "角色管理 API")
@RestController
@CrudRequestMapping(value = "/system/role", api = {Api.PAGE, Api.GET, Api.CREATE, Api.UPDATE, Api.DELETE})
public class RoleController extends BaseController<RoleService, RoleVO, RoleDetailVO, RoleQuery, RoleRequest> {}

View File

@ -2,15 +2,23 @@
-- changeset Charles7c:1
-- 初始化默认部门
INSERT IGNORE INTO `sys_dept` VALUES (1, 'Xxx科技有限公司', 0, 1, NULL, 1, 1, NOW(), 1, NOW());
INSERT IGNORE INTO `sys_dept` VALUES (2, '天津总部', 1, 1, NULL, 1, 1, NOW(), 1, NOW());
INSERT IGNORE INTO `sys_dept` VALUES (3, '研发部', 2, 1, NULL, 1, 1, NOW(), 1, NOW());
INSERT IGNORE INTO `sys_dept` VALUES (4, 'UI部', 2, 2, NULL, 1, 1, NOW(), 1, NOW());
INSERT IGNORE INTO `sys_dept` VALUES (5, '测试部', 2, 3, NULL, 1, 1, NOW(), 1, NOW());
INSERT IGNORE INTO `sys_dept` VALUES (6, '运维部', 2, 4, NULL, 1, 1, NOW(), 1, NOW());
INSERT IGNORE INTO `sys_dept` VALUES (7, '研发一组', 3, 1, NULL, 1, 1, NOW(), 1, NOW());
INSERT IGNORE INTO `sys_dept` VALUES (8, '研发二组', 3, 2, NULL, 2, 1, NOW(), 1, NOW());
INSERT IGNORE INTO `sys_dept` VALUES (1, 'Xxx科技有限公司', 0, '系统初始部门', 1, 1, 1, NOW(), 1, NOW());
INSERT IGNORE INTO `sys_dept` VALUES (2, '天津总部', 1, '系统初始部门', 1, 1, 1, NOW(), 1, NOW());
INSERT IGNORE INTO `sys_dept` VALUES (3, '研发部', 2, '系统初始部门', 1, 1, 1, NOW(), 1, NOW());
INSERT IGNORE INTO `sys_dept` VALUES (4, 'UI部', 2, '系统初始部门', 2, 1, 1, NOW(), 1, NOW());
INSERT IGNORE INTO `sys_dept` VALUES (5, '测试部', 2, '系统初始部门', 3, 1, 1, NOW(), 1, NOW());
INSERT IGNORE INTO `sys_dept` VALUES (6, '运维部', 2, '系统初始部门', 4, 1, 1, NOW(), 1, NOW());
INSERT IGNORE INTO `sys_dept` VALUES (7, '研发一组', 3, '系统初始部门', 1, 1, 1, NOW(), 1, NOW());
INSERT IGNORE INTO `sys_dept` VALUES (8, '研发二组', 3, '系统初始部门', 2, 2, 1, NOW(), 1, NOW());
-- 初始化默认用户admin/admin123test/123456
INSERT IGNORE INTO `sys_user` VALUES (1, 'admin', '超级管理员', '9802815bcc5baae7feb1ae0d0566baf2', 1, '18888888888', 'charles7c@126.com', NULL, NULL, 1, NOW(), 1, 1, NOW(), 1, NOW());
INSERT IGNORE INTO `sys_user` VALUES (2, 'test', '测试员', '8e114197e1b33783a00542ad67e80516', 0, NULL, NULL, NULL, NULL, 2, NOW(), 2, 1, NOW(), 1, NOW());
INSERT IGNORE INTO `sys_user` VALUES (1, 'admin', '超级管理员', '9802815bcc5baae7feb1ae0d0566baf2', 1, '18888888888', 'charles7c@126.com', NULL, '系统初始用户', 1, NOW(), 1, 1, NOW(), 1, NOW());
INSERT IGNORE INTO `sys_user` VALUES (2, 'test', '测试员', '8e114197e1b33783a00542ad67e80516', 0, NULL, NULL, NULL, '系统初始用户', 2, NOW(), 2, 1, NOW(), 1, NOW());
-- 初始化默认角色
INSERT IGNORE INTO `sys_role` VALUES (1, '超级管理员', 'admin', 1, NULL, '系统初始角色', 1, 1, 1, NOW(), 1, NOW());
INSERT IGNORE INTO `sys_role` VALUES (2, '测试人员', 'test', 4, NULL, '系统初始角色', 2, 2, 1, NOW(), 1, NOW());
-- 初始化默认用户和角色关联数据
INSERT IGNORE INTO `sys_user_role` VALUES (1, 1);
INSERT IGNORE INTO `sys_user_role` VALUES (2, 2);

View File

@ -5,8 +5,8 @@ CREATE TABLE IF NOT EXISTS `sys_dept` (
`dept_id` bigint(20) unsigned AUTO_INCREMENT COMMENT '部门ID',
`dept_name` varchar(255) NOT NULL COMMENT '部门名称',
`parent_id` bigint(20) unsigned DEFAULT 0 COMMENT '上级部门ID',
`dept_sort` int(11) unsigned DEFAULT 999 COMMENT '部门排序',
`description` varchar(512) DEFAULT NULL COMMENT '描述',
`dept_sort` int(11) unsigned DEFAULT 999 COMMENT '部门排序',
`status` tinyint(1) unsigned DEFAULT 1 COMMENT '状态1启用 2禁用',
`create_user` bigint(20) unsigned NOT NULL COMMENT '创建人',
`create_time` datetime NOT NULL COMMENT '创建时间',
@ -38,11 +38,35 @@ CREATE TABLE IF NOT EXISTS `sys_user` (
PRIMARY KEY (`user_id`) USING BTREE,
UNIQUE INDEX `uk_username`(`username`) USING BTREE,
UNIQUE INDEX `uk_email`(`email`) USING BTREE,
INDEX `idx_create_user`(`create_user`) USING BTREE,
INDEX `idx_dept_id`(`dept_id`) USING BTREE,
INDEX `idx_create_user`(`create_user`) USING BTREE,
INDEX `idx_update_user`(`update_user`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户表';
CREATE TABLE IF NOT EXISTS `sys_role` (
`role_id` bigint(20) unsigned AUTO_INCREMENT COMMENT '角色ID',
`role_name` varchar(255) NOT NULL COMMENT '角色名称',
`role_code` varchar(255) DEFAULT NULL COMMENT '角色编码',
`data_scope` tinyint(1) DEFAULT 4 COMMENT '数据权限1全部数据权限 2本部门及以下数据权限 3本部门数据权限 4仅本人数据权限 5自定数据权限',
`data_scope_dept_ids` json DEFAULT NULL COMMENT '数据权限范围部门ID数组',
`description` varchar(512) DEFAULT NULL COMMENT '描述',
`role_sort` int(11) unsigned DEFAULT 999 COMMENT '角色排序',
`status` tinyint(1) unsigned DEFAULT 1 COMMENT '状态1启用 2禁用',
`create_user` bigint(20) unsigned NOT NULL COMMENT '创建人',
`create_time` datetime NOT NULL COMMENT '创建时间',
`update_user` bigint(20) unsigned NOT NULL COMMENT '修改人',
`update_time` datetime NOT NULL COMMENT '修改时间',
PRIMARY KEY (`role_id`) USING BTREE,
INDEX `idx_create_user`(`create_user`) USING BTREE,
INDEX `idx_update_user`(`update_user`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='角色表';
CREATE TABLE IF NOT EXISTS `sys_user_role` (
`user_id` bigint(20) unsigned NOT NULL COMMENT '用户ID',
`role_id` bigint(20) unsigned NOT NULL COMMENT '角色ID',
PRIMARY KEY (`user_id`,`role_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户和角色关联表';
CREATE TABLE IF NOT EXISTS `sys_log` (
`log_id` bigint(20) unsigned AUTO_INCREMENT COMMENT '日志ID',
`description` varchar(255) NOT NULL COMMENT '日志描述',