diff --git a/src/app.module.ts b/src/app.module.ts index 98fb3dd..32bea0f 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -6,6 +6,7 @@ import { AppController } from './app.controller'; import { AlarmsModule } from './alarms/alarms.module'; import { ScheduleModule } from './schedules/schedule.module'; import { UserModule } from './users/user.module'; +import { DiariesModule } from './diaries/diary.module'; @Module({ imports: [ @@ -29,6 +30,7 @@ import { UserModule } from './users/user.module'; AlarmsModule, ScheduleModule, UserModule, + DiariesModule, ], controllers: [AppController], providers: [], diff --git a/src/diaries/diary.module.ts b/src/diaries/diary.module.ts new file mode 100644 index 0000000..6051d43 --- /dev/null +++ b/src/diaries/diary.module.ts @@ -0,0 +1,18 @@ +import { Module } from '@nestjs/common'; +import { TypeOrmModule } from '@nestjs/typeorm'; + +import { DiaryEntity } from './entities/diary.entity'; +import { DiaryImageEntity } from './entities/diary-image.entity'; +import { RecommendEntity } from './entities/recommend.entity'; + +@Module({ + imports: [ + TypeOrmModule.forFeature([ + DiaryEntity, + DiaryImageEntity, + RecommendEntity, + ]), + ], + exports: [TypeOrmModule], +}) +export class DiariesModule {} \ No newline at end of file diff --git a/src/diaries/entities/diary-image.entity.ts b/src/diaries/entities/diary-image.entity.ts new file mode 100644 index 0000000..013d610 --- /dev/null +++ b/src/diaries/entities/diary-image.entity.ts @@ -0,0 +1,28 @@ +import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm'; +import { SoftDeleteModel } from '../../global/base-model'; + +@Entity('diary_image') +export class DiaryImageEntity extends SoftDeleteModel { + @PrimaryGeneratedColumn({ + name: 'diary_image_id', + type: 'int', + }) + diaryImageId: number; + + @Column({ + name: 'diary_id', + type: 'int', + nullable: false, + comment: '일기 아이디', + }) + diaryId: number; + + @Column({ + name: 'image_url', + type: 'varchar', + length: 200, + nullable: false, + comment: '이미지 주소(S3 URL)', + }) + imageUrl: string; +} \ No newline at end of file diff --git a/src/diaries/entities/diary.entity.ts b/src/diaries/entities/diary.entity.ts new file mode 100644 index 0000000..6861d66 --- /dev/null +++ b/src/diaries/entities/diary.entity.ts @@ -0,0 +1,50 @@ +import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm'; +import { SoftDeleteModel } from '../../global/base-model'; +import { DiaryType } from '../enums/diary-type.enum'; + +@Entity('diary') +export class DiaryEntity extends SoftDeleteModel { + @PrimaryGeneratedColumn({ + name: 'diary_id', + type: 'int', + }) + diaryId: number; + + @Column({ + name: 'user_id', + type: 'int', + comment: '사용자 아이디', + }) + userId: number; + + @Column({ + name: 'diary_type', + type: 'enum', + enum: DiaryType, + enumName: 'diary_type_enum', + comment: '일기 유형', + }) + diaryType: DiaryType; + + @Column({ + name: 'diary_title', + type: 'varchar', + length: 50, + comment: '일기 제목', + }) + diaryTitle: string; + + @Column({ + type: 'text', + comment: '일기 내용', + }) + content: string; + + @Column({ + name: 'ai_summary', + type: 'text', + nullable: true, + comment: 'AI 일기 요약', + }) + aiSummary: string | null; +} \ No newline at end of file diff --git a/src/diaries/entities/recommend.entity.ts b/src/diaries/entities/recommend.entity.ts new file mode 100644 index 0000000..29be104 --- /dev/null +++ b/src/diaries/entities/recommend.entity.ts @@ -0,0 +1,43 @@ +import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm'; +import { BaseModel } from '../../global/base-model'; + +@Entity('recommend') +export class RecommendEntity extends BaseModel { + @PrimaryGeneratedColumn({ + name: 'recommend_id', + type: 'int', + }) + recommendId: number; + + @Column({ + name: 'category_id', + type: 'int', + nullable: false, + comment: '카테고리 아이디', + }) + categoryId: number; + + @Column({ + name: 'diary_id', + type: 'int', + nullable: false, + comment: '일기 아이디', + }) + diaryId: number; + + @Column({ + type: 'varchar', + length: 50, + nullable: false, + comment: '추천 일정 제목', + }) + title: string; + + @Column({ + name: 'is_added', + type: 'boolean', + nullable: false, + comment: '일정 추가 여부', + }) + isAdded: boolean; +} \ No newline at end of file diff --git a/src/diaries/enums/diary-type.enum.ts b/src/diaries/enums/diary-type.enum.ts new file mode 100644 index 0000000..f5274a8 --- /dev/null +++ b/src/diaries/enums/diary-type.enum.ts @@ -0,0 +1,4 @@ +export enum DiaryType { + QUESTION = 'QUESTION', + FREE = 'FREE', +} \ No newline at end of file