Skip to content

Commit

Permalink
Merge pull request #89 from Team-UMC/feature/#88/web-til-api
Browse files Browse the repository at this point in the history
[FEAT] web용 ìTIL 일별 조회 API 구현
  • Loading branch information
junseokkim authored Feb 18, 2024
2 parents 55788b4 + 453cdbb commit 3422488
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -74,6 +75,19 @@ public BaseResponse<TodayILearnedInfos> 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<TodayILearnedWebInfos> 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}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,26 @@ public static class TodayILearnedInfos {
private List<TodayILearnedInfo> 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<TodayILearnedWebInfo> todayILearnedInfos;
}

@Getter
@Builder
@NoArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -46,6 +50,16 @@ public TodayILearnedInfos toTodayILearnedInfos(List<TodayILearnedInfo> 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<String> files) {
return TodayILearnedDetail.builder()
.todayILearnedId(todayILearned.getId())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -17,6 +18,7 @@
public interface TodayILearnedService extends EntityLoader<TodayILearned, UUID> {
TodayILearnedResponse.TodayILearnedCreate createTodayILearned(Member member, List<MultipartFile> files, TodayILearnedCreate request);
TodayILearnedInfos getTodayILearnedInfos(Member member, String date);
TodayILearnedWebInfos getTodayILearnedWebInfos(Member member, String date);
TodayILearnedId updateTodayILearned(Member member, UUID todayILearnedId, List<MultipartFile> files, TodayILearnedUpdate request);
TodayILearnedId deleteTodayILearned(Member member, UUID todayILearnedId);
TodayILearnedDetail getTodayILearnedDetail(Member member, UUID todayILearnedId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<MultipartFile> files,
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/application-local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ spring:
jpa:
show-sql: true
hibernate:
ddl-auto: create
ddl-auto: update
properties:
hibernate:
format_sql: true

0 comments on commit 3422488

Please sign in to comment.