Skip to content

Commit

Permalink
Merge pull request #24 from Leets-Official/feat]-#21-프로젝트-소개-로직-개발
Browse files Browse the repository at this point in the history
[feat]  포트폴리오 삭제 로직 추가와 컬럼 수정
  • Loading branch information
taeseokyang authored Feb 25, 2024
2 parents 5518644 + 0277a2d commit ff8bc83
Show file tree
Hide file tree
Showing 13 changed files with 52 additions and 59 deletions.

This file was deleted.

7 changes: 0 additions & 7 deletions src/main/java/land/leets/domain/image/usecase/SaveImage.java

This file was deleted.

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

import com.fasterxml.jackson.annotation.JsonIgnore;
import jakarta.persistence.*;
import land.leets.domain.admin.domain.Admin;
import land.leets.domain.contributor.domain.Contributor;
import land.leets.domain.shared.BaseTimeEntity;
import lombok.*;
Expand Down Expand Up @@ -55,13 +54,10 @@ public class Portfolio extends BaseTimeEntity {
private String serviceUrl;

@Column
private String logoImgUrl;
private String logoImgName;

@Column
private String coverImgUrl;

@Column
private String mainImgUrl;
private String mainImgName;

}

Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,17 @@
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import land.leets.domain.portfolio.domain.ProjectScope;
import land.leets.domain.portfolio.presentation.dto.PortfolioRequest;
import land.leets.domain.portfolio.presentation.dto.PortfolioResponse;
import land.leets.domain.portfolio.presentation.dto.PortfoliosResponse;
import land.leets.domain.portfolio.usecase.CreatePortfolio;
import land.leets.domain.portfolio.usecase.GetPortfolios;
import land.leets.domain.portfolio.usecase.UpdatePortfolios;
import land.leets.global.error.ErrorResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;
import java.util.Map;

@RestController
@RequiredArgsConstructor
Expand All @@ -26,6 +24,7 @@ public class PortfolioController {

private final CreatePortfolio createPortfolio;
private final GetPortfolios getPortfolios;
private final UpdatePortfolios updatePortfolios;

@Operation(summary = "(관리자) 포트폴리오 추가", description = "포트폴리오를 추가합니다.")
@ApiResponses({
Expand All @@ -36,11 +35,8 @@ public class PortfolioController {
@ApiResponse(responseCode = "500", content = @Content(schema = @Schema(implementation = ErrorResponse.class)))
})
@PostMapping
public PortfolioResponse create(@RequestPart PortfolioRequest request,
@RequestPart(required = false) MultipartFile logoImg,
@RequestPart(required = false) MultipartFile coverImg,
@RequestPart(required = false) MultipartFile mainImg) {
return createPortfolio.execute(request, logoImg, coverImg, mainImg);
public PortfolioResponse create(@RequestBody PortfolioRequest request) {
return createPortfolio.execute(request);
}

@Operation(summary = "(비로그인) 포트폴리오 조회", description = "포트폴리오를 조회합니다.")
Expand All @@ -52,12 +48,17 @@ public PortfolioResponse create(@RequestPart PortfolioRequest request,
@ApiResponse(responseCode = "500", content = @Content(schema = @Schema(implementation = ErrorResponse.class)))
})
@GetMapping
public List<List<PortfoliosResponse>> getAll(@RequestParam(required = false) String generation) {
public List<List<PortfoliosResponse>> getAll(@RequestParam(required = false) String generation) {
return getPortfolios.all(generation);
}

@GetMapping("/{portfolioId}")
public PortfolioResponse get(@PathVariable Long portfolioId) {
public PortfolioResponse get(@PathVariable Long portfolioId) {
return getPortfolios.one(portfolioId);
}

@DeleteMapping("/{portfolioId}")
public void delete(@PathVariable Long portfolioId) {
updatePortfolios.delete(portfolioId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,10 @@ public class PortfolioRequest {

@NotBlank
private List<Contributor> contributors;

@NotBlank
private String logoImgName;

@NotBlank
private String mainImgName;
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,10 @@ public class PortfolioResponse {
private String serviceUrl;

@NotBlank
private String logoImgUrl;
private String logoImgName;

@NotBlank
private String coverImgUrl;

@NotBlank
private String mainImgUrl;
private String mainImgName;

@NotBlank
private List<Contributor> contributors;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
package land.leets.domain.portfolio.presentation.dto;

import jakarta.validation.constraints.NotBlank;
import land.leets.domain.contributor.domain.Contributor;
import land.leets.domain.portfolio.domain.ProjectScope;
import land.leets.domain.portfolio.domain.ProjectType;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.time.LocalDate;
import java.util.List;

@Getter
@AllArgsConstructor
public class PortfoliosResponse {
Expand All @@ -21,5 +15,5 @@ public class PortfoliosResponse {
private String name;

@NotBlank
private String coverImgUrl;
private String mainImgName;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

import land.leets.domain.portfolio.presentation.dto.PortfolioRequest;
import land.leets.domain.portfolio.presentation.dto.PortfolioResponse;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

public interface CreatePortfolio {
PortfolioResponse execute(PortfolioRequest request, MultipartFile logoImg, MultipartFile coverImg, MultipartFile mainImg) ;
PortfolioResponse execute(PortfolioRequest request);
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import land.leets.domain.portfolio.presentation.mapper.PortfolioMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

@Service
@RequiredArgsConstructor
Expand All @@ -20,10 +19,7 @@ public class CreatePortfolioImpl implements CreatePortfolio {
private final CreateContributor createContributor;

@Override
public PortfolioResponse execute(PortfolioRequest request, MultipartFile logoImg, MultipartFile coverImg, MultipartFile mainImg) {
String logoImgUrl = saveImage.save(logoImg);
String coverImgUrl = saveImage.save(coverImg);
String mainImgUrl = saveImage.save(mainImg);
public PortfolioResponse execute(PortfolioRequest request) {

Portfolio portfolio = Portfolio.builder()
.generation(request.getGeneration())
Expand All @@ -35,9 +31,8 @@ public PortfolioResponse execute(PortfolioRequest request, MultipartFile logoImg
.startDate(request.getStartDate())
.endDate(request.getEndDate())
.contributors(request.getContributors())
.logoImgUrl(logoImgUrl)
.coverImgUrl(coverImgUrl)
.mainImgUrl(mainImgUrl)
.logoImgName(request.getLogoImgName())
.mainImgName(request.getMainImgName())
.build();
Portfolio save = portfolioRepository.save(portfolio);
createContributor.execute(request.getContributors(), save);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package land.leets.domain.portfolio.usecase;

public interface UpdatePortfolios {
void delete(Long portfolioId);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package land.leets.domain.portfolio.usecase;

import land.leets.domain.portfolio.domain.repository.PortfolioRepository;
import land.leets.domain.portfolio.exception.PortfolioNotFoundException;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
public class UpdatePortfoliosImpl implements UpdatePortfolios {
private final PortfolioRepository portfolioRepository;

@Override
public void delete(Long portfolioId) {
if (!portfolioRepository.existsById(portfolioId)) {
throw new PortfolioNotFoundException();
}
portfolioRepository.deleteById(portfolioId);
}
}
2 changes: 1 addition & 1 deletion src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,4 @@ target:
prod: ${TARGET_URL_PROD}

image:
path: ${IMAGE_PATH:/home/}
path: src/main/resources/images/
Binary file added src/main/resources/images/test.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ff8bc83

Please sign in to comment.