-
Notifications
You must be signed in to change notification settings - Fork 1
[FEATURE] 봉사활동 모집글 생성 기능 #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a201425
fd6743c
2b97ac6
3b32f5e
730ca2b
5963ed0
75eb88f
2c19009
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
| 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.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,31 @@ | ||
| 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,9 @@ | ||
| package com.somemore.location.service; | ||
|
|
||
| import com.somemore.location.dto.request.LocationCreateRequestDto; | ||
|
|
||
| public interface LocationCommandService { | ||
|
|
||
| public Long createLocation(LocationCreateRequestDto dto); | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| 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 lombok.RequiredArgsConstructor; | ||
| import org.springframework.stereotype.Service; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
|
|
||
| @RequiredArgsConstructor | ||
| @Transactional | ||
| @Service | ||
| public class LocationCommander implements LocationCommandService { | ||
|
|
||
| private final LocationRepository locationRepository; | ||
|
|
||
| public Long createLocation(LocationCreateRequestDto dto) { | ||
| Location location = dto.toEntity(); | ||
|
|
||
| locationRepository.save(location); | ||
|
|
||
| return location.getId(); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| 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 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 lombok.Builder; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| @Getter | ||
| @NoArgsConstructor(access = PROTECTED) | ||
| @Entity | ||
| @Table(name = "Recruit_board") | ||
| public class RecruitBoard { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. BaseEntity 상속 일부러 아직 안 하신 건가요?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 헉 죄송합니다.. 까먹었습니다.. |
||
|
|
||
| @Id | ||
| @GeneratedValue(strategy = IDENTITY) | ||
| private Long id; | ||
|
|
||
| @Column(name = "location_id", nullable = false) | ||
| private Long locationId; | ||
|
|
||
| @Column(name = "center_id", nullable = false) | ||
| private Long centerId; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. centerId는 UUID인 거 같아요 |
||
|
|
||
| @Column(name = "title", nullable = false) | ||
| private String title; | ||
|
|
||
| @Lob | ||
| @Column(name = "content", nullable = false) | ||
| private String content; | ||
|
|
||
| @Enumerated(value = STRING) | ||
| @Column(name = "recruit_status", nullable = false, length = 20) | ||
| private RecruitStatus recruitStatus = RECRUITING; | ||
|
|
||
| @Column(name = "img_url", nullable = false) | ||
| private String imgUrl; | ||
|
|
||
| @Column(name = "volunteer_date", nullable = false) | ||
| private LocalDateTime volunteerDate; | ||
|
|
||
| @Enumerated(value = STRING) | ||
| @Column(name = "volunteer_type", nullable = false, length = 20) | ||
| private VolunteerType volunteerType; | ||
|
|
||
| @Column(name = "volunteer_hours", nullable = false) | ||
| private int volunteerHours; | ||
|
|
||
| @Column(name = "admitted", nullable = false) | ||
| private Boolean admitted; | ||
|
|
||
| @Builder | ||
| public RecruitBoard(Long locationId, Long centerId, String title, String content, String imgUrl, | ||
| LocalDateTime volunteerDate, VolunteerType volunteerType, int volunteerHours, | ||
| Boolean admitted) { | ||
| this.locationId = locationId; | ||
| this.centerId = centerId; | ||
| this.title = title; | ||
| this.content = content; | ||
| this.imgUrl = imgUrl; | ||
| this.volunteerDate = volunteerDate; | ||
| this.volunteerType = volunteerType; | ||
| this.volunteerHours = volunteerHours; | ||
| this.admitted = admitted; | ||
| } | ||
| } | ||
| 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; | ||
|
|
||
| } |
| 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,34 @@ | ||||||
| package com.somemore.recruitboard.dto.command; | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
저희 컨벤션이 위와 같지 않나요?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 음.. 컨벤션상으로 request가 맞긴합니다. 제 나름대로의 규칙을 정한건.. dto.request 패키지는 컨트롤러에서 사용되는 dto, dto.command 패키지는 파사드 서비스에서 다른 서비스를 호출할 때 dto 정보가 달라질 경우 필요 정보만 담는 dto가 모인 패키지로 생각하고 넣긴했는데, 이부분 의논해보면 좋을 것 같습니다. 레코드명에 Command가 들어가는 이유도 비슷한 dto 패키지를 나눈 맥락과 동일하다고 말씀드릴수 있을 것 같아요. |
||||||
|
|
||||||
| import com.somemore.recruitboard.domain.RecruitBoard; | ||||||
| import com.somemore.recruitboard.domain.VolunteerType; | ||||||
| import java.time.LocalDateTime; | ||||||
| import lombok.Builder; | ||||||
|
|
||||||
| @Builder | ||||||
| public record RecruitBoardCreateCommandRequestDto( | ||||||
| Long centerId, | ||||||
| Long locationId, | ||||||
| String imgUrl, | ||||||
| String title, | ||||||
| String content, | ||||||
| LocalDateTime volunteerDate, | ||||||
| VolunteerType volunteerType, | ||||||
| Integer volunteerHours, | ||||||
| Boolean admitted | ||||||
| ) { | ||||||
|
|
||||||
| public RecruitBoard toEntity() { | ||||||
| return RecruitBoard.builder() | ||||||
| .locationId(locationId) | ||||||
| .centerId(centerId) | ||||||
| .title(title) | ||||||
| .content(content) | ||||||
| .imgUrl(imgUrl) | ||||||
| .volunteerDate(volunteerDate) | ||||||
| .volunteerType(volunteerType) | ||||||
| .admitted(admitted) | ||||||
| .build(); | ||||||
| } | ||||||
|
|
||||||
| } | ||||||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
인터페이스 메서드는 기본적으로 public으로 간주되는데, 이를 명시적으로 작성하는 것에 대해서 여쭤보고 싶습니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
아 이 부분은 실수입니다.. public 제거하는 방향을 수정하겠습니다 ㅎㅎ