-
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.
- Loading branch information
Showing
14 changed files
with
705 additions
and
2 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
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
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,53 @@ | ||
import { | ||
Entity, | ||
EntityRepositoryType, | ||
ManyToOne, | ||
OneToOne, | ||
PrimaryKeyProp, | ||
Property, | ||
Rel, | ||
} from '@mikro-orm/core'; | ||
|
||
import { GroupMap } from './group-map.entity'; | ||
import { PlaceForMapRepository } from './place-for-map.repository'; | ||
import { Place } from './place.entity'; | ||
import { User } from './user.entity'; | ||
|
||
@Entity({ | ||
comment: 'GroupMap에 속한 Place', | ||
repository: () => PlaceForMapRepository, | ||
}) | ||
export class PlaceForMap { | ||
@ManyToOne(() => GroupMap, { primary: true }) | ||
map: Rel<GroupMap>; | ||
|
||
@ManyToOne(() => Place, { primary: true }) | ||
place: Rel<Place>; | ||
|
||
// 나중에 정규화 하고싶으면 PlaceForMapPhoto라는 Entity를 만들어서 관리하면 될듯. | ||
@Property({ | ||
type: 'json', | ||
comment: '사진 URL과 코멘트를 담은 객체 배열', | ||
}) | ||
comments: { photoUrls: string[]; comment: string; userId: number }[]; | ||
|
||
// 나중에 정규화 하고싶으면 PlaceForMapLike라는 Entity를 만들어서 관리하면 될듯. | ||
@Property({ | ||
type: 'json', | ||
comment: '좋아요 누른 유저 ID 배열', | ||
}) | ||
likedUserIds: number[]; | ||
|
||
@OneToOne(() => User) | ||
createdBy: User; | ||
|
||
@Property() | ||
createdAt: Date = new Date(); | ||
|
||
@Property({ onUpdate: () => new Date() }) | ||
updatedAt: Date = new Date(); | ||
|
||
[PrimaryKeyProp]: ['map', 'place']; | ||
|
||
[EntityRepositoryType]: PlaceForMapRepository; | ||
} |
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,5 @@ | ||
import { ExtendedEntityRepository } from 'src/common/helper/extended-repository.helper'; | ||
|
||
import { PlaceForMap } from './place-for-map.entity'; | ||
|
||
export class PlaceForMapRepository extends ExtendedEntityRepository<PlaceForMap> {} |
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,46 @@ | ||
import { | ||
Entity, | ||
EntityRepositoryType, | ||
OneToOne, | ||
PrimaryKey, | ||
Property, | ||
} from '@mikro-orm/core'; | ||
|
||
import { KakaoPlace } from './kakao-place.entity'; | ||
import { PlaceRepository } from './place.repository'; | ||
|
||
@Entity({ | ||
comment: '장소 정보', | ||
repository: () => PlaceRepository, | ||
}) | ||
export class Place { | ||
@PrimaryKey({ | ||
type: 'integer', | ||
autoincrement: true, | ||
}) | ||
id: number; | ||
|
||
// OneToOne | ||
@OneToOne({ entity: () => KakaoPlace }) | ||
kakaoPlace: KakaoPlace; | ||
|
||
@Property({ | ||
type: 'integer', | ||
comment: '경도', | ||
}) | ||
x: number; | ||
|
||
@Property({ | ||
type: 'integer', | ||
comment: '위도', | ||
}) | ||
y: number; | ||
|
||
@Property() | ||
createdAt: Date = new Date(); | ||
|
||
@Property({ onUpdate: () => new Date() }) | ||
updatedAt: Date = new Date(); | ||
|
||
[EntityRepositoryType]: PlaceRepository; | ||
} |
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,5 @@ | ||
import { ExtendedEntityRepository } from 'src/common/helper/extended-repository.helper'; | ||
|
||
import { Place } from './place.entity'; | ||
|
||
export class PlaceRepository extends ExtendedEntityRepository<Place> {} |
Oops, something went wrong.