Skip to content

Commit

Permalink
Merge pull request #32 from STUDIO-EYE/develop
Browse files Browse the repository at this point in the history
V.0.0.4
  • Loading branch information
phonil authored Nov 4, 2024
2 parents 24643e0 + 64a5395 commit d894ecb
Show file tree
Hide file tree
Showing 17 changed files with 1,609 additions and 172 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public ApiResponse<Ceo> updateCeoTextInformation(@Valid @RequestPart("request")

@Operation(summary = "CEO 이미지 정보 수정 API")
@PutMapping("/ceo/image")
public ApiResponse<Ceo> updateCeoImageInformation(@RequestPart(value = "file", required = false) MultipartFile file) {
public ApiResponse<Ceo> updateCeoImageInformation(@RequestPart(value = "file", required = false) MultipartFile file) throws IOException {
return ceoService.updateCeoImageInformation(file);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
package studio.studioeye.domain.ceo.application;

import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import studio.studioeye.domain.ceo.dao.CeoRepository;
import studio.studioeye.domain.ceo.domain.Ceo;
import studio.studioeye.domain.ceo.dto.request.CreateCeoServiceRequestDto;
import studio.studioeye.domain.ceo.dto.request.UpdateCeoServiceRequestDto;
import studio.studioeye.infrastructure.s3.S3Adapter;
import studio.studioeye.global.common.response.ApiResponse;
import studio.studioeye.global.exception.error.ErrorCode;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.List;
Expand Down Expand Up @@ -87,8 +86,7 @@ public ApiResponse<Ceo> updateCeoTextInformation(UpdateCeoServiceRequestDto dto)
return ApiResponse.ok("CEO 텍스트 정보를 성공적으로 수정했습니다.", savedCeo);
}

@SneakyThrows
public ApiResponse<Ceo> updateCeoImageInformation(MultipartFile file) {
public ApiResponse<Ceo> updateCeoImageInformation(MultipartFile file) throws IOException {
String imageUrl = null;
String fileName = null;
List<Ceo> ceoList = ceoRepository.findAll();
Expand Down Expand Up @@ -117,6 +115,9 @@ public ApiResponse<String> deleteCeoInformation() {
return ApiResponse.withError(ErrorCode.CEO_IS_EMPTY);
}
Ceo ceo = ceoList.get(0);
String ceoImageFileName = ceoList.get(0).getImageFileName();
if(ceoImageFileName != null) s3Adapter.deleteFile(ceoImageFileName);

ceoRepository.delete(ceo);
return ApiResponse.ok("CEO 정보를 성공적으로 삭제했습니다.");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package studio.studioeye.domain.ceo.dao;

import org.springframework.data.jpa.repository.JpaRepository;
import studio.studioeye.domain.ceo.domain.Ceo;
import org.springframework.data.jpa.repository.JpaRepository;

public interface CeoRepository extends JpaRepository<Ceo, Long> {
}
2 changes: 1 addition & 1 deletion src/main/java/studio/studioeye/domain/ceo/domain/Ceo.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package studio.studioeye.domain.ceo.domain;

import studio.studioeye.domain.ceo.dto.request.UpdateCeoServiceRequestDto;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
Expand All @@ -9,7 +10,6 @@
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import studio.studioeye.domain.ceo.dto.request.UpdateCeoServiceRequestDto;

@Entity
@Getter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public ApiResponse<List<Faq>> retrieveAllFaq() {
public ApiResponse<List<FaqQuestions>> retrieveAllFaqTitle() {
List<FaqQuestions> faqQuestions = faqRepository.findAllQuestions();
if(faqQuestions.isEmpty()) {
return ApiResponse.ok("FAQ가 존재하지 않습니다.");
return ApiResponse.withError(ErrorCode.INVALID_FAQ_ID);
}
return ApiResponse.ok("FAQ 목록을 성공적으로 조회했습니다.", faqQuestions);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
package studio.studioeye.domain.project.api;

import studio.studioeye.domain.project.application.ProjectService;
import studio.studioeye.domain.project.domain.Project;
import studio.studioeye.domain.project.dto.request.*;
import studio.studioeye.global.common.response.ApiResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import studio.studioeye.domain.project.application.ProjectService;
import studio.studioeye.domain.project.domain.Project;
import studio.studioeye.domain.project.dto.request.*;
import studio.studioeye.global.common.response.ApiResponse;

import java.io.IOException;
import java.util.List;

@Tag(name = "프로젝트 API", description = "프로젝트 등록 / 수정 / 삭제 / 조회")
Expand All @@ -22,40 +23,17 @@ public class ProjectController {

private final ProjectService projectService;

// POST
@Operation(summary = "프로젝트 등록 API")
@PostMapping("/projects")
public ApiResponse<Project> createProject(@Valid @RequestPart("request") CreateProjectRequestDto dto,
@RequestPart(value = "file", required = false) MultipartFile mainImgFile,
@RequestPart(value = "files", required = false) List<MultipartFile> files){
return projectService.createProject(dto.toServiceRequest(), mainImgFile, files);
}

@Operation(summary = "프로젝트 수정 API")
@PutMapping("/projects")
public ApiResponse<Project> updateProject(@Valid @RequestPart("request") UpdateProjectRequestDto dto,
@RequestPart(value = "file", required = false) MultipartFile mainImgFile,
@RequestPart(value = "files", required = false) List<MultipartFile> files){
return projectService.updateProject(dto.toServiceRequest(), mainImgFile, files);
}

@Operation(summary = "Artwork Page 프로젝트 순서 변경 API")
@PutMapping("/projects/sequence")
public ApiResponse<String> changeSequenceProject(@RequestBody List<ChangeSequenceProjectReq> changeSequenceProjectReqList){
return projectService.changeSequenceProject(changeSequenceProjectReqList);
}

@Operation(summary = "Main Page 프로젝트 순서 변경 API")
@PutMapping("/projects/main/sequence")
public ApiResponse<String> changeMainSequenceProject(@RequestBody List<ChangeMainSequenceProjectReq> changeMainSequenceProjectReqList){
return projectService.changeMainSequenceProject(changeMainSequenceProjectReqList);
}

@Operation(summary = "프로젝트 삭제 API")
@DeleteMapping("/projects/{projectId}")
public ApiResponse<String> deleteProject(@PathVariable Long projectId){
return projectService.deleteProject(projectId);
@RequestPart(value = "responsiveFile", required = false) MultipartFile responsiveMainImgFile,
@RequestPart(value = "files", required = false) List<MultipartFile> files) throws IOException {
return projectService.createProject(dto.toServiceRequest(), mainImgFile, responsiveMainImgFile, files);
}

// GET
@Operation(summary = "프로젝트 전체 조회 API (request 페이지, sequence 순)")
@GetMapping("/projects")
public ApiResponse<List<Project>> retrieveAllArtworkProject(){
Expand All @@ -81,6 +59,29 @@ public Page<Project> retrieveArtworkProjectPage(@RequestParam(defaultValue = "0"
return projectService.retrieveArtworkProjectPage(page, size);
}

// PUT
@Operation(summary = "프로젝트 수정 API")
@PutMapping("/projects")
public ApiResponse<Project> updateProject(@Valid @RequestPart("request") UpdateProjectRequestDto dto,
@RequestPart(value = "file", required = false) MultipartFile mainImgFile,
@RequestPart(value = "responsiveFile", required = false) MultipartFile responsiveMainImgFile,
@RequestPart(value = "files", required = false) List<MultipartFile> files) throws IOException {
return projectService.updateProject(dto.toServiceRequest(), mainImgFile, responsiveMainImgFile, files);
}

@Operation(summary = "Artwork Page 프로젝트 순서 변경 API")
@PutMapping("/projects/sequence")
public ApiResponse<String> changeSequenceProject(@RequestBody List<ChangeSequenceProjectReq> changeSequenceProjectReqList){
return projectService.changeSequenceProject(changeSequenceProjectReqList);
}

@Operation(summary = "Main Page 프로젝트 순서 변경 API")
@PutMapping("/projects/main/sequence")
public ApiResponse<String> changeMainSequenceProject(@RequestBody List<ChangeMainSequenceProjectReq> changeMainSequenceProjectReqList){
return projectService.changeMainSequenceProject(changeMainSequenceProjectReqList);
}


@Operation(summary = "게시 여부 변경 API")
@PutMapping("/projects/is-posted")
public ApiResponse<Project> updatePostingStatus(@Valid @RequestBody UpdatePostingStatusDto dto){
Expand All @@ -93,4 +94,12 @@ public ApiResponse<Project> updateProjectType(@Valid @RequestBody UpdateProjectT
return projectService.updateProjectType(dto);
}


// DELETE
@Operation(summary = "프로젝트 삭제 API")
@DeleteMapping("/projects/{projectId}")
public ApiResponse<String> deleteProject(@PathVariable Long projectId){
return projectService.deleteProject(projectId);
}

}
Loading

0 comments on commit d894ecb

Please sign in to comment.