diff --git a/src/main/java/cotato/growingpain/log/domain/ActivityType.java b/src/main/java/cotato/growingpain/log/ActivityCategory.java similarity index 74% rename from src/main/java/cotato/growingpain/log/domain/ActivityType.java rename to src/main/java/cotato/growingpain/log/ActivityCategory.java index 3e6d6b5..479922c 100644 --- a/src/main/java/cotato/growingpain/log/domain/ActivityType.java +++ b/src/main/java/cotato/growingpain/log/ActivityCategory.java @@ -1,9 +1,9 @@ -package cotato.growingpain.log.domain; +package cotato.growingpain.log; import lombok.Getter; @Getter -public enum ActivityType { +public enum ActivityCategory { EXTRA_ACTIVITY("대외활동"), VOLUNTEER_ACTIVITY("봉사활동"), @@ -14,7 +14,7 @@ public enum ActivityType { private final String description; - ActivityType(String description) { + ActivityCategory(String description) { this.description = description; } } \ No newline at end of file diff --git a/src/main/java/cotato/growingpain/log/domain/ApplicationType.java b/src/main/java/cotato/growingpain/log/ApplicationType.java similarity index 89% rename from src/main/java/cotato/growingpain/log/domain/ApplicationType.java rename to src/main/java/cotato/growingpain/log/ApplicationType.java index 952d010..9382074 100644 --- a/src/main/java/cotato/growingpain/log/domain/ApplicationType.java +++ b/src/main/java/cotato/growingpain/log/ApplicationType.java @@ -1,4 +1,4 @@ -package cotato.growingpain.log.domain; +package cotato.growingpain.log; import lombok.Getter; diff --git a/src/main/java/cotato/growingpain/log/domain/Result.java b/src/main/java/cotato/growingpain/log/Result.java similarity index 88% rename from src/main/java/cotato/growingpain/log/domain/Result.java rename to src/main/java/cotato/growingpain/log/Result.java index c6ab354..a523340 100644 --- a/src/main/java/cotato/growingpain/log/domain/Result.java +++ b/src/main/java/cotato/growingpain/log/Result.java @@ -1,4 +1,4 @@ -package cotato.growingpain.log.domain; +package cotato.growingpain.log; import lombok.Getter; diff --git a/src/main/java/cotato/growingpain/log/controller/ActivityLogController.java b/src/main/java/cotato/growingpain/log/controller/ActivityLogController.java new file mode 100644 index 0000000..bc7f595 --- /dev/null +++ b/src/main/java/cotato/growingpain/log/controller/ActivityLogController.java @@ -0,0 +1,87 @@ +package cotato.growingpain.log.controller; + +import static cotato.growingpain.common.Response.createSuccess; + +import cotato.growingpain.common.Response; +import cotato.growingpain.log.dto.ActivityLogDTO; +import cotato.growingpain.log.dto.request.ActivityLogRequestDTO; +import cotato.growingpain.log.service.ActivityLogService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import jakarta.validation.Valid; +import java.util.List; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.HttpStatus; +import org.springframework.security.core.annotation.AuthenticationPrincipal; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PatchMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; + +@Slf4j +@RestController +@RequestMapping("/api/activity-logs") +@RequiredArgsConstructor +public class ActivityLogController { + private final ActivityLogService activityLogService; + + @Operation(summary = "활동 기록 저장", description = "활동 기록을 등록하기 위한 메소드") + @ApiResponse(content = @Content(schema = @Schema(implementation = Response.class))) + @PostMapping("") + @ResponseStatus(HttpStatus.CREATED) + public Response createJobPost( + @RequestBody @Valid ActivityLogRequestDTO activityLogRequestDTO, + @AuthenticationPrincipal Long memberId) { + activityLogService.createActivityLog(activityLogRequestDTO, memberId); + return createSuccess("활동 기록 등록 완료", null); + } + + @Operation(summary = "활동 기록 리스트 조회", description = "활동 기록 리스트를 조회하기 위한 메소드") + @ApiResponse(content = @Content(schema = @Schema(implementation = Response.class))) + @GetMapping("") + @ResponseStatus(HttpStatus.OK) + public Response> retrieveActivityLogList( + @AuthenticationPrincipal Long memberId) { + List activityLogList = activityLogService.retrieveActivityLogsByMemberId(memberId); + return createSuccess("활동 기록 조회 완료", activityLogList); + } + + @Operation(summary = "활동 기록 상세 조회", description = "활동 기록을 상세 조회하기 위한 메소드") + @ApiResponse(content = @Content(schema = @Schema(implementation = Response.class))) + @GetMapping("/{activityLogId}") + @ResponseStatus(HttpStatus.OK) + public Response retrieveActivityLogById( + @PathVariable Long activityLogId) { + ActivityLogDTO activityLogDTO = activityLogService.retrieveActivityLogById(activityLogId); + return Response.createSuccess("활동 기록 상세 조회 완료", activityLogDTO); + } + + @Operation(summary = "활동 기록 수정", description = "활동 기록을 수정하기 위한 메소드") + @ApiResponse(content = @Content(schema = @Schema(implementation = Response.class))) + @PatchMapping("/{activityLogId}") + @ResponseStatus(HttpStatus.OK) + public Response updateActivityLog(@PathVariable Long activityLogId, + @RequestBody ActivityLogDTO updatedActivityLogDTO) { + ActivityLogDTO updatedActivityLog = activityLogService.updateActivityLog(activityLogId, updatedActivityLogDTO); + return Response.createSuccess("활동 기록 수정 완료", updatedActivityLog); + } + + @Operation(summary = "활동 기록 삭제", description = "활동 기록을 삭제하기 위한 메소드") + @ApiResponse(content = @Content(schema = @Schema(implementation = Response.class))) + @DeleteMapping("/{activityLogId}") + @ResponseStatus(HttpStatus.NO_CONTENT) + public Response deleteActivityLog(@PathVariable Long activityLogId, + @AuthenticationPrincipal Long memberId) { + activityLogService.deleteActivityLog(activityLogId, memberId); + + return Response.createSuccess("활동 기록 삭제 완료", null); + } +} diff --git a/src/main/java/cotato/growingpain/log/domain/controller/JobPostController.java b/src/main/java/cotato/growingpain/log/controller/JobPostController.java similarity index 91% rename from src/main/java/cotato/growingpain/log/domain/controller/JobPostController.java rename to src/main/java/cotato/growingpain/log/controller/JobPostController.java index b3e0216..436061b 100644 --- a/src/main/java/cotato/growingpain/log/domain/controller/JobPostController.java +++ b/src/main/java/cotato/growingpain/log/controller/JobPostController.java @@ -1,11 +1,11 @@ -package cotato.growingpain.log.domain.controller; +package cotato.growingpain.log.controller; import cotato.growingpain.common.Response; -import cotato.growingpain.log.domain.dto.JobPostListRetrieveDTO; -import cotato.growingpain.log.domain.dto.JobPostRequestDTO; -import cotato.growingpain.log.domain.dto.JobPostRetrieveDTO; import cotato.growingpain.log.domain.entity.JobPost; -import cotato.growingpain.log.domain.service.JobService; +import cotato.growingpain.log.dto.request.JobPostRequestDTO; +import cotato.growingpain.log.dto.request.JobPostRetrieveDTO; +import cotato.growingpain.log.dto.retrieve.JobPostListRetrieveDTO; +import cotato.growingpain.log.service.JobService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; @@ -18,9 +18,9 @@ import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PatchMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseStatus; @@ -66,7 +66,7 @@ public Response getJobPostById(@PathVariable Long jobPostId) @Operation(summary = "지원 현황 내용 수정", description = "지원 현황을 수정하기 위한 메소드") @ApiResponse(content = @Content(schema = @Schema(implementation = Response.class))) - @PutMapping("/{jobPostId}") + @PatchMapping("/{jobPostId}") @ResponseStatus(HttpStatus.OK) public Response updateJobPost( @PathVariable Long jobPostId, diff --git a/src/main/java/cotato/growingpain/log/domain/entity/ActivityLog.java b/src/main/java/cotato/growingpain/log/domain/entity/ActivityLog.java index 229d0ea..6e97959 100644 --- a/src/main/java/cotato/growingpain/log/domain/entity/ActivityLog.java +++ b/src/main/java/cotato/growingpain/log/domain/entity/ActivityLog.java @@ -2,7 +2,8 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import cotato.growingpain.common.domain.BaseTimeEntity; -import cotato.growingpain.log.domain.ActivityType; +import cotato.growingpain.log.ActivityCategory; +import cotato.growingpain.log.dto.ActivityLogDTO; import cotato.growingpain.member.domain.entity.Member; import jakarta.persistence.Column; import jakarta.persistence.Entity; @@ -40,8 +41,8 @@ public class ActivityLog extends BaseTimeEntity { /* ------------ Information Column ------------ */ /* -------------------------------------------- */ @Enumerated(EnumType.STRING) - @Column(name = "activity_type") - private ActivityType activityType; + @Column(name = "activity_category") + private ActivityCategory activityCategory; @Column(name = "activity_name") private String activityName; @@ -58,17 +59,14 @@ public class ActivityLog extends BaseTimeEntity { @Column(name = "contribution") private int contribution; - @Column(name = "activity_start_date") - private String activityStartDate; - - @Column(name = "activity_close_date") - private String activityCloseDate; + @Column(name = "activity_duration") + private String activityDuration; - @Column(name = "image_url") - private String imageUrl; + @Column(name = "activity_type") + private String activityType; - @Column(name = "file_url") - private String fileUrl; + @Column(name = "url") + private String url; @CreatedDate @Column(updatable = false) @@ -87,31 +85,41 @@ public class ActivityLog extends BaseTimeEntity { @Builder public ActivityLog( - ActivityType activityType, + ActivityCategory activityCategory, String activityName, String content, String performance, String role, - Integer contribution, - String activityStartDate, - String activityCloseDate, - String imageUrl, - String fileUrl, + String activityDuration, + String activityType, + String url, + int contribution, Member member ) { // Relation Column this.member = member; // Information Column - this.activityType = activityType; + this.activityCategory = activityCategory; this.activityName = activityName; this.content = content; this.performance = performance; this.role = role; + this.activityDuration = activityDuration; this.contribution = contribution; - this.activityStartDate = activityStartDate; - this.activityCloseDate = activityCloseDate; - this.imageUrl = imageUrl; - this.fileUrl = fileUrl; + this.activityType = activityType; + this.url = url; + } + + public void updateFromDTO(ActivityLogDTO updatedActivityLogDTO) { + this.activityCategory = updatedActivityLogDTO.activityCategory(); + this.activityName = updatedActivityLogDTO.activityName(); + this.content = updatedActivityLogDTO.content(); + this.performance = updatedActivityLogDTO.performance(); + this.role = updatedActivityLogDTO.role(); + this.activityDuration = updatedActivityLogDTO.activityDuration(); + this.activityType = updatedActivityLogDTO.activityType(); + this.url = updatedActivityLogDTO.url(); + this.contribution = updatedActivityLogDTO.contribution(); } } diff --git a/src/main/java/cotato/growingpain/log/domain/entity/ApplicationDetail.java b/src/main/java/cotato/growingpain/log/domain/entity/ApplicationDetail.java index 959cb01..2af9c1e 100644 --- a/src/main/java/cotato/growingpain/log/domain/entity/ApplicationDetail.java +++ b/src/main/java/cotato/growingpain/log/domain/entity/ApplicationDetail.java @@ -2,7 +2,7 @@ import com.fasterxml.jackson.annotation.JsonBackReference; import com.fasterxml.jackson.annotation.JsonIgnore; -import cotato.growingpain.log.domain.dto.ApplicationDetailRequestDTO; +import cotato.growingpain.log.dto.request.ApplicationDetailRequestDTO; import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.FetchType; diff --git a/src/main/java/cotato/growingpain/log/domain/entity/JobApplication.java b/src/main/java/cotato/growingpain/log/domain/entity/JobApplication.java index aa7f097..f736bc0 100644 --- a/src/main/java/cotato/growingpain/log/domain/entity/JobApplication.java +++ b/src/main/java/cotato/growingpain/log/domain/entity/JobApplication.java @@ -4,11 +4,11 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonManagedReference; import cotato.growingpain.common.domain.BaseTimeEntity; -import cotato.growingpain.log.domain.ApplicationType; -import cotato.growingpain.log.domain.Result; -import cotato.growingpain.log.domain.dto.ApplicationDetailRequestDTO; -import cotato.growingpain.log.domain.dto.JobApplicationRequestDTO; -import cotato.growingpain.log.domain.repository.ApplicationDetailRepository; +import cotato.growingpain.log.ApplicationType; +import cotato.growingpain.log.Result; +import cotato.growingpain.log.dto.request.ApplicationDetailRequestDTO; +import cotato.growingpain.log.dto.request.JobApplicationRequestDTO; +import cotato.growingpain.log.repository.ApplicationDetailRepository; import cotato.growingpain.member.domain.entity.Member; import jakarta.persistence.CascadeType; import jakarta.persistence.Column; diff --git a/src/main/java/cotato/growingpain/log/domain/entity/JobPost.java b/src/main/java/cotato/growingpain/log/domain/entity/JobPost.java index 82ee92f..334cccc 100644 --- a/src/main/java/cotato/growingpain/log/domain/entity/JobPost.java +++ b/src/main/java/cotato/growingpain/log/domain/entity/JobPost.java @@ -2,10 +2,10 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonManagedReference; -import cotato.growingpain.log.domain.dto.JobApplicationRequestDTO; -import cotato.growingpain.log.domain.dto.JobPostRequestDTO; -import cotato.growingpain.log.domain.repository.ApplicationDetailRepository; -import cotato.growingpain.log.domain.repository.JobApplicationRepository; +import cotato.growingpain.log.dto.request.JobApplicationRequestDTO; +import cotato.growingpain.log.dto.request.JobPostRequestDTO; +import cotato.growingpain.log.repository.ApplicationDetailRepository; +import cotato.growingpain.log.repository.JobApplicationRepository; import cotato.growingpain.member.domain.entity.Member; import jakarta.persistence.CascadeType; import jakarta.persistence.Column; diff --git a/src/main/java/cotato/growingpain/log/domain/service/JobApplicationService.java b/src/main/java/cotato/growingpain/log/domain/service/JobApplicationService.java deleted file mode 100644 index 09e4eb5..0000000 --- a/src/main/java/cotato/growingpain/log/domain/service/JobApplicationService.java +++ /dev/null @@ -1,14 +0,0 @@ -package cotato.growingpain.log.domain.service; - -import cotato.growingpain.member.repository.MemberRepository; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; - -@Service -@RequiredArgsConstructor -public class JobApplicationService { - - private final MemberRepository memberRepository; - - -} diff --git a/src/main/java/cotato/growingpain/log/dto/ActivityLogDTO.java b/src/main/java/cotato/growingpain/log/dto/ActivityLogDTO.java new file mode 100644 index 0000000..8347fd4 --- /dev/null +++ b/src/main/java/cotato/growingpain/log/dto/ActivityLogDTO.java @@ -0,0 +1,54 @@ +package cotato.growingpain.log.dto; + +import cotato.growingpain.log.ActivityCategory; +import cotato.growingpain.log.domain.entity.ActivityLog; +import cotato.growingpain.member.domain.entity.Member; +import lombok.Builder; +import lombok.extern.slf4j.Slf4j; + +@Slf4j +@Builder +public record ActivityLogDTO( + Long id, + ActivityCategory activityCategory, + String activityName, + String content, + String performance, + String role, + String activityDuration, + String activityType, + String url, + int contribution +) { + public static ActivityLogDTO fromEntity(ActivityLog activityLog) { + return ActivityLogDTO.builder() + .id(activityLog.getId()) + .activityName(activityLog.getActivityName()) + .activityCategory(activityLog.getActivityCategory()) + .activityDuration(activityLog.getActivityDuration()) + .content(activityLog.getContent()) + .performance(activityLog.getPerformance()) + .role(activityLog.getRole()) + .activityDuration(activityLog.getActivityDuration()) + .activityType(activityLog.getActivityType()) + .contribution(activityLog.getContribution()) + .url(activityLog.getUrl()) + .build(); + } + + public ActivityLog toEntity(Member member) { + ActivityLog activityLog = ActivityLog.builder() + .activityName(this.activityName) + .activityCategory(this.activityCategory) + .activityDuration(this.activityDuration) + .content(this.content) + .performance(this.performance) + .role(this.role) + .contribution(this.contribution) + .activityType(this.activityType) + .url(this.url) + .member(member) + .build(); + return activityLog; + } +} diff --git a/src/main/java/cotato/growingpain/log/domain/dto/ApplicationDetailDTO.java b/src/main/java/cotato/growingpain/log/dto/ApplicationDetailDTO.java similarity index 92% rename from src/main/java/cotato/growingpain/log/domain/dto/ApplicationDetailDTO.java rename to src/main/java/cotato/growingpain/log/dto/ApplicationDetailDTO.java index d0162bb..f10a074 100644 --- a/src/main/java/cotato/growingpain/log/domain/dto/ApplicationDetailDTO.java +++ b/src/main/java/cotato/growingpain/log/dto/ApplicationDetailDTO.java @@ -1,4 +1,4 @@ -package cotato.growingpain.log.domain.dto; +package cotato.growingpain.log.dto; import cotato.growingpain.log.domain.entity.ApplicationDetail; import lombok.Builder; diff --git a/src/main/java/cotato/growingpain/log/dto/request/ActivityLogRequestDTO.java b/src/main/java/cotato/growingpain/log/dto/request/ActivityLogRequestDTO.java new file mode 100644 index 0000000..0b40df9 --- /dev/null +++ b/src/main/java/cotato/growingpain/log/dto/request/ActivityLogRequestDTO.java @@ -0,0 +1,29 @@ +package cotato.growingpain.log.dto.request; + +import cotato.growingpain.log.ActivityCategory; +import cotato.growingpain.log.domain.entity.ActivityLog; +import cotato.growingpain.member.domain.entity.Member; + +public record ActivityLogRequestDTO( + ActivityCategory activityCategory, + String activityName, + String role, + String activityDuration, + String activityType, + String url, + int contribution +) { + public ActivityLog toEntity(Member member) { + ActivityLog activityLog = ActivityLog.builder() + .activityName(this.activityName) + .activityCategory(this.activityCategory) + .activityDuration(this.activityDuration) + .role(this.role) + .contribution(this.contribution) + .activityType(this.activityType) + .url(this.url) + .member(member) + .build(); + return activityLog; + } +} diff --git a/src/main/java/cotato/growingpain/log/domain/dto/ApplicationDetailRequestDTO.java b/src/main/java/cotato/growingpain/log/dto/request/ApplicationDetailRequestDTO.java similarity index 91% rename from src/main/java/cotato/growingpain/log/domain/dto/ApplicationDetailRequestDTO.java rename to src/main/java/cotato/growingpain/log/dto/request/ApplicationDetailRequestDTO.java index b461078..9d0fc5d 100644 --- a/src/main/java/cotato/growingpain/log/domain/dto/ApplicationDetailRequestDTO.java +++ b/src/main/java/cotato/growingpain/log/dto/request/ApplicationDetailRequestDTO.java @@ -1,4 +1,4 @@ -package cotato.growingpain.log.domain.dto; +package cotato.growingpain.log.dto.request; import cotato.growingpain.log.domain.entity.ApplicationDetail; import cotato.growingpain.log.domain.entity.JobApplication; diff --git a/src/main/java/cotato/growingpain/log/domain/dto/JobApplicationRequestDTO.java b/src/main/java/cotato/growingpain/log/dto/request/JobApplicationRequestDTO.java similarity index 92% rename from src/main/java/cotato/growingpain/log/domain/dto/JobApplicationRequestDTO.java rename to src/main/java/cotato/growingpain/log/dto/request/JobApplicationRequestDTO.java index b53bea9..ae6341a 100644 --- a/src/main/java/cotato/growingpain/log/domain/dto/JobApplicationRequestDTO.java +++ b/src/main/java/cotato/growingpain/log/dto/request/JobApplicationRequestDTO.java @@ -1,7 +1,7 @@ -package cotato.growingpain.log.domain.dto; +package cotato.growingpain.log.dto.request; -import cotato.growingpain.log.domain.ApplicationType; -import cotato.growingpain.log.domain.Result; +import cotato.growingpain.log.ApplicationType; +import cotato.growingpain.log.Result; import cotato.growingpain.log.domain.entity.ApplicationDetail; import cotato.growingpain.log.domain.entity.JobApplication; import cotato.growingpain.log.domain.entity.JobPost; diff --git a/src/main/java/cotato/growingpain/log/domain/dto/JobPostRequestDTO.java b/src/main/java/cotato/growingpain/log/dto/request/JobPostRequestDTO.java similarity index 96% rename from src/main/java/cotato/growingpain/log/domain/dto/JobPostRequestDTO.java rename to src/main/java/cotato/growingpain/log/dto/request/JobPostRequestDTO.java index 8ad9ee1..652a1ce 100644 --- a/src/main/java/cotato/growingpain/log/domain/dto/JobPostRequestDTO.java +++ b/src/main/java/cotato/growingpain/log/dto/request/JobPostRequestDTO.java @@ -1,4 +1,4 @@ -package cotato.growingpain.log.domain.dto; +package cotato.growingpain.log.dto.request; import cotato.growingpain.log.domain.entity.JobApplication; import cotato.growingpain.log.domain.entity.JobPost; diff --git a/src/main/java/cotato/growingpain/log/domain/dto/JobPostRetrieveDTO.java b/src/main/java/cotato/growingpain/log/dto/request/JobPostRetrieveDTO.java similarity index 88% rename from src/main/java/cotato/growingpain/log/domain/dto/JobPostRetrieveDTO.java rename to src/main/java/cotato/growingpain/log/dto/request/JobPostRetrieveDTO.java index 6341e65..3fb6796 100644 --- a/src/main/java/cotato/growingpain/log/domain/dto/JobPostRetrieveDTO.java +++ b/src/main/java/cotato/growingpain/log/dto/request/JobPostRetrieveDTO.java @@ -1,6 +1,7 @@ -package cotato.growingpain.log.domain.dto; +package cotato.growingpain.log.dto.request; import cotato.growingpain.log.domain.entity.JobPost; +import cotato.growingpain.log.dto.retrieve.JobApplicationRetrieveDTO; import java.util.List; import lombok.Builder; import lombok.extern.slf4j.Slf4j; diff --git a/src/main/java/cotato/growingpain/log/domain/dto/JobApplicationListRetrieveDTO.java b/src/main/java/cotato/growingpain/log/dto/retrieve/JobApplicationListRetrieveDTO.java similarity index 96% rename from src/main/java/cotato/growingpain/log/domain/dto/JobApplicationListRetrieveDTO.java rename to src/main/java/cotato/growingpain/log/dto/retrieve/JobApplicationListRetrieveDTO.java index 0ac7f8e..ecae0c2 100644 --- a/src/main/java/cotato/growingpain/log/domain/dto/JobApplicationListRetrieveDTO.java +++ b/src/main/java/cotato/growingpain/log/dto/retrieve/JobApplicationListRetrieveDTO.java @@ -1,4 +1,4 @@ -package cotato.growingpain.log.domain.dto; +package cotato.growingpain.log.dto.retrieve; import cotato.growingpain.log.domain.entity.JobApplication; import lombok.Builder; diff --git a/src/main/java/cotato/growingpain/log/domain/dto/JobApplicationRetrieveDTO.java b/src/main/java/cotato/growingpain/log/dto/retrieve/JobApplicationRetrieveDTO.java similarity index 93% rename from src/main/java/cotato/growingpain/log/domain/dto/JobApplicationRetrieveDTO.java rename to src/main/java/cotato/growingpain/log/dto/retrieve/JobApplicationRetrieveDTO.java index 5769a1c..390aa38 100644 --- a/src/main/java/cotato/growingpain/log/domain/dto/JobApplicationRetrieveDTO.java +++ b/src/main/java/cotato/growingpain/log/dto/retrieve/JobApplicationRetrieveDTO.java @@ -1,6 +1,7 @@ -package cotato.growingpain.log.domain.dto; +package cotato.growingpain.log.dto.retrieve; import cotato.growingpain.log.domain.entity.JobApplication; +import cotato.growingpain.log.dto.ApplicationDetailDTO; import java.util.List; import lombok.Builder; import lombok.extern.slf4j.Slf4j; diff --git a/src/main/java/cotato/growingpain/log/domain/dto/JobPostListRetrieveDTO.java b/src/main/java/cotato/growingpain/log/dto/retrieve/JobPostListRetrieveDTO.java similarity index 94% rename from src/main/java/cotato/growingpain/log/domain/dto/JobPostListRetrieveDTO.java rename to src/main/java/cotato/growingpain/log/dto/retrieve/JobPostListRetrieveDTO.java index dde7278..6f4789c 100644 --- a/src/main/java/cotato/growingpain/log/domain/dto/JobPostListRetrieveDTO.java +++ b/src/main/java/cotato/growingpain/log/dto/retrieve/JobPostListRetrieveDTO.java @@ -1,4 +1,4 @@ -package cotato.growingpain.log.domain.dto; +package cotato.growingpain.log.dto.retrieve; import cotato.growingpain.log.domain.entity.JobPost; import java.util.List; diff --git a/src/main/java/cotato/growingpain/log/repository/ActivityLogRepository.java b/src/main/java/cotato/growingpain/log/repository/ActivityLogRepository.java new file mode 100644 index 0000000..b7fc015 --- /dev/null +++ b/src/main/java/cotato/growingpain/log/repository/ActivityLogRepository.java @@ -0,0 +1,17 @@ +package cotato.growingpain.log.repository; + +import cotato.growingpain.log.domain.entity.ActivityLog; +import cotato.growingpain.log.dto.request.ActivityLogRequestDTO; +import java.util.List; +import java.util.Optional; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface ActivityLogRepository extends JpaRepository { + List findByMemberId(Long memberId); + + Optional findByMemberIdAndId(Long activityLogId, Long memberId); + + Optional findById(Long activityLogId); +} diff --git a/src/main/java/cotato/growingpain/log/domain/repository/ApplicationDetailRepository.java b/src/main/java/cotato/growingpain/log/repository/ApplicationDetailRepository.java similarity index 81% rename from src/main/java/cotato/growingpain/log/domain/repository/ApplicationDetailRepository.java rename to src/main/java/cotato/growingpain/log/repository/ApplicationDetailRepository.java index c0c690b..904f1e9 100644 --- a/src/main/java/cotato/growingpain/log/domain/repository/ApplicationDetailRepository.java +++ b/src/main/java/cotato/growingpain/log/repository/ApplicationDetailRepository.java @@ -1,4 +1,4 @@ -package cotato.growingpain.log.domain.repository; +package cotato.growingpain.log.repository; import cotato.growingpain.log.domain.entity.ApplicationDetail; import org.springframework.data.jpa.repository.JpaRepository; diff --git a/src/main/java/cotato/growingpain/log/domain/repository/JobApplicationRepository.java b/src/main/java/cotato/growingpain/log/repository/JobApplicationRepository.java similarity index 85% rename from src/main/java/cotato/growingpain/log/domain/repository/JobApplicationRepository.java rename to src/main/java/cotato/growingpain/log/repository/JobApplicationRepository.java index 3a5b453..26d4dfe 100644 --- a/src/main/java/cotato/growingpain/log/domain/repository/JobApplicationRepository.java +++ b/src/main/java/cotato/growingpain/log/repository/JobApplicationRepository.java @@ -1,4 +1,4 @@ -package cotato.growingpain.log.domain.repository; +package cotato.growingpain.log.repository; import cotato.growingpain.log.domain.entity.JobApplication; import java.util.List; diff --git a/src/main/java/cotato/growingpain/log/domain/repository/JobPostRepository.java b/src/main/java/cotato/growingpain/log/repository/JobPostRepository.java similarity index 87% rename from src/main/java/cotato/growingpain/log/domain/repository/JobPostRepository.java rename to src/main/java/cotato/growingpain/log/repository/JobPostRepository.java index 0cc7ae4..742ed4d 100644 --- a/src/main/java/cotato/growingpain/log/domain/repository/JobPostRepository.java +++ b/src/main/java/cotato/growingpain/log/repository/JobPostRepository.java @@ -1,4 +1,4 @@ -package cotato.growingpain.log.domain.repository; +package cotato.growingpain.log.repository; import cotato.growingpain.log.domain.entity.JobPost; import java.util.List; diff --git a/src/main/java/cotato/growingpain/log/service/ActivityLogService.java b/src/main/java/cotato/growingpain/log/service/ActivityLogService.java new file mode 100644 index 0000000..65ce04b --- /dev/null +++ b/src/main/java/cotato/growingpain/log/service/ActivityLogService.java @@ -0,0 +1,61 @@ +package cotato.growingpain.log.service; + +import cotato.growingpain.log.domain.entity.ActivityLog; +import cotato.growingpain.log.dto.ActivityLogDTO; +import cotato.growingpain.log.dto.request.ActivityLogRequestDTO; +import cotato.growingpain.log.repository.ActivityLogRepository; +import cotato.growingpain.member.domain.entity.Member; +import cotato.growingpain.member.repository.MemberRepository; +import jakarta.transaction.Transactional; +import java.util.List; +import java.util.NoSuchElementException; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +@Slf4j +@Service +@RequiredArgsConstructor +public class ActivityLogService { + + private final MemberRepository memberRepository; + private final ActivityLogRepository activityLogRepository; + + @Transactional + public void createActivityLog(final ActivityLogRequestDTO activityLogRequestDTO, Long memberId) { + Member member = memberRepository.findById(memberId) + .orElseThrow(() -> new RuntimeException("Member not found with ID: " + memberId)); + ActivityLog activityLog = activityLogRequestDTO.toEntity(member); + activityLogRepository.save(activityLog); + } + + @Transactional + public List retrieveActivityLogsByMemberId(Long memberId) { + return activityLogRepository.findByMemberId(memberId); + } + + @Transactional + public ActivityLogDTO retrieveActivityLogById(Long activityLogId) { + ActivityLog activityLog = activityLogRepository.findById(activityLogId) + .orElseThrow(() -> new NoSuchElementException("ActivityLog not found with ID: " + activityLogId)); + + return ActivityLogDTO.fromEntity(activityLog); + } + + @Transactional + public ActivityLogDTO updateActivityLog(Long activityLogId, ActivityLogDTO updatedActivityLogDTO) { + ActivityLog existingActivityLog = activityLogRepository.findById(activityLogId) + .orElseThrow(() -> new NoSuchElementException("ActivityLog not found with ID: " + activityLogId)); + existingActivityLog.updateFromDTO(updatedActivityLogDTO); + ActivityLog savedActivityLog = activityLogRepository.save(existingActivityLog); + + return ActivityLogDTO.fromEntity(savedActivityLog); + } + + @Transactional + public void deleteActivityLog(Long activityLogId, Long memberId) { + ActivityLog existingActivityLog = activityLogRepository.findByMemberIdAndId(activityLogId, memberId) + .orElseThrow(() -> new NoSuchElementException("ActivityLog not found with ID: " + activityLogId)); + activityLogRepository.delete(existingActivityLog); + } +} diff --git a/src/main/java/cotato/growingpain/log/domain/service/JobService.java b/src/main/java/cotato/growingpain/log/service/JobService.java similarity index 81% rename from src/main/java/cotato/growingpain/log/domain/service/JobService.java rename to src/main/java/cotato/growingpain/log/service/JobService.java index 627dd1b..0c1e5b2 100644 --- a/src/main/java/cotato/growingpain/log/domain/service/JobService.java +++ b/src/main/java/cotato/growingpain/log/service/JobService.java @@ -1,13 +1,13 @@ -package cotato.growingpain.log.domain.service; +package cotato.growingpain.log.service; -import cotato.growingpain.log.domain.dto.JobPostListRetrieveDTO; -import cotato.growingpain.log.domain.dto.JobPostRequestDTO; -import cotato.growingpain.log.domain.dto.JobPostRetrieveDTO; import cotato.growingpain.log.domain.entity.JobApplication; import cotato.growingpain.log.domain.entity.JobPost; -import cotato.growingpain.log.domain.repository.ApplicationDetailRepository; -import cotato.growingpain.log.domain.repository.JobApplicationRepository; -import cotato.growingpain.log.domain.repository.JobPostRepository; +import cotato.growingpain.log.dto.request.JobPostRequestDTO; +import cotato.growingpain.log.dto.request.JobPostRetrieveDTO; +import cotato.growingpain.log.dto.retrieve.JobPostListRetrieveDTO; +import cotato.growingpain.log.repository.ApplicationDetailRepository; +import cotato.growingpain.log.repository.JobApplicationRepository; +import cotato.growingpain.log.repository.JobPostRepository; import cotato.growingpain.member.domain.entity.Member; import cotato.growingpain.member.repository.MemberRepository; import java.util.List; @@ -34,14 +34,8 @@ public void createJobPost(final JobPostRequestDTO jobPostRequest, Long memberId) Member member = memberRepository.findById(memberId) .orElseThrow(() -> new RuntimeException("Member not found with ID: " + memberId)); - log.info("Found member with ID: {}", member.getId()); - log.info(jobPostRequest.jobApplications().toString()); - JobPost jobPost = jobPostRequest.toEntity(member); - log.info("Creating job post with job part: {}", jobPost.getJobPart()); - log.debug("JobPost details: {}", jobPost); - JobPost savedJobPost = jobPostRepository.save(jobPost); jobPost.getJobApplications().forEach(jobApplication -> { @@ -93,4 +87,5 @@ public void deleteJobPost(Long jobPostId, Long memberId) { jobPostRepository.delete(jobPost); } + } diff --git a/src/main/java/cotato/growingpain/member/domain/entity/Member.java b/src/main/java/cotato/growingpain/member/domain/entity/Member.java index 9b689af..4da47c2 100644 --- a/src/main/java/cotato/growingpain/member/domain/entity/Member.java +++ b/src/main/java/cotato/growingpain/member/domain/entity/Member.java @@ -170,13 +170,14 @@ public void updateRole(MemberRole memberRole) { this.memberRole = memberRole; } - public void updateDefaultInfo(String field, String belong, MemberJob job){ + public void updateDefaultInfo(String field, String belong, MemberJob job) { this.field = field; this.belong = belong; this.job = job; } - public void updateAdditionalInfo(String educationBackground, String skill, String activityHistory, String award, String languageScore, String career, String aboutMe) { + public void updateAdditionalInfo(String educationBackground, String skill, String activityHistory, String award, + String languageScore, String career, String aboutMe) { this.educationBackground = educationBackground; this.skill = skill; this.activityHistory = activityHistory;