Skip to content

Commit

Permalink
Update: Controller 및 dto naming convention 정리
Browse files Browse the repository at this point in the history
  • Loading branch information
BYEONGRYEOL committed Jun 1, 2024
1 parent 06dcbe0 commit 92fec02
Show file tree
Hide file tree
Showing 75 changed files with 418 additions and 515 deletions.
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ dependencies {
testImplementation 'org.springframework.security:spring-security-test'
testRuntimeOnly 'com.h2database:h2:1.4.200'

// swagger
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.0.2'

}

test {
Expand Down
43 changes: 0 additions & 43 deletions src/main/java/com/gt/genti/adapter/in/web/SSEController.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
package com.gt.genti.adapter.in.web;
package com.gt.genti.adapter.in.web.admin;

import static com.gt.genti.other.util.ApiUtils.*;

import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.http.ResponseEntity;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.gt.genti.application.service.PictureGenerateRequestService;
import com.gt.genti.dto.PictureGenerateRequestDetailResponseDto;
import com.gt.genti.dto.PGREQDetailFindResponseDto;

import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotNull;
Expand All @@ -25,11 +22,11 @@
@RestController
@RequestMapping("/api/admin/picture-generate-requests")
@RequiredArgsConstructor
public class AdminPictureGenerateRequestController {
public class AdminPGREQController {
private final PictureGenerateRequestService pictureGenerateRequestService;

@GetMapping("/all")
public ResponseEntity<ApiResult<Page<PictureGenerateRequestDetailResponseDto>>> getAllPictureGenerateRequest(
public ResponseEntity<ApiResult<Page<PGREQDetailFindResponseDto>>> getAllPictureGenerateRequest(
@RequestParam @NotNull int page,
@RequestParam @NotNull @Min(1) int size,
@RequestParam(defaultValue = "id") String sortBy,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,42 +1,40 @@
package com.gt.genti.adapter.in.web;
package com.gt.genti.adapter.in.web.admin;

import static com.gt.genti.other.util.ApiUtils.*;

import java.util.List;

import org.springframework.http.ResponseEntity;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.gt.genti.application.service.PictureGenerateWorkService;
import com.gt.genti.dto.PictureGenerateRequestDetailResponseDto;
import com.gt.genti.dto.PictureGenerateResponseAdminSubmitDto;
import com.gt.genti.dto.UpdatePictureUrlRequestDto;
import com.gt.genti.dto.PGRESUpdateByAdminResponseDto;
import com.gt.genti.dto.PictureUrlUpdateRequestDto;
import com.gt.genti.other.auth.UserDetailsImpl;

import lombok.RequiredArgsConstructor;

@RestController
@RequestMapping("/api/admin/picture-generate-responses")
@RequiredArgsConstructor
public class AdminPictureGenerateWorkController {
public class AdminPGRESController {
private final PictureGenerateWorkService pictureGenerateWorkService;

@PostMapping("/{pictureGenerateResponseId}/submit")
public ResponseEntity<ApiResult<PictureGenerateResponseAdminSubmitDto>> submit(
public ResponseEntity<ApiResult<PGRESUpdateByAdminResponseDto>> submit(
@PathVariable Long pictureGenerateResponseId) {
return success(pictureGenerateWorkService.submitFinal(pictureGenerateResponseId));
}

@PostMapping("/{pictureGenerateResponseId}/pictures")
public ResponseEntity<ApiResult<Boolean>> updatePictureList(
@AuthenticationPrincipal UserDetailsImpl userDetails,
@RequestBody List<UpdatePictureUrlRequestDto> reuqestDtoList,
@RequestBody List<PictureUrlUpdateRequestDto> reuqestDtoList,
@PathVariable Long pictureGenerateResponseId) {
return success(pictureGenerateWorkService.updatePictureListCreatedByAdmin(userDetails.getId(), reuqestDtoList,
pictureGenerateResponseId));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
package com.gt.genti.adapter.in.web;
package com.gt.genti.adapter.in.web.admin;

import static com.gt.genti.other.util.ApiUtils.*;

import java.util.List;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.gt.genti.application.service.ReportService;
import com.gt.genti.dto.ReportResponseDto;
import com.gt.genti.dto.ReportUpdateDto;
import com.gt.genti.other.util.ApiUtils;
import com.gt.genti.dto.ReportFindResponseDto;
import com.gt.genti.dto.ReportUpdateRequestDto;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

@RestController
Expand All @@ -26,13 +23,13 @@
public class AdminReportController {
private final ReportService reportService;
@GetMapping("")
public ResponseEntity<ApiResult<List<ReportResponseDto>>> getAllReports(){
public ResponseEntity<ApiResult<List<ReportFindResponseDto>>> getAllReports(){
return success(reportService.getAllReports());
}

@PostMapping("")
public ResponseEntity<ApiResult<Boolean>> updateReport(@RequestBody ReportUpdateDto reportUpdateDto){
return success(reportService.updateReport(reportUpdateDto));
public ResponseEntity<ApiResult<Boolean>> updateReport(@RequestBody ReportUpdateRequestDto reportUpdateRequestDto){
return success(reportService.updateReport(reportUpdateRequestDto));
}

}
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package com.gt.genti.adapter.in.web;
package com.gt.genti.adapter.in.web.admin;

import static com.gt.genti.other.util.ApiUtils.*;

import java.util.List;
import java.util.Objects;

import org.springframework.data.domain.Page;
Expand All @@ -18,13 +17,12 @@
import com.gt.genti.application.service.UserService;
import com.gt.genti.domain.enums.UserRole;
import com.gt.genti.domain.enums.converter.EnumUtil;
import com.gt.genti.dto.ChangeUserRoleDto;
import com.gt.genti.dto.ChangeUserStatusDto;
import com.gt.genti.dto.UserInfoResponseDtoForAdmin;
import com.gt.genti.dto.UserRoleUpdateRequestDto;
import com.gt.genti.dto.UserStatusUpdateRequestDto;
import com.gt.genti.dto.UserFindByAdminResponseDto;

import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotNull;
import jakarta.websocket.server.PathParam;
import lombok.RequiredArgsConstructor;

@RestController
Expand All @@ -35,26 +33,26 @@ public class AdminUserController {

@PostMapping("/users/{userId}/status")
public ResponseEntity<ApiResult<Boolean>> changeUserStatus(@PathVariable Long userId,
@RequestBody ChangeUserStatusDto changeUserStatusDto) {
return success(userService.updateUserStatus(userId, changeUserStatusDto));
@RequestBody UserStatusUpdateRequestDto userStatusUpdateRequestDto) {
return success(userService.updateUserStatus(userId, userStatusUpdateRequestDto));
}

@PostMapping("/users/{userId}/role")
public ResponseEntity<ApiResult<Boolean>> changeUserRole(@PathVariable Long userId,
@RequestBody ChangeUserRoleDto changeUserRoleDto) {
return success(userService.updateUserRole(userId, changeUserRoleDto));
@RequestBody UserRoleUpdateRequestDto userRoleUpdateRequestDto) {
return success(userService.updateUserRole(userId, userRoleUpdateRequestDto));
}

@GetMapping("/users")
public ResponseEntity<ApiResult<Page<UserInfoResponseDtoForAdmin>>> getAllUserInfo(
public ResponseEntity<ApiResult<Page<UserFindByAdminResponseDto>>> getAllUserInfo(
@RequestParam(value = "role", defaultValue = "ALL") @NotNull String role,
@RequestParam(value = "page", defaultValue = "0") @NotNull int page,
@RequestParam(value = "size", defaultValue = "10") @NotNull @Min(1) int size
) {
//TODO Role에 따라 분기
// edited at 2024-05-24
// author 서병렬
Page<UserInfoResponseDtoForAdmin> result;
Page<UserFindByAdminResponseDto> result;
if (Objects.equals(role, "ALL")) {
result = userService.getAllUserInfo(page,size);
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.gt.genti.adapter.in.web;
package com.gt.genti.adapter.in.web.admin;

import static com.gt.genti.other.util.ApiUtils.*;

Expand All @@ -12,10 +12,10 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.gt.genti.dto.AddPromptOnlyExampleRequestDto;
import com.gt.genti.dto.AddResponseExampleRequestDto;
import com.gt.genti.dto.PromptOnlyExampleResponseDto;
import com.gt.genti.dto.ResponseExampleResponseDto;
import com.gt.genti.dto.PromptOnlyExampleSaveRequestDto;
import com.gt.genti.dto.ExampleSaveRequestDto;
import com.gt.genti.dto.PromptOnlyExampleFindResponseDto;
import com.gt.genti.dto.ExampleWithPictureFindResponseDto;
import com.gt.genti.other.auth.UserDetailsImpl;
import com.gt.genti.service.ResponseExampleService;

Expand All @@ -24,22 +24,22 @@
@RestController
@RequestMapping("/api/admin/examples")
@RequiredArgsConstructor
public class AdminExampleController {
public class ExampleController {
private final ResponseExampleService responseExampleService;

@GetMapping("/with-picture")
public ResponseEntity<ApiResult<List<ResponseExampleResponseDto>>> getAllResponseExamples() {
public ResponseEntity<ApiResult<List<ExampleWithPictureFindResponseDto>>> getAllResponseExamples() {
return success(responseExampleService.getAllResponseExamples());
}

@GetMapping("/prompt-only")
public ResponseEntity<ApiResult<List<PromptOnlyExampleResponseDto>>> getAllPromptOnlyExamples() {
public ResponseEntity<ApiResult<List<PromptOnlyExampleFindResponseDto>>> getAllPromptOnlyExamples() {
return success(responseExampleService.getAllPromptOnlyExamples());
}

@PostMapping("/with-picture")
public ResponseEntity<ApiResult<Boolean>> addResponseExample(
@RequestBody List<AddResponseExampleRequestDto> requestDtoList,
@RequestBody List<ExampleSaveRequestDto> requestDtoList,
@AuthenticationPrincipal UserDetailsImpl userDetails
) {
responseExampleService.addResponseExamples(requestDtoList, userDetails.getId());
Expand All @@ -48,7 +48,7 @@ public ResponseEntity<ApiResult<Boolean>> addResponseExample(

@PostMapping("/prompt-only")
public ResponseEntity<ApiResult<Boolean>> addPromptOnlyExample(
@RequestBody List<AddPromptOnlyExampleRequestDto> requestDtoList,
@RequestBody List<PromptOnlyExampleSaveRequestDto> requestDtoList,
@AuthenticationPrincipal UserDetailsImpl userDetails
) {
responseExampleService.addPromptOnlyExamples(requestDtoList, userDetails.getId());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.gt.genti.adapter.in.web;
package com.gt.genti.adapter.in.web.common;

import static com.gt.genti.other.util.ApiUtils.*;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.gt.genti.adapter.in.web;
package com.gt.genti.adapter.in.web.common;

import static com.gt.genti.other.util.ApiUtils.*;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
package com.gt.genti.adapter.in.web;
package com.gt.genti.adapter.in.web.creator;

import static com.gt.genti.other.util.ApiUtils.*;

import org.springframework.http.ResponseEntity;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.gt.genti.dto.CreatorInfoResponseDto;
import com.gt.genti.dto.UpdateAccountInfoRequestDto;
import com.gt.genti.dto.UpdateCreatorStatusRequestDto;
import com.gt.genti.dto.UpdateCreatorStatusResponseDto;
import com.gt.genti.dto.UserInfoResponseDto;
import com.gt.genti.other.annotation.ToBeUpdated;
import com.gt.genti.other.aop.annotation.CheckUserIsQuit;
import com.gt.genti.dto.CreatorFindResponseDto;
import com.gt.genti.dto.AccountUpdateRequestDto;
import com.gt.genti.dto.CreatorStatusUpdateRequestDto;
import com.gt.genti.dto.CreatorStatusUpdateResponseDto;
import com.gt.genti.other.auth.UserDetailsImpl;
import com.gt.genti.service.CreatorService;

Expand All @@ -30,22 +26,22 @@ public class CreatorController {
private final CreatorService creatorService;

@GetMapping("")
public ResponseEntity<ApiResult<CreatorInfoResponseDto>> getCreatorInfo(
public ResponseEntity<ApiResult<CreatorFindResponseDto>> getCreatorInfo(
@AuthenticationPrincipal UserDetailsImpl userDetails) {
return success(creatorService.getCreatorInfo(userDetails.getId()));
}

@PostMapping("/account")
public ResponseEntity<ApiResult<Boolean>> updateAccountInfo(
@AuthenticationPrincipal UserDetailsImpl userDetails,
@RequestBody UpdateAccountInfoRequestDto updateAccountInfoRequestDto) {
return success(creatorService.updateAccountInfo(userDetails.getId(), updateAccountInfoRequestDto));
@RequestBody AccountUpdateRequestDto accountUpdateRequestDto) {
return success(creatorService.updateAccountInfo(userDetails.getId(), accountUpdateRequestDto));
}
@PostMapping("/status")
public ResponseEntity<ApiResult<UpdateCreatorStatusResponseDto>> updateCreatorStatus(
public ResponseEntity<ApiResult<CreatorStatusUpdateResponseDto>> updateCreatorStatus(
@AuthenticationPrincipal UserDetailsImpl userDetails,
@RequestBody UpdateCreatorStatusRequestDto updateCreatorStatusRequestDto) {
return success(creatorService.updateCreatorStatus(userDetails.getId(), updateCreatorStatusRequestDto));
@RequestBody CreatorStatusUpdateRequestDto creatorStatusUpdateRequestDto) {
return success(creatorService.updateCreatorStatus(userDetails.getId(), creatorStatusUpdateRequestDto));
}


Expand Down
Loading

0 comments on commit 92fec02

Please sign in to comment.