fixed: response status 변경, list 객체 바인딩 수정
This commit is contained in:
@@ -12,6 +12,7 @@ import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.web.PageableDefault;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
@@ -88,6 +89,7 @@ public class BoardApiController {
|
||||
* @return BoardResponseDto 게시판 상세 응답 DTO
|
||||
*/
|
||||
@PostMapping("/api/v1/boards")
|
||||
@ResponseStatus(HttpStatus.CREATED)
|
||||
public BoardResponseDto save(@RequestBody @Valid BoardSaveRequestDto requestDto) {
|
||||
return boardService.save(requestDto);
|
||||
}
|
||||
@@ -110,6 +112,7 @@ public class BoardApiController {
|
||||
* @param boardNo 게시판 번호
|
||||
*/
|
||||
@DeleteMapping("/api/v1/boards/{boardNo}")
|
||||
@ResponseStatus(HttpStatus.NO_CONTENT)
|
||||
public void delete(@PathVariable Integer boardNo) {
|
||||
boardService.delete(boardNo);
|
||||
}
|
||||
|
||||
@@ -194,7 +194,7 @@ public class BoardResponseDto implements Serializable {
|
||||
* @param posts 게시물 목록
|
||||
*/
|
||||
public void setNewestPosts(List<PostsSimpleResponseDto> posts) {
|
||||
this.posts = new ArrayList<>(posts);
|
||||
this.posts = posts == null ? null : new ArrayList<>(posts);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import org.egovframe.cloud.boardservice.api.comment.dto.CommentSaveRequestDto;
|
||||
import org.egovframe.cloud.boardservice.api.comment.dto.CommentUpdateRequestDto;
|
||||
import org.egovframe.cloud.boardservice.service.comment.CommentService;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@@ -94,6 +95,7 @@ public class CommentApiController {
|
||||
* @param requestDto 댓글 등록 요청 DTO
|
||||
*/
|
||||
@PostMapping("/api/v1/comments")
|
||||
@ResponseStatus(HttpStatus.CREATED)
|
||||
public CommentResponseDto save(@RequestBody @Valid CommentSaveRequestDto requestDto) {
|
||||
return commentService.save(requestDto);
|
||||
}
|
||||
@@ -119,6 +121,7 @@ public class CommentApiController {
|
||||
* @param commentNo 댓글 번호
|
||||
*/
|
||||
@DeleteMapping("/api/v1/comments/delete/{boardNo}/{postsNo}/{commentNo}")
|
||||
@ResponseStatus(HttpStatus.NO_CONTENT)
|
||||
public void deleteByCreator(@PathVariable Integer boardNo, @PathVariable Integer postsNo, @PathVariable Integer commentNo) {
|
||||
String userId = SecurityContextHolder.getContext().getAuthentication().getName();
|
||||
|
||||
@@ -143,6 +146,7 @@ public class CommentApiController {
|
||||
* @param commentNo 댓글 번호
|
||||
*/
|
||||
@DeleteMapping("/api/v1/comments/{boardNo}/{postsNo}/{commentNo}")
|
||||
@ResponseStatus(HttpStatus.NO_CONTENT)
|
||||
public void delete(@PathVariable Integer boardNo, @PathVariable Integer postsNo, @PathVariable Integer commentNo) {
|
||||
commentService.delete(boardNo, postsNo, commentNo);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.web.SortDefault;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@@ -132,6 +133,7 @@ public class PostsApiController {
|
||||
* @return PostsResponseDto 게시물 상세 응답 DTO
|
||||
*/
|
||||
@PostMapping("/api/v1/posts/save/{boardNo}")
|
||||
@ResponseStatus(HttpStatus.CREATED)
|
||||
public PostsResponseDto saveByCreator(@PathVariable Integer boardNo, @RequestBody @Valid PostsSimpleSaveRequestDto requestDto) {
|
||||
String userId = SecurityContextHolder.getContext().getAuthentication().getName();
|
||||
return postsService.save(boardNo, requestDto, userId);
|
||||
@@ -159,6 +161,7 @@ public class PostsApiController {
|
||||
* @param postsNo 게시물 번호
|
||||
*/
|
||||
@DeleteMapping("/api/v1/posts/remove/{boardNo}/{postsNo}")
|
||||
@ResponseStatus(HttpStatus.NO_CONTENT)
|
||||
public void deleteByCreator(@PathVariable Integer boardNo, @PathVariable Integer postsNo) {
|
||||
String userId = SecurityContextHolder.getContext().getAuthentication().getName();
|
||||
|
||||
@@ -173,6 +176,7 @@ public class PostsApiController {
|
||||
* @return PostsResponseDto 게시물 상세 응답 DTO
|
||||
*/
|
||||
@PostMapping("/api/v1/posts/{boardNo}")
|
||||
@ResponseStatus(HttpStatus.CREATED)
|
||||
public PostsResponseDto save(@PathVariable Integer boardNo, @RequestBody @Valid PostsSaveRequestDto requestDto) {
|
||||
return postsService.save(boardNo, requestDto);
|
||||
}
|
||||
@@ -222,6 +226,7 @@ public class PostsApiController {
|
||||
* @param requestDtoList 게시물 삭제 요청 DTO List
|
||||
*/
|
||||
@PutMapping("/api/v1/posts/delete")
|
||||
@ResponseStatus(HttpStatus.NO_CONTENT)
|
||||
public void delete(@RequestBody @Valid List<PostsDeleteRequestDto> requestDtoList) {
|
||||
postsService.delete(requestDtoList);
|
||||
}
|
||||
|
||||
@@ -203,14 +203,14 @@ public class PostsResponseDto implements Serializable {
|
||||
* 이전 게시물
|
||||
*/
|
||||
public void setPrevPosts(List<PostsSimpleResponseDto> prevPosts) {
|
||||
this.prevPosts = new ArrayList<>(prevPosts);
|
||||
this.prevPosts = prevPosts == null ? null : new ArrayList<>(prevPosts);
|
||||
}
|
||||
|
||||
/**
|
||||
* 다음 게시물
|
||||
*/
|
||||
public void setNextPosts(List<PostsSimpleResponseDto> nextPosts) {
|
||||
this.nextPosts = new ArrayList<>(nextPosts);
|
||||
this.nextPosts = nextPosts == null ? null : new ArrayList<>(nextPosts);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ public class Posts extends BaseEntity {
|
||||
this.noticeAt = noticeAt;
|
||||
this.deleteAt = deleteAt;
|
||||
this.creator = creator;
|
||||
this.comments = new ArrayList<>(comments);
|
||||
this.comments = comments == null ? null : new ArrayList<>(comments);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -26,7 +26,7 @@ public class HttpUtil {
|
||||
* static method 만으로 구성된 유틸리티 클래스
|
||||
* 객체 생성 금지
|
||||
*/
|
||||
private HttpUtil() {
|
||||
private HttpUtil() throws IllegalStateException {
|
||||
throw new IllegalStateException("Http Utility Class");
|
||||
}
|
||||
|
||||
|
||||
@@ -238,7 +238,7 @@ public class BoardApiControllerTest {
|
||||
);
|
||||
|
||||
// then
|
||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.CREATED);
|
||||
|
||||
BoardResponseDto dto = responseEntity.getBody();
|
||||
assertThat(dto).isNotNull();
|
||||
@@ -354,7 +354,7 @@ public class BoardApiControllerTest {
|
||||
);
|
||||
|
||||
// then
|
||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT);
|
||||
|
||||
Optional<Board> board = selectData(boardNo);
|
||||
assertThat(board).isNotPresent();
|
||||
|
||||
@@ -320,7 +320,7 @@ class CommentApiControllerTest {
|
||||
);
|
||||
|
||||
// then
|
||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.CREATED);
|
||||
|
||||
CommentResponseDto dto = responseEntity.getBody();
|
||||
assertThat(dto).isNotNull();
|
||||
@@ -476,7 +476,7 @@ class CommentApiControllerTest {
|
||||
);
|
||||
|
||||
// then
|
||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT);
|
||||
|
||||
Optional<Comment> comment = selectData(boardNo, postsNo, commentNo);
|
||||
assertThat(comment).isPresent();
|
||||
|
||||
@@ -442,7 +442,7 @@ class PostsApiControllerTest {
|
||||
);
|
||||
|
||||
// then
|
||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.CREATED);
|
||||
|
||||
PostsResponseDto dto = responseEntity.getBody();
|
||||
assertThat(dto).isNotNull();
|
||||
@@ -640,7 +640,7 @@ class PostsApiControllerTest {
|
||||
);
|
||||
|
||||
// then
|
||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT);
|
||||
|
||||
List<Posts> list = postsRepository.findAll();
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.ContentDisposition;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -56,6 +57,7 @@ public class AttachmentApiController {
|
||||
* @throws Exception
|
||||
*/
|
||||
@PostMapping(value = "/api/v1/upload")
|
||||
@ResponseStatus(HttpStatus.CREATED)
|
||||
public AttachmentFileResponseDto upload(@RequestParam("file") MultipartFile file) {
|
||||
return attachmentService.uploadFile(file);
|
||||
}
|
||||
@@ -69,6 +71,7 @@ public class AttachmentApiController {
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(value = "/api/v1/upload/multi")
|
||||
@ResponseStatus(HttpStatus.CREATED)
|
||||
public List<AttachmentFileResponseDto> uploadMulti(@RequestParam("files") List<MultipartFile> files) {
|
||||
return attachmentService.uploadFiles(files);
|
||||
}
|
||||
@@ -81,6 +84,7 @@ public class AttachmentApiController {
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(value = "/api/v1/upload/editor")
|
||||
@ResponseStatus(HttpStatus.CREATED)
|
||||
public AttachmentEditorResponseDto uploadEditor(@RequestBody AttachmentBase64RequestDto editorRequestDto) {
|
||||
return attachmentService.uploadEditor(editorRequestDto);
|
||||
}
|
||||
@@ -210,6 +214,7 @@ public class AttachmentApiController {
|
||||
* @return 새로 생성한 첨부파일 code
|
||||
*/
|
||||
@PostMapping(value = "/api/v1/attachments/file")
|
||||
@ResponseStatus(HttpStatus.CREATED)
|
||||
public String save(@RequestBody List<AttachmentTempSaveRequestDto> saveRequestDtoList) {
|
||||
return attachmentService.save(saveRequestDtoList);
|
||||
}
|
||||
@@ -260,6 +265,7 @@ public class AttachmentApiController {
|
||||
* @param uniqueId
|
||||
*/
|
||||
@DeleteMapping(value = "/api/v1/attachments/{uniqueId}")
|
||||
@ResponseStatus(HttpStatus.NO_CONTENT)
|
||||
public void delete(@PathVariable String uniqueId) {
|
||||
attachmentService.delete(uniqueId);
|
||||
}
|
||||
@@ -273,6 +279,7 @@ public class AttachmentApiController {
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(value = "/api/v1/attachments/upload", consumes = {MediaType.MULTIPART_FORM_DATA_VALUE, MediaType.APPLICATION_JSON_VALUE})
|
||||
@ResponseStatus(HttpStatus.CREATED)
|
||||
public String uploadAndSave(@RequestPart(value = "files", required = true) List<MultipartFile> files,
|
||||
@RequestPart(value = "info", required = false) AttachmentUploadRequestDto uploadRequestDto) {
|
||||
return attachmentService.uploadAndSave(files, uploadRequestDto);
|
||||
@@ -339,6 +346,7 @@ public class AttachmentApiController {
|
||||
* @param attachmentCode
|
||||
*/
|
||||
@DeleteMapping("/api/v1/attachments/{attachmentCode}/children")
|
||||
@ResponseStatus(HttpStatus.NO_CONTENT)
|
||||
public void deleteAllEmptyEntity(@PathVariable String attachmentCode) {
|
||||
attachmentService.deleteAllEmptyEntity(attachmentCode);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.web.PageableDefault;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
@@ -94,6 +95,7 @@ public class BannerApiController {
|
||||
* @return BannerResponseDto 배너 상세 응답 DTO
|
||||
*/
|
||||
@PostMapping("/api/v1/banners")
|
||||
@ResponseStatus(HttpStatus.CREATED)
|
||||
public BannerResponseDto save(@RequestBody @Valid BannerSaveRequestDto requestDto) {
|
||||
return bannerService.save(requestDto);
|
||||
}
|
||||
@@ -128,6 +130,7 @@ public class BannerApiController {
|
||||
* @param bannerNo 배너 번호
|
||||
*/
|
||||
@DeleteMapping("/api/v1/banners/{bannerNo}")
|
||||
@ResponseStatus(HttpStatus.NO_CONTENT)
|
||||
public void delete(@PathVariable Integer bannerNo) {
|
||||
bannerService.delete(bannerNo);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import org.egovframe.cloud.portalservice.domain.code.CodeRepository;
|
||||
import org.egovframe.cloud.portalservice.service.code.CodeService;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
@@ -79,6 +80,7 @@ public class CodeApiController {
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/api/v1/codes")
|
||||
@ResponseStatus(HttpStatus.CREATED)
|
||||
public String save(@RequestBody @Valid CodeSaveRequestDto requestDto) {
|
||||
return codeService.save(requestDto);
|
||||
}
|
||||
@@ -113,6 +115,7 @@ public class CodeApiController {
|
||||
* @param codeId
|
||||
*/
|
||||
@DeleteMapping("/api/v1/codes/{codeId}")
|
||||
@ResponseStatus(HttpStatus.NO_CONTENT)
|
||||
public void delete(@PathVariable String codeId) {
|
||||
codeService.delete(codeId);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import org.egovframe.cloud.portalservice.domain.code.CodeRepository;
|
||||
import org.egovframe.cloud.portalservice.service.code.CodeDetailService;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
@@ -100,6 +101,7 @@ public class CodeDetailApiController {
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/api/v1/code-details")
|
||||
@ResponseStatus(HttpStatus.CREATED)
|
||||
public String save(@RequestBody @Valid CodeDetailSaveRequestDto requestDto) {
|
||||
return codeDetailService.save(requestDto);
|
||||
}
|
||||
@@ -134,6 +136,7 @@ public class CodeDetailApiController {
|
||||
* @param codeId
|
||||
*/
|
||||
@DeleteMapping("/api/v1/code-details/{codeId}")
|
||||
@ResponseStatus(HttpStatus.NO_CONTENT)
|
||||
public void delete(@PathVariable String codeId) {
|
||||
codeDetailService.delete(codeId);
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.web.PageableDefault;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
@@ -72,6 +73,7 @@ public class ContentApiController {
|
||||
* @return ContentResponseDto 컨텐츠 상세 응답 DTO
|
||||
*/
|
||||
@PostMapping("/api/v1/contents")
|
||||
@ResponseStatus(HttpStatus.CREATED)
|
||||
public ContentResponseDto save(@RequestBody @Valid ContentSaveRequestDto requestDto) {
|
||||
return contentService.save(requestDto);
|
||||
}
|
||||
@@ -94,6 +96,7 @@ public class ContentApiController {
|
||||
* @param contentNo 컨텐츠 번호
|
||||
*/
|
||||
@DeleteMapping("/api/v1/contents/{contentNo}")
|
||||
@ResponseStatus(HttpStatus.NO_CONTENT)
|
||||
public void delete(@PathVariable Integer contentNo) {
|
||||
contentService.delete(contentNo);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.egovframe.cloud.portalservice.api.menu.dto.*;
|
||||
import org.egovframe.cloud.portalservice.domain.menu.SiteRepository;
|
||||
import org.egovframe.cloud.portalservice.service.menu.MenuService;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
@@ -75,6 +76,7 @@ public class MenuApiController {
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(value = "/api/v1/menus")
|
||||
@ResponseStatus(HttpStatus.CREATED)
|
||||
public MenuTreeResponseDto save(@RequestBody @Valid MenuTreeRequestDto menuTreeRequestDto) {
|
||||
return menuService.save(menuTreeRequestDto);
|
||||
}
|
||||
@@ -121,6 +123,7 @@ public class MenuApiController {
|
||||
* @param menuId
|
||||
*/
|
||||
@DeleteMapping(value = "/api/v1/menus/{menuId}")
|
||||
@ResponseStatus(HttpStatus.NO_CONTENT)
|
||||
public void delete(@PathVariable Long menuId) {
|
||||
menuService.delete(menuId);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import org.egovframe.cloud.portalservice.api.menu.dto.MenuRoleResponseDto;
|
||||
import org.egovframe.cloud.portalservice.api.menu.dto.MenuSideResponseDto;
|
||||
import org.egovframe.cloud.portalservice.domain.user.User;
|
||||
import org.egovframe.cloud.portalservice.service.menu.MenuRoleService;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
@@ -54,6 +55,7 @@ public class MenuRoleApiController {
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/api/v1/menu-roles")
|
||||
@ResponseStatus(HttpStatus.CREATED)
|
||||
public String save(@RequestBody List<MenuRoleRequestDto> menuRoleRequestDtoList) {
|
||||
return menuRoleService.save(menuRoleRequestDtoList);
|
||||
}
|
||||
|
||||
@@ -48,6 +48,6 @@ public class MenuDnDRequestDto {
|
||||
this.parentId = parentId;
|
||||
this.level = level;
|
||||
this.icon = icon;
|
||||
this.children = new ArrayList<>(children);
|
||||
this.children = children == null ? null : new ArrayList<>(children);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,6 +54,6 @@ public class MenuRoleRequestDto {
|
||||
this.sortSeq = sortSeq;
|
||||
this.icon = icon;
|
||||
this.level = level;
|
||||
this.children = new ArrayList<>(children);
|
||||
this.children = children == null ? null : new ArrayList<>(children);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import org.egovframe.cloud.portalservice.api.policy.dto.PolicyUpdateRequestDto;
|
||||
import org.egovframe.cloud.portalservice.service.policy.PolicyService;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
@@ -76,6 +77,7 @@ public class PolicyApiController {
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/api/v1/policies")
|
||||
@ResponseStatus(HttpStatus.CREATED)
|
||||
public Long save(@RequestBody PolicySaveRequestDto saveRequestDto) {
|
||||
return policyService.save(saveRequestDto);
|
||||
}
|
||||
@@ -110,6 +112,7 @@ public class PolicyApiController {
|
||||
* @param id
|
||||
*/
|
||||
@DeleteMapping("/api/v1/policies/{id}")
|
||||
@ResponseStatus(HttpStatus.NO_CONTENT)
|
||||
public void delete(@PathVariable Long id) {
|
||||
policyService.delete(id);
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.web.PageableDefault;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
@@ -83,6 +84,7 @@ public class PrivacyApiController {
|
||||
* @return PrivacyResponseDto 개인정보처리방침 상세 응답 DTO
|
||||
*/
|
||||
@PostMapping("/api/v1/privacies")
|
||||
@ResponseStatus(HttpStatus.CREATED)
|
||||
public PrivacyResponseDto save(@RequestBody @Valid PrivacySaveRequestDto requestDto) {
|
||||
return privacyService.save(requestDto);
|
||||
}
|
||||
@@ -117,6 +119,7 @@ public class PrivacyApiController {
|
||||
* @param privacyNo 개인정보처리방침 번호
|
||||
*/
|
||||
@DeleteMapping("/api/v1/privacies/{privacyNo}")
|
||||
@ResponseStatus(HttpStatus.NO_CONTENT)
|
||||
public void delete(@PathVariable Integer privacyNo) {
|
||||
privacyService.delete(privacyNo);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import lombok.RequiredArgsConstructor;
|
||||
import org.egovframe.cloud.portalservice.api.statistics.dto.StatisticsResponseDto;
|
||||
import org.egovframe.cloud.portalservice.api.statistics.dto.StatisticsYMRequestDto;
|
||||
import org.egovframe.cloud.portalservice.service.statistics.StatisticsService;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
@@ -59,6 +60,7 @@ public class StatisticsApiController {
|
||||
* @param request
|
||||
*/
|
||||
@PostMapping("/api/v1/statistics/{statisticsId}")
|
||||
@ResponseStatus(HttpStatus.CREATED)
|
||||
public void save(@PathVariable String statisticsId, HttpServletRequest request) {
|
||||
statisticsService.save(request, statisticsId);
|
||||
}
|
||||
|
||||
@@ -187,7 +187,7 @@ class AttachmentApiControllerTest {
|
||||
ResponseEntity<AttachmentEditorResponseDto> responseEntity =
|
||||
restTemplate.postForEntity(url, requestDto, AttachmentEditorResponseDto.class);
|
||||
|
||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.CREATED);
|
||||
assertThat(responseEntity.getBody().getOriginalFileName()).isEqualTo(testFile.getFilename());
|
||||
}
|
||||
|
||||
@@ -209,7 +209,7 @@ class AttachmentApiControllerTest {
|
||||
restTemplate.postForEntity(url, requestEntity, AttachmentFileResponseDto.class);
|
||||
|
||||
//then
|
||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.CREATED);
|
||||
|
||||
}
|
||||
|
||||
@@ -234,7 +234,7 @@ class AttachmentApiControllerTest {
|
||||
new ParameterizedTypeReference<List<AttachmentFileResponseDto>>() {});
|
||||
|
||||
//then
|
||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.CREATED);
|
||||
|
||||
}
|
||||
|
||||
@@ -273,7 +273,7 @@ class AttachmentApiControllerTest {
|
||||
ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, saveRequestDtoList, String.class);
|
||||
|
||||
//then
|
||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -454,7 +454,7 @@ class AttachmentApiControllerTest {
|
||||
ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, requestEntity, String.class);
|
||||
|
||||
//then
|
||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.CREATED);
|
||||
List<Attachment> attachmentList = attachmentRepository.findByCode(responseEntity.getBody());
|
||||
attachmentList.stream().forEach(attachment -> {
|
||||
Path filePath = Paths.get(fileStorageUtils.getFileStorageLocation()+"/" +attachment.getPhysicalFileName())
|
||||
|
||||
@@ -289,7 +289,7 @@ class BannerApiControllerTest {
|
||||
);
|
||||
|
||||
// then
|
||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.CREATED);
|
||||
|
||||
BannerResponseDto dto = responseEntity.getBody();
|
||||
assertThat(dto).isNotNull();
|
||||
@@ -386,7 +386,7 @@ class BannerApiControllerTest {
|
||||
);
|
||||
|
||||
// then
|
||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT);
|
||||
|
||||
Optional<Banner> banner = selectData(bannerNo);
|
||||
assertThat(banner).isNotPresent();
|
||||
|
||||
@@ -128,7 +128,7 @@ class CodeApiControllerTest {
|
||||
ResponseEntity<String> responseEntity = restTemplate.exchange(API_URL, HttpMethod.POST, httpEntity, String.class);
|
||||
|
||||
// then
|
||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -133,7 +133,7 @@ class CodeDetailApiControllerTest {
|
||||
ResponseEntity<String> responseEntity = restTemplate.exchange(API_URL, HttpMethod.POST, httpEntity, String.class);
|
||||
|
||||
// then
|
||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -193,7 +193,7 @@ class ContentApiControllerTest {
|
||||
});
|
||||
|
||||
// then
|
||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.CREATED);
|
||||
|
||||
ContentResponseDto dto = responseEntity.getBody();
|
||||
assertThat(dto).isNotNull();
|
||||
@@ -270,7 +270,7 @@ class ContentApiControllerTest {
|
||||
ContentResponseDto.class);
|
||||
|
||||
// then
|
||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT);
|
||||
|
||||
Optional<Content> content = selectData(contentNo);
|
||||
assertThat(content).isNotPresent();
|
||||
|
||||
@@ -232,7 +232,7 @@ class MenuApiControllerTest {
|
||||
ResponseEntity<MenuTreeResponseDto> responseEntity = restTemplate.postForEntity(url, menuTreeRequestDto, MenuTreeResponseDto.class);
|
||||
|
||||
//then
|
||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.CREATED);
|
||||
System.out.println(responseEntity.getBody());
|
||||
assertThat(responseEntity.getBody()).extracting("name").isEqualTo(menuTreeRequestDto.getName());
|
||||
|
||||
|
||||
@@ -189,7 +189,7 @@ class MenuRoleApiControllerTest {
|
||||
restTemplate.exchange("/api/v1/menu-roles", HttpMethod.POST, httpEntity, String.class);
|
||||
|
||||
//then
|
||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.CREATED);
|
||||
assertThat(responseEntity.getBody()).isEqualTo("Success");
|
||||
|
||||
List<MenuRole> roles = menuRoleRepository.findAll();
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.egovframe.cloud.portalservice.api.message;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import java.util.Map;
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.egovframe.cloud.portalservice.api.message.dto.MessageListResponseDto;
|
||||
import org.egovframe.cloud.portalservice.domain.message.Message;
|
||||
@@ -52,10 +53,14 @@ class MessageApiControllerTest {
|
||||
String lang = "ko";
|
||||
|
||||
// when
|
||||
ResponseEntity<List<MessageListResponseDto>> responseEntity = restTemplate.exchange(API_URL + lang, HttpMethod.GET, null, new ParameterizedTypeReference<List<MessageListResponseDto>>(){});
|
||||
ResponseEntity<Map<String, String>> responseEntity =
|
||||
restTemplate.exchange(API_URL + lang, HttpMethod.GET, null, new ParameterizedTypeReference<Map<String, String>>(){});
|
||||
|
||||
// then
|
||||
responseEntity.getBody().forEach(messageListResponseDto -> System.out.println("id = " + messageListResponseDto.getMessageId() + ", messageName() = " + messageListResponseDto.getMessageName()));
|
||||
Map<String, String> body = responseEntity.getBody();
|
||||
body.entrySet().stream().forEach(entry -> {
|
||||
System.out.println("id = " + entry.getKey() + ", messageName() = " + entry.getValue());
|
||||
});
|
||||
Assertions.assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
Assertions.assertThat(responseEntity.getBody().size()).isEqualTo(3);
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ class PolicyApiControllerTest {
|
||||
ResponseEntity<Long> responseEntity = restTemplate.postForEntity(API_URL, requestDto, Long.class);
|
||||
|
||||
//then
|
||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.CREATED);
|
||||
Optional<Policy> policy = policyRepository.findById(responseEntity.getBody().longValue());
|
||||
|
||||
System.out.println(policy.get().toString());
|
||||
|
||||
@@ -232,7 +232,7 @@ class PrivacyApiControllerTest {
|
||||
);
|
||||
|
||||
// then
|
||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.CREATED);
|
||||
|
||||
PrivacyResponseDto dto = responseEntity.getBody();
|
||||
assertThat(dto).isNotNull();
|
||||
@@ -354,7 +354,7 @@ class PrivacyApiControllerTest {
|
||||
);
|
||||
|
||||
// then
|
||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT);
|
||||
|
||||
Optional<Privacy> privacy = selectData(privacyNo);
|
||||
assertThat(privacy).isNotPresent();
|
||||
|
||||
@@ -12,6 +12,7 @@ import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.web.PageableDefault;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
@@ -115,6 +116,7 @@ public class AuthorizationApiController {
|
||||
* @return AuthorizationResponseDto 인가 상세 응답 DTO
|
||||
*/
|
||||
@PostMapping("/api/v1/authorizations")
|
||||
@ResponseStatus(HttpStatus.CREATED)
|
||||
public AuthorizationResponseDto save(@RequestBody @Valid AuthorizationSaveRequestDto requestDto) {
|
||||
return authorizationService.save(requestDto);
|
||||
}
|
||||
@@ -137,6 +139,7 @@ public class AuthorizationApiController {
|
||||
* @param authorizationNo 인가 번호
|
||||
*/
|
||||
@DeleteMapping("/api/v1/authorizations/{authorizationNo}")
|
||||
@ResponseStatus(HttpStatus.NO_CONTENT)
|
||||
public void delete(@PathVariable Integer authorizationNo) {
|
||||
authorizationService.delete(authorizationNo);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import org.egovframe.cloud.userservice.api.role.dto.RoleAuthorizationSaveRequest
|
||||
import org.egovframe.cloud.userservice.service.role.RoleAuthorizationService;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
@@ -59,6 +60,7 @@ public class RoleAuthorizationApiController {
|
||||
* @return List<RoleAuthorizationListResponseDto> 등록한 권한 인가 목록 응답 DTO
|
||||
*/
|
||||
@PostMapping("/api/v1/role-authorizations")
|
||||
@ResponseStatus(HttpStatus.CREATED)
|
||||
public List<RoleAuthorizationListResponseDto> save(@RequestBody @Valid List<RoleAuthorizationSaveRequestDto> requestDtoList) {
|
||||
return roleAuthorizationService.save(requestDtoList);
|
||||
}
|
||||
@@ -69,6 +71,7 @@ public class RoleAuthorizationApiController {
|
||||
* @param requestDtoList 권한 인가 삭제 요청 DTO List
|
||||
*/
|
||||
@PutMapping("/api/v1/role-authorizations")
|
||||
@ResponseStatus(HttpStatus.NO_CONTENT)
|
||||
public void delete(@RequestBody @Valid List<RoleAuthorizationDeleteRequestDto> requestDtoList) {
|
||||
roleAuthorizationService.delete(requestDtoList);
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import org.springframework.core.env.Environment;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@@ -72,6 +73,7 @@ public class UserApiController {
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/api/v1/users")
|
||||
@ResponseStatus(HttpStatus.CREATED)
|
||||
public Long save(@RequestBody @Valid UserSaveRequestDto requestDto) {
|
||||
return userService.save(requestDto);
|
||||
}
|
||||
@@ -153,6 +155,7 @@ public class UserApiController {
|
||||
* @return Boolean 성공 여부
|
||||
*/
|
||||
@PostMapping("/api/v1/users/join")
|
||||
@ResponseStatus(HttpStatus.CREATED)
|
||||
public Boolean join(@RequestBody @Valid UserJoinRequestDto requestDto) {
|
||||
return userService.join(requestDto);
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ public class Authorization extends BaseEntity {
|
||||
this.urlPatternValue = urlPatternValue;
|
||||
this.httpMethodCode = httpMethodCode;
|
||||
this.sortSeq = sortSeq;
|
||||
this.roleAuthorizations = new ArrayList<>(roleAuthorizations);
|
||||
this.roleAuthorizations = roleAuthorizations == null ? null : new ArrayList<>(roleAuthorizations);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -245,7 +245,7 @@ class AuthorizationApiControllerTest {
|
||||
// then
|
||||
resultActions
|
||||
.andDo(MockMvcResultHandlers.print())
|
||||
.andExpect(MockMvcResultMatchers.status().isOk());
|
||||
.andExpect(MockMvcResultMatchers.status().isCreated());
|
||||
|
||||
String responseData = resultActions.andReturn().getResponse().getContentAsString();
|
||||
JSONObject jsonObject = new JSONObject(responseData);
|
||||
@@ -333,7 +333,7 @@ class AuthorizationApiControllerTest {
|
||||
// then
|
||||
resultActions
|
||||
.andDo(MockMvcResultHandlers.print())
|
||||
.andExpect(MockMvcResultMatchers.status().isOk());
|
||||
.andExpect(MockMvcResultMatchers.status().isNoContent());
|
||||
|
||||
Optional<Authorization> authorization = selectData(authorizationNo);
|
||||
assertThat(authorization).isNotPresent();
|
||||
|
||||
@@ -228,7 +228,7 @@ class RoleAuthorizationApiControllerTest {
|
||||
// then
|
||||
resultActions
|
||||
.andDo(MockMvcResultHandlers.print())
|
||||
.andExpect(MockMvcResultMatchers.status().isOk());
|
||||
.andExpect(MockMvcResultMatchers.status().isCreated());
|
||||
|
||||
String responseData = resultActions.andReturn().getResponse().getContentAsString();
|
||||
JSONArray jsonArray = new JSONArray(responseData);
|
||||
@@ -282,7 +282,7 @@ class RoleAuthorizationApiControllerTest {
|
||||
// then
|
||||
resultActions
|
||||
.andDo(MockMvcResultHandlers.print())
|
||||
.andExpect(MockMvcResultMatchers.status().isOk());
|
||||
.andExpect(MockMvcResultMatchers.status().isNoContent());
|
||||
|
||||
List<RoleAuthorization> entityList = roleAuthorizationRepository.findAll(Sort.by(Sort.Direction.ASC, "roleAuthorizationId.authorizationNo"));
|
||||
for (int i = entityList.size() - 1; i >= 0; i--) {
|
||||
|
||||
@@ -324,7 +324,7 @@ class UserApiControllerTest {
|
||||
// then
|
||||
resultActions
|
||||
.andDo(MockMvcResultHandlers.print())
|
||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||
.andExpect(MockMvcResultMatchers.status().isCreated())
|
||||
.andExpect(MockMvcResultMatchers.content().string("true"));
|
||||
|
||||
// userRepository.findByEmail("test_join" + TEST_COM).ifPresent(u -> deleteUser(u.getId()));
|
||||
|
||||
Reference in New Issue
Block a user