Skip to content

Commit

Permalink
Feat: 없는 태그 생성 when create place
Browse files Browse the repository at this point in the history
  • Loading branch information
Ho-s committed Aug 2, 2024
1 parent bb2d29c commit 53641ed
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions src/place/place.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,22 @@ export class PlaceService {
},
});

const newTags = defaultTags.map((v) => {
const tag = new Tag();
tag.name = v.name;
tag.iconType = v.iconType;
tag.map = rel(GroupMap, mapId);
tags.push(tag);

return tag;
});
const restTagNamesAfterDefatulTag = restTagNames
.filter((name) => !defaultTags.find((k) => k.name === name))
.map((name) => ({ name, iconType: null }));

const newTags = [...defaultTags, ...restTagNamesAfterDefatulTag].map(
(v) => {
const tag = new Tag();
tag.name = v.name;
tag.iconType = v.iconType;
tag.map = rel(GroupMap, mapId);
tags.push(tag);

return tag;
},
);

await this.tagRepository.persistAndFlush(newTags);
}

Expand Down

0 comments on commit 53641ed

Please sign in to comment.