-
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.
Update: 생성 요청 DTO 하나로 통일, 생성 시 외부 도메인 의존 제거, api 수정
- Loading branch information
1 parent
a41e670
commit ee093bc
Showing
7 changed files
with
43 additions
and
83 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
28 changes: 5 additions & 23 deletions
28
src/main/java/me/ajaja/module/footprint/application/port/CreateFootprintService.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,45 +1,27 @@ | ||
package me.ajaja.module.footprint.application.port; | ||
|
||
import static me.ajaja.global.exception.ErrorCode.*; | ||
|
||
import java.util.List; | ||
|
||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import me.ajaja.global.exception.AjajaException; | ||
import me.ajaja.module.footprint.application.port.in.CreateFootprintUseCase; | ||
import me.ajaja.module.footprint.application.port.out.CreateFootprintPort; | ||
import me.ajaja.module.footprint.domain.Footprint; | ||
import me.ajaja.module.footprint.domain.FootprintFactory; | ||
import me.ajaja.module.footprint.domain.Target; | ||
import me.ajaja.module.footprint.domain.Writer; | ||
import me.ajaja.module.footprint.dto.FootprintParam; | ||
import me.ajaja.module.plan.application.port.out.FindPlanPort; | ||
import me.ajaja.module.plan.domain.Plan; | ||
import me.ajaja.module.user.application.port.out.RetrieveUserPort; | ||
import me.ajaja.module.user.domain.User; | ||
import me.ajaja.module.footprint.dto.FootprintRequest; | ||
|
||
@Service | ||
@Transactional | ||
@RequiredArgsConstructor | ||
public class CreateFootprintService implements CreateFootprintUseCase { | ||
private final FootprintFactory footprintFactory; | ||
private final CreateFootprintPort createFootprintPort; | ||
private final RetrieveUserPort retrieveUserPort; | ||
private final FindPlanPort findPlanPort; | ||
|
||
@Override | ||
public Long create(Long userId, Long targetId, FootprintParam.Create param, List<String> tags) { | ||
User user = retrieveUserPort.loadById(userId).orElseThrow(() -> new AjajaException(USER_NOT_FOUND)); | ||
Writer writer = new Writer(user.getId(), user.getNickname().getNickname()); | ||
|
||
Plan plan = findPlanPort.findById(targetId).orElseThrow(() -> new AjajaException(NOT_FOUND_PLAN)); | ||
Target target = new Target(plan.getId(), plan.getPlanTitle()); | ||
|
||
Footprint footprint = footprintFactory.create(target, writer, param); | ||
public Long create(Long userId, FootprintRequest.Create param) { | ||
Footprint footprint = footprintFactory.create(userId, param); | ||
Long footprintId = createFootprintPort.create(footprint); | ||
|
||
return createFootprintPort.create(footprint); | ||
return footprintId; | ||
} | ||
} |
6 changes: 2 additions & 4 deletions
6
src/main/java/me/ajaja/module/footprint/application/port/in/CreateFootprintUseCase.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,9 +1,7 @@ | ||
package me.ajaja.module.footprint.application.port.in; | ||
|
||
import java.util.List; | ||
|
||
import me.ajaja.module.footprint.dto.FootprintParam; | ||
import me.ajaja.module.footprint.dto.FootprintRequest; | ||
|
||
public interface CreateFootprintUseCase { | ||
Long create(Long userId, Long targetId, FootprintParam.Create param, List<String> tags); | ||
Long create(Long userId, FootprintRequest.Create param); | ||
} |
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 |
---|---|---|
|
@@ -4,5 +4,4 @@ | |
|
||
public interface GetFootprintPort { | ||
Footprint getFootprint(Long id); | ||
|
||
} |
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
33 changes: 0 additions & 33 deletions
33
src/main/java/me/ajaja/module/footprint/dto/FootprintParam.java
This file was deleted.
Oops, something went wrong.
26 changes: 25 additions & 1 deletion
26
src/main/java/me/ajaja/module/footprint/dto/FootprintRequest.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,13 +1,37 @@ | ||
package me.ajaja.module.footprint.dto; | ||
|
||
import java.beans.ConstructorProperties; | ||
import java.util.List; | ||
|
||
import lombok.Data; | ||
import me.ajaja.module.footprint.domain.Footprint; | ||
|
||
public final class FootprintRequest { | ||
@Data | ||
public static class Create { | ||
private final FootprintParam.Create param; | ||
private final Long targetId; | ||
private final Footprint.Type type; | ||
private final String title; | ||
private final boolean visible; | ||
private final String content; | ||
private final String keepContent; | ||
private final String problemContent; | ||
private final String tryContent; | ||
private final List<String> tags; | ||
|
||
@ConstructorProperties({"targetId", "type", "title", "visible", "content", "keepContent", "problemContent", | ||
"tryContent", "tags"}) | ||
public Create(Long targetId, Footprint.Type type, String title, boolean visible, String content, | ||
String keepContent, String problemContent, String tryContent, List<String> tags) { | ||
this.targetId = targetId; | ||
this.type = type; | ||
this.title = title; | ||
this.visible = visible; | ||
this.content = content; | ||
this.keepContent = keepContent; | ||
this.problemContent = problemContent; | ||
this.tryContent = tryContent; | ||
this.tags = tags; | ||
} | ||
} | ||
} |
UseCase
에서는 id를 넘겨주는데 안 쓰고 있다면 void로 바꾸거나 사용하는 쪽으로 해야할 것 같아요!