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: 新增用户管理模块-查看所有用户&分页&删除 #148

Merged
Merged
Show file tree
Hide file tree
Changes from 3 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
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,24 @@ export class User {
@ManyToMany(() => Role)
@JoinTable({ name: 'user_role' })
role: Role[];
@Column({nullable: true})
department: string;
@Column({nullable: true})
employeeType: string;
@Column({type: 'timestamp',nullable: true})
probationStart: Date;
@Column({type: 'timestamp',nullable: true})
probationEnd: Date;
@Column({nullable: true})
probationDuration: string;
@Column({type: 'timestamp',nullable: true})
protocolStart: Date;
@Column({type: 'timestamp',nullable: true})
protocolEnd: Date;
@Column({nullable: true})
address: string;
@Column({nullable: true})
status: number;
@CreateDateColumn()
createTime: Date;
@UpdateDateColumn()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,13 @@ export class CreateUserDto {
})
password: string;
roleIds: number[] = [];
department?: string;
employeeType?: string;
probationStart?: Date;
probationEnd?: Date;
probationDuration?: string;
protocolStart?: Date;
protocolEnd?: Date;
address?: string;
status?: number;
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ export class UserService {
private readonly authService: AuthService
) {}
async create(createUserDto: CreateUserDto, isInit: boolean) {
const { email, password, roleIds = [], username } = createUserDto;
const { email, password, roleIds = [], username,
department, employeeType, probationStart, probationEnd, probationDuration,
protocolStart,protocolEnd,address,status} = createUserDto;
const userInfo = this.getUserInfo(email);
if (isInit == true && (await userInfo)) {
return userInfo;
Expand All @@ -40,6 +42,15 @@ export class UserService {
name: username,
role: await roles,
deleteAt: 0,
department: department,
employeeType: employeeType,
protocolStart: protocolStart,
protocolEnd: protocolEnd,
probationEnd: probationEnd,
probationStart: probationStart,
probationDuration: probationDuration,
address: address,
status: status,
});
return this.userRep.save(user);
} catch (err) {
Expand All @@ -53,12 +64,15 @@ export class UserService {
//获取所有用户信息
async getAllUser(paginationQuery: PaginationQueryDto): Promise<any> {
const { page, limit } = paginationQuery; // 从DTO获取分页参数
const relations = ['role', 'role.permission']
return await paginate<User>(this.userRep, {
page: Number(page) || Number(process.env.PAGITION_PAGE),
limit: Number(limit) || Number(process.env.PAGITION_LIMIT),
},{
where: {deleteAt: 0},
select: ['id', 'name', 'email', 'createTime', 'updateTime'],
select: ['id', 'name', 'email', 'department', 'employeeType', 'protocolStart', 'protocolEnd',
'probationEnd', 'probationStart', 'probationDuration', 'address', 'status'],
relations,
});
}

Expand Down
6 changes: 3 additions & 3 deletions packages/toolkits/pro/template/tinyvue/src/api/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,16 @@ export function logout(data: LogoutData) {
}

// 获取全部用户
export function getAllUser() {
return axios.get<UserInfo>(`/api/user`);
export function getAllUser(page?: number, limit?: number) {
return axios.get<UserInfo>(`/api/user?page=${page}&limit=${limit}`);
}

// 获取单个用户
export function getUserInfo(email: string) {
return axios.get<UserInfo>(`/api/user/info/${email}`);
}

export function delUser(email: string) {
export function deleteUser(email: string) {
return axios.delete<UserInfo>(`/api/user/${email}`);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
IconUser,
IconFiletext,
IconApplication,
IconGroup,
} from '@opentiny/vue-icon';
import { TreeMenu as tinyTreeMenu } from '@opentiny/vue';
import router from '@/router';
Expand All @@ -48,6 +49,7 @@
const iconUser = IconUser();
const iconFiletext = IconFiletext();
const iconApplication = IconApplication();
const iconGroup = IconGroup();
const tree = ref();
const expandeArr = ref();
const routerTitle = [
Expand Down Expand Up @@ -189,6 +191,24 @@
icon: null,
bold: 'title',
},
{
value: 'UserManager',
name: 'menu.userManager',
icon: iconGroup,
bold: 'main-title',
},
{
value: 'AllInfo',
name: 'menu.userManager.info',
icon: null,
bold: 'title',
},
{
value: 'AllSetting',
name: 'menu.userManager.setting',
icon: null,
bold: 'title',
},
];

// 获取路由数据
Expand Down Expand Up @@ -258,6 +278,7 @@
'Result',
'User',
'Cloud',
'UserManager',
];
if (filter.indexOf(data.id) === -1) {
router.push({ name: data.id });
Expand Down
6 changes: 6 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 @@ -24,6 +24,8 @@ import localeHello from '@/views/cloud/hello/locale/en-US';

import localeContracts from '@/views/cloud/contracts/locale/en-US';

import localeUserManager from '@/views/userManager/info/locale/en-US';

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

import localeHttpError from './en-US/httpError';
Expand All @@ -40,6 +42,9 @@ export default {
'menu.profile.detail': 'Basic details page',
'menu.visualization': 'Data Visualization',
'menu.user': 'User Center',
'menu.userManager': 'User Manager',
'menu.userManager.info': 'All User Info',
'menu.userManager.setting': 'All User Setting',
'navbar.docs': 'Docs',
'navbar.action.locale': 'Switch to English',
'messageBox.switchRoles': 'Switch Roles',
Expand All @@ -65,4 +70,5 @@ export default {
...localeHello,
...localeContracts,
...localeHttpError,
...localeUserManager,
};
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 @@ -24,10 +24,13 @@ import localeHello from '@/views/cloud/hello/locale/zh-CN';

import localeContracts from '@/views/cloud/contracts/locale/zh-CN';

import localeUserManager from '@/views/userManager/info/locale/zh-CN';

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

import localeHttpError from './zh-CN/httpError';


export default {
'menu.board': '看板',
'menu.home': '监控页',
Expand All @@ -40,6 +43,9 @@ export default {
'menu.profile.detail': '基础详情页',
'menu.visualization': '数据可视化',
'menu.user': '个人中心',
'menu.userManager': '用户管理',
'menu.userManager.info': '所有用户',
'menu.userManager.setting': '修改信息',
'navbar.docs': '文档中心',
'navbar.action.locale': '切换为中文',
'messageBox.switchRoles': '切换角色',
Expand All @@ -65,4 +71,5 @@ export default {
...localeHello,
...localeContracts,
...localeHttpError,
...localeUserManager,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { RoleType } from '@/types/roleType';

export default {
path: 'userManager',
name: 'UserManager',
id: 'UserManager',
label: 'UserManager',
component: () => import('@/views/userManager/index.vue'),
meta: {
locale: 'menu.userManager',
requiresAuth: true,
order: 9,
roles: [RoleType.admin],
},
children: [
{
path: 'allInfo',
name: 'AllInfo',
id: 'AllInfo',
label: 'AllInfo',
component: () => import('@/views/userManager/info/index.vue'),
meta: {
locale: 'menu.userManager.info',
requiresAuth: true,
roles: [RoleType.admin],
},
},
{
path: 'allSetting',
name: 'AllSetting',
id: 'AllSetting',
label: 'AllSetting',
component: () => import('@/views/userManager/setting/index.vue'),
meta: {
locale: 'menu.userManager.setting',
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