| 12345678910111213141516171819202122232425262728293031323334353637 |
- import { z } from '@hono/zod-openapi';
- // 定义 Permission 类型
- export type Permission = string;
- export const RoleSchemaMt = z.object({
- id: z.number().int().positive().openapi({
- description: '角色ID',
- example: 1
- }),
- tenantId: z.number().int().positive().openapi({
- description: '租户ID',
- example: 1
- }),
- name: z.string().max(50).openapi({
- description: '角色名称',
- example: 'admin'
- }),
- description: z.string().max(500).nullable().openapi({
- description: '角色描述',
- example: '系统管理员角色'
- }),
- permissions: z.array(z.string()).min(1).openapi({
- description: '角色权限列表',
- example: ['user:create', 'user:delete']
- }),
- createdAt: z.date().openapi({ description: '创建时间' }),
- updatedAt: z.date().openapi({ description: '更新时间' })
- });
- export const CreateRoleDtoMt = RoleSchemaMt.omit({ id: true, tenantId: true, createdAt: true, updatedAt: true });
- export const UpdateRoleDtoMt = RoleSchemaMt.partial();
- // 非多租户版本
- export const RoleSchema = RoleSchemaMt.omit({ tenantId: true });
- export const CreateRoleDto = RoleSchemaMt.omit({ id: true, tenantId: true, createdAt: true, updatedAt: true });
- export const UpdateRoleDto = RoleSchemaMt.partial();
|