Skip to content
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
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: string;
@Column({type: 'timestamp',nullable: true})
probationEnd: string;
@Column({nullable: true})
probationDuration: string;
@Column({type: 'timestamp',nullable: true})
protocolStart: string;
@Column({type: 'timestamp',nullable: true})
protocolEnd: string;
@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 @@ -111,7 +111,8 @@ export class AppModule implements OnModuleInit {
email: 'admin@no-reply.com',
password: 'admin',
roleIds: [role.id],
username: 'admin',
name: 'admin',
status: 1,
},
isInit
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export class CreateUserDto {
@IsNotEmpty({
message: '用户名不能为空',
})
username: string;
name: string;
@IsNotEmpty({
message: '邮箱不能为空',
})
Expand All @@ -14,4 +14,13 @@ export class CreateUserDto {
})
password: string;
roleIds: number[] = [];
department?: string;
employeeType?: string;
probationStart?: string;
probationEnd?: string;
probationDuration?: string;
protocolStart?: string;
protocolEnd?: string;
address?: string;
status?: number;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { PartialType } from '@nestjs/mapped-types';
import { CreateUserDto } from './create-user.dto';
import { IsNotEmpty } from 'class-validator';

export class UpdatePwdAdminDto extends PartialType(CreateUserDto) {
email: string;
@IsNotEmpty({
message: '新密码不能为空',
})
newPassword: string;
confirmNewPassword?: string;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { PartialType } from '@nestjs/mapped-types';
import { CreateUserDto } from './create-user.dto';
import { IsNotEmpty } from 'class-validator';

export class UpdatePwdUserDto extends PartialType(CreateUserDto) {
email: string;
token: string;
@IsNotEmpty({
message: '新密码不能为空',
})
newPassword: string;
@IsNotEmpty({
message: '旧密码不能为空',
})
oldPassword?: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,54 @@ import { CreateUserDto } from './create-user.dto';
import { IsNotEmpty } from 'class-validator';

export class UpdateUserDto extends PartialType(CreateUserDto) {
oldPassword: string;
newPassword: string;
@IsNotEmpty({
message: '旧密码不能为空',
message: '邮箱不能为空',
})
oldPassword: string;
email: string;
@IsNotEmpty({
message: '新密码不能为空',
message: '职业不能为空',
})
newPassword: string;
roleIds: number[] = [];
@IsNotEmpty({
message: '部门不能为空',
})
department: string;
@IsNotEmpty({
message: '招聘类型不能为空',
})
employeeType: string;
@IsNotEmpty({
message: '试用起始日期不能为空',
})
probationStart: string;
@IsNotEmpty({
message: '试用结束日期不能为空',
})
probationEnd: string;
@IsNotEmpty({
message: '试用期时长不能为空',
})
probationDuration: string;
@IsNotEmpty({
message: '合同起始日期不能为空',
})
protocolStart: string;
@IsNotEmpty({
message: '试用结束日期不能为空',
})
protocolEnd: string;
@IsNotEmpty({
message: '地址不能为空',
})
address: string;
@IsNotEmpty({
message: '状态不能为空',
})
status: number;
@IsNotEmpty({
message: '用户名不能为空',
})
name: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ import { UserService } from './user.service';
import { CreateUserDto } from './dto/create-user.dto';
import { Permission } from '../public/permission.decorator';
import { UpdateUserDto } from './dto/update-user.dto';
import { PaginationQueryDto } from './dto/pagination-query.dto'
import { PaginationQueryDto } from './dto/pagination-query.dto';
import {UpdatePwdAdminDto} from "./dto/update-pwd-admin.dto";
import {UpdatePwdUserDto} from "./dto/update-pwd-user.dto";

@Controller('user')
export class UserController {
Expand All @@ -35,7 +37,7 @@ export class UserController {
@Patch('/update')
@Permission('user::update')
async UpdateUser(@Body() body: UpdateUserDto) {
return this.userService.updateUserPwd(body);
return this.userService.updateUserInfo(body);
}
@Get()
@Permission('user::query')
Expand All @@ -44,4 +46,16 @@ export class UserController {
) {
return this.userService.getAllUser(paginationQuery);
}

@Patch('/admin/updatePwd')
@Permission('user::password::force-update')
async updatePwdAdmin(@Body() body: UpdatePwdAdminDto) {
return this.userService.updatePwdAdmin(body);
}

@Patch('/updatePwd')
@Permission('user::update')
async updatePwdUser(@Body() body: UpdatePwdUserDto) {
return this.userService.updatePwdUser(body);
}
}
Loading