Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions main/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ dependencies {

// Test Dependencies
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.testcontainers:testcontainers:1.17.3'
testImplementation 'org.testcontainers:junit-jupiter:1.16.2'
testImplementation 'org.testcontainers:postgresql:1.17.3'
testImplementation 'org.testcontainers:jdbc'
testImplementation 'org.testcontainers:testcontainers:2.0.2'
testImplementation 'org.testcontainers:junit-jupiter:1.20.6'
testImplementation 'org.testcontainers:postgresql:1.20.6'
testImplementation 'org.testcontainers:jdbc:1.20.6'

// Apache Commons Dependencies
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.14.0'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package org.sopt.makers.crew.main.entity.property;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

@Getter
@RequiredArgsConstructor
public enum PropertyKeys {

HOME("home"),
OFFICIAL_DATE("officialDateText"),
EVENT_NUM("eventNumbers"),
START_DATE("startDate"),
END_DATE("endDate"),
SOPT_MAP_EVENT("soptMapEvent");

private final String key;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package org.sopt.makers.crew.main.entity.soptmap;

import org.sopt.makers.crew.main.entity.common.BaseTimeEntity;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Entity
@Table(name = "event_gift")
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class EventGift extends BaseTimeEntity {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Column(name = "user_id")
private Long userId;

@Column(name = "map_id")
private Long mapId;

@Column(name = "gift_url")
private String giftUrl;

@Column(name = "claimable") //청구 수령 가능한
private Boolean claimable;

@Column(name = "active")
private Boolean active;

public void nonActive() {
this.active = false;
}

public void claimGift(Integer userId, Long mapId) {
this.userId = Long.valueOf(userId);
this.mapId = mapId;
this.claimable = false;
}

public void claimGift(Long userId, Long mapId) {
this.userId = userId;
this.mapId = mapId;
this.claimable = false;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package org.sopt.makers.crew.main.entity.soptmap;

import org.sopt.makers.crew.main.entity.common.BaseTimeEntity;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Getter
@Entity
@Table(name = "map_recommended")
public class MapRecommend extends BaseTimeEntity {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Column(name = "user_id")
private Long userId;

@Column(name = "sopt_map_id")
private Long soptMapId;

@Column(name = "active")
private Boolean active;

@Builder
private MapRecommend(Long userId, Long soptMapId, Boolean active) {
this.userId = userId;
this.soptMapId = soptMapId;
this.active = active;
}

public static MapRecommend create(Long userId, Long soptMapId) {
return MapRecommend.builder()
.userId(userId)
.soptMapId(soptMapId)
.active(true)
.build();
}

@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (!(o instanceof MapRecommend mapRecommend))
return false;
return this.getId() != null && this.getId().equals(mapRecommend.getId());
}

@Override
public int hashCode() {
return java.util.Objects.hash(this.getId());
}

public void deleteRecommend() {
this.active = false;
}

public void toggleStatus() {
this.active = !this.active;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.sopt.makers.crew.main.entity.soptmap;

import java.util.List;
import java.util.stream.Collectors;

public enum MapTag {
/**
* FOOD : 맛집
* CAFE : 카페
* ETC : 기타
*/
FOOD, CAFE, ETC;

public static List<MapTag> fromName(List<String> name) {
return name.stream().map(MapTag::valueOf).collect(Collectors.toList());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
package org.sopt.makers.crew.main.entity.soptmap;

import java.util.List;

import org.hibernate.annotations.JdbcTypeCode;
import org.hibernate.type.SqlTypes;
import org.sopt.makers.crew.main.entity.common.BaseTimeEntity;
import org.sopt.makers.crew.main.soptmap.service.dto.CreateSoptMapDto;
import org.sopt.makers.crew.main.soptmap.service.dto.UpdateSoptMapDto;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Getter
@Entity
@Table(name = "sopt_map")
public class SoptMap extends BaseTimeEntity {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@JdbcTypeCode(SqlTypes.JSON)
@Column(columnDefinition = "jsonb", name = "nearby_station_ids")
private List<Long> nearbyStationIds; // 주변 역 Id

@Column(name = "place_name")
private String placeName; // 장소명

@Column(name = "description")
private String description; // 한줄 소개

@Enumerated(EnumType.STRING)
@JdbcTypeCode(SqlTypes.JSON)
@Column(name = "map_tags", columnDefinition = "jsonb")
private List<MapTag> mapTags; // 지도 태그

@Column(name = "naver_link")
private String naverLink; // naverLink

@Column(name = "kakao_link")
private String kakaoLink; // kakaoLink

@Column(name = "creator_id")
private Long creatorId; // 작성자id

@Builder
private SoptMap(String placeName, Long creatorId, String description, List<MapTag> mapTags, String naverLink,
String kakaoLink, List<Long> nearbyStationIds) {
this.placeName = placeName;
this.creatorId = creatorId;
this.description = description;
this.mapTags = mapTags;
this.naverLink = naverLink;
this.kakaoLink = kakaoLink;
this.nearbyStationIds = nearbyStationIds;
}

public static SoptMap create(Integer creatorId, CreateSoptMapDto dto, List<Long> nearbyStationIds) {
return SoptMap.builder()
.placeName(dto.getPlaceName())
.creatorId(Long.valueOf(creatorId))
.description(dto.getDescription())
.mapTags(dto.getTags())
.naverLink(dto.getNaverLink())
.kakaoLink(dto.getKakaoLink())
.nearbyStationIds(nearbyStationIds)
.build();
}

public void update(UpdateSoptMapDto dto, List<Long> nearbyStationIds) {
this.placeName = dto.getPlaceName();
this.description = dto.getDescription();
this.mapTags = dto.getTags();
this.naverLink = dto.getNaverLink();
this.kakaoLink = dto.getKakaoLink();
this.nearbyStationIds = nearbyStationIds;
}

@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (!(o instanceof SoptMap soptMap))
return false;
return this.getId() != null && this.getId().equals(soptMap.getId());
}

@Override
public int hashCode() {
return java.util.Objects.hash(this.getId());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
package org.sopt.makers.crew.main.entity.soptmap;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

import lombok.Getter;

@Getter
public enum SubwayLine {

// 1~9호선 (별다른 별칭이 없는 경우)
LINE_1("1호선"),
LINE_2("2호선"),
LINE_3("3호선"),
LINE_4("4호선"),
LINE_5("5호선"),
LINE_6("6호선"),
LINE_7("7호선"),
LINE_8("8호선"),
LINE_9("9호선"),

// 인천 지하철
INCHEON_1("인천1호선"),
INCHEON_2("인천2호선"),

// 경기/광역/기타 노선
SINBUNDANG("신분당선"),
SUIN_BUNDANG("수인분당선"),
GYEONGUI_JUNGANG("경의중앙선"),
GYEONGCHUN("경춘선"),
GYEONGGANG("경강선"),

// 별칭이 필요한 노선들 (가변 인자로 여러 개 등록 가능)
UI_SINSEOL("우이신설선", "우이신설경전철"),
SILLIM("신림선", "신림경전철"),

// 두 이름 모두 처리
EVERLINE("에버라인", "용인경전철"),

GIMPO_GOLD("김포골드라인"),
SEOHAE("서해선"),
AIRPORT_RAILROAD("공항철도"),
UIJEONGBU("의정부경전철"),
GTX_A("GTX-A", "지티엑스A");

private final String value; // 대표 명칭 (DB 저장용)
private final List<String> aliases; // 인식 가능한 다른 이름들

// 생성자: 첫 번째는 대표 이름, 나머지는 별칭으로 처리
SubwayLine(String value, String... aliases) {
this.value = value;
this.aliases = Arrays.asList(aliases);
}

public static List<String> fromValues(List<SubwayLine> lines) {
return lines.stream().map(SubwayLine::getValue).collect(Collectors.toList());
}

/**
* JSON 역직렬화 및 문자열 변환 시 사용
* 입력값이 대표 이름이거나 별칭 중 하나라면 해당 Enum 반환
*/
@JsonCreator
public static SubwayLine fromValue(String input) {
if (input == null) {
throw new IllegalArgumentException("지하철 노선 값이 null입니다.");
}

return Arrays.stream(values())
.filter(line -> line.value.equals(input) || line.aliases.contains(input) || line.name().equals(input))
.findFirst()
.orElseThrow(() -> new IllegalArgumentException("유효하지 않은 지하철 노선입니다: " + input));
}

/**
* JSON 직렬화 시 사용할 값 (대표 명칭 반환)
*/
@JsonValue
public String getValue() {
return value;
}
}
Loading