Skip to content

Commit

Permalink
Merge pull request #10 from PLADI-ALM/feat/PDS-137-update-project
Browse files Browse the repository at this point in the history
[PDS-137] 아카이빙 프로젝트 이름변경 API
  • Loading branch information
leeseunghakhello authored Oct 21, 2023
2 parents dba3630 + 346bfc6 commit 247aece
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package com.example.PLADIALMArchiving.archiving.controller;

import com.example.PLADIALMArchiving.archiving.dto.request.RegisterProjectReq;
import com.example.PLADIALMArchiving.archiving.dto.request.SearchMaterialReq;
import com.example.PLADIALMArchiving.archiving.dto.request.UpdateMaterialReq;
import com.example.PLADIALMArchiving.archiving.dto.request.UploadMaterialReq;
import com.example.PLADIALMArchiving.archiving.dto.request.*;
import com.example.PLADIALMArchiving.archiving.dto.response.DownloadMaterialRes;
import com.example.PLADIALMArchiving.archiving.dto.response.SearchMaterialRes;
import com.example.PLADIALMArchiving.archiving.dto.response.SearchProjectRes;
Expand Down Expand Up @@ -168,4 +165,22 @@ public ResponseCustom<Page<SearchProjectRes>> searchProject(
{
return ResponseCustom.OK(archivingService.searchProject(pageable));
}

/**
* 프로젝트 이름을 변경한다.
*/
@Operation(summary = "프로젝트 이름 변경 (김민기)", description = "아카이빙 프로젝트 이름을 변경한다.")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "(S0001)요청에 성공했습니다."),
@ApiResponse(responseCode = "404", description = "(P0002)존재하지 않는 프로젝트입니다.", content = @Content(schema = @Schema(implementation = ResponseCustom.class)))
})
@PatchMapping("/projects/{projectId}")
public ResponseCustom<?> updateProject(
@Parameter(description = "(Long) 프로젝트 Id", example = "1") @PathVariable Long projectId,
@RequestBody @Valid UpdateProjectReq updateProjectReq
)
{
archivingService.updateProject(projectId, updateProjectReq);
return ResponseCustom.OK();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.example.PLADIALMArchiving.archiving.dto.request;

import lombok.Getter;

@Getter
public class UpdateProjectReq {
private String name;
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,8 @@ public static Project toEntity(String name) {
public Project(String name) {
this.name = name;
}

public void update(String name) {
this.name = name;
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package com.example.PLADIALMArchiving.archiving.service;

import com.example.PLADIALMArchiving.archiving.dto.request.RegisterProjectReq;
import com.example.PLADIALMArchiving.archiving.dto.request.SearchMaterialReq;
import com.example.PLADIALMArchiving.archiving.dto.request.UpdateMaterialReq;
import com.example.PLADIALMArchiving.archiving.dto.request.UploadMaterialReq;
import com.example.PLADIALMArchiving.archiving.dto.request.*;
import com.example.PLADIALMArchiving.archiving.dto.response.DownloadMaterialRes;
import com.example.PLADIALMArchiving.archiving.dto.response.SearchMaterialRes;
import com.example.PLADIALMArchiving.archiving.dto.response.SearchProjectRes;
Expand Down Expand Up @@ -103,4 +100,10 @@ public Page<SearchProjectRes> searchProject(Pageable pageable) {
Page<Project> all = projectRepository.findAll(pageable);
return all.map(SearchProjectRes::toDto);
}

@Transactional
public void updateProject(Long projectId, UpdateProjectReq updateProjectReq) {
Project project = projectRepository.findById(projectId).orElseThrow(() -> new BaseException(BaseResponseCode.PROJECT_NOT_FOUND));
project.update(updateProjectReq.getName());
}
}

0 comments on commit 247aece

Please sign in to comment.