-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ feat: 시도, 구군, 음식 카테고리, 피드, 피드 좋아요 entity,repository 추가 (#22)
- Loading branch information
1 parent
fa7f671
commit fc07bee
Showing
14 changed files
with
279 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { Entity, JoinColumn, ManyToOne, PrimaryColumn } from "typeorm"; | ||
|
||
import { ArticleEntity } from "./article.entity"; | ||
import { MemberEntity } from "./member.entity"; | ||
|
||
@Entity("article_likes") | ||
export class ArticleLikeEntity { | ||
@PrimaryColumn({ type: "int" }) | ||
articleId!: number; | ||
|
||
@ManyToOne(() => ArticleEntity, (article) => article.articleLikes) | ||
@JoinColumn({ name: "articleId", referencedColumnName: "id" }) | ||
article!: ArticleEntity; | ||
|
||
@PrimaryColumn({ type: "int" }) | ||
memberId!: number; | ||
|
||
@ManyToOne(() => MemberEntity, (member) => member.articleLikes) | ||
@JoinColumn({ name: "memberId", referencedColumnName: "id" }) | ||
member!: MemberEntity; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { | ||
Column, | ||
CreateDateColumn, | ||
Entity, | ||
JoinColumn, | ||
ManyToOne, | ||
OneToMany, | ||
PrimaryGeneratedColumn, | ||
UpdateDateColumn, | ||
} from "typeorm"; | ||
|
||
import { ArticleLikeEntity } from "./article-like.entity"; | ||
import { CategoryEntity } from "./category.entity"; | ||
import { DistrictEntity } from "./district.entity"; | ||
import { MemberEntity } from "./member.entity"; | ||
import { RegionEntity } from "./region.entity"; | ||
|
||
@Entity("articles") | ||
export class ArticleEntity { | ||
@PrimaryGeneratedColumn({ type: "int" }) | ||
id!: number; | ||
|
||
@Column({ type: "varchar", length: 100 }) | ||
title!: string; | ||
|
||
@Column({ type: "text" }) | ||
content!: string; | ||
|
||
@Column({ type: "datetime" }) | ||
startTime!: Date; | ||
|
||
@Column({ type: "datetime" }) | ||
endTime!: Date; | ||
|
||
@Column({ type: "int" }) | ||
memberId!: number; | ||
|
||
@ManyToOne(() => MemberEntity, (member) => member.articles) | ||
@JoinColumn({ name: "memberId", referencedColumnName: "id" }) | ||
member!: MemberEntity; | ||
|
||
@Column({ type: "int" }) | ||
categoryId!: number; | ||
|
||
@ManyToOne(() => CategoryEntity, (category) => category.articles) | ||
@JoinColumn({ name: "categoryId", referencedColumnName: "id" }) | ||
category!: CategoryEntity; | ||
|
||
@Column({ type: "int" }) | ||
regionId!: number; | ||
|
||
@ManyToOne(() => RegionEntity, (region) => region.articles) | ||
@JoinColumn({ name: "regionId", referencedColumnName: "id" }) | ||
region!: RegionEntity; | ||
|
||
@Column({ type: "int" }) | ||
districtId!: number; | ||
|
||
@ManyToOne(() => DistrictEntity, (district) => district.articles) | ||
@JoinColumn({ name: "districtId", referencedColumnName: "id" }) | ||
district!: DistrictEntity; | ||
|
||
@OneToMany(() => ArticleLikeEntity, (articleLike) => articleLike.article) | ||
articleLikes!: ArticleLikeEntity[]; | ||
|
||
@CreateDateColumn({ type: "timestamp", nullable: false }) | ||
createdAt!: Date; | ||
|
||
@UpdateDateColumn({ type: "timestamp", nullable: false }) | ||
updatedAt!: Date; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from "typeorm"; | ||
|
||
import { ArticleEntity } from "./article.entity"; | ||
|
||
@Entity("category") | ||
export class CategoryEntity { | ||
@PrimaryGeneratedColumn({ type: "int" }) | ||
id!: number; | ||
|
||
@Column({ type: "varchar", length: 50 }) | ||
name!: string; | ||
|
||
@OneToMany(() => ArticleEntity, (article) => article.category) | ||
articles!: ArticleEntity[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { | ||
Column, | ||
Entity, | ||
JoinColumn, | ||
ManyToOne, | ||
OneToMany, | ||
PrimaryGeneratedColumn, | ||
} from "typeorm"; | ||
|
||
import { ArticleEntity } from "./article.entity"; | ||
import { RegionEntity } from "./region.entity"; | ||
|
||
@Entity("district") | ||
export class DistrictEntity { | ||
@PrimaryGeneratedColumn({ type: "int" }) | ||
id!: number; | ||
|
||
@Column({ type: "varchar", length: 50 }) | ||
name!: string; | ||
|
||
@Column({ type: "int" }) | ||
regionId!: number; | ||
|
||
@ManyToOne(() => RegionEntity, (region) => region.districts) | ||
@JoinColumn({ name: "regionId", referencedColumnName: "id" }) | ||
region!: RegionEntity; | ||
|
||
@OneToMany(() => ArticleEntity, (article) => article.district) | ||
articles!: ArticleEntity[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from "typeorm"; | ||
|
||
import { ArticleEntity } from "./article.entity"; | ||
import { DistrictEntity } from "./district.entity"; | ||
|
||
@Entity("region") | ||
export class RegionEntity { | ||
@PrimaryGeneratedColumn({ type: "int" }) | ||
id!: number; | ||
|
||
@Column({ type: "varchar", length: 50 }) | ||
name!: string; | ||
|
||
@OneToMany(() => DistrictEntity, (district) => district.region) | ||
districts!: DistrictEntity[]; | ||
|
||
@OneToMany(() => ArticleEntity, (article) => article.region) | ||
articles!: ArticleEntity[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { Injectable } from "@nestjs/common"; | ||
import { InjectRepository } from "@nestjs/typeorm"; | ||
import { QueryRunner, Repository } from "typeorm"; | ||
|
||
import { ArticleLikeEntity } from "@APP/entities/article-like.entity"; | ||
|
||
@Injectable() | ||
export class ArticleLikesRepository extends Repository<ArticleLikeEntity> { | ||
constructor( | ||
@InjectRepository(ArticleLikeEntity) | ||
private readonly repository: Repository<ArticleLikeEntity>, | ||
) { | ||
super(repository.target, repository.manager, repository.queryRunner); | ||
} | ||
|
||
getRepository(qr?: QueryRunner) { | ||
return qr | ||
? qr.manager.getRepository<ArticleLikeEntity>(ArticleLikeEntity) | ||
: this.repository; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { Injectable } from "@nestjs/common"; | ||
import { InjectRepository } from "@nestjs/typeorm"; | ||
import { QueryRunner, Repository } from "typeorm"; | ||
|
||
import { ArticleEntity } from "@APP/entities/article.entity"; | ||
|
||
@Injectable() | ||
export class ArticlesRepository extends Repository<ArticleEntity> { | ||
constructor( | ||
@InjectRepository(ArticleEntity) | ||
private readonly repository: Repository<ArticleEntity>, | ||
) { | ||
super(repository.target, repository.manager, repository.queryRunner); | ||
} | ||
|
||
getRepository(qr?: QueryRunner) { | ||
return qr | ||
? qr.manager.getRepository<ArticleEntity>(ArticleEntity) | ||
: this.repository; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { Injectable } from "@nestjs/common"; | ||
import { InjectRepository } from "@nestjs/typeorm"; | ||
import { QueryRunner, Repository } from "typeorm"; | ||
|
||
import { CategoryEntity } from "@APP/entities/category.entity"; | ||
|
||
@Injectable() | ||
export class CategoriesRepository extends Repository<CategoryEntity> { | ||
constructor( | ||
@InjectRepository(CategoryEntity) | ||
private readonly repository: Repository<CategoryEntity>, | ||
) { | ||
super(repository.target, repository.manager, repository.queryRunner); | ||
} | ||
|
||
getRepository(qr?: QueryRunner) { | ||
return qr | ||
? qr.manager.getRepository<CategoryEntity>(CategoryEntity) | ||
: this.repository; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { Injectable } from "@nestjs/common"; | ||
import { InjectRepository } from "@nestjs/typeorm"; | ||
import { QueryRunner, Repository } from "typeorm"; | ||
|
||
import { DistrictEntity } from "@APP/entities/district.entity"; | ||
|
||
@Injectable() | ||
export class DistrictsRepository extends Repository<DistrictEntity> { | ||
constructor( | ||
@InjectRepository(DistrictEntity) | ||
private readonly repository: Repository<DistrictEntity>, | ||
) { | ||
super(repository.target, repository.manager, repository.queryRunner); | ||
} | ||
|
||
getRepository(qr?: QueryRunner) { | ||
return qr | ||
? qr.manager.getRepository<DistrictEntity>(DistrictEntity) | ||
: this.repository; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { Injectable } from "@nestjs/common"; | ||
import { InjectRepository } from "@nestjs/typeorm"; | ||
import { QueryRunner, Repository } from "typeorm"; | ||
|
||
import { RegionEntity } from "@APP/entities/region.entity"; | ||
|
||
@Injectable() | ||
export class RegionsRepository extends Repository<RegionEntity> { | ||
constructor( | ||
@InjectRepository(RegionEntity) | ||
private readonly repository: Repository<RegionEntity>, | ||
) { | ||
super(repository.target, repository.manager, repository.queryRunner); | ||
} | ||
|
||
getRepository(qr?: QueryRunner) { | ||
return qr | ||
? qr.manager.getRepository<RegionEntity>(RegionEntity) | ||
: this.repository; | ||
} | ||
} |