| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- import { Entity, PrimaryGeneratedColumn, Column, Index } from 'typeorm';
- import { z } from '@hono/zod-openapi';
- @Entity('area_data')
- export class AreaData {
- @PrimaryGeneratedColumn({ unsigned: true })
- id!: number;
- @Column({ name: 'parent_id', type: 'int', unsigned: true, nullable: true })
- parentId?: number;
- @Column({ name: 'name', type: 'varchar', length: 100 })
- name!: string;
- @Column({ name: 'created_at', type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' })
- createdAt!: Date;
- @Column({
- name: 'updated_at',
- type: 'timestamp',
- default: () => 'CURRENT_TIMESTAMP',
- onUpdate: 'CURRENT_TIMESTAMP'
- })
- updatedAt!: Date;
- }
- export const AreaDataSchema = z.object({
- id: z.number().int().positive().openapi({
- description: '区域ID',
- example: 1
- }),
- parentId: z.number().int().positive().nullable().openapi({
- description: '父区域ID,自引用',
- example: 0
- }),
- name: z.string().max(100).openapi({
- description: '区域名称',
- example: '北京市'
- }),
- createdAt: z.date().openapi({
- description: '创建时间',
- example: '2023-01-01T00:00:00Z'
- }),
- updatedAt: z.date().openapi({
- description: '更新时间',
- example: '2023-01-01T00:00:00Z'
- })
- });
- export const CreateAreaDataDto = z.object({
- parentId: z.number().int().positive().nullable().openapi({
- description: '父区域ID,自引用',
- example: 0
- }),
- name: z.string().max(100).openapi({
- description: '区域名称',
- example: '北京市'
- })
- });
- export const UpdateAreaDataDto = z.object({
- parentId: z.number().int().positive().nullable().optional().openapi({
- description: '父区域ID,自引用',
- example: 0
- }),
- name: z.string().max(100).optional().openapi({
- description: '区域名称',
- example: '北京市'
- })
- });
|