system-config.schema.ts 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. import { z } from '@hono/zod-openapi';
  2. export const SystemConfigSchema = z.object({
  3. id: z.number().int().positive().openapi({
  4. description: '系统配置ID',
  5. example: 1
  6. }),
  7. configKey: z.string().min(1).max(255).openapi({
  8. description: '配置键',
  9. example: 'app.login.enabled'
  10. }),
  11. configValue: z.string().openapi({
  12. description: '配置值',
  13. example: 'true'
  14. }),
  15. description: z.string().nullable().openapi({
  16. description: '配置描述',
  17. example: '控制小程序登录功能是否开启'
  18. }),
  19. createdBy: z.number().int().positive().nullable().openapi({
  20. description: '创建用户ID',
  21. example: 1
  22. }),
  23. updatedBy: z.number().int().positive().nullable().openapi({
  24. description: '更新用户ID',
  25. example: 1
  26. }),
  27. createdAt: z.coerce.date().openapi({
  28. description: '创建时间',
  29. example: '2023-01-15T10:30:00Z'
  30. }),
  31. updatedAt: z.coerce.date().openapi({
  32. description: '更新时间',
  33. example: '2023-01-16T14:20:00Z'
  34. })
  35. });
  36. export const CreateSystemConfigSchema = z.object({
  37. configKey: z.string().min(1).max(255).openapi({
  38. description: '配置键',
  39. example: 'app.login.enabled'
  40. }),
  41. configValue: z.string().openapi({
  42. description: '配置值',
  43. example: 'true'
  44. }),
  45. description: z.string().nullable().optional().openapi({
  46. description: '配置描述',
  47. example: '控制小程序登录功能是否开启'
  48. })
  49. });
  50. export const UpdateSystemConfigSchema = z.object({
  51. configKey: z.string().min(1).max(255).optional().openapi({
  52. description: '配置键',
  53. example: 'app.login.enabled'
  54. }),
  55. configValue: z.string().optional().openapi({
  56. description: '配置值',
  57. example: 'false'
  58. }),
  59. description: z.string().nullable().optional().openapi({
  60. description: '配置描述',
  61. example: '控制小程序登录功能是否开启'
  62. })
  63. });
  64. export const SystemConfigListSchema = z.array(SystemConfigSchema);