parent
14f5711e87
commit
cc81b40b58
@ -0,0 +1,30 @@ |
||||
import { |
||||
createParamDecorator, |
||||
ExecutionContext, |
||||
SetMetadata, |
||||
} from '@nestjs/common'; |
||||
|
||||
export const UserInfoDecorator = (...args: string[]) => |
||||
SetMetadata('userinfoDecorator', args); |
||||
|
||||
// nest g d [name]
|
||||
// 自定义装饰器
|
||||
|
||||
// ? ?
|
||||
// ? 函数名称: userinfoDto
|
||||
// ? 函数描述: 限制userinfo数据格式
|
||||
// ? ?
|
||||
export class userinfoDto { |
||||
uuid: string; |
||||
} |
||||
|
||||
// ? ?
|
||||
// ? 函数名称: getUserinfo
|
||||
// ? 函数描述: 获取token用户信息
|
||||
// ? ?
|
||||
export const getUserinfo = createParamDecorator( |
||||
(data: string, ctx: ExecutionContext) => { |
||||
const req = ctx.switchToHttp().getRequest(); |
||||
return req.userinfo as userinfoDto; |
||||
}, |
||||
); |
@ -0,0 +1,32 @@ |
||||
import { IsNumber, IsString, Length } from 'class-validator'; |
||||
|
||||
export class PositionCreateDTO { |
||||
// @ 父id
|
||||
@IsNumber({}, { message: '父id必须为数字!' }) |
||||
fatherid: number; |
||||
|
||||
// @ 定位类型
|
||||
@Length(1, 128, { message: '请将角色定位类型长度控制在8到128位之间!' }) |
||||
@IsString({ message: '角色定位类型应为字符串格式!' }) |
||||
type: string; |
||||
|
||||
// @ 角色名称
|
||||
@Length(1, 128, { message: '请将角色定位名称长度控制在8到128位之间!' }) |
||||
@IsString({ message: '角色定位名称应为字符串格式!' }) |
||||
name: string; |
||||
|
||||
// @ 角色标识
|
||||
@Length(1, 128, { message: '请将角色定位标识长度控制在8到128位之间!' }) |
||||
@IsString({ message: '角色定位标识应为字符串格式!' }) |
||||
index: string; |
||||
|
||||
// @ 描述
|
||||
@Length(1, 128, { message: '请将角色定位描述长度控制在8到128位之间!' }) |
||||
@IsString({ message: '角色定位描述应为字符串格式!' }) |
||||
describe: string; |
||||
|
||||
// @ 图标
|
||||
@Length(8, 255, { message: '请将角色定位图标地址长度控制在8到128位之间!' }) |
||||
@IsString({ message: '角色定位图标地址应为字符串格式!' }) |
||||
ico: string; |
||||
} |
Loading…
Reference in new issue