Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ public class ManagePostService {
private final PostStatsRepository postStatsRepository;
private final StudyAccessValidator studyAccessValidator;

public void createPost(long studyId, long writerId, ManagePostRequest request) {
public long createPost(long studyId, long writerId, ManagePostRequest request) {
studyAccessValidator.validateStudyMember(studyId, writerId);
WriterInfo writerInfo = getWriterInfo(writerId);
Post post = createAndSavePost(request, studyId, writerInfo);
initializeAndSavePostStats(post);
return post.getId();
}

public void updatePost(long studyId, long postId, ManagePostRequest request, long writerId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import kr.spot.code.status.SuccessStatus;
import kr.spot.post.application.command.LikePostService;
import kr.spot.post.application.command.ManagePostService;
import kr.spot.post.presentation.command.dto.CreatePostResponse;
import kr.spot.post.presentation.command.dto.ManagePostRequest;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
Expand Down Expand Up @@ -38,12 +39,13 @@ public class PostCommandController {
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "404", description = "`STUDY404`: 스터디를 찾을 수 없습니다.", content = @Content(schema = @Schema(implementation = ApiResponse.class)))
})
@PostMapping
public ResponseEntity<ApiResponse<Void>> createPost(
public ResponseEntity<ApiResponse<CreatePostResponse>> createPost(
@Parameter(description = "스터디 ID", required = true) @PathVariable Long studyId,
@CurrentMember @Parameter(hidden = true) Long writerId,
@RequestBody ManagePostRequest request) {
managePostService.createPost(studyId, writerId, request);
return ResponseEntity.ok(ApiResponse.onSuccess(SuccessStatus._CREATED));
long postId = managePostService.createPost(studyId, writerId, request);
return ResponseEntity.ok(
ApiResponse.onSuccess(SuccessStatus._CREATED, CreatePostResponse.from(postId)));
}

@Operation(summary = "스터디 게시글 수정", description = "스터디의 게시글을 수정합니다. 작성자만 수정할 수 있습니다.")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package kr.spot.post.presentation.command.dto;

public record CreatePostResponse(Long postId) {

public static CreatePostResponse from(long postId) {
return new CreatePostResponse(postId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class ManageReviewService {
private final ReviewRepository reviewRepository;
private final StudyAccessValidator studyAccessValidator;

public void createReview(long studyId, long memberId, CreateReviewRequest request,
public long createReview(long studyId, long memberId, CreateReviewRequest request,
MultipartFile imageFile) {
studyAccessValidator.validateStudyMember(studyId, memberId);

Expand All @@ -38,9 +38,10 @@ public void createReview(long studyId, long memberId, CreateReviewRequest reques
Content content = Content.of(request.activity(), request.learned(), request.encouragement(),
imageUrl);

Review review = Review.of(idGenerator.nextId(), studyId, writerInfo, content,
request.isPrivate());
long reviewId = idGenerator.nextId();
Review review = Review.of(reviewId, studyId, writerInfo, content, request.isPrivate());
reviewRepository.save(review);
return reviewId;
}

public void deleteReview(long studyId, long reviewId, long memberId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import kr.spot.review.application.command.ManageReviewService;
import kr.spot.review.domain.enums.Reaction;
import kr.spot.review.presentation.command.dto.CreateReviewRequest;
import kr.spot.review.presentation.command.dto.CreateReviewResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
Expand All @@ -32,14 +33,15 @@ public class ReviewCommandController {

@Operation(summary = "스터디 회고록 작성", description = "특정 스터디에 대한 회고록을 작성합니다.")
@PostMapping
public ResponseEntity<ApiResponse<Void>> createReview(
public ResponseEntity<ApiResponse<CreateReviewResponse>> createReview(
@PathVariable Long studyId,
@CurrentMember @Parameter(hidden = true) Long memberId,
@RequestPart CreateReviewRequest request,
@RequestPart(required = false) MultipartFile imageFile
) {
manageReviewService.createReview(studyId, memberId, request, imageFile);
return ResponseEntity.ok(ApiResponse.onSuccess(SuccessStatus._CREATED));
long reviewId = manageReviewService.createReview(studyId, memberId, request, imageFile);
return ResponseEntity.ok(
ApiResponse.onSuccess(SuccessStatus._CREATED, CreateReviewResponse.from(reviewId)));
}

@Operation(summary = "스터디 회고록 삭제", description = "특정 스터디에 대한 회고록을 삭제합니다.")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package kr.spot.review.presentation.command.dto;

public record CreateReviewResponse(Long reviewId) {

public static CreateReviewResponse from(long reviewId) {
return new CreateReviewResponse(reviewId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ public class ManageScheduleService {
private final IdGenerator idGenerator;
private final ScheduleRepository scheduleRepository;

public void createSchedule(CreateScheduleRequest request, long studyId) {
Schedule schedule = Schedule.of(idGenerator.nextId(), studyId, request.title(),
public long createSchedule(CreateScheduleRequest request, long studyId) {
long scheduleId = idGenerator.nextId();
Schedule schedule = Schedule.of(scheduleId, studyId, request.title(),
request.locationInfo(),
request.startAt(), request.endAt());

scheduleRepository.save(schedule);
return scheduleId;
}

public void deleteSchedule(long studyId, long scheduleId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import kr.spot.code.status.SuccessStatus;
import kr.spot.schedule.application.command.ManageScheduleService;
import kr.spot.schedule.presentation.command.dto.CreateScheduleRequest;
import kr.spot.schedule.presentation.command.dto.CreateScheduleResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
Expand All @@ -35,11 +36,12 @@ public class ScheduleCommandController {
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "404", description = "`STUDY404`: 스터디를 찾을 수 없습니다.", content = @Content(schema = @Schema(implementation = ApiResponse.class)))
})
@PostMapping
public ResponseEntity<ApiResponse<Void>> createSchedule(
public ResponseEntity<ApiResponse<CreateScheduleResponse>> createSchedule(
@Parameter(description = "스터디 ID", required = true) @PathVariable Long studyId,
@RequestBody CreateScheduleRequest request) {
manageScheduleService.createSchedule(request, studyId);
return ResponseEntity.ok(ApiResponse.onSuccess(SuccessStatus._CREATED));
long scheduleId = manageScheduleService.createSchedule(request, studyId);
return ResponseEntity.ok(
ApiResponse.onSuccess(SuccessStatus._CREATED, CreateScheduleResponse.from(scheduleId)));
}

@Operation(summary = "스터디 일정 삭제", description = "스터디의 일정을 삭제합니다.")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package kr.spot.schedule.presentation.command.dto;

public record CreateScheduleResponse(Long scheduleId) {

public static CreateScheduleResponse from(long scheduleId) {
return new CreateScheduleResponse(scheduleId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class CreateStudyService {
private final StudyStatsRepository studyStatsRepository;
private final StudyMemberRepository studyMemberRepository;

public void createStudy(CreateStudyRequest request, Long leaderId, MultipartFile imageFile) {
public long createStudy(CreateStudyRequest request, long leaderId, MultipartFile imageFile) {
long studyId = idGenerator.nextId();
Study study = Study.of(studyId, leaderId, request.name(), request.maxMembers(),
Fee.of(request.hasFee(), request.amount()), null, request.description(), request.isOnline());
Expand All @@ -53,6 +53,7 @@ public void createStudy(CreateStudyRequest request, Long leaderId, MultipartFile
saveAllStudyRegions(request, studyId);

eventPublisher.publishEvent(StudyCreatedEvent.of(studyId, imageFile));
return studyId;
}

private void saveAllStudyCategories(CreateStudyRequest request, long studyId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import kr.spot.study.application.command.CreateStudyService;
import kr.spot.study.application.command.StudyLikeService;
import kr.spot.study.presentation.command.dto.request.CreateStudyRequest;
import kr.spot.study.presentation.command.dto.response.CreateStudyResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
Expand Down Expand Up @@ -47,11 +48,13 @@ public class StudyCommandController {
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "401", description = "인증되지 않은 사용자입니다.", content = @Content(schema = @Schema(implementation = kr.spot.ApiResponse.class)))
})
@PostMapping
public ResponseEntity<ApiResponse<Void>> createStudy(@RequestPart CreateStudyRequest request,
public ResponseEntity<ApiResponse<CreateStudyResponse>> createStudy(
@RequestPart CreateStudyRequest request,
@CurrentMember @Parameter(hidden = true) Long memberId,
@RequestPart(required = false) MultipartFile imageFile) {
createStudyService.createStudy(request, memberId, imageFile);
return ResponseEntity.ok(ApiResponse.onSuccess(SuccessStatus._CREATED));
long studyId = createStudyService.createStudy(request, memberId, imageFile);
return ResponseEntity.ok(
ApiResponse.onSuccess(SuccessStatus._CREATED, CreateStudyResponse.from(studyId)));
}

@Operation(summary = "스터디 좋아요", description = "스터디에 좋아요를 누릅니다.")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package kr.spot.study.presentation.command.dto.response;

public record CreateStudyResponse(Long studyId) {

public static CreateStudyResponse from(long studyId) {
return new CreateStudyResponse(studyId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,17 @@ public class ManageTodoService {
private final IdGenerator idGenerator;
private final TodoRepository todoRepository;

public void createTodo(long studyId, long memberId, CreateTodoRequest request) {
public long createTodo(long studyId, long memberId, CreateTodoRequest request) {
long todoId = idGenerator.nextId();
Todo todo = Todo.of(
idGenerator.nextId(),
todoId,
studyId,
memberId,
request.dueDate(),
request.content()
);
todoRepository.save(todo);
return todoId;
}

public void updateTodo(long studyId, long todoId, long memberId, UpdateTodoRequest request) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import kr.spot.code.status.SuccessStatus;
import kr.spot.todo.application.command.ManageTodoService;
import kr.spot.todo.presentation.command.dto.CreateTodoRequest;
import kr.spot.todo.presentation.command.dto.CreateTodoResponse;
import kr.spot.todo.presentation.command.dto.UpdateTodoRequest;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
Expand All @@ -37,12 +38,13 @@ public class TodoCommandController {
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "404", description = "`STUDY404`: 스터디를 찾을 수 없습니다.", content = @Content(schema = @Schema(implementation = ApiResponse.class)))
})
@PostMapping
public ResponseEntity<ApiResponse<Void>> createTodo(
public ResponseEntity<ApiResponse<CreateTodoResponse>> createTodo(
@Parameter(description = "스터디 ID", required = true) @PathVariable Long studyId,
@CurrentMember @Parameter(hidden = true) Long memberId,
@RequestBody CreateTodoRequest request) {
manageTodoService.createTodo(studyId, memberId, request);
return ResponseEntity.ok(ApiResponse.onSuccess(SuccessStatus._CREATED));
long todoId = manageTodoService.createTodo(studyId, memberId, request);
return ResponseEntity.ok(
ApiResponse.onSuccess(SuccessStatus._CREATED, CreateTodoResponse.from(todoId)));
}

@Operation(summary = "투두 수정", description = "투두 내용과 마감일을 수정합니다.")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package kr.spot.todo.presentation.command.dto;

public record CreateTodoResponse(Long todoId) {

public static CreateTodoResponse from(long todoId) {
return new CreateTodoResponse(todoId);
}
}