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

fest #150

Closed

fest #150

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
Expand Up @@ -10,7 +10,6 @@ import {
import { RoleService } from './role.service';
import { CreateRoleDto } from './dto/create-role.dto';
import { UpdateRoleDto } from './dto/update-role.dto';
import { DeleteRoleDto } from './dto/delete-role.dto';
import { Permission } from '../public/permission.decorator';

@Controller('role')
Expand All @@ -29,16 +28,22 @@ export class RoleController {
return this.roleService.findAll();
}

@Permission('role::get')
@Get('/detail')
getAllRoleDetail() {
return this.roleService.findAllDetail();
}

@Patch()
@Permission('role::update')
updateRole(@Body() dto: UpdateRoleDto) {
return this.roleService.update(dto);
}

@Delete()
@Delete('/:id')
@Permission('role::remove')
deleteRole(@Body() dto: DeleteRoleDto) {
return this.roleService.delete(dto);
deleteRole(@Param('id') id: number) {
return this.roleService.delete(id);
}

@Permission('role::get')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { HttpException, HttpStatus, Injectable } from '@nestjs/common';
import { CreateRoleDto } from './dto/create-role.dto';
import { UpdateRoleDto } from './dto/update-role.dto';
import { DeleteRoleDto } from './dto/delete-role.dto';
import { InjectRepository } from '@nestjs/typeorm';
import { Menu, Permission, Role } from '@app/models';
import { DataSource, In, Repository } from 'typeorm';
Expand Down Expand Up @@ -42,7 +41,15 @@ export class RoleService {
return this.role.save({ name, permission: permissions, menus });
}
findAll() {
return this.role.find();
return this.role.find()
}

findAllDetail(){
return this.role
.createQueryBuilder('role')
.leftJoinAndSelect('role.menus','menus')
.leftJoinAndSelect('role.permission','permission')
.getMany();
}

async findOne(id: string) {
Expand Down Expand Up @@ -83,10 +90,10 @@ export class RoleService {
role.menus = menus.length ? menus : undefined;
return this.role.save(role);
}
async delete(data: DeleteRoleDto) {
async delete(id: number) {
const role = await this.role.find({
where: {
name: data.name,
id: id,
},
});
return this.role.remove(role);
Expand Down
19 changes: 19 additions & 0 deletions packages/toolkits/pro/template/tinyvue/src/api/menu.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import axios from "axios";



export function getAllMenu() {
return axios.get('/api/menu');
}

export function updateMenu(data: any) {
return axios.patch(`/api/menu`, data);
}

export function deleteMenu(id: number) {
return axios.delete(`/api/menu/${id}`);
}

export function createMenu(data: any) {
return axios.post(`/api/menu`, data);
}
18 changes: 17 additions & 1 deletion packages/toolkits/pro/template/tinyvue/src/api/role.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@ import axios from "axios";



export function getRoles() {
export function getAllRole() {
return axios.get('/api/role');
}

export function getAllRoleDetail() {
return axios.get('/api/role/detail');
}

export function updateRole(data: any) {
return axios.patch(`/api/role`, data);
}

export function deleteRole(id: number) {
return axios.delete(`/api/role/${id}`);
}

export function createRole(data: any) {
return axios.post(`/api/role`, data);
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
IconApplication,
IconGroup,
IconFolderOpened,
IconActivation,
} from '@opentiny/vue-icon';
import { TreeMenu as tinyTreeMenu } from '@opentiny/vue';
import router from '@/router';
Expand All @@ -52,6 +53,7 @@
const iconApplication = IconApplication();
const iconFolderOpened = IconFolderOpened();
const iconGroup = IconGroup();
const iconActivation = IconActivation();
const tree = ref();
const expandeArr = ref();
const routerTitle = [
Expand Down Expand Up @@ -230,17 +232,18 @@
bold: 'title',
},
{
value: 'PermissionSetting',
name: 'menu.permission.setting',
icon: null,
bold: 'title',
value: 'Role',
name: 'menu.role',
icon: iconActivation,
bold: 'main-title',
},
{
value: 'PermissionAdd',
name: 'menu.permission.permissionAdd',
value: 'AllRole',
name: 'menu.role.info',
icon: null,
bold: 'title',
},

];

// 获取路由数据
Expand Down Expand Up @@ -311,6 +314,8 @@
'User',
'Cloud',
'UserManager',
'Permission',
'Role'
];
if (filter.indexOf(data.id) === -1) {
router.push({ name: data.id });
Expand Down
5 changes: 5 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 @@ -32,6 +32,8 @@ import localeUserManagerUserAdd from '@/views/userManager/useradd/locale/en-US';

import localePermission from '@/views/permission/info/locale/en-US';

import localeRole from '@/views/role/info/locale/en-US';

import localeSettings from './en-US/settings';

import localeHttpError from './en-US/httpError';
Expand All @@ -56,6 +58,8 @@ export default {
'menu.permission.info':'All Permission Info',
'menu.permission.setting':'Permission Setting',
'menu.permission.permissionAdd':'Add Permission',
'menu.role': 'Role Manager',
'menu.role.info':'All Role Info',
'navbar.docs': 'Docs',
'navbar.action.locale': 'Switch to English',
'messageBox.switchRoles': 'Switch Roles',
Expand Down Expand Up @@ -86,4 +90,5 @@ export default {
...localeUserManagerSetting,
...localeUserManagerUserAdd,
...localePermission,
...localeRole,
};
5 changes: 5 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 @@ -32,6 +32,8 @@ import localeUserManagerUserAdd from '@/views/userManager/useradd/locale/zh-CN';

import localePermission from '@/views/permission/info/locale/zh-CN';

import localeRole from '@/views/role/info/locale/zh-CN';

import localeSettings from './zh-CN/settings';

import localeHttpError from './zh-CN/httpError';
Expand All @@ -57,6 +59,8 @@ export default {
'menu.permission.info':'查看权限',
'menu.permission.setting':'修改权限',
'menu.permission.permissionAdd':'添加权限',
'menu.role': '角色管理',
'menu.role.info':'查看角色',
'navbar.docs': '文档中心',
'navbar.action.locale': '切换为中文',
'messageBox.switchRoles': '切换角色',
Expand Down Expand Up @@ -87,4 +91,5 @@ export default {
...localeUserManagerSetting,
...localeUserManagerUserAdd,
...localePermission,
...localeRole,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { RoleType } from '@/types/roleType';

export default {
path: 'role',
name: 'Role',
id: 'Role',
label: 'Role',
component: () => import('@/views/role/index.vue'),
meta: {
locale: 'menu.role',
requiresAuth: true,
order: 9,
roles: [RoleType.admin],
},
children: [
{
path: 'allRole',
name: 'AllRole',
id: 'AllRole',
label: 'AllRole',
component: () => import('@/views/role/info/index.vue'),
meta: {
locale: 'menu.role.info',
requiresAuth: true,
roles: [RoleType.admin],
},
},
],
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="tiny-fullscreen-scroll">
<div class="tiny-fullscreen-wrapper">
<div class="permission-add-btn">
<tiny-button type="primary" @click="handleAddPermission">添加权限</tiny-button>
<tiny-button type="primary" @click="handleAddPermission">{{ $t('permissionInfo.modal.title.add') }}</tiny-button>
</div>
<div class="table">
<tiny-grid ref="expandGrid"
Expand Down Expand Up @@ -291,7 +291,6 @@ function handleAddPermission() {
async function handlePermissionAddSubmit() {
let data = state.permissionAddData;
let newTemp = {
id: data.id,
name: data.name,
desc: data.desc,
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<template>
<router-view />
</template>

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