-
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: Add categoryIconMapping entity * Feat: Add categoryIconCodeMapping logic - 장소의 카테고리를 기준으로 노출할 icon을 매핑하는 로직 추가 - category_icon_mapping 테이블에 데이터를 저장해 이용함 - 매번 테이블을 조회하기에는 불필요한 데이터로 생각됨. 추후 인메모리캐시 혹은 redis 등 캐싱을 고려해야 할듯 * Fix: Edit category_icon_code type - 숫자로 저장되도록 수정
- Loading branch information
Showing
16 changed files
with
285 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { | ||
Entity, | ||
EntityRepositoryType, | ||
PrimaryKey, | ||
Property, | ||
} from '@mikro-orm/core'; | ||
|
||
import { CategoryIconMappingRepository } from 'src/entities/category-icon-mapping.repository'; | ||
|
||
@Entity({ repository: () => CategoryIconMappingRepository }) | ||
export class CategoryIconMapping { | ||
@PrimaryKey({ autoincrement: true }) | ||
id: number; | ||
|
||
@Property() | ||
kakaoCategory: string; | ||
|
||
@Property() | ||
categoryGroup: string; | ||
|
||
@Property() | ||
iconCode: number; | ||
|
||
@Property({ defaultRaw: 'CURRENT_TIMESTAMP' }) | ||
createdAt: Date = new Date(); | ||
|
||
[EntityRepositoryType]: CategoryIconMappingRepository; | ||
} |
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,4 @@ | ||
import { ExtendedEntityRepository } from 'src/common/helper/extended-repository.helper'; | ||
import { CategoryIconMapping } from 'src/entities/category-icon-mapping.entity'; | ||
|
||
export class CategoryIconMappingRepository extends ExtendedEntityRepository<CategoryIconMapping> {} |
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,13 @@ | ||
import { Migration } from '@mikro-orm/migrations'; | ||
|
||
export class Migration20240727070747 extends Migration { | ||
async up(): Promise<void> { | ||
this.addSql( | ||
'create table "category_icon_mapping" ("id" serial primary key, "kakao_category" varchar(255) not null, "category_group" varchar(255) not null, "icon_code" int not null, "created_at" timestamptz not null);', | ||
); | ||
} | ||
|
||
async down(): Promise<void> { | ||
this.addSql('drop table if exists "category_icon_mapping" cascade;'); | ||
} | ||
} |
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 { Migration } from '@mikro-orm/migrations'; | ||
|
||
export class Migration20240727071134 extends Migration { | ||
async up(): Promise<void> { | ||
this.addSql( | ||
'alter table "category_icon_mapping" alter column "created_at" type timestamptz using ("created_at"::timestamptz);', | ||
); | ||
this.addSql( | ||
'alter table "category_icon_mapping" alter column "created_at" set default CURRENT_TIMESTAMP;', | ||
); | ||
} | ||
|
||
async down(): Promise<void> { | ||
this.addSql( | ||
'alter table "category_icon_mapping" alter column "created_at" drop default;', | ||
); | ||
this.addSql( | ||
'alter table "category_icon_mapping" alter column "created_at" type timestamptz using ("created_at"::timestamptz);', | ||
); | ||
} | ||
} |
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,16 @@ | ||
import { Migration } from '@mikro-orm/migrations'; | ||
|
||
export class Migration20240729140952 extends Migration { | ||
async up(): Promise<void> { | ||
this.addSql( | ||
'alter table "kakao_place" add column "category_icon_code" varchar(255) null;', | ||
); | ||
this.addSql( | ||
'comment on column "kakao_place"."category_icon_code" is \'카카오맵 basicInfo.category.cate1name을 기준으로 매핑한 icon_code\';', | ||
); | ||
} | ||
|
||
async down(): Promise<void> { | ||
this.addSql('alter table "kakao_place" drop column "category_icon_code";'); | ||
} | ||
} |
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 { Migration } from '@mikro-orm/migrations'; | ||
|
||
export class Migration20240729152526 extends Migration { | ||
async up(): Promise<void> { | ||
this.addSql( | ||
'alter table "kakao_place" alter column "category_icon_code" type int using ("category_icon_code"::int);', | ||
); | ||
this.addSql( | ||
'comment on column "kakao_place"."category" is \'카카오맵 basicInfo.category.catename\';', | ||
); | ||
} | ||
|
||
async down(): Promise<void> { | ||
this.addSql( | ||
'alter table "kakao_place" alter column "category_icon_code" type varchar(255) using ("category_icon_code"::varchar(255));', | ||
); | ||
this.addSql( | ||
'comment on column "kakao_place"."category" is \'카카오맵 basicInfo.category.cate1name\';', | ||
); | ||
} | ||
} |
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
Oops, something went wrong.