Skip to content

Commit

Permalink
Merge pull request #150 from Team-Shaka/develop
Browse files Browse the repository at this point in the history
Fix: 순위버그
  • Loading branch information
swa07016 authored Jan 8, 2024
2 parents c2c3f9b + fd3df63 commit 1acc546
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 23 deletions.
7 changes: 2 additions & 5 deletions src/main/java/briefing/briefing/api/BriefingApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.Optional;

import jakarta.validation.Valid;

import org.springdoc.core.annotations.ParameterObject;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
Expand Down Expand Up @@ -71,26 +72,22 @@ public void createBriefing(@RequestBody final BriefingRequestDTO.BriefingCreate
briefingCommandService.createBriefing(request);
}


/*
* TODO 브리핑 수정 API는 우선적으로 인가 처리를 진행하지 않으나
* 빠른 시일 내로 브리핑 등록과 함께 인가 처리 예정
* 즉 유저에게 권한을 부여하는 일련의 과정에 대한 리팩토링이 필요함 이는 CYY1007이 진행하겠음
*/

/**
*
* @param id, BriefingResponseDTO.BriefingUpdateDTO
* @return 수정된 값, 요청으로 온 값과 동일
*/

@Operation(summary = "03-04Briefing \uD83D\uDCF0 브리핑 내용 수정", description = "")
@Parameter(name = "id", description = "브리핑 아이디", example = "1")
@PatchMapping("/briefings/{id}")
public CommonResponse<BriefingResponseDTO.BriefingUpdateDTO> patchBriefingContent(
@PathVariable(name = "id") Long id,
@RequestBody @Valid BriefingRequestDTO.BriefingUpdateDTO request
){
@RequestBody @Valid BriefingRequestDTO.BriefingUpdateDTO request) {

Briefing briefing = briefingCommandService.updateBriefing(id, request);
return CommonResponse.onSuccess(BriefingConverter.toBriefingUpdateDTO(briefing));
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/briefing/briefing/api/BriefingConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,8 @@ public static BriefingResponseDTO.BriefingV2PreviewListDTO toBriefingPreviewV2Te
.build();
}

public static BriefingResponseDTO.BriefingUpdateDTO toBriefingUpdateDTO(Briefing briefing){
return BriefingResponseDTO.BriefingUpdateDTO
.builder()
public static BriefingResponseDTO.BriefingUpdateDTO toBriefingUpdateDTO(Briefing briefing) {
return BriefingResponseDTO.BriefingUpdateDTO.builder()
.title(briefing.getTitle())
.subTitle(briefing.getSubtitle())
.content(briefing.getContent())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package briefing.briefing.application;

import java.util.List;
import java.util.Optional;

import briefing.exception.ErrorCode;
import briefing.exception.handler.BriefingException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

Expand All @@ -16,10 +13,10 @@
import briefing.briefing.domain.repository.ArticleRepository;
import briefing.briefing.domain.repository.BriefingArticleRepository;
import briefing.briefing.domain.repository.BriefingRepository;
import briefing.exception.ErrorCode;
import briefing.exception.handler.BriefingException;
import lombok.RequiredArgsConstructor;

import javax.swing.text.html.Option;

@Service
@Transactional
@RequiredArgsConstructor
Expand All @@ -42,11 +39,14 @@ public void createBriefing(final BriefingRequestDTO.BriefingCreate request) {
briefingArticleRepository.saveAll(briefingArticles);
}

public Briefing updateBriefing(Long id, final BriefingRequestDTO.BriefingUpdateDTO request){
public Briefing updateBriefing(Long id, final BriefingRequestDTO.BriefingUpdateDTO request) {

Briefing briefing = briefingRepository.findById(id).orElseThrow(() -> new BriefingException(ErrorCode.NOT_FOUND_BRIEFING));
Briefing briefing =
briefingRepository
.findById(id)
.orElseThrow(() -> new BriefingException(ErrorCode.NOT_FOUND_BRIEFING));

briefing.updateBriefing(request.getTitle(),request.getSubTitle(),request.getContent());
briefing.updateBriefing(request.getTitle(), request.getSubTitle(), request.getContent());

return briefing;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
import briefing.briefing.domain.BriefingType;
import briefing.briefing.domain.TimeOfDay;
import briefing.chatting.domain.GptModel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

public class BriefingRequestDTO {

Expand Down Expand Up @@ -41,7 +38,7 @@ public static class BriefingCreate {
}

@Getter
public static class BriefingUpdateDTO{
public static class BriefingUpdateDTO {
String title;
String subTitle;
String content;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public static class BriefingPreviewV2TempDTO {
@Getter
@NoArgsConstructor
@AllArgsConstructor
public static class BriefingUpdateDTO{
public static class BriefingUpdateDTO {
String title;
String subTitle;
String content;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/briefing/briefing/domain/Briefing.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void setContent(String content) {
this.content = content;
}

public void updateBriefing(String title, String subtitle, String content){
public void updateBriefing(String title, String subtitle, String content) {
Optional.ofNullable(title).ifPresent(this::setTitle);
Optional.ofNullable(subtitle).ifPresent(this::setSubtitle);
Optional.ofNullable(content).ifPresent(this::setContent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public List<Briefing> findTop10ByTypeOrderByCreatedAtDesc(BriefingType type) {
DateTimePath<LocalDateTime> dateTime = briefing.createdAt;
DateTemplate<LocalDate> date =
Expressions.dateTemplate(
LocalDate.class, "DATE_FORMAT({0}, {1})", dateTime, "%Y-%m-%d");
LocalDate.class, "DATE_FORMAT({0}, {1})", dateTime, "%Y-%m-%d %H");

List<Tuple> results =
queryFactory
Expand Down

0 comments on commit 1acc546

Please sign in to comment.