From 23a596974a523553faab9628a6653c11ec9e647d Mon Sep 17 00:00:00 2001 From: dl-00-e8 Date: Thu, 9 Feb 2023 03:13:40 +0900 Subject: [PATCH] =?UTF-8?q?[FEAT]=20=EA=B2=80=EC=83=89=20API=20#24?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../search/controller/SearchController.java | 25 +++++++++++++++++++ .../api/search/dto/request/PostSearchReq.java | 18 +++++++++++++ .../search/dto/response/PostArticleRes.java | 7 ++++++ .../search/dto/response/PostEditorRes.java | 7 ++++++ .../search/dto/response/PostSearchRes.java | 13 ++++++++++ .../search/repository/SearchRepository.java | 13 ++++++++++ .../domain/search/service/SearchService.java | 21 ++++++++++++++++ 7 files changed, 104 insertions(+) create mode 100644 src/main/java/com/mews/mews_backend/api/search/controller/SearchController.java create mode 100644 src/main/java/com/mews/mews_backend/api/search/dto/request/PostSearchReq.java create mode 100644 src/main/java/com/mews/mews_backend/api/search/dto/response/PostArticleRes.java create mode 100644 src/main/java/com/mews/mews_backend/api/search/dto/response/PostEditorRes.java create mode 100644 src/main/java/com/mews/mews_backend/api/search/dto/response/PostSearchRes.java create mode 100644 src/main/java/com/mews/mews_backend/domain/search/repository/SearchRepository.java create mode 100644 src/main/java/com/mews/mews_backend/domain/search/service/SearchService.java diff --git a/src/main/java/com/mews/mews_backend/api/search/controller/SearchController.java b/src/main/java/com/mews/mews_backend/api/search/controller/SearchController.java new file mode 100644 index 0000000..56b5bcf --- /dev/null +++ b/src/main/java/com/mews/mews_backend/api/search/controller/SearchController.java @@ -0,0 +1,25 @@ +package com.mews.mews_backend.api.search.controller; + +import com.mews.mews_backend.api.search.dto.response.PostSearchRes; +import io.swagger.annotations.Api; +import lombok.RequiredArgsConstructor; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequiredArgsConstructor +@Api(tags = {"Mews Search API"}) +@RequestMapping("/search") +public class SearchController { + + @PostMapping(value = "/{keyword}") + public ResponseEntity Search(@PathVariable ("keyword") String string) { + PostSearchRes postSearchRes = new PostSearchRes(); + + + return ResponseEntity.ok(postSearchRes); + } +} diff --git a/src/main/java/com/mews/mews_backend/api/search/dto/request/PostSearchReq.java b/src/main/java/com/mews/mews_backend/api/search/dto/request/PostSearchReq.java new file mode 100644 index 0000000..51177bc --- /dev/null +++ b/src/main/java/com/mews/mews_backend/api/search/dto/request/PostSearchReq.java @@ -0,0 +1,18 @@ +package com.mews.mews_backend.api.search.dto.request; + +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import javax.validation.constraints.NotBlank; + +@AllArgsConstructor +@NoArgsConstructor +@Getter +public class PostSearchReq { + + @NotBlank + @ApiModelProperty(notes = "검색 키워드", example = "작성자") + private String keyword; +} diff --git a/src/main/java/com/mews/mews_backend/api/search/dto/response/PostArticleRes.java b/src/main/java/com/mews/mews_backend/api/search/dto/response/PostArticleRes.java new file mode 100644 index 0000000..b1cc746 --- /dev/null +++ b/src/main/java/com/mews/mews_backend/api/search/dto/response/PostArticleRes.java @@ -0,0 +1,7 @@ +package com.mews.mews_backend.api.search.dto.response; + +import lombok.Getter; + +@Getter +public class PostArticleRes { +} diff --git a/src/main/java/com/mews/mews_backend/api/search/dto/response/PostEditorRes.java b/src/main/java/com/mews/mews_backend/api/search/dto/response/PostEditorRes.java new file mode 100644 index 0000000..26c219c --- /dev/null +++ b/src/main/java/com/mews/mews_backend/api/search/dto/response/PostEditorRes.java @@ -0,0 +1,7 @@ +package com.mews.mews_backend.api.search.dto.response; + +import lombok.Getter; + +@Getter +public class PostEditorRes { +} diff --git a/src/main/java/com/mews/mews_backend/api/search/dto/response/PostSearchRes.java b/src/main/java/com/mews/mews_backend/api/search/dto/response/PostSearchRes.java new file mode 100644 index 0000000..8e971f0 --- /dev/null +++ b/src/main/java/com/mews/mews_backend/api/search/dto/response/PostSearchRes.java @@ -0,0 +1,13 @@ +package com.mews.mews_backend.api.search.dto.response; + +import lombok.Getter; + +import java.util.List; + +@Getter +public class PostSearchRes { + + private List postArticleRes; + + private List postSearchRes; +} diff --git a/src/main/java/com/mews/mews_backend/domain/search/repository/SearchRepository.java b/src/main/java/com/mews/mews_backend/domain/search/repository/SearchRepository.java new file mode 100644 index 0000000..6956d48 --- /dev/null +++ b/src/main/java/com/mews/mews_backend/domain/search/repository/SearchRepository.java @@ -0,0 +1,13 @@ +package com.mews.mews_backend.domain.search.repository; + +import com.mews.mews_backend.domain.calendar.entity.Calendar; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.config.EnableJpaRepositories; +import org.springframework.stereotype.Repository; + + +@Repository +@EnableJpaRepositories +public interface SearchRepository extends JpaRepository { + +} \ No newline at end of file diff --git a/src/main/java/com/mews/mews_backend/domain/search/service/SearchService.java b/src/main/java/com/mews/mews_backend/domain/search/service/SearchService.java new file mode 100644 index 0000000..6df295a --- /dev/null +++ b/src/main/java/com/mews/mews_backend/domain/search/service/SearchService.java @@ -0,0 +1,21 @@ +package com.mews.mews_backend.domain.search.service; + +import com.mews.mews_backend.domain.search.repository.SearchRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import javax.transaction.Transactional; + +@Service +@Transactional +public class SearchService { + + private final SearchRepository searchRepository; + + @Autowired + public SearchService(SearchRepository searchRepository) { + this.searchRepository = searchRepository; + } + + +}