Skip to content

Commit

Permalink
chore: 태그 관련 번쩍 네이밍 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
hoonyworld committed Jan 24, 2025
1 parent 1276a1d commit 65045dd
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 40 deletions.
16 changes: 8 additions & 8 deletions main/src/main/java/org/sopt/makers/crew/main/entity/tag/Tag.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class Tag extends BaseTimeEntity {

/**
* @implSpec : 모임태그 or 번쩍태그 구분
* @implNote : 모임태그일 경우, lightningId == null
* @implNote : 모임태그일 경우, flashId == null
* @implNote : 번쩍태그일 경우, meetingId == null
* */
@Enumerated(EnumType.STRING)
Expand All @@ -45,18 +45,18 @@ public class Tag extends BaseTimeEntity {
@Column(name = "meetingId")
private Integer meetingId;

@Column(name = "lightningId")
private Integer lightningId;
@Column(name = "flashId")
private Integer flashId;

@Column(name = "welcomeMessageTypes", columnDefinition = "jsonb")
@Type(JsonBinaryType.class)
private List<WelcomeMessageType> welcomeMessageTypes;

@Builder
private Tag(TagType tagType, Integer meetingId, Integer lightningId, List<WelcomeMessageType> welcomeMessageTypes) {
private Tag(TagType tagType, Integer meetingId, Integer flashId, List<WelcomeMessageType> welcomeMessageTypes) {
this.tagType = tagType;
this.meetingId = meetingId;
this.lightningId = lightningId;
this.flashId = flashId;
this.welcomeMessageTypes = welcomeMessageTypes;
}

Expand All @@ -65,17 +65,17 @@ public static Tag createGeneralMeetingTag(TagType tagType, Integer meetingId,
return Tag.builder()
.tagType(tagType)
.meetingId(meetingId)
.lightningId(null)
.flashId(null)
.welcomeMessageTypes(welcomeMessageTypes)
.build();
}

public static Tag createLightningMeetingTag(TagType tagType, Integer lightningId,
public static Tag createFlashMeetingTag(TagType tagType, Integer flashId,
List<WelcomeMessageType> welcomeMessageTypes) {
return Tag.builder()
.tagType(tagType)
.meetingId(null)
.lightningId(lightningId)
.flashId(flashId)
.welcomeMessageTypes(welcomeMessageTypes)
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
import org.springframework.data.jpa.repository.JpaRepository;

public interface TagRepository extends JpaRepository<Tag, Integer> {
Optional<WelcomeMessageTypeProjection> findByLightningId(Integer lightningId);
Optional<WelcomeMessageTypeProjection> findByFlashId(Integer flashId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

public enum TagType {
MEETING,
LIGHTNING
FLASH
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.sopt.makers.crew.main.tag.v2.dto.response;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;

@Schema(name = "TagV2CreateFlashTagResponseDto", description = "번쩍 모임 태그 생성 응답 Dto")
public record TagV2CreateFlashTagResponseDto(
@Schema(description = "모임 태그 id", example = "1")
@NotNull
Integer tagId
) {
public static TagV2CreateFlashTagResponseDto from(Integer tagId) {
return new TagV2CreateFlashTagResponseDto(tagId);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import java.util.List;

import org.sopt.makers.crew.main.entity.tag.enums.WelcomeMessageType;
import org.sopt.makers.crew.main.tag.v2.dto.response.TagV2CreateTagResponseDto;
import org.sopt.makers.crew.main.tag.v2.dto.response.TagV2CreateFlashTagResponseDto;

public interface TagV2Service {
TagV2CreateTagResponseDto createLightningTag(List<String> welcomeMessageTypes, Integer lightningId);
TagV2CreateFlashTagResponseDto createFlashTag(List<String> welcomeMessageTypes, Integer flashId);

List<WelcomeMessageType> getWelcomeMessageTypesByLightningId(Integer lightningId);
List<WelcomeMessageType> getWelcomeMessageTypesByFlashId(Integer flashId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import org.sopt.makers.crew.main.entity.tag.enums.TagType;
import org.sopt.makers.crew.main.entity.tag.enums.WelcomeMessageType;
import org.sopt.makers.crew.main.global.exception.BadRequestException;
import org.sopt.makers.crew.main.tag.v2.dto.response.TagV2CreateTagResponseDto;
import org.sopt.makers.crew.main.tag.v2.dto.response.TagV2CreateFlashTagResponseDto;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

Expand All @@ -28,38 +28,38 @@ public class TagV2ServiceImpl implements TagV2Service {

@Override
@Transactional
public TagV2CreateTagResponseDto createLightningTag(List<String> welcomeMessageTypes,
Integer lightningId) {
public TagV2CreateFlashTagResponseDto createFlashTag(List<String> welcomeMessageTypes,
Integer flashId) {

if (lightningId == null) {
if (flashId == null) {
throw new BadRequestException(VALIDATION_EXCEPTION.getErrorCode());
}

if (welcomeMessageTypes == null || welcomeMessageTypes.isEmpty()) {
return saveTag(lightningId, List.of());
return saveTag(flashId, List.of());
}

List<WelcomeMessageType> welcomeMessageTypeEnums = welcomeMessageTypes.stream()
.map(WelcomeMessageType::ofValue)
.toList();

return saveTag(lightningId, welcomeMessageTypeEnums);
return saveTag(flashId, welcomeMessageTypeEnums);
}

@Override
public List<WelcomeMessageType> getWelcomeMessageTypesByLightningId(Integer lightningId) {
if (lightningId == null) {
public List<WelcomeMessageType> getWelcomeMessageTypesByFlashId(Integer flashId) {
if (flashId == null) {
throw new BadRequestException(VALIDATION_EXCEPTION.getErrorCode());
}

return tagRepository.findByLightningId(lightningId)
return tagRepository.findByFlashId(flashId)
.map(WelcomeMessageTypeProjection::getWelcomeMessageTypes)
.orElse(Collections.emptyList());
}

private TagV2CreateTagResponseDto saveTag(Integer lightningId, List<WelcomeMessageType> welcomeMessageTypeEnums) {
Tag tag = Tag.createLightningMeetingTag(TagType.LIGHTNING, lightningId, welcomeMessageTypeEnums);
private TagV2CreateFlashTagResponseDto saveTag(Integer flashId, List<WelcomeMessageType> welcomeMessageTypeEnums) {
Tag tag = Tag.createFlashMeetingTag(TagType.FLASH, flashId, welcomeMessageTypeEnums);
tagRepository.save(tag);
return TagV2CreateTagResponseDto.from(tag.getId());
return TagV2CreateFlashTagResponseDto.from(tag.getId());
}
}

0 comments on commit 65045dd

Please sign in to comment.