From 4f8bc6c04602c917ae74149af766344a3e9ed054 Mon Sep 17 00:00:00 2001 From: lijiahang Date: Wed, 16 Aug 2023 10:38:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=94=A8=E6=88=B7=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/PermissionController.java | 5 +- orion-ops-ui/src/api/system/menu.ts | 7 + orion-ops-ui/src/api/user/user.ts | 117 +++++++++ .../system/menu/components/menu-table.vue | 33 ++- .../user/user/components/user-form-modal.vue | 171 +++++++++++++ .../views/user/user/components/user-table.vue | 229 ++++++++++++++++++ orion-ops-ui/src/views/user/user/index.vue | 32 +++ .../src/views/user/user/types/enum.types.ts | 27 +++ .../src/views/user/user/types/form.rules.ts | 70 ++++++ .../views/user/user/types/table.columns.ts | 98 ++++++++ 10 files changed, 783 insertions(+), 6 deletions(-) create mode 100644 orion-ops-ui/src/api/user/user.ts create mode 100644 orion-ops-ui/src/views/user/user/components/user-form-modal.vue create mode 100644 orion-ops-ui/src/views/user/user/components/user-table.vue create mode 100644 orion-ops-ui/src/views/user/user/index.vue create mode 100644 orion-ops-ui/src/views/user/user/types/enum.types.ts create mode 100644 orion-ops-ui/src/views/user/user/types/form.rules.ts create mode 100644 orion-ops-ui/src/views/user/user/types/table.columns.ts diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/controller/PermissionController.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/controller/PermissionController.java index 4fc51375..fb781bad 100644 --- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/controller/PermissionController.java +++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/controller/PermissionController.java @@ -13,6 +13,7 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -38,9 +39,9 @@ public class PermissionController { @Resource private PermissionService permissionService; - @GetMapping("/init-cache") + @PutMapping("/init-cache") @Operation(summary = "初始化角色权限缓存") - @PreAuthorize("@ss.hasPermission('infra:system:init-permission-cache')") + @PreAuthorize("@ss.hasPermission('infra:system-menu:init-cache')") public HttpWrapper initCache() { permissionService.initPermissionCache(); return HttpWrapper.ok(); diff --git a/orion-ops-ui/src/api/system/menu.ts b/orion-ops-ui/src/api/system/menu.ts index 61e34740..365986a8 100644 --- a/orion-ops-ui/src/api/system/menu.ts +++ b/orion-ops-ui/src/api/system/menu.ts @@ -85,3 +85,10 @@ export function updateMenuStatus(request: MenuUpdateRequest) { export function deleteMenu(id: number) { return axios.delete('/infra/system-menu/delete', { params: { id } }); } + +/** + * 初始化缓存 + */ +export function initCache() { + return axios.put('/infra/permission/init-cache'); +} diff --git a/orion-ops-ui/src/api/user/user.ts b/orion-ops-ui/src/api/user/user.ts new file mode 100644 index 00000000..115f233d --- /dev/null +++ b/orion-ops-ui/src/api/user/user.ts @@ -0,0 +1,117 @@ +import axios from 'axios'; +import qs from 'query-string'; +import { DataGrid, Pagination } from '@/types/global'; + +/** + * 用户创建请求 + */ +export interface UserCreateRequest { + username?: string; + password?: string; + nickname?: string; + avatar?: string; + mobile?: string; + email?: string; + status?: number; + lastLoginTime?: string; +} + +/** + * 用户更新请求 + */ +export interface UserUpdateRequest extends UserCreateRequest { + id: number; +} + +/** + * 用户查询请求 + */ +export interface UserQueryRequest extends Pagination { + id?: number; + username?: string; + password?: string; + nickname?: string; + avatar?: string; + mobile?: string; + email?: string; + status?: number; + lastLoginTime?: string; +} + +/** + * 用户查询响应 + */ +export interface UserQueryResponse { + id?: number; + username?: string; + password?: string; + nickname?: string; + avatar?: string; + mobile?: string; + email?: string; + status?: number; + lastLoginTime?: number; + createTime: number; + updateTime: number; + creator: string; + updater: string; +} + +/** + * 创建用户 + */ +export function createUser(request: UserCreateRequest) { + return axios.post('/infra/system-user/create', request); +} + +/** + * 通过 id 更新用户 + */ +export function updateUser(request: UserUpdateRequest) { + return axios.put('/infra/system-user/update', request); +} + +/** + * 通过 id 查询用户 + */ +export function getUser(id: number) { + return axios.get('/infra/system-user/get', { params: { id } }); +} + +/** + * 通过 id 批量查询用户 + */ +export function getUserList(idList: Array) { + return axios.get('/infra/system-user/list', { + params: { idList }, + paramsSerializer: params => { + return qs.stringify(params, { arrayFormat: 'comma' }); + } + }); +} + +/** + * 分页查询用户 + */ +export function getUserPage(request: UserQueryRequest) { + return axios.post>('/infra/system-user/query', request); +} + +/** + * 通过 id 删除用户 + */ +export function deleteUser(id: number) { + return axios.delete('/infra/system-user/delete', { params: { id } }); +} + +/** + * 通过 id 批量删除用户 + */ +export function batchDeleteUser(idList: Array) { + return axios.delete('/infra/system-user/delete-batch', { + params: { idList }, + paramsSerializer: params => { + return qs.stringify(params, { arrayFormat: 'comma' }); + } + }); +} diff --git a/orion-ops-ui/src/views/system/menu/components/menu-table.vue b/orion-ops-ui/src/views/system/menu/components/menu-table.vue index 1f93e3a2..0e3afef0 100644 --- a/orion-ops-ui/src/views/system/menu/components/menu-table.vue +++ b/orion-ops-ui/src/views/system/menu/components/menu-table.vue @@ -55,13 +55,27 @@ - + - 折叠/展开 + {{ expandStatus ? '折叠' : '展开' }} + + + + 刷新缓存 + + + @@ -158,7 +172,7 @@ + + + + diff --git a/orion-ops-ui/src/views/user/user/components/user-table.vue b/orion-ops-ui/src/views/user/user/components/user-table.vue new file mode 100644 index 00000000..9ae78fad --- /dev/null +++ b/orion-ops-ui/src/views/user/user/components/user-table.vue @@ -0,0 +1,229 @@ + + + + + + + diff --git a/orion-ops-ui/src/views/user/user/index.vue b/orion-ops-ui/src/views/user/user/index.vue new file mode 100644 index 00000000..c38f6466 --- /dev/null +++ b/orion-ops-ui/src/views/user/user/index.vue @@ -0,0 +1,32 @@ + + + + + + + diff --git a/orion-ops-ui/src/views/user/user/types/enum.types.ts b/orion-ops-ui/src/views/user/user/types/enum.types.ts new file mode 100644 index 00000000..894219bc --- /dev/null +++ b/orion-ops-ui/src/views/user/user/types/enum.types.ts @@ -0,0 +1,27 @@ +/** + * + */ +export const USER_STATUS_ENUM = { + DISABLED: { + value: null, + label: '', + color: '', + status: '0', + name: 'DISABLED', + }, + ENABLED: { + value: null, + label: '', + color: '', + status: '1', + name: 'ENABLED', + }, + LOCKED: { + value: null, + label: '', + color: '', + status: '2', + name: 'LOCKED', + }, +} + diff --git a/orion-ops-ui/src/views/user/user/types/form.rules.ts b/orion-ops-ui/src/views/user/user/types/form.rules.ts new file mode 100644 index 00000000..3352c0ba --- /dev/null +++ b/orion-ops-ui/src/views/user/user/types/form.rules.ts @@ -0,0 +1,70 @@ +import { FieldRule } from '@arco-design/web-vue'; + +export const username = [{ + required: true, + message: '请输入用户名' +}, { + maxLength: 32, + message: '用户名长度不能大于32位' +}] as FieldRule[]; + +export const password = [{ + required: true, + message: '请输入密码' +}, { + maxLength: 64, + message: '密码长度不能大于64位' +}] as FieldRule[]; + +export const nickname = [{ + required: true, + message: '请输入花名' +}, { + maxLength: 16, + message: '花名长度不能大于16位' +}] as FieldRule[]; + +export const avatar = [{ + required: true, + message: '请输入头像地址' +}, { + maxLength: 500, + message: '头像地址长度不能大于500位' +}] as FieldRule[]; + +export const mobile = [{ + required: true, + message: '请输入手机号' +}, { + maxLength: 15, + message: '手机号长度不能大于15位' +}] as FieldRule[]; + +export const email = [{ + required: true, + message: '请输入邮箱' +}, { + maxLength: 64, + message: '邮箱长度不能大于64位' +}] as FieldRule[]; + +export const status = [{ + required: true, + message: '请输入用户状态 0停用 1启用 2锁定' +}] as FieldRule[]; + +export const lastLoginTime = [{ + required: true, + message: '请输入最后登录时间' +}] as FieldRule[]; + +export default { + username, + password, + nickname, + avatar, + mobile, + email, + status, + lastLoginTime, +} as Record; diff --git a/orion-ops-ui/src/views/user/user/types/table.columns.ts b/orion-ops-ui/src/views/user/user/types/table.columns.ts new file mode 100644 index 00000000..1fd4894a --- /dev/null +++ b/orion-ops-ui/src/views/user/user/types/table.columns.ts @@ -0,0 +1,98 @@ +import { TableColumnData } from '@arco-design/web-vue/es/table/interface'; +import { dateFormat } from '@/utils'; + +const columns = [ + { + title: 'id', + dataIndex: 'id', + slotName: 'id', + width: 70, + align: 'left', + fixed: 'left', + }, { + title: '用户名', + dataIndex: 'username', + slotName: 'username', + align: 'center', + ellipsis: true, + tooltip: true, + }, { + title: '密码', + dataIndex: 'password', + slotName: 'password', + align: 'center', + ellipsis: true, + tooltip: true, + }, { + title: '花名', + dataIndex: 'nickname', + slotName: 'nickname', + align: 'center', + ellipsis: true, + tooltip: true, + }, { + title: '头像地址', + dataIndex: 'avatar', + slotName: 'avatar', + align: 'center', + ellipsis: true, + tooltip: true, + }, { + title: '手机号', + dataIndex: 'mobile', + slotName: 'mobile', + align: 'center', + ellipsis: true, + tooltip: true, + }, { + title: '邮箱', + dataIndex: 'email', + slotName: 'email', + align: 'center', + ellipsis: true, + tooltip: true, + }, { + title: '用户状态 0停用 1启用 2锁定', + dataIndex: 'status', + slotName: 'status', + align: 'center', + }, { + title: '最后登录时间', + dataIndex: 'lastLoginTime', + slotName: 'lastLoginTime', + align: 'center', + render: ({ record }) => { + return record.lastLoginTime && dateFormat(new Date(record.lastLoginTime)); + }, + }, { + title: '创建时间', + dataIndex: 'createTime', + slotName: 'createTime', + render: ({ record }) => { + return dateFormat(new Date(record.createTime)); + }, + }, { + title: '修改时间', + dataIndex: 'updateTime', + slotName: 'updateTime', + render: ({ record }) => { + return dateFormat(new Date(record.createTime)); + }, + }, { + title: '创建人', + dataIndex: 'creator', + slotName: 'creator', + }, { + title: '修改人', + dataIndex: 'updater', + slotName: 'updater', + }, { + title: '操作', + slotName: 'handle', + width: 130, + align: 'center', + fixed: 'right', + }, +] as TableColumnData[]; + +export default columns;