Skip to content

Commit

Permalink
Merge pull request #48 from Team-Growthook/fix/#47-action-plan-create
Browse files Browse the repository at this point in the history
[FIX]액션 플랜 생성 로직 수정
  • Loading branch information
Hong0329 authored Jan 4, 2024
2 parents eac8e4f + 47f4cf8 commit 1077368
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.example.growthookserver.api.actionplan.dto.request.ActionPlanCreateRequestDto;
import com.example.growthookserver.api.actionplan.dto.request.ActionPlanUpdateRequestDto;
import com.example.growthookserver.api.actionplan.dto.response.ActionPlanCreateResponseDto;
import com.example.growthookserver.api.actionplan.dto.response.ActionPlanGetResponseDto;
import com.example.growthookserver.api.actionplan.dto.response.DoingActionPlanGetResponseDto;
import com.example.growthookserver.api.actionplan.dto.response.FinishedActionPlanGetResponseDto;
Expand All @@ -27,8 +26,9 @@ public class ActionPlanController {
@PostMapping("seed/{seedId}/actionPlan")
@ResponseStatus(HttpStatus.CREATED)
@Operation(summary = "ActionPlanPost",description = "액션 플랜 생성 API입니다.")
public ApiResponse<ActionPlanCreateResponseDto> createActionPlan(@PathVariable("seedId")Long seedId, @Valid @RequestBody ActionPlanCreateRequestDto actionPlanCreateRequestDto) {
return ApiResponse.success(SuccessStatus.POST_ACTIONPLAN_SUCCESS, actionPlanService.createActionPlan(seedId, actionPlanCreateRequestDto));
public ApiResponse createActionPlan(@PathVariable("seedId")Long seedId, @Valid @RequestBody ActionPlanCreateRequestDto actionPlanCreateRequestDto) {
actionPlanService.createActionPlan(seedId, actionPlanCreateRequestDto);
return ApiResponse.success(SuccessStatus.POST_ACTIONPLAN_SUCCESS.getStatusCode(), SuccessStatus.POST_ACTIONPLAN_SUCCESS.getMessage());
}

@GetMapping("seed/{seedId}/actionPlan")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
package com.example.growthookserver.api.actionplan.dto.request;

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.List;

@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor
public class ActionPlanCreateRequestDto {
@NotBlank
@NotNull
@Size(max = 40)
private String content;
private List<String> contents;
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.example.growthookserver.api.actionplan.dto.request.ActionPlanCreateRequestDto;
import com.example.growthookserver.api.actionplan.dto.request.ActionPlanUpdateRequestDto;
import com.example.growthookserver.api.actionplan.dto.response.ActionPlanCreateResponseDto;
import com.example.growthookserver.api.actionplan.dto.response.ActionPlanGetResponseDto;
import com.example.growthookserver.api.actionplan.dto.response.DoingActionPlanGetResponseDto;
import com.example.growthookserver.api.actionplan.dto.response.FinishedActionPlanGetResponseDto;
Expand All @@ -11,7 +10,7 @@

public interface ActionPlanService {
//* 액션플랜 생성
ActionPlanCreateResponseDto createActionPlan(Long seedId, ActionPlanCreateRequestDto actionPlanCreateRequestDto);
void createActionPlan(Long seedId, ActionPlanCreateRequestDto actionPlanCreateRequestDto);

//* 씨앗 별 액션 플랜 조회
List<ActionPlanGetResponseDto> getActionPlan(Long seedId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.example.growthookserver.api.actionplan.domain.ActionPlan;
import com.example.growthookserver.api.actionplan.dto.request.ActionPlanCreateRequestDto;
import com.example.growthookserver.api.actionplan.dto.request.ActionPlanUpdateRequestDto;
import com.example.growthookserver.api.actionplan.dto.response.ActionPlanCreateResponseDto;
import com.example.growthookserver.api.actionplan.dto.response.ActionPlanGetResponseDto;
import com.example.growthookserver.api.actionplan.dto.response.DoingActionPlanGetResponseDto;
import com.example.growthookserver.api.actionplan.dto.response.FinishedActionPlanGetResponseDto;
Expand All @@ -30,14 +29,18 @@ public class ActionPlanServiceImpl implements ActionPlanService {

@Override
@Transactional
public ActionPlanCreateResponseDto createActionPlan(Long seedId, ActionPlanCreateRequestDto actionPlanCreateRequestDto){
public void createActionPlan(Long seedId, ActionPlanCreateRequestDto actionPlanCreateRequestDto){
Seed seed = seedRepository.findSeedByIdOrThrow(seedId);
ActionPlan actionPlan = ActionPlan.builder()
.content(actionPlanCreateRequestDto.getContent())
.seed(seed)
.build();
ActionPlan savedActionPlan = actionPlanRepository.save(actionPlan);
return ActionPlanCreateResponseDto.of(savedActionPlan.getId());

List<String> contents = actionPlanCreateRequestDto.getContents();

for(String content : contents) {
ActionPlan actionPlan = ActionPlan.builder()
.content(content)
.seed(seed)
.build();
actionPlanRepository.save(actionPlan);
}
}

@Override
Expand Down

0 comments on commit 1077368

Please sign in to comment.