Skip to content

Commit

Permalink
경매품 조회 기능 및 페이지네이션 구현
Browse files Browse the repository at this point in the history
[#6] 경매품 조회 페이지네이션 구현
  • Loading branch information
puleugo authored Sep 14, 2023
2 parents f7e25ac + f3ac2cc commit c656182
Show file tree
Hide file tree
Showing 41 changed files with 1,293 additions and 314 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ FROM openjdk:8-jdk-alpine
ARG JAR_FILE=build/libs/gyeongnam-gyeongmae-0.0.1.jar
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","-jar","/app.jar","-Dspring.profile.active=dev"]
EXPOSE 8081
EXPOSE 8081
60 changes: 42 additions & 18 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import com.ewerk.gradle.plugins.tasks.QuerydslCompile

group = "megabrain"
version = "0.0.1"

val javaVersion = JavaVersion.VERSION_1_8
val springBootVersion: String = "2.7.14"
val queryDslVersion = "5.0.0"

buildscript {
repositories {
Expand All @@ -19,43 +22,42 @@ repositories {
mavenCentral()
}

sourceSets {
main {
java.srcDir("src/core/java")
}
}

plugins {
java
idea
jacoco

id("org.springframework.boot") version "2.7.14"
id("io.spring.dependency-management") version "1.0.15.RELEASE"
id("com.ewerk.gradle.plugins.querydsl") version "1.0.10"
}

java {
sourceCompatibility = javaVersion
withSourcesJar()
}

sourceSets {
main {
java {
srcDir(file("src/main/java"))
}

configurations {
compileOnly {
extendsFrom(configurations.annotationProcessor.get())
}
}

tasks.withType<Jar>() {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
java {
sourceCompatibility = javaVersion
withSourcesJar()
}

tasks.register<Copy>("check exist application.yml file") {
val ymlFile = File("src/main/resources/application.yml");
val ymlFile = File("src/main/resources/application.yml")
if (!ymlFile.exists()) {
logger.error("We were unable to find the application.yml file, please verify that it is located in the resource folder.")
} else {
logger.error("found yml")
}
}


springBoot {
buildInfo()
}
Expand All @@ -69,14 +71,36 @@ dependencies {
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310")
implementation("org.springdoc:springdoc-openapi-ui:1.6.9")
implementation("org.projectlombok:lombok")
implementation("org.hibernate:hibernate-core")
implementation("org.hibernate:hibernate-entitymanager")
runtimeOnly("org.postgresql:postgresql")
annotationProcessor("org.projectlombok:lombok")
testAnnotationProcessor("org.projectlombok:lombok")
testImplementation("org.springframework.boot:spring-boot-starter-test")
annotationProcessor("org.springframework.boot:spring-boot-configuration-processor")

implementation("com.querydsl:querydsl-jpa:${queryDslVersion}")
annotationProcessor("com.querydsl:querydsl-apt:${queryDslVersion}")
}

// 쿼리DSL 설치 검증
val querydslDir = "$buildDir/generated/querydsl"
querydsl {
jpa = true
querydslSourcesDir = querydslDir
}
sourceSets.getByName("main") {
java.srcDir(querydslDir)
}
configurations {
named("querydsl") {
extendsFrom(configurations.compileClasspath.get())
}
}
tasks.withType<QuerydslCompile> {
options.annotationProcessorPath = configurations.querydsl.get()
dependsOn("sourcesJar")
}

// 테스트
tasks.withType<Test> {
useJUnitPlatform()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package megabrain.gyeongnamgyeongmae.domain.auctionItem.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import megabrain.gyeongnamgyeongmae.domain.auctionItem.domain.repostiory.AuctionItemCommentRepository;
import megabrain.gyeongnamgyeongmae.domain.auctionItem.dto.AuctionItemCommentDeleteRequest;
import megabrain.gyeongnamgyeongmae.domain.auctionItem.dto.Comment.AuctionItemCommentParentDto;
import megabrain.gyeongnamgyeongmae.domain.auctionItem.dto.AuctionItemCommentRequest;
import megabrain.gyeongnamgyeongmae.domain.auctionItem.dto.AuctionItemCommentUpdateRequest;
import megabrain.gyeongnamgyeongmae.domain.auctionItem.service.Comment.AuctionItemCommentServiceImpl;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Tag(name = "경매품에 답글 작성", description = "경매품 댓글 관련 API")
@RequestMapping({"api/auctions/comments"})
@RestController
@RequiredArgsConstructor
public class AuctionItemCommentController {

private final AuctionItemCommentRepository auctionItemCommentRepository;
private final AuctionItemCommentServiceImpl auctionItemCommentServiceImpl;

@Operation(summary = "댓글 쓰기 ", description = "경매품 댓글 쓰기")
@ResponseStatus(HttpStatus.CREATED)
@PostMapping({"{id}"})
public ResponseEntity<HttpStatus> createAuctionItemComment(@PathVariable Long id, @RequestBody AuctionItemCommentRequest auctionItemCommentRequest) {
Long memberId = auctionItemCommentRequest.getUserId();
this.auctionItemCommentServiceImpl.createAuctionItemComment(auctionItemCommentRequest, id, memberId);
return ResponseEntity.status(HttpStatus.CREATED).build();
}

@Operation(summary = "경매품에 대한 댓글 보기", description = "경매품에 대한 경매품 댓글 보기")
@GetMapping({"{id}"})
public ResponseEntity<List<AuctionItemCommentParentDto>> findAuctionItemCommentById(@PathVariable Long id) {
List<AuctionItemCommentParentDto> commentViews = this.auctionItemCommentServiceImpl.findAuctionItemCommentById(id);
return ResponseEntity.ok(commentViews);
}


@Operation(summary = "경매품 댓글 수정 ", description = "경매품 댓글 수정")
@PutMapping({""})
public ResponseEntity<HttpStatus> updateAuctionItemComment(@RequestBody AuctionItemCommentUpdateRequest auctionItemCommentUpdateRequest) {
this.auctionItemCommentServiceImpl.updateAuctionItemComment(auctionItemCommentUpdateRequest);
return ResponseEntity.status(HttpStatus.OK).build();
}

@Operation(summary = "경매품 댓글 삭제",description = "경매품 댓글 삭제")
@DeleteMapping({""})
public ResponseEntity<HttpStatus> deleteAuctionItemComment(AuctionItemCommentDeleteRequest auctionItemCommentDeleteRequest) {
this.auctionItemCommentServiceImpl.deleteAuctionItemComment(auctionItemCommentDeleteRequest);
return ResponseEntity.status(HttpStatus.OK).build();
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -2,51 +2,57 @@

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import javax.transaction.Transactional;
import javax.validation.Valid;
import lombok.RequiredArgsConstructor;
import megabrain.gyeongnamgyeongmae.domain.auctionItem.dto.AuctionItemResponse;
import megabrain.gyeongnamgyeongmae.domain.auctionItem.dto.CreateAuctionItemRequest;
import megabrain.gyeongnamgyeongmae.domain.auctionItem.dto.UpdateAuctionItemRequest;
import megabrain.gyeongnamgyeongmae.domain.auctionItem.service.Item.AuctionItemService;
import megabrain.gyeongnamgyeongmae.domain.auctionItem.service.Item.AuctionItemServiceImpl;
import megabrain.gyeongnamgyeongmae.domain.category.service.CategoryService;
import megabrain.gyeongnamgyeongmae.domain.member.service.MemberService;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@Tag(name = "경매품 게시", description = "경매품 게시 관련 API")
@RequestMapping("api/auctions")
import javax.validation.Valid;

@Tag(name = "경매품 업로드", description = "경매품 작성 관련 api")
@RequestMapping({"api/auctions/"})
@RestController
@RequiredArgsConstructor
public class AuctionItemController {

private final AuctionItemService auctionItemService;
private final CategoryService categoryService;
private final MemberService memberService;

@Operation(summary = "Post AuctionItem", description = "경매품 올리기")
@ResponseStatus(HttpStatus.CREATED)
@PostMapping()
public ResponseEntity<HttpStatus> createAuctionItem(
@RequestBody @Valid CreateAuctionItemRequest createAuctionItemRequest) {
auctionItemService.createAuctionItem(createAuctionItemRequest);
return ResponseEntity.status(HttpStatus.CREATED).build();
}

@Operation(summary = "Show AuctionItem", description = "경매품 상세보기")
@GetMapping("{id}")
public ResponseEntity<AuctionItemResponse> findAuctionItemById(@PathVariable Long id) {
AuctionItemResponse auctionItemResponse = auctionItemService.findAuctionItemById(id);
return ResponseEntity.ok(auctionItemResponse);
}

@Operation(summary = "Update AuctionItem", description = "경매품 수정하기")
@PutMapping()
@Transactional
public ResponseEntity<HttpStatus> updateAuctionItemById(
@RequestBody @Valid UpdateAuctionItemRequest upDateAuctionItemRequest) {
auctionItemService.updateAuctionItem(upDateAuctionItemRequest);
return ResponseEntity.status(HttpStatus.OK).build();
}
private final AuctionItemServiceImpl auctionItemServiceImpl;
private final CategoryService categoryService;
private final MemberService memberService;

@Operation(summary = "Post AuctionItem", description = "경매품 올리기")
@ResponseStatus(HttpStatus.CREATED)
@PostMapping("")
public ResponseEntity<HttpStatus> createAuctionItem(@RequestBody @Valid CreateAuctionItemRequest createAuctionItemRequest) {
this.auctionItemServiceImpl.createAuctionItem(createAuctionItemRequest);
return ResponseEntity.status(HttpStatus.CREATED).build();
}

@Operation(summary = "Show AuctionItem", description = "경매품 상세보기")
@GetMapping("{id}")
public ResponseEntity<AuctionItemResponse> findAuctionItemById(@PathVariable Long id) {
AuctionItemResponse auctionItemResponse = auctionItemServiceImpl.findAuctionItemById(id);
return ResponseEntity.ok(auctionItemResponse);
}

@Operation(summary = "Update AuctionItem", description = "경매품 수정하기")
@PutMapping("{id}")
public ResponseEntity<HttpStatus> updateAuctionItemById(@PathVariable Long id, @RequestBody @Valid UpdateAuctionItemRequest upDateAuctionItemRequest) {
this.auctionItemServiceImpl.updateAuctionItem(upDateAuctionItemRequest, id);
return ResponseEntity.status(HttpStatus.OK).build();
}


@Operation(summary = "Delete AuctionItem", description = "경매품 삭제하기")
@DeleteMapping("{id}")
public ResponseEntity<HttpStatus> deleteAuctionItemById(@PathVariable Long id) {
this.auctionItemServiceImpl.deleteAuctionItemById(id);
return ResponseEntity.status(HttpStatus.OK).build();
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package megabrain.gyeongnamgyeongmae.domain.auctionItem.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import megabrain.gyeongnamgyeongmae.domain.auctionItem.domain.repostiory.AuctionItemRepository;
import megabrain.gyeongnamgyeongmae.domain.auctionItem.dto.AuctionItemFirstView;
import megabrain.gyeongnamgyeongmae.domain.auctionItem.dto.SearchItem.SearchAuctionItemSortedRequest;
import megabrain.gyeongnamgyeongmae.domain.auctionItem.service.Item.AuctionItemServiceImpl;
import megabrain.gyeongnamgyeongmae.domain.auctionItem.service.Search.AuctionItemSearchServiceImpl;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Tag(name = "경매품 검색", description = "경매품 검색 관련 API")
@RequestMapping({"api/auctions/search"})
@RestController
@RequiredArgsConstructor
public class AuctionItemSearchController {

private final AuctionItemServiceImpl auctionItemServiceImpl;
private final AuctionItemRepository AuctionItemRepository;
private final AuctionItemSearchServiceImpl auctionItemSearchServiceImpl;

@Operation(summary = "Search AuctionItem", description = "경매품 검색하기")
@GetMapping("")
public ResponseEntity<Page<AuctionItemFirstView>> findItemCategory(@ModelAttribute SearchAuctionItemSortedRequest searchAuctionItemSortedRequest, Pageable pageable) {
Page<AuctionItemFirstView> result = this.auctionItemSearchServiceImpl.findAuctionItembyRequest(searchAuctionItemSortedRequest, pageable);
return ResponseEntity.ok(result);
}
}
Loading

0 comments on commit c656182

Please sign in to comment.