-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
33 changed files
with
1,801 additions
and
51 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
src/main/java/com/ajou/hertz/common/dto/CoordinateDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.ajou.hertz.common.dto; | ||
|
||
import com.ajou.hertz.common.entity.Coordinate; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@AllArgsConstructor(access = AccessLevel.PRIVATE) | ||
@NoArgsConstructor(access = AccessLevel.PRIVATE) | ||
@Getter | ||
public class CoordinateDto { | ||
|
||
private String lat; | ||
private String lng; | ||
|
||
public static CoordinateDto from(Coordinate coordinate) { | ||
return new CoordinateDto(coordinate.getLat(), coordinate.getLng()); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
src/main/java/com/ajou/hertz/common/dto/FullAddressDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.ajou.hertz.common.dto; | ||
|
||
import com.ajou.hertz.common.entity.FullAddress; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@AllArgsConstructor(access = AccessLevel.PRIVATE) | ||
@NoArgsConstructor(access = AccessLevel.PRIVATE) | ||
@Getter | ||
public class FullAddressDto { | ||
|
||
private String sido; | ||
private String sgg; | ||
private String lotNumberAddress; | ||
private String roadAddress; | ||
private String detailAddress; | ||
|
||
public static FullAddressDto from(FullAddress fullAddress) { | ||
return new FullAddressDto( | ||
fullAddress.getSido(), | ||
fullAddress.getSgg(), | ||
fullAddress.getLotNumberAddress(), | ||
fullAddress.getRoadAddress(), | ||
fullAddress.getDetailAddress() | ||
); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
src/main/java/com/ajou/hertz/common/dto/request/CoordinateRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.ajou.hertz.common.dto.request; | ||
|
||
import com.ajou.hertz.common.entity.Coordinate; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import jakarta.validation.constraints.NotBlank; | ||
import lombok.AccessLevel; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
@AllArgsConstructor(access = AccessLevel.PROTECTED) | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@Setter | ||
@Getter | ||
public class CoordinateRequest { | ||
|
||
@Schema(description = "위도", example = "37.123456") | ||
@NotBlank | ||
private String lat; | ||
|
||
@Schema(description = "경도", example = "127.123456") | ||
@NotBlank | ||
private String lng; | ||
|
||
public Coordinate toEntity() { | ||
return new Coordinate(lat, lng); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
src/main/java/com/ajou/hertz/common/dto/request/FullAddressRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.ajou.hertz.common.dto.request; | ||
|
||
import com.ajou.hertz.common.entity.FullAddress; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import jakarta.validation.constraints.NotBlank; | ||
import lombok.AccessLevel; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
@AllArgsConstructor(access = AccessLevel.PROTECTED) | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@Setter | ||
@Getter | ||
public class FullAddressRequest { | ||
|
||
@Schema(description = "전체 주소", example = "서울특별시 강남구 역삼동 123-45") | ||
@NotBlank | ||
private String fullAddress; | ||
|
||
@Schema(description = "상세주소", example = "아주 빌딩 2층") | ||
@NotBlank | ||
private String detailAddress; | ||
|
||
public FullAddress toEntity() { | ||
return FullAddress.of(fullAddress, detailAddress); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/com/ajou/hertz/common/dto/response/CoordinateResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.ajou.hertz.common.dto.response; | ||
|
||
import com.ajou.hertz.common.dto.CoordinateDto; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.AccessLevel; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@AllArgsConstructor(access = AccessLevel.PRIVATE) | ||
@NoArgsConstructor(access = AccessLevel.PRIVATE) | ||
@Getter | ||
public class CoordinateResponse { | ||
|
||
@Schema(description = "위도", example = "37.123456") | ||
private String lat; | ||
|
||
@Schema(description = "경도", example = "127.123456") | ||
private String lng; | ||
|
||
public static CoordinateResponse from(CoordinateDto coordinateDto) { | ||
return new CoordinateResponse(coordinateDto.getLat(), coordinateDto.getLng()); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
src/main/java/com/ajou/hertz/common/dto/response/FullAddressResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.ajou.hertz.common.dto.response; | ||
|
||
import com.ajou.hertz.common.dto.FullAddressDto; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.AccessLevel; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@AllArgsConstructor(access = AccessLevel.PRIVATE) | ||
@NoArgsConstructor(access = AccessLevel.PRIVATE) | ||
@Getter | ||
public class FullAddressResponse { | ||
|
||
|
||
@Schema(description = "시/도", example = "서울특별시") | ||
private String sido; | ||
|
||
@Schema(description = "시/군/구", example = "강남구") | ||
private String sgg; | ||
|
||
@Schema(description = "지번주소", example = "수원시 팔달구 권선로11") | ||
private String lotNumberAddress; | ||
|
||
@Schema(description = "도로명 주소", example = "서울특별시 강남구 역삼동 123-45번지") | ||
private String roadAddress; | ||
|
||
@Schema(description = "상세주소", example = "아주 빌딩 2층") | ||
private String detailAddress; | ||
|
||
public static FullAddressResponse from(FullAddressDto fullAddressDto) { | ||
return new FullAddressResponse( | ||
fullAddressDto.getSido(), | ||
fullAddressDto.getSgg(), | ||
fullAddressDto.getLotNumberAddress(), | ||
fullAddressDto.getRoadAddress(), | ||
fullAddressDto.getDetailAddress() | ||
); | ||
} | ||
} |
31 changes: 16 additions & 15 deletions
31
src/main/java/com/ajou/hertz/common/entity/BaseEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,32 @@ | ||
package com.ajou.hertz.common.entity; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
import org.springframework.data.annotation.CreatedBy; | ||
import org.springframework.data.annotation.LastModifiedBy; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.MappedSuperclass; | ||
import lombok.AccessLevel; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import org.springframework.data.annotation.CreatedBy; | ||
import org.springframework.data.annotation.LastModifiedBy; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@Getter | ||
@MappedSuperclass | ||
public abstract class BaseEntity extends TimeTrackedBaseEntity { | ||
|
||
@CreatedBy | ||
@Column(nullable = false, updatable = false) | ||
protected Long createdBy; | ||
@CreatedBy | ||
@Column(nullable = false, updatable = false) | ||
protected Long createdBy; | ||
|
||
@LastModifiedBy | ||
@Column(nullable = false) | ||
protected Long updatedBy; | ||
@LastModifiedBy | ||
@Column(nullable = false) | ||
protected Long updatedBy; | ||
|
||
protected BaseEntity(LocalDateTime createdAt, LocalDateTime updatedAt, Long createdBy, Long updatedBy) { | ||
super(createdAt, updatedAt); | ||
this.createdBy = createdBy; | ||
this.updatedBy = updatedBy; | ||
} | ||
protected BaseEntity(LocalDateTime createdAt, LocalDateTime updatedAt, Long createdBy, Long updatedBy) { | ||
super(createdAt, updatedAt); | ||
this.createdBy = createdBy; | ||
this.updatedBy = updatedBy; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
src/main/java/com/ajou/hertz/domain/practice_room/controller/PracticeRoomController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package com.ajou.hertz.domain.practice_room.controller; | ||
|
||
import static com.ajou.hertz.common.constant.GlobalConstants.*; | ||
|
||
import java.net.URI; | ||
|
||
import org.springdoc.core.annotations.ParameterObject; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.security.core.annotation.AuthenticationPrincipal; | ||
import org.springframework.web.bind.annotation.ModelAttribute; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import com.ajou.hertz.common.auth.UserPrincipal; | ||
import com.ajou.hertz.domain.practice_room.dto.PracticeRoomDto; | ||
import com.ajou.hertz.domain.practice_room.dto.request.CreateNewPracticeRoomRequest; | ||
import com.ajou.hertz.domain.practice_room.dto.response.PracticeRoomResponse; | ||
import com.ajou.hertz.domain.practice_room.service.PracticeRoomCommandService; | ||
|
||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.media.Content; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponses; | ||
import io.swagger.v3.oas.annotations.security.SecurityRequirement; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import jakarta.validation.Valid; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Tag(name = "합주실 관련 API") | ||
@RequiredArgsConstructor | ||
@RequestMapping("/api/practice-rooms") | ||
@RestController | ||
public class PracticeRoomController { | ||
|
||
private final PracticeRoomCommandService practiceRoomCommandService; | ||
|
||
@Operation( | ||
summary = "합주실 매물 등록", | ||
description = """ | ||
<p>합주실 매물을 등록합니다. | ||
<p>요청 시 <strong>multipart/form-data</strong> content-type으로 요쳥해야 합니다. | ||
""", | ||
security = @SecurityRequirement(name = "access-token") | ||
) | ||
@ApiResponses({ | ||
@ApiResponse(responseCode = "201"), | ||
@ApiResponse(responseCode = "400", description = "[2800] 악기 설명에 링크(URL)이 첨부되어 있는 경우.", content = @Content) | ||
}) | ||
@PostMapping( | ||
headers = API_VERSION_HEADER_NAME + "=" + 1, | ||
consumes = MediaType.MULTIPART_FORM_DATA_VALUE | ||
) | ||
public ResponseEntity<PracticeRoomResponse> createNewPracticeRoomV1( | ||
@AuthenticationPrincipal UserPrincipal userPrincipal, | ||
@ParameterObject @ModelAttribute @Valid CreateNewPracticeRoomRequest createNewPracticeRoomRequest | ||
) { | ||
PracticeRoomDto practiceRoomCreated = practiceRoomCommandService.createNewPracticeRoom( | ||
userPrincipal.getUserId(), | ||
createNewPracticeRoomRequest | ||
); | ||
return ResponseEntity | ||
.created(URI.create("/api/practice-rooms/" + practiceRoomCreated.getId())) | ||
.body(PracticeRoomResponse.from(practiceRoomCreated)); | ||
} | ||
|
||
} |
Oops, something went wrong.