-
Notifications
You must be signed in to change notification settings - Fork 0
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 #5 from JECT-Study/J01-39-be-공지사항-기능
J01 39 be 공지사항 기능
- Loading branch information
Showing
32 changed files
with
361 additions
and
120 deletions.
There are no files selected for viewing
4 changes: 0 additions & 4 deletions
4
src/main/java/ject/componote/domain/announcement/api/FAQController.java
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
src/main/java/ject/componote/domain/announcement/api/NoticeController.java
This file was deleted.
Oops, something went wrong.
6 changes: 0 additions & 6 deletions
6
src/main/java/ject/componote/domain/announcement/domain/FAQRepository.java
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
src/main/java/ject/componote/domain/announcement/error/FAQException.java
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
src/main/java/ject/componote/domain/announcement/error/NoticeException.java
This file was deleted.
Oops, something went wrong.
20 changes: 0 additions & 20 deletions
20
src/main/java/ject/componote/domain/announcement/model/Description.java
This file was deleted.
Oops, something went wrong.
20 changes: 0 additions & 20 deletions
20
src/main/java/ject/componote/domain/announcement/model/Title.java
This file was deleted.
Oops, something went wrong.
18 changes: 0 additions & 18 deletions
18
src/main/java/ject/componote/domain/announcement/model/converter/DescriptionConverter.java
This file was deleted.
Oops, something went wrong.
18 changes: 0 additions & 18 deletions
18
src/main/java/ject/componote/domain/announcement/model/converter/TitleConverter.java
This file was deleted.
Oops, something went wrong.
30 changes: 30 additions & 0 deletions
30
src/main/java/ject/componote/domain/faq/api/FAQController.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 ject.componote.domain.faq.api; | ||
|
||
import jakarta.validation.Valid; | ||
import ject.componote.domain.common.dto.response.PageResponse; | ||
import ject.componote.domain.faq.application.FAQService; | ||
import ject.componote.domain.faq.dto.request.FAQRequest; | ||
import ject.componote.domain.faq.dto.response.FAQResponse; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.web.PageableDefault; | ||
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; | ||
|
||
@RequestMapping("/faqs") | ||
@RestController | ||
@RequiredArgsConstructor | ||
public class FAQController { | ||
private final FAQService faqService; | ||
|
||
@GetMapping | ||
public ResponseEntity<PageResponse<FAQResponse>> getFAQs(@ModelAttribute @Valid final FAQRequest faqRequest, | ||
@PageableDefault final Pageable pageable) { | ||
return ResponseEntity.ok( | ||
faqService.getFAQs(faqRequest, pageable) | ||
); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/ject/componote/domain/faq/api/FAQTypeConstant.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 ject.componote.domain.faq.api; | ||
|
||
import ject.componote.domain.faq.domain.FAQType; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
public enum FAQTypeConstant { | ||
ALL(null), | ||
COMPONENT(FAQType.COMPONENT), | ||
DESIGN(FAQType.DESIGN), | ||
SERVICE(FAQType.SERVICE), | ||
ETC(FAQType.ETC); | ||
|
||
private final FAQType type; | ||
|
||
FAQTypeConstant(final FAQType type) { | ||
this.type = type; | ||
} | ||
|
||
public boolean isAll() { | ||
return this == ALL; | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
src/main/java/ject/componote/domain/faq/application/FAQService.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,37 @@ | ||
package ject.componote.domain.faq.application; | ||
|
||
import ject.componote.domain.common.dto.response.PageResponse; | ||
import ject.componote.domain.faq.api.FAQTypeConstant; | ||
import ject.componote.domain.faq.dao.FAQRepository; | ||
import ject.componote.domain.faq.domain.FAQ; | ||
import ject.componote.domain.faq.domain.FAQType; | ||
import ject.componote.domain.faq.dto.request.FAQRequest; | ||
import ject.componote.domain.faq.dto.response.FAQResponse; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
@Transactional(readOnly = true) | ||
public class FAQService { | ||
private final FAQRepository faqRepository; | ||
|
||
public PageResponse<FAQResponse> getFAQs(final FAQRequest request, final Pageable pageable) { | ||
final FAQTypeConstant typeConstant = request.type(); | ||
final Page<FAQResponse> page = findAllFAQsWithConditions(typeConstant, pageable) | ||
.map(FAQResponse::from); | ||
return PageResponse.from(page); | ||
} | ||
|
||
private Page<FAQ> findAllFAQsWithConditions(final FAQTypeConstant typeConstant, final Pageable pageable) { | ||
if (typeConstant.isAll()) { | ||
return faqRepository.findAll(pageable); | ||
} | ||
|
||
final FAQType type = typeConstant.getType(); | ||
return faqRepository.findAllByType(type, pageable); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/ject/componote/domain/faq/dao/FAQRepository.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,11 @@ | ||
package ject.componote.domain.faq.dao; | ||
|
||
import ject.componote.domain.faq.domain.FAQ; | ||
import ject.componote.domain.faq.domain.FAQType; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface FAQRepository extends JpaRepository<FAQ, Long> { | ||
Page<FAQ> findAllByType(final FAQType type, final Pageable pageable); | ||
} |
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
2 changes: 1 addition & 1 deletion
2
...e/domain/announcement/domain/FAQType.java → .../componote/domain/faq/domain/FAQType.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
7 changes: 7 additions & 0 deletions
7
src/main/java/ject/componote/domain/faq/dto/request/FAQRequest.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,7 @@ | ||
package ject.componote.domain.faq.dto.request; | ||
|
||
import jakarta.validation.constraints.NotNull; | ||
import ject.componote.domain.faq.api.FAQTypeConstant; | ||
|
||
public record FAQRequest(@NotNull FAQTypeConstant type) { | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/ject/componote/domain/faq/dto/response/FAQResponse.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 ject.componote.domain.faq.dto.response; | ||
|
||
import ject.componote.domain.faq.domain.FAQ; | ||
|
||
public record FAQResponse(String title, String content) { | ||
public static FAQResponse from(final FAQ faq) { | ||
return new FAQResponse(faq.getTitle().getValue(), faq.getContent().getValue()); | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
src/main/java/ject/componote/domain/faq/error/FAQException.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,4 @@ | ||
package ject.componote.domain.faq.error; | ||
|
||
public class FAQException { | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/java/ject/componote/domain/faq/model/FAQContent.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 ject.componote.domain.faq.model; | ||
|
||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
import lombok.ToString; | ||
|
||
@EqualsAndHashCode | ||
@Getter | ||
@ToString | ||
public class FAQContent { | ||
private final String value; | ||
|
||
private FAQContent(final String value) { | ||
this.value = value; | ||
} | ||
|
||
public static FAQContent from(final String value) { | ||
return new FAQContent(value); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/java/ject/componote/domain/faq/model/FAQTitle.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 ject.componote.domain.faq.model; | ||
|
||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
import lombok.ToString; | ||
|
||
@Getter | ||
@EqualsAndHashCode | ||
@ToString | ||
public class FAQTitle { | ||
private final String value; | ||
|
||
private FAQTitle(final String value) { | ||
this.value = value; | ||
} | ||
|
||
public static FAQTitle from(final String value) { | ||
return new FAQTitle(value); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/ject/componote/domain/faq/model/converter/FAQContentConverter.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 ject.componote.domain.faq.model.converter; | ||
|
||
import jakarta.persistence.AttributeConverter; | ||
import jakarta.persistence.Converter; | ||
import ject.componote.domain.faq.model.FAQContent; | ||
|
||
@Converter | ||
public class FAQContentConverter implements AttributeConverter<FAQContent, String> { | ||
@Override | ||
public String convertToDatabaseColumn(final FAQContent attribute) { | ||
return attribute.getValue(); | ||
} | ||
|
||
@Override | ||
public FAQContent convertToEntityAttribute(final String dbData) { | ||
return FAQContent.from(dbData); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/ject/componote/domain/faq/model/converter/FAQTitleConverter.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 ject.componote.domain.faq.model.converter; | ||
|
||
import jakarta.persistence.AttributeConverter; | ||
import jakarta.persistence.Converter; | ||
import ject.componote.domain.faq.model.FAQTitle; | ||
|
||
@Converter | ||
public class FAQTitleConverter implements AttributeConverter<FAQTitle, String> { | ||
@Override | ||
public String convertToDatabaseColumn(final FAQTitle attribute) { | ||
return attribute.getValue(); | ||
} | ||
|
||
@Override | ||
public FAQTitle convertToEntityAttribute(final String dbData) { | ||
return FAQTitle.from(dbData); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/ject/componote/domain/notice/api/NoticeController.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,26 @@ | ||
package ject.componote.domain.notice.api; | ||
|
||
import ject.componote.domain.common.dto.response.PageResponse; | ||
import ject.componote.domain.notice.application.NoticeService; | ||
import ject.componote.domain.notice.dto.response.NoticeResponse; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.web.PageableDefault; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/notices") | ||
public class NoticeController { | ||
private final NoticeService noticeService; | ||
|
||
@GetMapping | ||
public ResponseEntity<PageResponse<NoticeResponse>> getNotices(@PageableDefault final Pageable pageable) { | ||
return ResponseEntity.ok( | ||
noticeService.getNotices(pageable) | ||
); | ||
} | ||
} |
Oops, something went wrong.