-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat : starpage create, layout, view, startype controller dev (#53)
- Loading branch information
1 parent
881672b
commit 8e04904
Showing
27 changed files
with
533 additions
and
25 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
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
12 changes: 12 additions & 0 deletions
12
...r/src/main/java/com/neo/needeachother/starpage/application/dto/CreatedStarPageResult.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,12 @@ | ||
package com.neo.needeachother.starpage.application.dto; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.ToString; | ||
|
||
@Getter | ||
@ToString | ||
@Builder | ||
public class CreatedStarPageResult { | ||
private String createdStarPageId; | ||
} |
15 changes: 15 additions & 0 deletions
15
.../src/main/java/com/neo/needeachother/starpage/application/dto/ModifiedStarTypeResult.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,15 @@ | ||
package com.neo.needeachother.starpage.application.dto; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.ToString; | ||
|
||
import java.util.List; | ||
|
||
@Getter | ||
@ToString | ||
@Builder | ||
public class ModifiedStarTypeResult { | ||
private String starPageId; | ||
private List<String> modifiedStarTypes; | ||
} |
15 changes: 15 additions & 0 deletions
15
...er/src/main/java/com/neo/needeachother/starpage/application/dto/StarPageLayoutResult.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,15 @@ | ||
package com.neo.needeachother.starpage.application.dto; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.ToString; | ||
|
||
@Getter | ||
@ToString | ||
@Builder | ||
public class StarPageLayoutResult { | ||
private Long layoutId; | ||
private String layoutTitle; | ||
private String layoutType; | ||
private String categoryId; | ||
} |
23 changes: 23 additions & 0 deletions
23
...in/java/com/neo/needeachother/starpage/application/mapper/StarPageLayoutResultMapper.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,23 @@ | ||
package com.neo.needeachother.starpage.application.mapper; | ||
|
||
import com.neo.needeachother.starpage.application.dto.StarPageLayoutResult; | ||
import com.neo.needeachother.starpage.domain.CategoricalLayoutLine; | ||
import com.neo.needeachother.starpage.domain.StarPageLayoutLine; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class StarPageLayoutResultMapper implements Mapper<StarPageLayoutLine, StarPageLayoutResult> { | ||
|
||
@Override | ||
public StarPageLayoutResult map(StarPageLayoutLine input) { | ||
StarPageLayoutResult.StarPageLayoutResultBuilder builder = StarPageLayoutResult.builder() | ||
.layoutId(input.getLayoutId()) | ||
.layoutTitle(input.getLayoutTitle().getValue()) | ||
.layoutType(input.getType().name()); | ||
|
||
if (input instanceof CategoricalLayoutLine) { | ||
builder.categoryId(((CategoricalLayoutLine) input).getCategoryId().getValue()); | ||
} | ||
return builder.build(); | ||
} | ||
} |
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
39 changes: 39 additions & 0 deletions
39
...r/src/main/java/com/neo/needeachother/starpage/presentation/StarPageCreateController.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,39 @@ | ||
package com.neo.needeachother.starpage.presentation; | ||
|
||
import com.neo.needeachother.starpage.application.CreateStarPageService; | ||
import com.neo.needeachother.starpage.application.dto.CreatedStarPageResult; | ||
import com.neo.needeachother.starpage.domain.SNSLine; | ||
import com.neo.needeachother.starpage.presentation.dto.CreateStarPageRequest; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
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.RestController; | ||
|
||
import java.net.URI; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/api/v1/starpage") | ||
public class StarPageCreateController { | ||
|
||
private final CreateStarPageService createStarPageService; | ||
|
||
@PostMapping | ||
public ResponseEntity<CreatedStarPageResult> demandCreateNewStarPage(@RequestBody CreateStarPageRequest createStarPageRequest) { | ||
|
||
CreatedStarPageResult createdStarPageResult = createStarPageService.createStarPage( | ||
createStarPageRequest.getStarNickName(), | ||
createStarPageRequest.getEmail(), | ||
createStarPageRequest.getStarTypeSet(), | ||
createStarPageRequest.getSnsProfiles().stream() | ||
.map(snsProfile -> SNSLine.of(snsProfile.getSnsTypeName(), snsProfile.getUrl())) | ||
.toList(), | ||
createStarPageRequest.getStarPageIntroduce() | ||
); | ||
|
||
return ResponseEntity.created(URI.create("/api/v1/starpage/" + createdStarPageResult.getCreatedStarPageId())) | ||
.body(createdStarPageResult); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...r/src/main/java/com/neo/needeachother/starpage/presentation/StarPageLayoutController.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,35 @@ | ||
package com.neo.needeachother.starpage.presentation; | ||
|
||
import com.neo.needeachother.starpage.application.LayoutManagementService; | ||
import com.neo.needeachother.starpage.application.dto.StarPageLayoutResult; | ||
import com.neo.needeachother.starpage.presentation.dto.AddCategoricalLayoutRequest; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
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.RestController; | ||
|
||
import java.net.URI; | ||
import java.util.List; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/api/v1/starpage") | ||
public class StarPageLayoutController { | ||
|
||
private final LayoutManagementService layoutManagementService; | ||
|
||
@PostMapping("/layout") | ||
public ResponseEntity demandAddLayout(@RequestBody AddCategoricalLayoutRequest addCategoricalLayoutRequest){ | ||
List<StarPageLayoutResult> result = layoutManagementService.appendLayoutInStarPage( | ||
addCategoricalLayoutRequest.getStarPageId(), | ||
addCategoricalLayoutRequest.getEmail(), | ||
addCategoricalLayoutRequest.getCategoryId() | ||
); | ||
|
||
Long appendedLayoutId = result.get(result.size() - 1).getLayoutId(); | ||
return ResponseEntity.created(URI.create("/api/v1/starpage/layout?id=" + appendedLayoutId)) | ||
.body(result); | ||
} | ||
} |
Oops, something went wrong.