-
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.
Merge pull request #2 from Hey-Porori/feat/initial-setup
[Feat] 프로젝트 초기 설정
- Loading branch information
Showing
17 changed files
with
331 additions
and
1 deletion.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -35,3 +35,6 @@ out/ | |
|
||
### VS Code ### | ||
.vscode/ | ||
|
||
### Spring Boot ### | ||
src/main/resources/application.properties |
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
12 changes: 12 additions & 0 deletions
12
src/main/java/HeyPorori/transaction/config/BaseException.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,12 @@ | ||
package HeyPorori.transaction.config; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
@Getter | ||
@Setter | ||
@AllArgsConstructor | ||
public class BaseException extends Exception { | ||
private BaseResponseStatus status; | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/HeyPorori/transaction/config/BaseResponse.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 HeyPorori.transaction.config; | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import com.fasterxml.jackson.annotation.JsonPropertyOrder; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
import static HeyPorori.transaction.config.BaseResponseStatus.SUCCESS; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
@JsonPropertyOrder({"statusCode", "message", "data"}) | ||
public class BaseResponse<T> { | ||
private String message; | ||
private int statusCode; | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
private T data; | ||
|
||
public BaseResponse(T data) { | ||
this.message = SUCCESS.getMessage(); | ||
this.statusCode = SUCCESS.getStatusCode(); | ||
this.data = data; | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/java/HeyPorori/transaction/config/BaseResponseStatus.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,20 @@ | ||
package HeyPorori.transaction.config; | ||
|
||
import lombok.Getter; | ||
|
||
@Getter | ||
public enum BaseResponseStatus { | ||
/* 요청 성공 */ | ||
SUCCESS(true, 1000, "요청에 성공하였습니다.") | ||
; | ||
|
||
private final boolean isSuccess; | ||
private final int statusCode; | ||
private final String message; | ||
|
||
private BaseResponseStatus(boolean isSuccess, int statusCode, String message) { | ||
this.isSuccess = isSuccess; | ||
this.statusCode = statusCode; | ||
this.message = message; | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/HeyPorori/transaction/config/BaseTimeEntity.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,23 @@ | ||
package HeyPorori.transaction.config; | ||
|
||
import lombok.Getter; | ||
import org.springframework.data.annotation.CreatedDate; | ||
import org.springframework.data.annotation.LastModifiedDate; | ||
import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.EntityListeners; | ||
import javax.persistence.MappedSuperclass; | ||
import java.time.LocalDateTime; | ||
|
||
@Getter | ||
@MappedSuperclass | ||
@EntityListeners(AuditingEntityListener.class) | ||
public class BaseTimeEntity { | ||
@CreatedDate | ||
@Column(updatable = false) | ||
private LocalDateTime createdAt; | ||
|
||
@LastModifiedDate | ||
private LocalDateTime updatedAt; | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/HeyPorori/transaction/config/SwaggerConfig.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,18 @@ | ||
package HeyPorori.transaction.config; | ||
|
||
import io.swagger.v3.oas.models.OpenAPI; | ||
import io.swagger.v3.oas.models.info.Info; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
public class SwaggerConfig { | ||
@Bean | ||
public OpenAPI customOpenAPI() { | ||
return new OpenAPI() | ||
.info(new Info() | ||
.title("중고거래 서비스 API") | ||
.version("1.7.0") | ||
.description("[한이음 ICT 멘토링 공모전 프로젝트] 클라우드를 활용한 지역 기반 거래 플랫폼 - 중고거래 서비스")); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
src/main/java/HeyPorori/transaction/controller/TransactionController.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 HeyPorori.transaction.controller; | ||
|
||
import HeyPorori.transaction.config.BaseException; | ||
import HeyPorori.transaction.config.BaseResponse; | ||
import HeyPorori.transaction.service.TransactionService; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.media.Content; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponses; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RequiredArgsConstructor | ||
@Tag(name = "중고거래", description = "중고거래 관련 API 입니다.") | ||
@RestController | ||
@RequestMapping("/api/transactions") | ||
public class TransactionController { | ||
private final TransactionService transactionService; | ||
|
||
@Operation(summary = "Swagger UI 테스트용 메서드", description = "프로젝트 초기 Swagger UI 정상작동을 확인하기 위한 메서드입니다.") | ||
@ApiResponse(responseCode = "200", description = "요청 성공", content = @Content(mediaType = "application/json", schema = @Schema(implementation = BaseResponse.class))) | ||
@GetMapping("/test") | ||
public BaseResponse<String> testSwagger() { | ||
return new BaseResponse<>("테스트 성공"); | ||
} | ||
} |
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,23 @@ | ||
package HeyPorori.transaction.domain; | ||
|
||
import lombok.Getter; | ||
|
||
@Getter | ||
public enum Category { | ||
ELECTRONICS("전자제품", "스마트폰, 컴퓨터, 태블릿, TV, 오디오 기기 등"), | ||
CLOTHING_ACCESSORIES("의류 및 액세서리", "옷, 신발, 가방, 모자, 보석 등"), | ||
FURNITURE_HOME_GOODS("가구 및 가정용품", "테이블, 의자, 침대, 조명, 주방 용품 등"), | ||
SPORTS_LEISURE("스포츠 및 레저", "운동기구, 캠핑 용품, 자전거, 낚시 용품 등"), | ||
CARS_MOTORCYCLES("자동차 및 오토바이", "중고차, 오토바이, 자동차 부품, 액세서리 등"), | ||
BOOKS_MUSIC("도서 및 음악", "소설, 교육자료, CD, LP, 악기 등"), | ||
BABY_KIDS("아기 및 어린이 용품", "아기 의류, 장난감, 유모차, 아기 침대 등"), | ||
ETC("기타", ""); | ||
|
||
private final String name; | ||
private final String description; | ||
|
||
Category(String name, String description) { | ||
this.name = name; | ||
this.description = description; | ||
} | ||
} |
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,31 @@ | ||
package HeyPorori.transaction.domain; | ||
|
||
import HeyPorori.transaction.config.BaseTimeEntity; | ||
import lombok.*; | ||
|
||
import javax.persistence.*; | ||
|
||
@Entity | ||
@Getter | ||
@Setter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@Table(name = "recommend") | ||
public class Recommend extends BaseTimeEntity { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "recommend_id") | ||
private Long recommendId; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY, optional = false) | ||
@JoinColumn(name = "transaction_id") | ||
private Transaction transactionId; | ||
|
||
@Column(name = "user_id", nullable = false) | ||
private Long userId; | ||
|
||
@Builder | ||
public Recommend(Transaction transactionId, Long userId){ | ||
this.transactionId = transactionId; | ||
this.userId = userId; | ||
} | ||
} |
75 changes: 75 additions & 0 deletions
75
src/main/java/HeyPorori/transaction/domain/Transaction.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,75 @@ | ||
package HeyPorori.transaction.domain; | ||
|
||
import HeyPorori.transaction.config.BaseTimeEntity; | ||
import lombok.*; | ||
import org.hibernate.annotations.ColumnDefault; | ||
import org.hibernate.annotations.DynamicInsert; | ||
import org.hibernate.annotations.DynamicUpdate; | ||
|
||
import javax.persistence.*; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@Entity | ||
@Getter | ||
@Setter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@Table(name = "transaction") | ||
@DynamicInsert | ||
@DynamicUpdate | ||
public class Transaction extends BaseTimeEntity { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "transaction_id") | ||
private Long transactionId; | ||
|
||
@Column(nullable = false, name = "user_id") | ||
private Long userId; | ||
|
||
@Column(nullable = false, columnDefinition = "varchar(20)") | ||
private String title; | ||
|
||
@Column(nullable = false, columnDefinition = "varchar(200)") | ||
private String content; | ||
|
||
@ColumnDefault("0") | ||
private int recommend; | ||
|
||
@Column(nullable = false) | ||
private String address; | ||
|
||
@Column(nullable = false) | ||
private Double latitude; | ||
|
||
@Column(nullable = false) | ||
private Double longitude; | ||
|
||
@Column(nullable = false) | ||
private Category category; | ||
|
||
@ColumnDefault("'ACTIVE'") | ||
private String status; | ||
|
||
@OneToMany(mappedBy = "transactionId", fetch = FetchType.LAZY, cascade = CascadeType.PERSIST) | ||
private List<TransactionAttach> attachList = new ArrayList<>(); | ||
|
||
@OneToMany(mappedBy = "transactionId", fetch = FetchType.LAZY, cascade = CascadeType.PERSIST) | ||
private List<Recommend> recommendList = new ArrayList<>(); | ||
|
||
@Builder | ||
public Transaction(Long userId, String title, String content, int recommend, String address, Double latitude, Double longitude, Category category, String status){ | ||
this.userId = userId; | ||
this.title = title; | ||
this.content = content; | ||
this.recommend = recommend; | ||
this.address = address; | ||
this.latitude = latitude; | ||
this.longitude = longitude; | ||
this.category = category; | ||
this.status = status; | ||
} | ||
|
||
public void changeStatus(String status) { | ||
this.status = status; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/main/java/HeyPorori/transaction/domain/TransactionAttach.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,33 @@ | ||
package HeyPorori.transaction.domain; | ||
|
||
import HeyPorori.transaction.config.BaseTimeEntity; | ||
import lombok.*; | ||
import org.hibernate.annotations.DynamicUpdate; | ||
|
||
import javax.persistence.*; | ||
|
||
@Entity | ||
@Getter | ||
@Setter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@Table(name = "transaction_attach") | ||
@DynamicUpdate | ||
public class TransactionAttach extends BaseTimeEntity { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "attach_id") | ||
private Long attachId; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY, optional = false) | ||
@JoinColumn(name = "transaction_id") | ||
private Transaction transactionId; | ||
|
||
@Column(name = "image_url", nullable = false) | ||
private String imageUrl; | ||
|
||
@Builder | ||
public TransactionAttach(Transaction transactionId, String imageUrl){ | ||
this.transactionId = transactionId; | ||
this.imageUrl = imageUrl; | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/HeyPorori/transaction/repository/RecommendRepository.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,9 @@ | ||
package HeyPorori.transaction.repository; | ||
|
||
import HeyPorori.transaction.domain.Recommend; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public interface RecommendRepository extends JpaRepository<Recommend, Long> { | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/HeyPorori/transaction/repository/TransactionAttachRepository.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,9 @@ | ||
package HeyPorori.transaction.repository; | ||
|
||
import HeyPorori.transaction.domain.TransactionAttach; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public interface TransactionAttachRepository extends JpaRepository<TransactionAttach, Long> { | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/HeyPorori/transaction/repository/TransactionRepository.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,9 @@ | ||
package HeyPorori.transaction.repository; | ||
|
||
import HeyPorori.transaction.domain.Transaction; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public interface TransactionRepository extends JpaRepository<Transaction, Long> { | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/HeyPorori/transaction/service/TransactionService.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,10 @@ | ||
package HeyPorori.transaction.service; | ||
|
||
import org.springframework.stereotype.Service; | ||
|
||
import javax.transaction.Transactional; | ||
|
||
@Service | ||
@Transactional | ||
public class TransactionService { | ||
} |
This file was deleted.
Oops, something went wrong.