Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 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
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.

40 changes: 40 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,40 @@
package com.somemore.location.domain;

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

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.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

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

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

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

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

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

@Builder
public Location(String address, String latitude, String longitude) {
this.address = address;
this.latitude = latitude;
this.longitude = longitude;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
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.NotBlank;
import lombok.Builder;

@JsonNaming(SnakeCaseStrategy.class)
@Builder
public record LocationCreateRequestDto(
@Schema(description = "도로명 주소", example = "서울특별시 서초구 반포대로 45, 4층(서초동, 명정빌딩)")
@NotBlank(message = "주소는 필수 입력 값입니다.")
String address,
@Schema(description = "주소에 해당하는 위도 정보", example = "37.4845373748015")
@NotBlank(message = "위도는 필수 입력 값입니다.")
String latitude,
@Schema(description = "주소에 해당하는 경도 정보", example = "127.010842267696")
@NotBlank(message = "경도는 필수 입력 값입니다.")
String 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;

import com.somemore.location.domain.Location;
import com.somemore.location.dto.request.LocationCreateRequestDto;
import com.somemore.location.repository.LocationRepository;
import com.somemore.location.usecase.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;

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;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package com.somemore.recruitboard.dto.request;

import com.fasterxml.jackson.databind.PropertyNamingStrategies.SnakeCaseStrategy;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import com.somemore.location.dto.request.LocationCreateRequestDto;
import com.somemore.recruitboard.domain.RecruitBoard;
import com.somemore.recruitboard.domain.VolunteerType;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Positive;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.UUID;
import lombok.Builder;

@JsonNaming(SnakeCaseStrategy.class)
@Builder
public record RecruitBoardCreateRequestDto(
@Schema(description = "봉사 모집글 제목", example = "서울 청계천 환경 미화 봉사 모집")
@NotBlank(message = "모집글 제목은 필수 값입니다.")
String title,
@Schema(description = "봉사 모집글 내용", example = "서울 청계천 주변 환경 미화 봉사 모집합니다. <br>")
@NotBlank(message = "모집글 내용은 필수 값입니다.")
String content,
@Schema(description = "봉사 지역", example = "서울")
@NotBlank(message = "봉사 지역은 필수 값입니다.")
String region,
@Schema(description = "예상 모집 인원", example = "4")
@NotNull(message = "예상 모집 인원은 필수 값입니다.")
Integer recruitmentCount,
@Schema(description = "봉사 일시", example = "2024-11-20T10:00:00")
@NotNull(message = "봉사 일시는 필수 값입니다.")
LocalDateTime volunteerDate,
@Schema(description = "봉사 활동 유형", example = "ENVIRONMENTAL_PROTECTION")
@NotNull(message = "봉사 활동 유형은 필수 값입니다.")
VolunteerType volunteerType,
@Schema(description = "봉사 시간(시)", example = "1")
@Positive(message = "봉사 시간(시)은 1이상 이어야 합니다.")
Integer volunteerHours,
@Schema(description = "봉사 시간(분)", example = "30")
@Positive(message = "봉사 시간(분)은 1이상 이어야 합니다.")
Integer volunteerMinutes,
@Schema(description = "봉사 시간 인정 여부", example = "true")
@NotNull(message = "시간 인정 여부는 필수 값입니다.")
Boolean admitted,
@NotNull(message = "위치 정보는 필수 값입니다.")
LocationCreateRequestDto location
){
public RecruitBoard toEntity(UUID centerId, Long locationId, String imgUrl) {
return RecruitBoard.builder()
.centerId(centerId)
.locationId(locationId)
.title(title)
.content(content)
.region(region)
.recruitmentCount(recruitmentCount)
.imgUrl(imgUrl)
.volunteerDate(volunteerDate)
.volunteerType(volunteerType)
.volunteerHours(LocalTime.of(volunteerHours, volunteerMinutes))
.admitted(admitted)
.build();
}
}
Loading
Loading