diff --git a/packages/toolkits/pro/template/server/nestJs/src/permission/dto/delete-permission.dto.ts b/packages/toolkits/pro/template/server/nestJs/src/permission/dto/delete-permission.dto.ts deleted file mode 100644 index 58e93846..00000000 --- a/packages/toolkits/pro/template/server/nestJs/src/permission/dto/delete-permission.dto.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { IsNotEmpty } from 'class-validator'; - -export class DeletePermissionDto { - @IsNotEmpty() - name: string; -} diff --git a/packages/toolkits/pro/template/server/nestJs/src/permission/permission.controller.ts b/packages/toolkits/pro/template/server/nestJs/src/permission/permission.controller.ts index 35eb9816..7a17091d 100644 --- a/packages/toolkits/pro/template/server/nestJs/src/permission/permission.controller.ts +++ b/packages/toolkits/pro/template/server/nestJs/src/permission/permission.controller.ts @@ -1,7 +1,14 @@ -import { Body, Controller, Delete, Get, Patch, Post } from '@nestjs/common'; +import { + Body, + Controller, + Delete, + Get, + Param, + Patch, + Post +} from '@nestjs/common'; import { PermissionService } from './permission.service'; import { CreatePermissionDto } from './dto/create-permission.dto'; -import { DeletePermissionDto } from './dto/delete-permission.dto'; import { Permission } from '../public/permission.decorator'; import { UpdatePermissionDto } from './dto/update-permission.dto'; @@ -27,9 +34,9 @@ export class PermissionController { return this.permissionService.findPermission(); } - @Delete() + @Delete('/:id') @Permission('permission::remove') - del(@Body() dto: DeletePermissionDto) { - return this.permissionService.delPermission(dto); + del(@Param('id') id: number) { + return this.permissionService.delPermission(id); } } diff --git a/packages/toolkits/pro/template/server/nestJs/src/permission/permission.service.ts b/packages/toolkits/pro/template/server/nestJs/src/permission/permission.service.ts index 6b628bd0..1902c779 100644 --- a/packages/toolkits/pro/template/server/nestJs/src/permission/permission.service.ts +++ b/packages/toolkits/pro/template/server/nestJs/src/permission/permission.service.ts @@ -1,7 +1,6 @@ import { HttpException, HttpStatus, Injectable } from '@nestjs/common'; import { CreatePermissionDto } from './dto/create-permission.dto'; import { UpdatePermissionDto } from './dto/update-permission.dto'; -import { DeletePermissionDto } from './dto/delete-permission.dto'; import { InjectRepository } from '@nestjs/typeorm'; import { Permission } from '@app/models'; import { Repository } from 'typeorm'; @@ -42,10 +41,9 @@ export class PermissionService { async findPermission() { return this.permission.find(); } - async delPermission(deletePermissionDto: DeletePermissionDto) { - const { name } = deletePermissionDto; + async delPermission(id: number) { const permissionInfo = await this.permission.findOne({ - where: { name }, + where: { id }, }); return this.permission.remove(permissionInfo); } diff --git a/packages/toolkits/pro/template/tinyvue/src/api/permission.ts b/packages/toolkits/pro/template/tinyvue/src/api/permission.ts new file mode 100644 index 00000000..8add257c --- /dev/null +++ b/packages/toolkits/pro/template/tinyvue/src/api/permission.ts @@ -0,0 +1,17 @@ +import axios from 'axios'; + +export function getAllPermission() { + return axios.get(`/api/permission`); +} + +export function updatePermission(data: any) { + return axios.patch(`/api/permission`, data); +} + +export function deletePermission(id: number) { + return axios.delete(`/api/permission/${id}`); +} + +export function createPermission(data: any) { + return axios.post(`/api/permission`, data); +} diff --git a/packages/toolkits/pro/template/tinyvue/src/components/menu/index.vue b/packages/toolkits/pro/template/tinyvue/src/components/menu/index.vue index a2fec5b2..b53081d4 100644 --- a/packages/toolkits/pro/template/tinyvue/src/components/menu/index.vue +++ b/packages/toolkits/pro/template/tinyvue/src/components/menu/index.vue @@ -34,6 +34,7 @@ IconFiletext, IconApplication, IconGroup, + IconFolderOpened, } from '@opentiny/vue-icon'; import { TreeMenu as tinyTreeMenu } from '@opentiny/vue'; import router from '@/router'; @@ -49,6 +50,7 @@ const iconUser = IconUser(); const iconFiletext = IconFiletext(); const iconApplication = IconApplication(); + const iconFolderOpened = IconFolderOpened(); const iconGroup = IconGroup(); const tree = ref(); const expandeArr = ref(); @@ -215,6 +217,30 @@ icon: null, bold: 'title', }, + { + value: 'Permission', + name: 'menu.permission', + icon: iconFolderOpened, + bold: 'main-title', + }, + { + value: 'AllPermission', + name: 'menu.permission.info', + icon: null, + bold: 'title', + }, + { + value: 'PermissionSetting', + name: 'menu.permission.setting', + icon: null, + bold: 'title', + }, + { + value: 'PermissionAdd', + name: 'menu.permission.permissionAdd', + icon: null, + bold: 'title', + }, ]; // 获取路由数据 diff --git a/packages/toolkits/pro/template/tinyvue/src/locale/en-US.ts b/packages/toolkits/pro/template/tinyvue/src/locale/en-US.ts index a231f6c4..750d6e04 100644 --- a/packages/toolkits/pro/template/tinyvue/src/locale/en-US.ts +++ b/packages/toolkits/pro/template/tinyvue/src/locale/en-US.ts @@ -30,6 +30,8 @@ import localeUserManagerSetting from '@/views/userManager/setting/locale/en-US'; import localeUserManagerUserAdd from '@/views/userManager/useradd/locale/en-US'; +import localePermission from '@/views/permission/info/locale/en-US'; + import localeSettings from './en-US/settings'; import localeHttpError from './en-US/httpError'; @@ -50,6 +52,10 @@ export default { 'menu.userManager.info': 'All User Info', 'menu.userManager.setting': 'All User Setting', 'menu.userManager.useradd': 'Add User', + 'menu.permission':'Permission Manager', + 'menu.permission.info':'All Permission Info', + 'menu.permission.setting':'Permission Setting', + 'menu.permission.permissionAdd':'Add Permission', 'navbar.docs': 'Docs', 'navbar.action.locale': 'Switch to English', 'messageBox.switchRoles': 'Switch Roles', @@ -79,4 +85,5 @@ export default { ...localeUserManager, ...localeUserManagerSetting, ...localeUserManagerUserAdd, + ...localePermission, }; diff --git a/packages/toolkits/pro/template/tinyvue/src/locale/zh-CN.ts b/packages/toolkits/pro/template/tinyvue/src/locale/zh-CN.ts index b50a37f5..09ae2408 100644 --- a/packages/toolkits/pro/template/tinyvue/src/locale/zh-CN.ts +++ b/packages/toolkits/pro/template/tinyvue/src/locale/zh-CN.ts @@ -30,6 +30,8 @@ import localeUserManagerSetting from '@/views/userManager/setting/locale/zh-CN'; import localeUserManagerUserAdd from '@/views/userManager/useradd/locale/zh-CN'; +import localePermission from '@/views/permission/info/locale/zh-CN'; + import localeSettings from './zh-CN/settings'; import localeHttpError from './zh-CN/httpError'; @@ -51,6 +53,10 @@ export default { 'menu.userManager.info': '所有用户', 'menu.userManager.setting': '修改信息', 'menu.userManager.useradd': '添加用户', + 'menu.permission':'权限管理', + 'menu.permission.info':'查看权限', + 'menu.permission.setting':'修改权限', + 'menu.permission.permissionAdd':'添加权限', 'navbar.docs': '文档中心', 'navbar.action.locale': '切换为中文', 'messageBox.switchRoles': '切换角色', @@ -80,4 +86,5 @@ export default { ...localeUserManager, ...localeUserManagerSetting, ...localeUserManagerUserAdd, + ...localePermission, }; diff --git a/packages/toolkits/pro/template/tinyvue/src/router/routes/modules/permission.ts b/packages/toolkits/pro/template/tinyvue/src/router/routes/modules/permission.ts new file mode 100644 index 00000000..2b3bc4bf --- /dev/null +++ b/packages/toolkits/pro/template/tinyvue/src/router/routes/modules/permission.ts @@ -0,0 +1,29 @@ +import { RoleType } from '@/types/roleType'; + +export default { + path: 'permission', + name: 'Permission', + id: 'Permission', + label: 'Permission', + component: () => import('@/views/permission/index.vue'), + meta: { + locale: 'menu.Permission', + requiresAuth: true, + order: 9, + roles: [RoleType.admin], + }, + children: [ + { + path: 'allPermission', + name: 'AllPermission', + id: 'AllPermission', + label: 'AllPermission', + component: () => import('@/views/permission/info/index.vue'), + meta: { + locale: 'menu.permission.info', + requiresAuth: true, + roles: [RoleType.admin], + }, + }, + ], +}; diff --git a/packages/toolkits/pro/template/tinyvue/src/views/permission/index.vue b/packages/toolkits/pro/template/tinyvue/src/views/permission/index.vue new file mode 100644 index 00000000..6c71efda --- /dev/null +++ b/packages/toolkits/pro/template/tinyvue/src/views/permission/index.vue @@ -0,0 +1,5 @@ + + + diff --git a/packages/toolkits/pro/template/tinyvue/src/views/permission/info/components/info-tab.vue b/packages/toolkits/pro/template/tinyvue/src/views/permission/info/components/info-tab.vue new file mode 100644 index 00000000..88f53dfb --- /dev/null +++ b/packages/toolkits/pro/template/tinyvue/src/views/permission/info/components/info-tab.vue @@ -0,0 +1,358 @@ + + + + + diff --git a/packages/toolkits/pro/template/tinyvue/src/views/permission/info/index.vue b/packages/toolkits/pro/template/tinyvue/src/views/permission/info/index.vue new file mode 100644 index 00000000..a31b9ef3 --- /dev/null +++ b/packages/toolkits/pro/template/tinyvue/src/views/permission/info/index.vue @@ -0,0 +1,61 @@ + + + + + diff --git a/packages/toolkits/pro/template/tinyvue/src/views/permission/info/locale/en-US.ts b/packages/toolkits/pro/template/tinyvue/src/views/permission/info/locale/en-US.ts new file mode 100644 index 00000000..6ccf6461 --- /dev/null +++ b/packages/toolkits/pro/template/tinyvue/src/views/permission/info/locale/en-US.ts @@ -0,0 +1,16 @@ +export default { + 'menu.allPermission.info': 'Permission', + 'permissionInfo.table.id': 'ID', + 'permissionInfo.table.name': 'Name', + 'permissionInfo.table.desc': 'Desc', + 'permissionInfo.table.operations': 'Operation', + 'permissionInfo.table.operations.update': 'Update', + 'permissionInfo.table.operations.delete': 'Delete', + 'permissionInfo.modal.title.update': 'Update Permission', + 'permissionInfo.modal.title.add': 'Add Permission', + 'permissionInfo.modal.input.permission': 'Permission', + 'permissionInfo.modal.input.name': 'Name', + 'permissionInfo.modal.input.id': 'ID', + 'permissionInfo.modal.message.error': 'Error', + 'permissionInfo.modal.message.notNull': 'Not Null', +}; diff --git a/packages/toolkits/pro/template/tinyvue/src/views/permission/info/locale/zh-CN.ts b/packages/toolkits/pro/template/tinyvue/src/views/permission/info/locale/zh-CN.ts new file mode 100644 index 00000000..491bd2dc --- /dev/null +++ b/packages/toolkits/pro/template/tinyvue/src/views/permission/info/locale/zh-CN.ts @@ -0,0 +1,16 @@ +export default { + 'menu.allPermission.info': '查看权限', + 'permissionInfo.table.id': 'ID', + 'permissionInfo.table.name': '名称', + 'permissionInfo.table.desc': '权限', + 'permissionInfo.table.operations': '操作', + 'permissionInfo.table.operations.update': '修改', + 'permissionInfo.table.operations.delete': '删除', + 'permissionInfo.modal.title.update': '修改权限', + 'permissionInfo.modal.title.add': '添加权限', + 'permissionInfo.modal.input.permission': '权限', + 'permissionInfo.modal.input.name': '名称', + 'permissionInfo.modal.input.id': 'id', + 'permissionInfo.modal.message.error': '错误', + 'permissionInfo.modal.message.notNull': '不能为空', +}; diff --git a/packages/toolkits/pro/template/tinyvue/src/views/userManager/setting/index.vue b/packages/toolkits/pro/template/tinyvue/src/views/userManager/setting/index.vue index 9e28591a..4286f560 100644 --- a/packages/toolkits/pro/template/tinyvue/src/views/userManager/setting/index.vue +++ b/packages/toolkits/pro/template/tinyvue/src/views/userManager/setting/index.vue @@ -181,7 +181,7 @@ const router = useRouter(); // 初始化请求数据 onMounted(() => { - fecthData(); + fetchData(); fetchRole() }); @@ -289,7 +289,7 @@ async function handleSubmit() { } } -async function fecthData() { +async function fetchData() { if (route.query.email !== undefined || null) { const {data} = await getUserInfo(route.query.email); if (data.status === 1) {