-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…crud ✨ Feature: #13 feature activity log crud
- Loading branch information
Showing
27 changed files
with
327 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...owingpain/log/domain/ApplicationType.java → ...tato/growingpain/log/ApplicationType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package cotato.growingpain.log.domain; | ||
package cotato.growingpain.log; | ||
|
||
import lombok.Getter; | ||
|
||
|
2 changes: 1 addition & 1 deletion
2
...cotato/growingpain/log/domain/Result.java → ...n/java/cotato/growingpain/log/Result.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package cotato.growingpain.log.domain; | ||
package cotato.growingpain.log; | ||
|
||
import lombok.Getter; | ||
|
||
|
87 changes: 87 additions & 0 deletions
87
src/main/java/cotato/growingpain/log/controller/ActivityLogController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<ActivityLogRequestDTO> 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<List<ActivityLogRequestDTO>> retrieveActivityLogList( | ||
@AuthenticationPrincipal Long memberId) { | ||
List<ActivityLogRequestDTO> 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<ActivityLogDTO> 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<ActivityLogDTO> 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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 0 additions & 14 deletions
14
src/main/java/cotato/growingpain/log/domain/service/JobApplicationService.java
This file was deleted.
Oops, something went wrong.
54 changes: 54 additions & 0 deletions
54
src/main/java/cotato/growingpain/log/dto/ActivityLogDTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
.../log/domain/dto/ApplicationDetailDTO.java → ...ingpain/log/dto/ApplicationDetailDTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.