Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 新增权限管理模块 #149

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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);
}
Expand Down
17 changes: 17 additions & 0 deletions packages/toolkits/pro/template/tinyvue/src/api/permission.ts
Original file line number Diff line number Diff line change
@@ -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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
IconFiletext,
IconApplication,
IconGroup,
IconFolderOpened,
} from '@opentiny/vue-icon';
import { TreeMenu as tinyTreeMenu } from '@opentiny/vue';
import router from '@/router';
Expand All @@ -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();
Expand Down Expand Up @@ -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',
},
];

// 获取路由数据
Expand Down
7 changes: 7 additions & 0 deletions packages/toolkits/pro/template/tinyvue/src/locale/en-US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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',
Expand Down Expand Up @@ -79,4 +85,5 @@ export default {
...localeUserManager,
...localeUserManagerSetting,
...localeUserManagerUserAdd,
...localePermission,
};
7 changes: 7 additions & 0 deletions packages/toolkits/pro/template/tinyvue/src/locale/zh-CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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': '切换角色',
Expand Down Expand Up @@ -80,4 +86,5 @@ export default {
...localeUserManager,
...localeUserManagerSetting,
...localeUserManagerUserAdd,
...localePermission,
};
Original file line number Diff line number Diff line change
@@ -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],
},
},
],
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<template>
<router-view />
</template>

<script lang="ts" setup></script>
Loading