|
@@ -1,12 +1,5 @@
|
|
|
import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn } from 'typeorm';
|
|
import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn } from 'typeorm';
|
|
|
-import { z } from '@hono/zod-openapi';
|
|
|
|
|
-
|
|
|
|
|
-export enum MembershipType {
|
|
|
|
|
- SINGLE = 'single',
|
|
|
|
|
- MONTHLY = 'monthly',
|
|
|
|
|
- YEARLY = 'yearly',
|
|
|
|
|
- LIFETIME = 'lifetime'
|
|
|
|
|
-}
|
|
|
|
|
|
|
+import { MembershipType } from './membership-plan.schema';
|
|
|
|
|
|
|
|
@Entity('membership_plans')
|
|
@Entity('membership_plans')
|
|
|
export class MembershipPlan {
|
|
export class MembershipPlan {
|
|
@@ -48,40 +41,3 @@ export class MembershipPlan {
|
|
|
@UpdateDateColumn({ name: 'updated_at' })
|
|
@UpdateDateColumn({ name: 'updated_at' })
|
|
|
updatedAt!: Date;
|
|
updatedAt!: Date;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
-// Zod Schema定义
|
|
|
|
|
-export const MembershipPlanSchema = z.object({
|
|
|
|
|
- id: z.number().int().positive().openapi({ description: '套餐ID', example: 1 }),
|
|
|
|
|
- name: z.string().max(100).openapi({ description: '套餐名称', example: '单次会员' }),
|
|
|
|
|
- type: z.nativeEnum(MembershipType).openapi({ description: '套餐类型', example: MembershipType.SINGLE }),
|
|
|
|
|
- price: z.number().multipleOf(0.01).openapi({ description: '价格', example: 27.00 }),
|
|
|
|
|
- durationDays: z.number().int().min(0).openapi({ description: '有效期天数', example: 1 }),
|
|
|
|
|
- description: z.string().nullable().openapi({ description: '套餐描述', example: '24小时有效' }),
|
|
|
|
|
- features: z.array(z.string()).openapi({ description: '套餐功能', example: ['基础功能', '24小时使用'] }),
|
|
|
|
|
- isActive: z.number().int().min(0).max(1).openapi({ description: '是否启用', example: 1 }),
|
|
|
|
|
- sortOrder: z.number().int().openapi({ description: '排序', example: 0 }),
|
|
|
|
|
- createdAt: z.date().openapi({ description: '创建时间' }),
|
|
|
|
|
- updatedAt: z.date().openapi({ description: '更新时间' })
|
|
|
|
|
-});
|
|
|
|
|
-
|
|
|
|
|
-export const CreateMembershipPlanDto = z.object({
|
|
|
|
|
- name: z.string().max(100).openapi({ description: '套餐名称', example: '单次会员' }),
|
|
|
|
|
- type: z.nativeEnum(MembershipType).openapi({ description: '套餐类型', example: MembershipType.SINGLE }),
|
|
|
|
|
- price: z.number().multipleOf(0.01).positive().openapi({ description: '价格', example: 27.00 }),
|
|
|
|
|
- durationDays: z.number().int().min(0).openapi({ description: '有效期天数', example: 1 }),
|
|
|
|
|
- description: z.string().nullable().optional().openapi({ description: '套餐描述', example: '24小时有效' }),
|
|
|
|
|
- features: z.array(z.string()).optional().default([]).openapi({ description: '套餐功能', example: ['基础功能'] }),
|
|
|
|
|
- isActive: z.number().int().min(0).max(1).optional().default(1).openapi({ description: '是否启用', example: 1 }),
|
|
|
|
|
- sortOrder: z.number().int().optional().default(0).openapi({ description: '排序', example: 0 })
|
|
|
|
|
-});
|
|
|
|
|
-
|
|
|
|
|
-export const UpdateMembershipPlanDto = z.object({
|
|
|
|
|
- name: z.string().max(100).optional().openapi({ description: '套餐名称', example: '单次会员' }),
|
|
|
|
|
- type: z.nativeEnum(MembershipType).optional().openapi({ description: '套餐类型', example: MembershipType.SINGLE }),
|
|
|
|
|
- price: z.number().multipleOf(0.01).positive().optional().openapi({ description: '价格', example: 27.00 }),
|
|
|
|
|
- durationDays: z.number().int().min(0).optional().openapi({ description: '有效期天数', example: 1 }),
|
|
|
|
|
- description: z.string().nullable().optional().openapi({ description: '套餐描述', example: '24小时有效' }),
|
|
|
|
|
- features: z.array(z.string()).optional().openapi({ description: '套餐功能', example: ['基础功能'] }),
|
|
|
|
|
- isActive: z.number().int().min(0).max(1).optional().openapi({ description: '是否启用', example: 1 }),
|
|
|
|
|
- sortOrder: z.number().int().optional().openapi({ description: '排序', example: 0 })
|
|
|
|
|
-});
|
|
|