import { z } from '@hono/zod-openapi';

// 定义 Permission 类型
export type Permission = string;

export const RoleSchema = z.object({
  id: 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 CreateRoleDto = RoleSchema.omit({ id: true , createdAt: true, updatedAt: true });
export const UpdateRoleDto = RoleSchema.partial();