mirror of
https://github.com/FatttSnake/Pinnacle-OA.git
synced 2026-04-04 22:41:24 +08:00
Added enable status to Role, Group and User
This commit is contained in:
@@ -45,6 +45,12 @@ public class Group implements Serializable {
|
||||
@TableField("name")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 启用
|
||||
*/
|
||||
@TableField("enable")
|
||||
private Integer enable;
|
||||
|
||||
@TableField("deleted")
|
||||
@TableLogic
|
||||
private Long deleted;
|
||||
|
||||
@@ -49,6 +49,12 @@ public class Role implements Serializable {
|
||||
@TableField("name")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 启用
|
||||
*/
|
||||
@TableField("enable")
|
||||
private Integer enable;
|
||||
|
||||
@TableField(exist = false)
|
||||
private List<Menu> menus;
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ public class ResponseCode {
|
||||
|
||||
public static final int UNAUTHORIZED = 30010;
|
||||
public static final int ACCESS_DENIED = 30030;
|
||||
public static final int USER_DISABLE = 30031;
|
||||
|
||||
public static final int SYSTEM_ERROR = 50001;
|
||||
public static final int SYSTEM_TIMEOUT = 50002;
|
||||
|
||||
@@ -6,6 +6,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.dao.DuplicateKeyException;
|
||||
import org.springframework.security.access.AccessDeniedException;
|
||||
import org.springframework.security.authentication.BadCredentialsException;
|
||||
import org.springframework.security.authentication.DisabledException;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
|
||||
@@ -14,7 +15,7 @@ import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
public class CustomExceptionHandler {
|
||||
|
||||
@ExceptionHandler(value = Exception.class)
|
||||
public ResponseResult exceptionHandler(Exception e) {
|
||||
public ResponseResult<?> exceptionHandler(Exception e) {
|
||||
if (e instanceof DuplicateKeyException) {
|
||||
return ResponseResult.build(ResponseCode.DATABASE_SAVE_ERROR, "无法添加重复数据", null);
|
||||
}
|
||||
@@ -24,6 +25,9 @@ public class CustomExceptionHandler {
|
||||
if (e instanceof AccessDeniedException) {
|
||||
return ResponseResult.build(ResponseCode.ACCESS_DENIED, e.getMessage(), null);
|
||||
}
|
||||
if (e instanceof DisabledException) {
|
||||
return ResponseResult.build(ResponseCode.USER_DISABLE, e.getMessage(), null);
|
||||
}
|
||||
|
||||
log.debug(e.getMessage(), e);
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
<select id="getAll" resultMap="groupMap">
|
||||
select t_group.id as group_id,
|
||||
t_group.name as group_name,
|
||||
t_group.enable as group_enable,
|
||||
t_group.deleted as group_deleted,
|
||||
t_group.version as group_version,
|
||||
tr.id as role_id,
|
||||
@@ -20,6 +21,7 @@
|
||||
<select id="getOneById" resultMap="groupMap">
|
||||
select t_group.id as group_id,
|
||||
t_group.name as group_name,
|
||||
t_group.enable as group_enable,
|
||||
t_group.deleted as group_deleted,
|
||||
t_group.version as group_version,
|
||||
tr.id as role_id,
|
||||
@@ -38,6 +40,7 @@
|
||||
<resultMap id="groupMap" type="group">
|
||||
<id property="id" column="group_id"/>
|
||||
<result property="name" column="group_name"/>
|
||||
<result property="enable" column="group_enable"/>
|
||||
<result property="deleted" column="group_deleted"/>
|
||||
<result property="version" column="group_version"/>
|
||||
<collection property="roles" ofType="role">
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
<select id="getAll" resultMap="roleMap">
|
||||
select t_role.id as role_id,
|
||||
t_role.name as role_name,
|
||||
t_role.enable as role_enable,
|
||||
t_role.deleted as role_deleted,
|
||||
t_role.version as role_version,
|
||||
tm.id as menu_id,
|
||||
@@ -33,6 +34,7 @@
|
||||
<select id="getOneById" resultMap="roleMap">
|
||||
select t_role.id as role_id,
|
||||
t_role.name as role_name,
|
||||
t_role.enable as role_enable,
|
||||
t_role.deleted as role_deleted,
|
||||
t_role.version as role_version,
|
||||
tm.id as menu_id,
|
||||
@@ -63,6 +65,7 @@
|
||||
<resultMap id="roleMap" type="role">
|
||||
<id property="id" column="role_id"/>
|
||||
<result property="name" column="role_name"/>
|
||||
<result property="enable" column="role_enable"/>
|
||||
<result property="deleted" column="role_deleted"/>
|
||||
<result property="version" column="role_version"/>
|
||||
<collection property="menus" ofType="menu">
|
||||
|
||||
@@ -15,11 +15,13 @@
|
||||
ts.deleted as staff_deleted,
|
||||
ts.version as staff_version,
|
||||
tr.id as role_id,
|
||||
tr.enable as role_enable,
|
||||
tr.name as role_name,
|
||||
tr.deleted as role_deleted,
|
||||
tr.version as role_version,
|
||||
tg.id as group_id,
|
||||
tg.name as group_name,
|
||||
tg.enable as group_enable,
|
||||
tg.deleted as group_deleted,
|
||||
tg.version as group_version
|
||||
from t_user
|
||||
@@ -44,10 +46,12 @@
|
||||
ts.version as staff_version,
|
||||
tr.id as role_id,
|
||||
tr.name as role_name,
|
||||
tr.enable as role_enable,
|
||||
tr.deleted as role_deleted,
|
||||
tr.version as role_version,
|
||||
tg.id as group_id,
|
||||
tg.name as group_name,
|
||||
tg.enable as group_enable,
|
||||
tg.deleted as group_deleted,
|
||||
tg.version as group_version
|
||||
from t_user
|
||||
@@ -90,10 +94,10 @@
|
||||
from t_user
|
||||
left join (select * from t_staff where deleted = 0) as ts on ts.user_id = t_user.id
|
||||
left join (select * from t_user_group where deleted = 0) as tug on t_user.id = tug.user_id
|
||||
left join (select * from t_group where deleted = 0) as tg on tg.id = tug.group_id
|
||||
left join (select * from t_group where deleted = 0 and enable = 1) as tg on tg.id = tug.group_id
|
||||
left join (select * from t_role_group where deleted = 0) as trg on tg.id = trg.group_id
|
||||
left join (select * from t_user_role where deleted = 0) as tur on t_user.id = tur.user_id
|
||||
left join (select * from t_role where deleted = 0) as tr on tr.id = trg.role_id or tr.id = tur.role_id
|
||||
left join (select * from t_role where deleted = 0 and enable = 1) as tr on tr.id = trg.role_id or tr.id = tur.role_id
|
||||
left join (select * from t_power_role where deleted = 0) as tpr on tpr.role_id = tr.id
|
||||
left join t_power as tp on tp.id = tpr.power_id
|
||||
left join t_menu tm on tp.id = tm.power_id
|
||||
@@ -120,12 +124,14 @@
|
||||
<collection property="roles" ofType="role">
|
||||
<id property="id" column="role_id"/>
|
||||
<result property="name" column="role_name"/>
|
||||
<result property="enable" column="role_enable"/>
|
||||
<result property="deleted" column="role_deleted"/>
|
||||
<result property="version" column="role_version"/>
|
||||
</collection>
|
||||
<collection property="groups" ofType="group">
|
||||
<id property="id" column="group_id"/>
|
||||
<result property="name" column="group_name"/>
|
||||
<result property="enable" column="group_enable"/>
|
||||
<result property="deleted" column="group_deleted"/>
|
||||
<result property="version" column="group_version"/>
|
||||
</collection>
|
||||
|
||||
@@ -105,6 +105,7 @@ create table `t_group`
|
||||
(
|
||||
`id` bigint not null primary key,
|
||||
`name` varchar(30) not null comment '用户组名',
|
||||
`enable` int not null comment '启用',
|
||||
`deleted` bigint not null default 0,
|
||||
`version` int not null default 0,
|
||||
constraint t_group_unique unique (name, deleted)
|
||||
@@ -125,6 +126,7 @@ create table `t_role`
|
||||
(
|
||||
`id` bigint not null primary key,
|
||||
`name` varchar(20) not null comment '角色名',
|
||||
`enable` int not null comment '启用',
|
||||
`deleted` bigint not null default 0,
|
||||
`version` int not null default 0,
|
||||
constraint t_role_unique unique (name, deleted)
|
||||
|
||||
@@ -31,6 +31,12 @@
|
||||
}}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="状态" align="center">
|
||||
<template #default="scope">
|
||||
<el-tag type="success" v-if="scope.row.enable">启用</el-tag>
|
||||
<el-tag type="info" v-else>禁用</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="150" align="center">
|
||||
<template #default="scope">
|
||||
<el-button size="small" @click="$emit('onEdit', scope.$index, scope.row)"
|
||||
|
||||
@@ -31,6 +31,7 @@ const DATABASE_CONNECT_ERROR = 20036
|
||||
|
||||
const UNAUTHORIZED = 30010
|
||||
const ACCESS_DENIED = 30030
|
||||
const USER_DISABLE = 30031
|
||||
|
||||
const SYSTEM_ERROR = 50001
|
||||
const SYSTEM_TIMEOUT = 50002
|
||||
@@ -66,6 +67,7 @@ export {
|
||||
DATABASE_CONNECT_ERROR,
|
||||
UNAUTHORIZED,
|
||||
ACCESS_DENIED,
|
||||
USER_DISABLE,
|
||||
SYSTEM_ERROR,
|
||||
SYSTEM_TIMEOUT
|
||||
}
|
||||
|
||||
@@ -84,7 +84,12 @@
|
||||
import { getCaptchaSrc, login, verifyCaptcha } from '@/utils/auth'
|
||||
import backShape from '@/assets/svg/back-shape.svg'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { LOGIN_SUCCESS, LOGOUT_FAILED, PRODUCTION_NAME } from '@/constants/Common.constants'
|
||||
import {
|
||||
LOGIN_SUCCESS,
|
||||
LOGOUT_FAILED,
|
||||
PRODUCTION_NAME,
|
||||
USER_DISABLE
|
||||
} from '@/constants/Common.constants'
|
||||
import { setToken } from '@/utils/common'
|
||||
|
||||
export default {
|
||||
@@ -169,6 +174,13 @@ export default {
|
||||
})
|
||||
this.resetLogin()
|
||||
break
|
||||
case USER_DISABLE:
|
||||
ElMessage.error({
|
||||
dangerouslyUseHTMLString: true,
|
||||
message: '<strong>该用户已被禁用</strong>,请联系管理员'
|
||||
})
|
||||
this.resetLogin()
|
||||
break
|
||||
default:
|
||||
ElMessage.error({
|
||||
dangerouslyUseHTMLString: true,
|
||||
|
||||
@@ -49,6 +49,16 @@
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="状态">
|
||||
<el-switch
|
||||
v-model="groupForm.enable"
|
||||
inline-prompt
|
||||
active-text="启用"
|
||||
:active-value="1"
|
||||
inactive-text="禁用"
|
||||
:inactive-value="0"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</template>
|
||||
<template #footer>
|
||||
@@ -81,7 +91,8 @@ export default {
|
||||
roles: [],
|
||||
groupForm: {
|
||||
inputGroupName: '',
|
||||
selectedRoles: []
|
||||
selectedRoles: [],
|
||||
enable: 0
|
||||
},
|
||||
isAddNew: true,
|
||||
dialogTitle: '',
|
||||
@@ -130,6 +141,7 @@ export default {
|
||||
if (this.isAddNew) {
|
||||
this.groupForm.inputGroupName = ''
|
||||
this.groupForm.selectedRoles = []
|
||||
this.groupForm.enable = 0
|
||||
this.dialogTitle = '添加用户组'
|
||||
} else {
|
||||
this.dialogTitle = '编辑用户组'
|
||||
@@ -157,6 +169,7 @@ export default {
|
||||
for (const role of row.roles) {
|
||||
this.groupForm.selectedRoles.push(role.id)
|
||||
}
|
||||
this.groupForm.enable = row.enable
|
||||
this.isAddNew = false
|
||||
this.dialogVisible = true
|
||||
},
|
||||
@@ -193,7 +206,8 @@ export default {
|
||||
const groupObject = {
|
||||
id: '',
|
||||
name: this.groupForm.inputGroupName,
|
||||
roles: []
|
||||
roles: [],
|
||||
enable: this.groupForm.enable
|
||||
}
|
||||
for (const roleId of this.groupForm.selectedRoles) {
|
||||
const role = {
|
||||
|
||||
@@ -51,6 +51,16 @@
|
||||
@check-change="handleSelectedPowerChange"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="状态">
|
||||
<el-switch
|
||||
v-model="roleForm.enable"
|
||||
inline-prompt
|
||||
active-text="启用"
|
||||
:active-value="1"
|
||||
inactive-text="禁用"
|
||||
:inactive-value="0"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</template>
|
||||
<template #footer>
|
||||
@@ -88,7 +98,8 @@ export default {
|
||||
},
|
||||
roleForm: {
|
||||
inputRoleName: '',
|
||||
selectedPower: new Set()
|
||||
selectedPower: new Set(),
|
||||
enable: 0
|
||||
},
|
||||
isAddNew: true,
|
||||
defaultSelectedPower: [],
|
||||
@@ -156,6 +167,7 @@ export default {
|
||||
this.defaultSelectedPower = []
|
||||
this.roleForm.inputRoleName = ''
|
||||
this.roleForm.selectedPower.clear()
|
||||
this.roleForm.enable = 0
|
||||
this.dialogTitle = '添加角色'
|
||||
} else {
|
||||
this.dialogTitle = '编辑角色'
|
||||
@@ -209,6 +221,7 @@ export default {
|
||||
this.roleForm.inputRoleName = row.name
|
||||
this.editRoleId = row.id
|
||||
this.roleForm.selectedPower.clear()
|
||||
this.roleForm.enable = row.enable
|
||||
this.defaultSelectedPower = []
|
||||
for (const operation of row.operations) {
|
||||
this.defaultSelectedPower.push(operation.powerId)
|
||||
@@ -256,7 +269,8 @@ export default {
|
||||
const roleObject = {
|
||||
id: '',
|
||||
name: this.roleForm.inputRoleName,
|
||||
powers: []
|
||||
powers: [],
|
||||
enable: this.roleForm.enable
|
||||
}
|
||||
for (const powerId of this.roleForm.selectedPower) {
|
||||
const power = {
|
||||
|
||||
@@ -82,6 +82,16 @@
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="状态">
|
||||
<el-switch
|
||||
v-model="userForm.enable"
|
||||
inline-prompt
|
||||
active-text="启用"
|
||||
:active-value="1"
|
||||
inactive-text="禁用"
|
||||
:inactive-value="0"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</template>
|
||||
<template #footer>
|
||||
@@ -124,7 +134,8 @@ export default {
|
||||
inputUsername: '',
|
||||
inputPassword: '',
|
||||
selectedRoles: [],
|
||||
selectedGroups: []
|
||||
selectedGroups: [],
|
||||
enable: 0
|
||||
},
|
||||
isAddNew: true,
|
||||
dialogTitle: '',
|
||||
@@ -230,6 +241,7 @@ export default {
|
||||
this.userForm.selectedGroups.push(group.id)
|
||||
}
|
||||
}
|
||||
this.userForm.enable = row.enable
|
||||
this.isAddNew = false
|
||||
this.dialogVisible = true
|
||||
},
|
||||
@@ -270,6 +282,7 @@ export default {
|
||||
this.userForm.inputPassword = ''
|
||||
this.userForm.selectedRoles = []
|
||||
this.userForm.selectedGroups = []
|
||||
this.userForm.enable = 0
|
||||
this.dialogTitle = '添加用户'
|
||||
} else {
|
||||
this.dialogTitle = '编辑用户'
|
||||
@@ -288,7 +301,8 @@ export default {
|
||||
username: this.userForm.inputUsername,
|
||||
passwd: this.userForm.inputPassword,
|
||||
roles: [],
|
||||
groups: []
|
||||
groups: [],
|
||||
enable: this.userForm.enable
|
||||
}
|
||||
if (this.editUserId !== '1') {
|
||||
for (const roleId of this.userForm.selectedRoles) {
|
||||
|
||||
Reference in New Issue
Block a user