|
|
@@ -0,0 +1,99 @@
|
|
|
+import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn } from 'typeorm';
|
|
|
+import { z } from '@hono/zod-openapi';
|
|
|
+
|
|
|
+@Entity('elderly_universities')
|
|
|
+export class ElderlyUniversity {
|
|
|
+ @PrimaryGeneratedColumn({ unsigned: true })
|
|
|
+ id!: number;
|
|
|
+
|
|
|
+ @Column({ name: 'school_name', type: 'varchar', length: 255, comment: '学校名称' })
|
|
|
+ schoolName!: string;
|
|
|
+
|
|
|
+ @Column({ name: 'school_introduction', type: 'text', comment: '学校简介' })
|
|
|
+ schoolIntroduction!: string;
|
|
|
+
|
|
|
+ @Column({ name: 'teacher_resources', type: 'text', comment: '师资力量介绍' })
|
|
|
+ teacherResources!: string;
|
|
|
+
|
|
|
+ @Column({ name: 'course_count', type: 'int', unsigned: true, default: 0, comment: '课程数量' })
|
|
|
+ courseCount!: number;
|
|
|
+
|
|
|
+ @Column({ name: 'course_types', type: 'text', comment: '课程类型,多个类型用逗号分隔' })
|
|
|
+ courseTypes!: string;
|
|
|
+
|
|
|
+ @Column({ name: 'class_schedule', type: 'varchar', length: 500, comment: '上课时间' })
|
|
|
+ classSchedule!: string;
|
|
|
+
|
|
|
+ @Column({ name: 'contact_teacher', type: 'varchar', length: 100, comment: '联系老师' })
|
|
|
+ contactTeacher!: string;
|
|
|
+
|
|
|
+ @Column({ name: 'contact_phone', type: 'varchar', length: 20, comment: '联系电话' })
|
|
|
+ contactPhone!: string;
|
|
|
+
|
|
|
+ @Column({ name: 'school_address', type: 'varchar', length: 500, comment: '学校地址' })
|
|
|
+ schoolAddress!: string;
|
|
|
+
|
|
|
+ @Column({ name: 'favorite_count', type: 'int', unsigned: true, default: 0, comment: '收藏数' })
|
|
|
+ favoriteCount!: number;
|
|
|
+
|
|
|
+ @Column({ name: 'view_count', type: 'int', unsigned: true, default: 0, comment: '阅读数' })
|
|
|
+ viewCount!: number;
|
|
|
+
|
|
|
+ @Column({ name: 'like_count', type: 'int', unsigned: true, default: 0, comment: '点赞数' })
|
|
|
+ likeCount!: number;
|
|
|
+
|
|
|
+ @Column({ name: 'is_deleted', type: 'tinyint', default: 0, comment: '删除状态 0:未删除 1:已删除' })
|
|
|
+ isDeleted!: number;
|
|
|
+
|
|
|
+ @CreateDateColumn({ name: 'created_at' })
|
|
|
+ createdAt!: Date;
|
|
|
+
|
|
|
+ @UpdateDateColumn({ name: 'updated_at' })
|
|
|
+ updatedAt!: Date;
|
|
|
+}
|
|
|
+
|
|
|
+// 基础Schema定义
|
|
|
+export const ElderlyUniversitySchema = z.object({
|
|
|
+ id: z.number().int().positive().openapi({ description: '学校ID', example: 1 }),
|
|
|
+ schoolName: z.string().max(255).openapi({ description: '学校名称', example: '北京市老年大学' }),
|
|
|
+ schoolIntroduction: z.string().openapi({ description: '学校简介', example: '北京市老年大学成立于1985年,致力于为老年人提供优质教育服务...' }),
|
|
|
+ teacherResources: z.string().openapi({ description: '师资力量', example: '拥有专业教师50余人,其中教授10人,副教授20人...' }),
|
|
|
+ courseCount: z.coerce.number().int().min(0).openapi({ description: '课程数量', example: 25 }),
|
|
|
+ courseTypes: z.string().openapi({ description: '课程类型,多个用逗号分隔', example: '书法,绘画,舞蹈,音乐,计算机' }),
|
|
|
+ classSchedule: z.string().max(500).openapi({ description: '上课时间', example: '周一至周五 上午9:00-11:30,下午14:00-16:30' }),
|
|
|
+ contactTeacher: z.string().max(100).openapi({ description: '联系老师', example: '张老师' }),
|
|
|
+ contactPhone: z.string().max(20).openapi({ description: '联系电话', example: '010-12345678' }),
|
|
|
+ schoolAddress: z.string().max(500).openapi({ description: '学校地址', example: '北京市朝阳区某某街道123号' }),
|
|
|
+ favoriteCount: z.coerce.number().int().min(0).openapi({ description: '收藏数', example: 156 }),
|
|
|
+ viewCount: z.coerce.number().int().min(0).openapi({ description: '阅读数', example: 2345 }),
|
|
|
+ likeCount: z.coerce.number().int().min(0).openapi({ description: '点赞数', example: 89 }),
|
|
|
+ isDeleted: z.coerce.number().int().min(0).max(1).openapi({ description: '删除状态', example: 0 }),
|
|
|
+ createdAt: z.date().openapi({ description: '创建时间', example: '2024-01-15T08:00:00Z' }),
|
|
|
+ updatedAt: z.date().openapi({ description: '更新时间', example: '2024-01-15T08:00:00Z' })
|
|
|
+});
|
|
|
+
|
|
|
+// 创建DTO
|
|
|
+export const CreateElderlyUniversityDto = z.object({
|
|
|
+ schoolName: z.string().max(255).openapi({ description: '学校名称', example: '北京市老年大学' }),
|
|
|
+ schoolIntroduction: z.string().openapi({ description: '学校简介', example: '北京市老年大学成立于1985年...' }),
|
|
|
+ teacherResources: z.string().openapi({ description: '师资力量', example: '拥有专业教师50余人...' }),
|
|
|
+ courseCount: z.coerce.number().int().min(0).optional().default(0).openapi({ description: '课程数量', example: 25 }),
|
|
|
+ courseTypes: z.string().openapi({ description: '课程类型,多个用逗号分隔', example: '书法,绘画,舞蹈,音乐,计算机' }),
|
|
|
+ classSchedule: z.string().max(500).openapi({ description: '上课时间', example: '周一至周五 上午9:00-11:30...' }),
|
|
|
+ contactTeacher: z.string().max(100).openapi({ description: '联系老师', example: '张老师' }),
|
|
|
+ contactPhone: z.string().max(20).openapi({ description: '联系电话', example: '010-12345678' }),
|
|
|
+ schoolAddress: z.string().max(500).openapi({ description: '学校地址', example: '北京市朝阳区某某街道123号' })
|
|
|
+});
|
|
|
+
|
|
|
+// 更新DTO
|
|
|
+export const UpdateElderlyUniversityDto = z.object({
|
|
|
+ schoolName: z.string().max(255).optional().openapi({ description: '学校名称', example: '北京市老年大学' }),
|
|
|
+ schoolIntroduction: z.string().optional().openapi({ description: '学校简介', example: '北京市老年大学成立于1985年...' }),
|
|
|
+ teacherResources: z.string().optional().openapi({ description: '师资力量', example: '拥有专业教师50余人...' }),
|
|
|
+ courseCount: z.coerce.number().int().min(0).optional().openapi({ description: '课程数量', example: 30 }),
|
|
|
+ courseTypes: z.string().optional().openapi({ description: '课程类型,多个用逗号分隔', example: '书法,绘画,舞蹈,音乐,计算机' }),
|
|
|
+ classSchedule: z.string().max(500).optional().openapi({ description: '上课时间', example: '周一至周五 上午9:00-11:30...' }),
|
|
|
+ contactTeacher: z.string().max(100).optional().openapi({ description: '联系老师', example: '张老师' }),
|
|
|
+ contactPhone: z.string().max(20).optional().openapi({ description: '联系电话', example: '010-12345678' }),
|
|
|
+ schoolAddress: z.string().max(500).optional().openapi({ description: '学校地址', example: '北京市朝阳区某某街道123号' })
|
|
|
+});
|