merchant.mt.schema.ts 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. import { z } from '@hono/zod-openapi';
  2. export const MerchantSchemaMt = z.object({
  3. tenantId: z.number().int().positive().openapi({ description: '租户ID' }),
  4. id: z.number().int().positive().openapi({ description: '商户ID' }),
  5. name: z.string().min(1, '商户名称不能为空').max(255, '商户名称最多255个字符').nullable().openapi({
  6. description: '商户名称',
  7. example: '商户A'
  8. }),
  9. username: z.string().min(1, '用户名不能为空').max(20, '用户名最多20个字符').openapi({
  10. description: '用户名',
  11. example: 'merchant001'
  12. }),
  13. password: z.string().min(6, '密码至少6位').max(255, '密码最多255位').openapi({
  14. description: '密码',
  15. example: 'password123'
  16. }),
  17. phone: z.string().regex(/^1[3-9]\d{9}$/, '请输入正确的手机号').nullable().optional().openapi({
  18. description: '手机号码',
  19. example: '13800138000'
  20. }),
  21. realname: z.string().max(20, '姓名最多20个字符').nullable().optional().openapi({
  22. description: '姓名',
  23. example: '李四'
  24. }),
  25. loginNum: z.number().int().nonnegative('登录次数必须为非负数').default(0).openapi({
  26. description: '登录次数',
  27. example: 0
  28. }),
  29. loginTime: z.number().int().nonnegative('登录时间必须为非负数').default(0).openapi({
  30. description: '登录时间',
  31. example: 0
  32. }),
  33. loginIp: z.string().max(15, 'IP地址最多15个字符').nullable().optional().openapi({
  34. description: '登录IP',
  35. example: '192.168.1.1'
  36. }),
  37. lastLoginTime: z.number().int().nonnegative('上次登录时间必须为非负数').default(0).openapi({
  38. description: '上次登录时间',
  39. example: 0
  40. }),
  41. lastLoginIp: z.string().max(15, 'IP地址最多15个字符').nullable().optional().openapi({
  42. description: '上次登录IP',
  43. example: '192.168.1.1'
  44. }),
  45. state: z.number().int().min(1).max(2).default(2).openapi({
  46. description: '状态 1启用 2禁用',
  47. example: 1
  48. }),
  49. rsaPublicKey: z.string().max(2000, '公钥最多2000个字符').nullable().optional().openapi({
  50. description: '公钥',
  51. example: '-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA...\n-----END PUBLIC KEY-----'
  52. }),
  53. aesKey: z.string().max(32, 'aes秘钥最多32个字符').nullable().optional().openapi({
  54. description: 'aes秘钥',
  55. example: 'a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6'
  56. }),
  57. createdAt: z.coerce.date().openapi({
  58. description: '创建时间',
  59. example: '2024-01-01T12:00:00Z'
  60. }),
  61. updatedAt: z.coerce.date().openapi({
  62. description: '更新时间',
  63. example: '2024-01-01T12:00:00Z'
  64. }),
  65. createdBy: z.number().int().positive().nullable().openapi({
  66. description: '创建用户ID',
  67. example: 1
  68. }),
  69. updatedBy: z.number().int().positive().nullable().openapi({
  70. description: '更新用户ID',
  71. example: 1
  72. })
  73. });
  74. export const CreateMerchantDtoMt = z.object({
  75. tenantId: z.number().int().positive().openapi({ description: '租户ID' }),
  76. name: z.string().min(1, '商户名称不能为空').max(255, '商户名称最多255个字符').nullable().optional().openapi({
  77. description: '商户名称',
  78. example: '商户A'
  79. }),
  80. username: z.string().min(1, '用户名不能为空').max(20, '用户名最多20个字符').openapi({
  81. description: '用户名',
  82. example: 'merchant001'
  83. }),
  84. password: z.string().min(6, '密码至少6位').max(255, '密码最多255位').openapi({
  85. description: '密码',
  86. example: 'password123'
  87. }),
  88. phone: z.string().regex(/^1[3-9]\d{9}$/, '请输入正确的手机号').nullable().optional().openapi({
  89. description: '手机号码',
  90. example: '13800138000'
  91. }),
  92. realname: z.string().max(20, '姓名最多20个字符').nullable().optional().openapi({
  93. description: '姓名',
  94. example: '李四'
  95. }),
  96. state: z.number().int().min(1).max(2).default(2).openapi({
  97. description: '状态 1启用 2禁用',
  98. example: 1
  99. }),
  100. rsaPublicKey: z.string().max(2000, '公钥最多2000个字符').nullable().optional().openapi({
  101. description: '公钥',
  102. example: '-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA...\n-----END PUBLIC KEY-----'
  103. }),
  104. aesKey: z.string().max(32, 'aes秘钥最多32个字符').nullable().optional().openapi({
  105. description: 'aes秘钥',
  106. example: 'a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6'
  107. })
  108. });
  109. export const UpdateMerchantDtoMt = z.object({
  110. tenantId: z.number().int().positive().optional().openapi({ description: '租户ID' }),
  111. name: z.string().min(1, '商户名称不能为空').max(255, '商户名称最多255个字符').nullable().optional().openapi({
  112. description: '商户名称',
  113. example: '商户A'
  114. }),
  115. username: z.string().min(1, '用户名不能为空').max(20, '用户名最多20个字符').optional().openapi({
  116. description: '用户名',
  117. example: 'merchant001'
  118. }),
  119. password: z.string().min(6, '密码至少6位').max(255, '密码最多255位').optional().openapi({
  120. description: '密码',
  121. example: 'password123'
  122. }),
  123. phone: z.string().regex(/^1[3-9]\d{9}$/, '请输入正确的手机号').nullable().optional().openapi({
  124. description: '手机号码',
  125. example: '13800138000'
  126. }),
  127. realname: z.string().max(20, '姓名最多20个字符').nullable().optional().openapi({
  128. description: '姓名',
  129. example: '李四'
  130. }),
  131. state: z.number().int().min(1).max(2).optional().openapi({
  132. description: '状态 1启用 2禁用',
  133. example: 1
  134. }),
  135. rsaPublicKey: z.string().max(2000, '公钥最多2000个字符').nullable().optional().openapi({
  136. description: '公钥',
  137. example: '-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA...\n-----END PUBLIC KEY-----'
  138. }),
  139. aesKey: z.string().max(32, 'aes秘钥最多32个字符').nullable().optional().openapi({
  140. description: 'aes秘钥',
  141. example: 'a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6'
  142. })
  143. });