Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
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
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,6 @@ dependencies {

tasks.named('test') {
useJUnitPlatform()
jvmArgs("-XX:+EnableDynamicAgentLoading")
}

26 changes: 0 additions & 26 deletions src/main/java/com/somemore/Location.java

This file was deleted.

44 changes: 0 additions & 44 deletions src/main/java/com/somemore/RecruitBoard.java

This file was deleted.

42 changes: 42 additions & 0 deletions src/main/java/com/somemore/location/domain/Location.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.somemore.location.domain;

import static jakarta.persistence.GenerationType.IDENTITY;
import static lombok.AccessLevel.PROTECTED;

import com.somemore.global.common.BaseEntity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import java.math.BigDecimal;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@NoArgsConstructor(access = PROTECTED)
@Entity
@Table(name = "location")
public class Location extends BaseEntity {

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

@Column(name = "address", nullable = false)
private String address;

@Column(name = "latitude", nullable = false, precision = 11, scale = 8)
private BigDecimal latitude;

@Column(name = "longitude", nullable = false, precision = 12, scale = 8)
private BigDecimal longitude;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

정밀도를 8자리로 한이유


@Builder
public Location(String address, BigDecimal latitude, BigDecimal longitude) {
this.address = address;
this.latitude = latitude;
this.longitude = longitude;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.somemore.location.dto.request;


import com.fasterxml.jackson.databind.PropertyNamingStrategies.SnakeCaseStrategy;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import com.somemore.location.domain.Location;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.DecimalMax;
import jakarta.validation.constraints.DecimalMin;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import java.math.BigDecimal;
import lombok.Builder;

@JsonNaming(SnakeCaseStrategy.class)
@Builder
public record LocationCreateRequestDto(
@Schema(description = "도로명 주소", example = "서울특별시 서초구 반포대로 45, 4층(서초동, 명정빌딩)")
@NotBlank(message = "주소는 필수 입력 값입니다.")
String address,
@Schema(description = "주소에 해당하는 위도 정보", example = "37.4845373748015")
@NotNull(message = "위도는 필수 입력 값입니다.")
@DecimalMin(value = "33", message = "위도는 33도 이상이어야 합니다.")
@DecimalMax(value = "39", message = "위도는 38도 이하이어야 합니다.")
BigDecimal latitude,

@Schema(description = "주소에 해당하는 경도 정보", example = "127.010842267696")
@NotNull(message = "경도는 필수 입력 값입니다.")
@DecimalMin(value = "124", message = "경도는 124도 이상이어야 합니다.")
@DecimalMax(value = "132", message = "경도는 132도 이하이어야 합니다.")
BigDecimal longitude
) {

public Location toEntity() {
return Location.builder()
.address(address)
.latitude(latitude)
.longitude(longitude)
.build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.somemore.location.repository;

import com.somemore.location.domain.Location;
import org.springframework.data.jpa.repository.JpaRepository;

public interface LocationRepository extends JpaRepository<Location, Long> {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.somemore.location.service.command;

import com.somemore.location.domain.Location;
import com.somemore.location.dto.request.LocationCreateRequestDto;
import com.somemore.location.repository.LocationRepository;
import com.somemore.location.usecase.command.CreateLocationUseCase;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@RequiredArgsConstructor
@Transactional
@Service
public class CreateLocationService implements CreateLocationUseCase {

private final LocationRepository locationRepository;

@Override
public Long createLocation(LocationCreateRequestDto requestDto) {
Location location = requestDto.toEntity();
locationRepository.save(location);
return location.getId();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.somemore.location.usecase.command;

import com.somemore.location.dto.request.LocationCreateRequestDto;

public interface CreateLocationUseCase {

Long createLocation(LocationCreateRequestDto requestDto);

}
88 changes: 88 additions & 0 deletions src/main/java/com/somemore/recruitboard/domain/RecruitBoard.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
package com.somemore.recruitboard.domain;

import static com.somemore.recruitboard.domain.RecruitStatus.RECRUITING;
import static jakarta.persistence.EnumType.STRING;
import static jakarta.persistence.GenerationType.IDENTITY;
import static lombok.AccessLevel.PROTECTED;

import com.somemore.global.common.BaseEntity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Enumerated;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
import jakarta.persistence.Lob;
import jakarta.persistence.Table;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.UUID;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@NoArgsConstructor(access = PROTECTED)
@Entity
@Table(name = "recruit_board")
public class RecruitBoard extends BaseEntity {

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

@Column(name = "center_id", nullable = false)
private UUID centerId;

@Column(name = "location_id", nullable = false)
private Long locationId;

@Column(name = "title", nullable = false)
private String title;

@Lob
@Column(name = "content", nullable = false)
private String content;

@Column(name = "region", nullable = false)
private String region;

@Column(name = "recruitment_count", nullable = false)
private Integer recruitmentCount;

@Column(name = "img_url", nullable = false)
private String imgUrl;

@Enumerated(value = STRING)
@Column(name = "recruit_status", nullable = false, length = 20)
private RecruitStatus recruitStatus = RECRUITING;

@Column(name = "volunteer_date", nullable = false)
private LocalDateTime volunteerDate;

@Enumerated(value = STRING)
@Column(name = "volunteer_type", nullable = false, length = 30)
private VolunteerType volunteerType;

@Column(name = "volunteer_hours", nullable = false)
private LocalTime volunteerHours;

@Column(name = "admitted", nullable = false)
private Boolean admitted;

@Builder
public RecruitBoard(UUID centerId, Long locationId, String title, String content, String region,
Integer recruitmentCount, String imgUrl, LocalDateTime volunteerDate,
VolunteerType volunteerType, LocalTime volunteerHours, Boolean admitted) {
this.centerId = centerId;
this.locationId = locationId;
this.title = title;
this.content = content;
this.region = region;
this.recruitmentCount = recruitmentCount;
this.imgUrl = imgUrl;
this.volunteerDate = volunteerDate;
this.volunteerType = volunteerType;
this.volunteerHours = volunteerHours;
this.admitted = admitted;
}
}
16 changes: 16 additions & 0 deletions src/main/java/com/somemore/recruitboard/domain/RecruitStatus.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.somemore.recruitboard.domain;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

@Getter
@RequiredArgsConstructor
public enum RecruitStatus {
RECRUITING("모집중"),
CLOSED("마감"),
COMPLETED("종료"),

;
private final String text;

}
27 changes: 27 additions & 0 deletions src/main/java/com/somemore/recruitboard/domain/VolunteerType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.somemore.recruitboard.domain;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

@Getter
@RequiredArgsConstructor
public enum VolunteerType {

LIVING_SUPPORT("생활편의지원"),
HOUSING_ENVIRONMENT("주거환경"),
COUNSELING("상담"),
EDUCATION("교육"),
HEALTHCARE("보건의료"),
RURAL_SUPPORT("농어촌봉사"),
CULTURAL_EVENT("문화행사"),
ENVIRONMENTAL_PROTECTION("환경보호"),
ADMINISTRATIVE_SUPPORT("행정보조"),
SAFETY_PREVENTION("안전예방"),
PUBLIC_INTEREST_HUMAN_RIGHTS("공익인권"),
DISASTER_RELIEF("재해재난"),
MENTORING("멘토링"),
OTHER("기타"),

;
private final String text;
}
Loading
Loading