Skip to content

Commit

Permalink
[release] v1.0.1 (#103)
Browse files Browse the repository at this point in the history
Co-authored-by: Wonjun You <[email protected]>
  • Loading branch information
5uhwann and wonjunYou authored Sep 5, 2024
1 parent c2d55ae commit 2258f62
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import ddingdong.ddingdongBE.domain.activityreport.controller.dto.request.CreateActivityTermInfoRequest;
import ddingdong.ddingdongBE.domain.activityreport.controller.dto.response.ActivityReportListResponse;
import ddingdong.ddingdongBE.domain.activityreport.controller.dto.response.ActivityReportTermInfoResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
Expand All @@ -24,12 +23,6 @@ public interface AdminActivityReportApi {
@SecurityRequirement(name = "AccessToken")
List<ActivityReportListResponse> getActivityReports();

@Operation(summary = "활동 보고서 회차별 기간 조회 API")
@GetMapping("/term")
@ResponseStatus(HttpStatus.OK)
@SecurityRequirement(name = "AccessToken")
List<ActivityReportTermInfoResponse> getActivityTermInfos();

@Operation(summary = "활동 보고서 회차별 기간 설정 API")
@PostMapping("/term")
@ResponseStatus(HttpStatus.CREATED)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import ddingdong.ddingdongBE.domain.activityreport.controller.dto.request.UpdateActivityReportRequest;
import ddingdong.ddingdongBE.domain.activityreport.controller.dto.response.ActivityReportListResponse;
import ddingdong.ddingdongBE.domain.activityreport.controller.dto.response.ActivityReportResponse;
import ddingdong.ddingdongBE.domain.activityreport.controller.dto.response.ActivityReportTermInfoResponse;
import ddingdong.ddingdongBE.domain.activityreport.controller.dto.response.CurrentTermResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
Expand Down Expand Up @@ -82,4 +83,10 @@ void deleteActivityReport(
@RequestParam(value = "term") String term
);

@Operation(summary = "활동 보고서 회차별 기간 조회 API")
@GetMapping("/activity-reports/term")
@ResponseStatus(HttpStatus.OK)
@SecurityRequirement(name = "AccessToken")
List<ActivityReportTermInfoResponse> getActivityTermInfos();

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import ddingdong.ddingdongBE.domain.activityreport.api.AdminActivityReportApi;
import ddingdong.ddingdongBE.domain.activityreport.controller.dto.request.CreateActivityTermInfoRequest;
import ddingdong.ddingdongBE.domain.activityreport.controller.dto.response.ActivityReportListResponse;
import ddingdong.ddingdongBE.domain.activityreport.controller.dto.response.ActivityReportTermInfoResponse;
import ddingdong.ddingdongBE.domain.activityreport.service.ActivityReportService;
import ddingdong.ddingdongBE.domain.activityreport.service.ActivityReportTermInfoService;
import java.util.List;
Expand All @@ -23,11 +22,6 @@ public List<ActivityReportListResponse> getActivityReports() {
return activityReportService.getAll();
}

@Override
public List<ActivityReportTermInfoResponse> getActivityTermInfos() {
return activityReportTermInfoService.getAll();
}

@Override
public void createActivityTermInfo(CreateActivityTermInfoRequest request) {
activityReportTermInfoService.create(request.startDate(), request.totalTermCount());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
import ddingdong.ddingdongBE.domain.activityreport.controller.dto.response.ActivityReportDto;
import ddingdong.ddingdongBE.domain.activityreport.controller.dto.response.ActivityReportListResponse;
import ddingdong.ddingdongBE.domain.activityreport.controller.dto.response.ActivityReportResponse;
import ddingdong.ddingdongBE.domain.activityreport.controller.dto.response.ActivityReportTermInfoResponse;
import ddingdong.ddingdongBE.domain.activityreport.controller.dto.response.CurrentTermResponse;
import ddingdong.ddingdongBE.domain.activityreport.service.ActivityReportService;
import ddingdong.ddingdongBE.domain.activityreport.service.ActivityReportTermInfoService;
import ddingdong.ddingdongBE.domain.user.entity.User;
import ddingdong.ddingdongBE.file.service.FileService;
import java.util.ArrayList;
Expand All @@ -27,6 +29,7 @@
public class ClubActivityReportApiController implements ClubActivityReportApi {

private final ActivityReportService activityReportService;
private final ActivityReportTermInfoService activityReportTermInfoService;
private final FileService fileService;

public CurrentTermResponse getCurrentTerm() {
Expand Down Expand Up @@ -117,4 +120,10 @@ public void deleteActivityReport(
activityReportService.delete(user, term)
.forEach(it -> fileService.deleteFile(it.getId(), IMAGE, ACTIVITY_REPORT));
}

@Override
public List<ActivityReportTermInfoResponse> getActivityTermInfos() {
return activityReportTermInfoService.getAll();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import ddingdong.ddingdongBE.domain.activityreport.domain.ActivityReport;
import ddingdong.ddingdongBE.domain.activityreport.domain.Participant;
import ddingdong.ddingdongBE.domain.club.entity.Club;
import io.swagger.v3.oas.annotations.media.Schema;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
Expand All @@ -15,28 +16,45 @@ public class CreateActivityReportRequest {

public static final String DATE_FORMAT = "yyyy-MM-dd HH:mm";

@Schema(description = "활동 보고서 회차 정보")
private String term;

@Schema(description = "활동 보고서 내용")
private String content;

@Schema(description = "활동 장소")
private String place;

@Schema(description = "활동 시작 일시")
private String startDate;

@Schema(description = "활동 종료 일시")
private String endDate;

@Schema(description = "활동 참여자 명단")
private List<Participant> participants;

public ActivityReport toEntity(Club club) {
LocalDateTime startDateTime = parseToLocalDateTime(startDate);
LocalDateTime endDateTime = parseToLocalDateTime(endDate);

return ActivityReport.builder()
.term(this.term)
.content(this.content)
.place(this.place)
.startDate(parseToDate(this.getStartDate()))
.endDate(parseToDate(this.getEndDate()))
.participants(this.participants)
.club(club)
.build();
.term(this.term)
.content(this.content)
.place(this.place)
.startDate(startDateTime)
.endDate(endDateTime)
.participants(this.participants)
.club(club)
.build();
}

private LocalDateTime parseToDate(final String date) {
return LocalDateTime.parse(date, DateTimeFormatter.ofPattern(DATE_FORMAT));
private LocalDateTime parseToLocalDateTime(String dateString) {
if (dateString == null || dateString.isBlank()) {
return null;
}

return LocalDateTime.parse(dateString, DateTimeFormatter.ofPattern(DATE_FORMAT));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -69,20 +69,36 @@ public ActivityReport(String term, String content, String place, LocalDateTime s
}

public void update(final UpdateActivityReportRequest updateActivityReportRequest) {
this.content =
updateActivityReportRequest.getContent() != null ? updateActivityReportRequest.getContent() : this.content;
this.place =
updateActivityReportRequest.getPlace() != null ? updateActivityReportRequest.getPlace() : this.place;
this.startDate =
updateActivityReportRequest.getStartDate() != null ? LocalDateTime.parse(
updateActivityReportRequest.getStartDate(),
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")) : this.startDate;
this.endDate =
updateActivityReportRequest.getEndDate() != null ? LocalDateTime.parse(
updateActivityReportRequest.getEndDate(),
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")) : this.endDate;
this.participants =
updateActivityReportRequest.getParticipants() != null ? updateActivityReportRequest.getParticipants() :
this.participants;
this.content = updateActivityReportRequest.getContent() != null
? updateActivityReportRequest.getContent()
: this.content;

this.place = updateActivityReportRequest.getPlace() != null
? updateActivityReportRequest.getPlace()
: this.place;

this.startDate = processDate(updateActivityReportRequest.getStartDate(), this.startDate);
this.endDate = processDate(updateActivityReportRequest.getEndDate(), this.endDate);

this.participants = updateActivityReportRequest.getParticipants() != null
? updateActivityReportRequest.getParticipants()
: this.participants;
}

private LocalDateTime processDate(String dateString, LocalDateTime currentDate) {
if (dateString == null) {
return currentDate;
}

if (dateString.isBlank()) {
return null;
}

return parseToLocalDateTime(dateString);
}

private LocalDateTime parseToLocalDateTime(String dateString) {
return LocalDateTime.parse(dateString, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"));
}

}

0 comments on commit 2258f62

Please sign in to comment.