|
|
@@ -0,0 +1,143 @@
|
|
|
+import { z } from '@hono/zod-openapi';
|
|
|
+
|
|
|
+export const MerchantSchema = z.object({
|
|
|
+ id: z.number().int().positive().openapi({ description: '商户ID' }),
|
|
|
+ name: z.string().min(1, '商户名称不能为空').max(255, '商户名称最多255个字符').nullable().openapi({
|
|
|
+ description: '商户名称',
|
|
|
+ example: '商户A'
|
|
|
+ }),
|
|
|
+ username: z.string().min(1, '用户名不能为空').max(20, '用户名最多20个字符').openapi({
|
|
|
+ description: '用户名',
|
|
|
+ example: 'merchant001'
|
|
|
+ }),
|
|
|
+ password: z.string().min(6, '密码至少6位').max(255, '密码最多255位').openapi({
|
|
|
+ description: '密码',
|
|
|
+ example: 'password123'
|
|
|
+ }),
|
|
|
+ phone: z.string().regex(/^1[3-9]\d{9}$/, '请输入正确的手机号').nullable().optional().openapi({
|
|
|
+ description: '手机号码',
|
|
|
+ example: '13800138000'
|
|
|
+ }),
|
|
|
+ realname: z.string().max(20, '姓名最多20个字符').nullable().optional().openapi({
|
|
|
+ description: '姓名',
|
|
|
+ example: '李四'
|
|
|
+ }),
|
|
|
+ loginNum: z.number().int().nonnegative('登录次数必须为非负数').default(0).openapi({
|
|
|
+ description: '登录次数',
|
|
|
+ example: 0
|
|
|
+ }),
|
|
|
+ loginTime: z.number().int().nonnegative('登录时间必须为非负数').default(0).openapi({
|
|
|
+ description: '登录时间',
|
|
|
+ example: 0
|
|
|
+ }),
|
|
|
+ loginIp: z.string().max(15, 'IP地址最多15个字符').nullable().optional().openapi({
|
|
|
+ description: '登录IP',
|
|
|
+ example: '192.168.1.1'
|
|
|
+ }),
|
|
|
+ lastLoginTime: z.number().int().nonnegative('上次登录时间必须为非负数').default(0).openapi({
|
|
|
+ description: '上次登录时间',
|
|
|
+ example: 0
|
|
|
+ }),
|
|
|
+ lastLoginIp: z.string().max(15, 'IP地址最多15个字符').nullable().optional().openapi({
|
|
|
+ description: '上次登录IP',
|
|
|
+ example: '192.168.1.1'
|
|
|
+ }),
|
|
|
+ state: z.number().int().min(1).max(2).default(2).openapi({
|
|
|
+ description: '状态 1启用 2禁用',
|
|
|
+ example: 1
|
|
|
+ }),
|
|
|
+ rsaPublicKey: z.string().max(2000, '公钥最多2000个字符').nullable().optional().openapi({
|
|
|
+ description: '公钥',
|
|
|
+ example: '-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA...\n-----END PUBLIC KEY-----'
|
|
|
+ }),
|
|
|
+ aesKey: z.string().max(32, 'aes秘钥最多32个字符').nullable().optional().openapi({
|
|
|
+ description: 'aes秘钥',
|
|
|
+ example: 'a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6'
|
|
|
+ }),
|
|
|
+ createdAt: z.coerce.date().openapi({
|
|
|
+ description: '创建时间',
|
|
|
+ example: '2024-01-01T12:00:00Z'
|
|
|
+ }),
|
|
|
+ updatedAt: z.coerce.date().openapi({
|
|
|
+ description: '更新时间',
|
|
|
+ example: '2024-01-01T12:00:00Z'
|
|
|
+ }),
|
|
|
+ createdBy: z.number().int().positive().nullable().openapi({
|
|
|
+ description: '创建用户ID',
|
|
|
+ example: 1
|
|
|
+ }),
|
|
|
+ updatedBy: z.number().int().positive().nullable().openapi({
|
|
|
+ description: '更新用户ID',
|
|
|
+ example: 1
|
|
|
+ })
|
|
|
+});
|
|
|
+
|
|
|
+export const CreateMerchantDto = z.object({
|
|
|
+ name: z.string().min(1, '商户名称不能为空').max(255, '商户名称最多255个字符').nullable().optional().openapi({
|
|
|
+ description: '商户名称',
|
|
|
+ example: '商户A'
|
|
|
+ }),
|
|
|
+ username: z.string().min(1, '用户名不能为空').max(20, '用户名最多20个字符').openapi({
|
|
|
+ description: '用户名',
|
|
|
+ example: 'merchant001'
|
|
|
+ }),
|
|
|
+ password: z.string().min(6, '密码至少6位').max(255, '密码最多255位').openapi({
|
|
|
+ description: '密码',
|
|
|
+ example: 'password123'
|
|
|
+ }),
|
|
|
+ phone: z.string().regex(/^1[3-9]\d{9}$/, '请输入正确的手机号').nullable().optional().openapi({
|
|
|
+ description: '手机号码',
|
|
|
+ example: '13800138000'
|
|
|
+ }),
|
|
|
+ realname: z.string().max(20, '姓名最多20个字符').nullable().optional().openapi({
|
|
|
+ description: '姓名',
|
|
|
+ example: '李四'
|
|
|
+ }),
|
|
|
+ state: z.number().int().min(1).max(2).default(2).openapi({
|
|
|
+ description: '状态 1启用 2禁用',
|
|
|
+ example: 1
|
|
|
+ }),
|
|
|
+ rsaPublicKey: z.string().max(2000, '公钥最多2000个字符').nullable().optional().openapi({
|
|
|
+ description: '公钥',
|
|
|
+ example: '-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA...\n-----END PUBLIC KEY-----'
|
|
|
+ }),
|
|
|
+ aesKey: z.string().max(32, 'aes秘钥最多32个字符').nullable().optional().openapi({
|
|
|
+ description: 'aes秘钥',
|
|
|
+ example: 'a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6'
|
|
|
+ })
|
|
|
+});
|
|
|
+
|
|
|
+export const UpdateMerchantDto = z.object({
|
|
|
+ name: z.string().min(1, '商户名称不能为空').max(255, '商户名称最多255个字符').nullable().optional().openapi({
|
|
|
+ description: '商户名称',
|
|
|
+ example: '商户A'
|
|
|
+ }),
|
|
|
+ username: z.string().min(1, '用户名不能为空').max(20, '用户名最多20个字符').optional().openapi({
|
|
|
+ description: '用户名',
|
|
|
+ example: 'merchant001'
|
|
|
+ }),
|
|
|
+ password: z.string().min(6, '密码至少6位').max(255, '密码最多255位').optional().openapi({
|
|
|
+ description: '密码',
|
|
|
+ example: 'password123'
|
|
|
+ }),
|
|
|
+ phone: z.string().regex(/^1[3-9]\d{9}$/, '请输入正确的手机号').nullable().optional().openapi({
|
|
|
+ description: '手机号码',
|
|
|
+ example: '13800138000'
|
|
|
+ }),
|
|
|
+ realname: z.string().max(20, '姓名最多20个字符').nullable().optional().openapi({
|
|
|
+ description: '姓名',
|
|
|
+ example: '李四'
|
|
|
+ }),
|
|
|
+ state: z.number().int().min(1).max(2).optional().openapi({
|
|
|
+ description: '状态 1启用 2禁用',
|
|
|
+ example: 1
|
|
|
+ }),
|
|
|
+ rsaPublicKey: z.string().max(2000, '公钥最多2000个字符').nullable().optional().openapi({
|
|
|
+ description: '公钥',
|
|
|
+ example: '-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA...\n-----END PUBLIC KEY-----'
|
|
|
+ }),
|
|
|
+ aesKey: z.string().max(32, 'aes秘钥最多32个字符').nullable().optional().openapi({
|
|
|
+ description: 'aes秘钥',
|
|
|
+ example: 'a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6'
|
|
|
+ })
|
|
|
+});
|