-
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.
- Loading branch information
Showing
4 changed files
with
127 additions
and
100 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
72 changes: 45 additions & 27 deletions
72
src/main/java/com/backend/soullive_a/controller/ModelIntroductionController.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,27 +1,45 @@ | ||
package com.backend.soullive_a.controller; | ||
|
||
import com.backend.soullive_a.dto.response.ModelIntroductionResponse; | ||
import com.backend.soullive_a.service.ModelIntroductionService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/api/model/introduction") | ||
public class ModelIntroductionController { | ||
|
||
private final ModelIntroductionService modelIntroductionService; | ||
|
||
/** | ||
* 모델소개 조회 api | ||
* @param modelId | ||
* @return | ||
*/ | ||
@GetMapping("/{modelId}") | ||
public ModelIntroductionResponse getModelInroduction(@PathVariable Long modelId) { | ||
return modelIntroductionService.getModelIntroduction(modelId); | ||
} | ||
} | ||
//package com.backend.soullive_a.controller; | ||
// | ||
//import com.backend.soullive_a.dto.request.ModelIntroduceRequest; | ||
//import com.backend.soullive_a.dto.response.ModelIntroductionResponse; | ||
//import com.backend.soullive_a.dto.response.ModelResponse; | ||
//import com.backend.soullive_a.exception.base.BaseResponse; | ||
//import com.backend.soullive_a.service.ModelIntroductionService; | ||
//import jakarta.validation.Valid; | ||
//import lombok.RequiredArgsConstructor; | ||
//import org.springframework.web.bind.annotation.*; | ||
// | ||
//@RestController | ||
//@RequiredArgsConstructor | ||
//@RequestMapping("/api/model/introduction") | ||
//public class ModelIntroductionController { | ||
// | ||
// private final ModelIntroductionService modelIntroductionService; | ||
// | ||
// /** | ||
// * 모델소개 조회 api | ||
// * @param modelId | ||
// * @return | ||
// */ | ||
// @GetMapping("/{modelId}") | ||
// public BaseResponse<ModelIntroductionResponse> getModelIntroduction(@PathVariable Long modelId) { | ||
// return BaseResponse.<ModelIntroductionResponse>builder() | ||
// .isSuccess(true) | ||
// .code(2006) | ||
// .message("모델소개 정보 조회에 성공했습니다.") | ||
// .data(modelIntroductionService.getModelIntroduction(modelId)) | ||
// .build(); | ||
// } | ||
// | ||
// @PostMapping("/{modelId}") | ||
// public BaseResponse<ModelIntroductionResponse> createModelIntroduction( | ||
// @PathVariable Long modelId, | ||
// @RequestBody @Valid ModelIntroduceRequest request) { | ||
// return BaseResponse.<ModelIntroductionResponse>builder() | ||
// .isSuccess(true) | ||
// .code(2006) | ||
// .message("모델소개 정보 생성에 성공했습니다.") | ||
// .data(modelIntroductionService.createModelIntroduction(request, modelId)) | ||
// .build(); | ||
// } | ||
//} |
24 changes: 12 additions & 12 deletions
24
src/main/java/com/backend/soullive_a/service/ModelIntroductionService.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,12 +1,12 @@ | ||
package com.backend.soullive_a.service; | ||
|
||
import com.backend.soullive_a.dto.request.ModelIntroduceRequest; | ||
import com.backend.soullive_a.dto.response.ModelIntroductionResponse; | ||
|
||
import java.util.List; | ||
|
||
public interface ModelIntroductionService { | ||
public ModelIntroductionResponse getModelIntroduction(Long modelId); | ||
|
||
public ModelIntroductionResponse createModelIntroduction(ModelIntroduceRequest request, Long modelId); | ||
} | ||
//package com.backend.soullive_a.service; | ||
// | ||
//import com.backend.soullive_a.dto.request.ModelIntroduceRequest; | ||
//import com.backend.soullive_a.dto.response.ModelIntroductionResponse; | ||
// | ||
//import java.util.List; | ||
// | ||
//public interface ModelIntroductionService { | ||
// public ModelIntroductionResponse getModelIntroduction(Long modelId); | ||
// | ||
// public ModelIntroductionResponse createModelIntroduction(ModelIntroduceRequest request, Long modelId); | ||
//} |
128 changes: 68 additions & 60 deletions
128
src/main/java/com/backend/soullive_a/service/impl/ModelIntroductionServiceImpl.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,60 +1,68 @@ | ||
package com.backend.soullive_a.service.impl; | ||
|
||
import com.backend.soullive_a.dto.request.ModelIntroduceRequest; | ||
import com.backend.soullive_a.dto.response.ModelIntroductionResponse; | ||
import com.backend.soullive_a.entity.model.Model; | ||
import com.backend.soullive_a.entity.model.introduction.ModelImageKeyword; | ||
import com.backend.soullive_a.exception.custom.NotFoundUserException; | ||
import com.backend.soullive_a.repository.ModelImageKeywordRepository; | ||
import com.backend.soullive_a.repository.ModelRecentAdvertisementRepository; | ||
import com.backend.soullive_a.repository.ModelRecentWorkRepository; | ||
import com.backend.soullive_a.repository.ModelRepository; | ||
import com.backend.soullive_a.service.ModelIntroductionService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class ModelIntroductionServiceImpl implements ModelIntroductionService { | ||
|
||
private final ModelImageKeywordRepository modelImageKeywordRepository; | ||
private final ModelRecentWorkRepository modelRecentWorkRepository; | ||
private final ModelRecentAdvertisementRepository modelRecentAdvertisementRepository; | ||
private final ModelRepository modelRepository; | ||
|
||
/** | ||
* 모델 소개 조회 서비스 로직 | ||
* @param modelId | ||
* @return | ||
*/ | ||
@Override | ||
public ModelIntroductionResponse getModelIntroduction(Long modelId) { | ||
return ModelIntroductionResponse.builder() | ||
.modelImageKeywords(modelImageKeywordRepository.findAllById(modelId)) | ||
.modelRecentWorks(modelRecentWorkRepository.findAllById(modelId)) | ||
.modelRecentAdvertisements(modelRecentAdvertisementRepository.findAllById(modelId)) | ||
.build(); | ||
} | ||
|
||
/** | ||
* 모델소개 생성 서비스 로직 | ||
* @param modelId | ||
* @return | ||
*/ | ||
@Override | ||
public ModelIntroductionResponse createModelIntroduction(ModelIntroduceRequest request, Long modelId) { | ||
Model model = modelRepository.findById(modelId) | ||
.orElseThrow(() -> new NotFoundUserException()); | ||
|
||
return ModelIntroductionResponse.builder() | ||
.modelImageKeywords(request.modelImageKeywords()) | ||
.modelRecentWorks(request.modelRecentWorks()) | ||
.modelRecentAdvertisements(request.modelRecentAdvertisements()) | ||
.build(); | ||
|
||
|
||
} | ||
|
||
|
||
} | ||
//package com.backend.soullive_a.service.impl; | ||
// | ||
//import com.backend.soullive_a.dto.request.ModelIntroduceRequest; | ||
//import com.backend.soullive_a.dto.response.ModelIntroductionResponse; | ||
//import com.backend.soullive_a.entity.model.Model; | ||
//import com.backend.soullive_a.entity.model.introduction.ModelImageKeyword; | ||
//import com.backend.soullive_a.entity.model.introduction.ModelIntroduction; | ||
//import com.backend.soullive_a.exception.custom.NotFoundUserException; | ||
//import com.backend.soullive_a.repository.*; | ||
//import com.backend.soullive_a.service.ModelIntroductionService; | ||
//import lombok.RequiredArgsConstructor; | ||
//import org.springframework.stereotype.Service; | ||
// | ||
// | ||
//@Service | ||
//@RequiredArgsConstructor | ||
//public class ModelIntroductionServiceImpl implements ModelIntroductionService { | ||
// | ||
// private final ModelImageKeywordRepository modelImageKeywordRepository; | ||
// private final ModelRecentWorkRepository modelRecentWorkRepository; | ||
// private final ModelRecentAdvertisementRepository modelRecentAdvertisementRepository; | ||
// private final ModelRepository modelRepository; | ||
// private final ModelIntroductionRepository modelIntroductionRepository; | ||
// | ||
// /** | ||
// * 모델 소개 조회 서비스 로직 | ||
// * @param modelId | ||
// * @return | ||
// */ | ||
// @Override | ||
// public ModelIntroductionResponse getModelIntroduction(Long modelId) { | ||
// Model model = modelRepository.findById(modelId) | ||
// .orElseThrow(() -> new NotFoundUserException()); | ||
// | ||
// return ModelIntroductionResponse.builder() | ||
// .modelImageKeywords(modelImageKeywordRepository.findAllById(modelId)) | ||
// .modelRecentWorks(modelRecentWorkRepository.findAllById(modelId)) | ||
// .modelRecentAdvertisements(modelRecentAdvertisementRepository.findAllById(modelId)) | ||
// .build(); | ||
// } | ||
// | ||
// /** | ||
// * 모델소개 생성 서비스 로직 | ||
// * @param modelId | ||
// * @return | ||
// */ | ||
// @Override | ||
// public ModelIntroductionResponse createModelIntroduction(ModelIntroduceRequest request, Long modelId) { | ||
// Model model = modelRepository.findById(modelId) | ||
// .orElseThrow(() -> new NotFoundUserException()); | ||
// | ||
// ModelIntroduction modelIntroduction = modelIntroductionRepository.save( | ||
// ModelIntroduction.builder() | ||
// .model(model) | ||
// .build() | ||
// ); | ||
// | ||
// return ModelIntroductionResponse.builder() | ||
// .modelImageKeywords(request.modelImageKeywords()) | ||
// .modelRecentWorks(request.modelRecentWorks()) | ||
// .modelRecentAdvertisements(request.modelRecentAdvertisements()) | ||
// .build(); | ||
// | ||
// | ||
// } | ||
// | ||
// | ||
//} |