diff --git a/src/main/java/com/umc/networkingService/domain/todayILearned/controller/TodayILearnedController.java b/src/main/java/com/umc/networkingService/domain/todayILearned/controller/TodayILearnedController.java index b11d5dd8..e7badaeb 100644 --- a/src/main/java/com/umc/networkingService/domain/todayILearned/controller/TodayILearnedController.java +++ b/src/main/java/com/umc/networkingService/domain/todayILearned/controller/TodayILearnedController.java @@ -8,6 +8,7 @@ import com.umc.networkingService.domain.todayILearned.dto.response.TodayILearnedResponse.TodayILearnedId; import com.umc.networkingService.domain.todayILearned.dto.response.TodayILearnedResponse.TodayILearnedInfos; import com.umc.networkingService.domain.todayILearned.dto.response.TodayILearnedResponse.TodayILearnedDetail; +import com.umc.networkingService.domain.todayILearned.dto.response.TodayILearnedResponse.TodayILearnedWebInfos; import com.umc.networkingService.domain.todayILearned.service.TodayILearnedService; import com.umc.networkingService.global.common.base.BaseResponse; import io.swagger.v3.oas.annotations.Operation; @@ -74,6 +75,19 @@ public BaseResponse getTodayILearnedInfos(@CurrentMember Mem return BaseResponse.onSuccess(todayILearnedService.getTodayILearnedInfos(member, date)); } + @Operation(summary = "Today I Learned 조회(일별) - Web", description = "웹용 TIL(일별)을 조회하는 API입니다.") + @GetMapping("/web") + @ApiResponses(value = { + @ApiResponse(responseCode = "COMMON200", description = "성공") + }) + @Parameters(value = { + @Parameter(name="date", description = "현재 날짜를 2024-02-08 형식으로 전달해 주세요.") + }) + public BaseResponse getTodayILearnedWebInfos(@CurrentMember Member member, + @RequestParam(value = "date") String date) { + return BaseResponse.onSuccess(todayILearnedService.getTodayILearnedWebInfos(member, date)); + } + @Operation(summary = "Today I Learned 삭제", description = "TIL을 삭제하는 API입니다.") @DeleteMapping("/{todayILearnedId}") diff --git a/src/main/java/com/umc/networkingService/domain/todayILearned/dto/response/TodayILearnedResponse.java b/src/main/java/com/umc/networkingService/domain/todayILearned/dto/response/TodayILearnedResponse.java index 1fd35766..7eeca9ee 100644 --- a/src/main/java/com/umc/networkingService/domain/todayILearned/dto/response/TodayILearnedResponse.java +++ b/src/main/java/com/umc/networkingService/domain/todayILearned/dto/response/TodayILearnedResponse.java @@ -47,6 +47,26 @@ public static class TodayILearnedInfos { private List todayILearnedInfos; } + @Getter + @Builder + @NoArgsConstructor + @AllArgsConstructor + public static class TodayILearnedWebInfo { + private UUID todayILearnedId; + private String title; + private String subTitle; + private String content; + private Part part; + } + + @Getter + @Builder + @NoArgsConstructor + @AllArgsConstructor + public static class TodayILearnedWebInfos { + private List todayILearnedInfos; + } + @Getter @Builder @NoArgsConstructor diff --git a/src/main/java/com/umc/networkingService/domain/todayILearned/mapper/TodayILearnedMapper.java b/src/main/java/com/umc/networkingService/domain/todayILearned/mapper/TodayILearnedMapper.java index 87fae83b..d49b8839 100644 --- a/src/main/java/com/umc/networkingService/domain/todayILearned/mapper/TodayILearnedMapper.java +++ b/src/main/java/com/umc/networkingService/domain/todayILearned/mapper/TodayILearnedMapper.java @@ -2,10 +2,14 @@ import com.umc.networkingService.domain.member.entity.Member; import com.umc.networkingService.domain.todayILearned.dto.requeest.TodayILearnedRequest.TodayILearnedCreate; +import com.umc.networkingService.domain.todayILearned.dto.response.TodayILearnedResponse; import com.umc.networkingService.domain.todayILearned.dto.response.TodayILearnedResponse.TodayILearnedId; import com.umc.networkingService.domain.todayILearned.dto.response.TodayILearnedResponse.TodayILearnedInfo; import com.umc.networkingService.domain.todayILearned.dto.response.TodayILearnedResponse.TodayILearnedInfos; import com.umc.networkingService.domain.todayILearned.dto.response.TodayILearnedResponse.TodayILearnedDetail; +import com.umc.networkingService.domain.todayILearned.dto.response.TodayILearnedResponse.TodayILearnedWebInfos; +import com.umc.networkingService.domain.todayILearned.dto.response.TodayILearnedResponse.TodayILearnedWebInfo; + import com.umc.networkingService.domain.todayILearned.entity.TodayILearned; import org.springframework.stereotype.Component; @@ -46,6 +50,16 @@ public TodayILearnedInfos toTodayILearnedInfos(List todayILea .build(); } + public TodayILearnedWebInfo toTodayILearnedWebInfo(TodayILearned todayILearned) { + return TodayILearnedWebInfo.builder() + .todayILearnedId(todayILearned.getId()) + .title(todayILearned.getTitle()) + .subTitle(todayILearned.getSubtitle()) + .content(todayILearned.getContent()) + .part(todayILearned.getPart()) + .build(); + } + public TodayILearnedDetail toTodayILearnedDetail(TodayILearned todayILearned, List files) { return TodayILearnedDetail.builder() .todayILearnedId(todayILearned.getId()) diff --git a/src/main/java/com/umc/networkingService/domain/todayILearned/service/TodayILearnedService.java b/src/main/java/com/umc/networkingService/domain/todayILearned/service/TodayILearnedService.java index 85354db8..4fda11ba 100644 --- a/src/main/java/com/umc/networkingService/domain/todayILearned/service/TodayILearnedService.java +++ b/src/main/java/com/umc/networkingService/domain/todayILearned/service/TodayILearnedService.java @@ -7,6 +7,7 @@ import com.umc.networkingService.domain.todayILearned.dto.response.TodayILearnedResponse.TodayILearnedId; import com.umc.networkingService.domain.todayILearned.dto.response.TodayILearnedResponse.TodayILearnedInfos; import com.umc.networkingService.domain.todayILearned.dto.response.TodayILearnedResponse.TodayILearnedDetail; +import com.umc.networkingService.domain.todayILearned.dto.response.TodayILearnedResponse.TodayILearnedWebInfos; import com.umc.networkingService.domain.todayILearned.entity.TodayILearned; import com.umc.networkingService.global.common.base.EntityLoader; import org.springframework.web.multipart.MultipartFile; @@ -17,6 +18,7 @@ public interface TodayILearnedService extends EntityLoader { TodayILearnedResponse.TodayILearnedCreate createTodayILearned(Member member, List files, TodayILearnedCreate request); TodayILearnedInfos getTodayILearnedInfos(Member member, String date); + TodayILearnedWebInfos getTodayILearnedWebInfos(Member member, String date); TodayILearnedId updateTodayILearned(Member member, UUID todayILearnedId, List files, TodayILearnedUpdate request); TodayILearnedId deleteTodayILearned(Member member, UUID todayILearnedId); TodayILearnedDetail getTodayILearnedDetail(Member member, UUID todayILearnedId); diff --git a/src/main/java/com/umc/networkingService/domain/todayILearned/service/TodayILearnedServiceImpl.java b/src/main/java/com/umc/networkingService/domain/todayILearned/service/TodayILearnedServiceImpl.java index 6b75ceb3..aef073dd 100644 --- a/src/main/java/com/umc/networkingService/domain/todayILearned/service/TodayILearnedServiceImpl.java +++ b/src/main/java/com/umc/networkingService/domain/todayILearned/service/TodayILearnedServiceImpl.java @@ -7,6 +7,7 @@ import com.umc.networkingService.domain.todayILearned.dto.response.TodayILearnedResponse; import com.umc.networkingService.domain.todayILearned.dto.response.TodayILearnedResponse.TodayILearnedId; import com.umc.networkingService.domain.todayILearned.dto.response.TodayILearnedResponse.TodayILearnedInfos; +import com.umc.networkingService.domain.todayILearned.dto.response.TodayILearnedResponse.TodayILearnedWebInfos; import com.umc.networkingService.domain.todayILearned.entity.TodayILearned; import com.umc.networkingService.domain.todayILearned.entity.TodayILearnedFile; import com.umc.networkingService.domain.todayILearned.mapper.TodayILearnedMapper; @@ -67,6 +68,18 @@ public TodayILearnedInfos getTodayILearnedInfos(Member member, String stringDate .toList()); } + @Override + public TodayILearnedWebInfos getTodayILearnedWebInfos(Member member, String stringDate) { + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + LocalDate date = LocalDate.parse(stringDate,formatter); + + return new TodayILearnedWebInfos( + todayILearnedRepository.findTodayILearnedByWriterAndCreateDate(member, date) + .stream() + .map(todayILearnedMapper::toTodayILearnedWebInfo) + .toList()); + } + @Override @Transactional public TodayILearnedId updateTodayILearned(Member member, UUID todayILearnedId, List files, diff --git a/src/main/resources/application-local.yml b/src/main/resources/application-local.yml index 5dcdf205..9ed46296 100644 --- a/src/main/resources/application-local.yml +++ b/src/main/resources/application-local.yml @@ -13,7 +13,7 @@ spring: jpa: show-sql: true hibernate: - ddl-auto: create + ddl-auto: update properties: hibernate: format_sql: true \ No newline at end of file