Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pet 151 refactor : Todo, Register, TodoTeam, Category API Url 수정 #93

Merged
merged 5 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,103 +1,112 @@
[[Todo-API]]
== Todo API
[[Todo-Team-API]]
== Todo Team API

[[Todo-API-가입된-Todo-Team-목록]]
=== 가입된 Todo Team 목록
[[가입된-Todo-Team-조회-마이페이지]]
=== 가입된 Todo Team 조회 (마이페이지용)

operation::todo-team-controller-test/get-todo-teams[snippets='http-request,request-parameters,request-headers,http-response,response-fields']

[[Todo-API-Todo-Team에-가입된-사용자-조회]]
=== Todo Team에 가입된 사용자 조회 (todo 생성할 때 사용)

operation::register-controller-test/get-registers[snippets='http-request,request-parameters,request-headers,http-response,response-fields']

[[Todo-API-Todo-Team에-가입된-사용자-조회]]
=== Todo Team에 가입된 사용자 조회 (관리자 페이지에서 회원 정보 조회할 때 사용)

operation::register-controller-test/get-manage-registers[snippets='http-request,request-parameters,request-headers,http-response,response-fields']

[[Todo-API-Todo-Team에-가입된-사용자-권한-수정]]
=== Todo Team에 가입된 사용자 권한 수정

operation::register-controller-test/put-authority[snippets='http-request,path-parameters,request-headers,request-fields,http-response']


[[Todo-API-Todo-Team-탈퇴]]
=== Todo Team 탈퇴
[[가입된-Todo-Team-조회-메인페이지-todo페이지]]
=== 가입된 Todo Team 조회 (메인페이지, todo페이지에서 페밀리 선택 버튼)

operation::register-controller-test/unregister-todo-team[snippets='http-request,path-parameters,request-headers,http-response']
operation::todo-team-controller-test/get-todo-team-name[snippets='http-request,request-headers,http-response,response-fields']

[[Todo-API-Todo-Team-가입]]
[[Todo-Team-가입]]
=== Todo Team 가입

operation::register-controller-test/post-register[snippets='http-request,request-parameters,request-headers,http-response']

[[Todo-API-Todo-Team-생성]]
[[Todo-Team-생성]]
=== Todo Team 생성

operation::todo-team-controller-test/post-todo-team[snippets='http-request,request-part-todoTeamCreateInfo-fields,request-headers,http-response']

[[Todo-API-Todo-Team-Code-생성]]
[[Todo-Team-Code-생성]]
=== Todo Team Code 생성

operation::todo-team-controller-test/get-todo-team-random-code[snippets='http-request,request-headers,http-response,response-fields']

[[Todo-API-Todo-Team-Code-조회]]
[[Todo-Team-Id로-Code-조회]]
=== Todo Team Id로 Todo Team Code 조회

operation::todo-team-controller-test/get-todo-team-code[snippets='http-request,path-parameters,request-headers,http-response,response-fields']

[[Todo-API-Todo-Team-Code-조회]]
[[Todo-Team-Code로-조회]]
=== Todo Team Code로 Todo Team 조회

operation::todo-team-controller-test/get-todo-team-by-code[snippets='http-request,request-parameters,request-headers,http-response,response-fields']

[[Todo-API-가장-최근에-가입한-Todo-Team-조회]]
=== 가장 최근에 가입한 TodoTeam 조회

operation::todo-team-controller-test/get-todo-team-name[snippets='http-request,request-headers,http-response,response-fields']
[[Todo-API]]
== Todo API

[[Todo-API-할당-받은-Todo-조회]]
=== 할당받은 Todo 조회
[[할당-받은-Todo-조회-메인페이지-조회용]]
=== 할당받은 Todo 조회 (메인페이지 조회용)

operation::todo-controller-test/get-todos[snippets='http-request,path-parameters,request-parameters,request-headers,http-response,response-fields']

[[Todo-API-Todo-달성률]]
[[카테고리-하위-Todo-조회]]
=== 카테고리 하위 Todo 조회

operation::todo-controller-test/get-todo-list[snippets='http-request,path-parameters,request-headers,request-parameters,http-response,response-fields']

[[Todo-달성률]]
=== Todo 달성률 조회

operation::todo-controller-test/get-todo-progress[snippets='http-request,path-parameters,request-headers,http-response,response-fields']

[[Todo-API-투두-주차-달성률-비교-조회]]
=== Todo 주차 달성률 비교

operation::todo-controller-test/get-week-progress-compare[snippets='http-request,path-parameters,request-headers,http-response,response-fields']

[[Todo-API-투두생성]]
=== Todo 생성

operation::todo-controller-test/post-todo[snippets='http-request,request-fields,request-headers,http-response']

[[Todo-API-투두-리스트-조회]]
=== Todo 카테고리 리스트 조회
[[Todo-날짜-변경]]
=== Todo 날짜 변경

operation::todo-controller-test/change-scheduled-date[snippets='http-request,path-parameters,request-headers,request-fields,http-response']

[[Todo-이름-변경]]
=== Todo 이름 변경

operation::todo-controller-test/change-todo-name[snippets='http-request,path-parameters,request-headers,request-fields,http-response']


[[Category-API]]
== Category API

[[todo-team-id로-카테고리-조회]]
=== Todo Team Id로 카테고리 조회

operation::category-controller-test/get-category-list[snippets='http-request,path-parameters,request-headers,http-response,response-fields']

[[Todo-API-투두-리스트-조회]]
=== Todo 투두 리스트 조회
[[Register-API]]
== Register API

operation::todo-controller-test/get-todo-list[snippets='http-request,path-parameters,request-headers,request-parameters,http-response,response-fields']
[[Todo-Team에-가입된-사용자-조회]]
=== Todo Team에 가입된 사용자 조회 (todo 생성할 때 사용)

[[Todo-API-투두-주차-달성률-비교-조회]]
=== Todo 주차 달성률 비교
operation::register-controller-test/get-registers[snippets='http-request,path-parameters,request-headers,http-response,response-fields']

operation::todo-controller-test/get-week-progress-compare[snippets='http-request,path-parameters,request-headers,http-response,response-fields']
[[Todo-Team에-가입된-사용자-조회]]
=== Todo Team에 가입된 사용자 조회 (관리자 페이지에서 회원 정보 조회할 때 사용)

[[Todo-API-투두-팀-가입-기간-조회]]
=== Todo 팀 가입 기간 조회
operation::register-controller-test/get-manage-registers[snippets='http-request,path-parameters,request-headers,http-response,response-fields']

operation::todo-controller-test/get-register-term[snippets='http-request,path-parameters,request-headers,http-response,response-fields']
[[Todo-API-Todo-Team에-가입된-사용자-권한-수정]]
=== Todo Team에 가입된 사용자 권한 수정

[[Todo-API-투두-날짜-변경]]
=== Todo 날짜 변경
operation::register-controller-test/put-authority[snippets='http-request,path-parameters,request-headers,request-fields,http-response']

operation::todo-controller-test/change-scheduled-date[snippets='http-request,path-parameters,request-headers,request-fields,http-response']
[[Todo-Team-탈퇴]]
=== Todo Team 탈퇴

[[Todo-API-투두-이름-변경]]
=== Todo 이름 변경
operation::register-controller-test/unregister-todo-team[snippets='http-request,path-parameters,request-headers,http-response']

[[Todo-팀-가입-기간-조회]]
=== Todo 팀 가입 기간 조회

operation::todo-controller-test/change-todo-name[snippets='http-request,path-parameters,request-headers,request-fields,http-response']
operation::register-controller-test/get-register-term[snippets='http-request,path-parameters,request-headers,http-response,response-fields']
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,18 @@
import com.pawith.todoapplication.dto.response.CategoryListResponse;
import com.pawith.todoapplication.service.CategoryGetUseCase;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
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.RestController;

@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/category")
public class CategoryController {

private final CategoryGetUseCase categoryGetUseCase;

@GetMapping("/{teamId}")
public CategoryListResponse getCategoryList(@PathVariable Long teamId){
return categoryGetUseCase.getCategoryList(teamId);
@GetMapping("/teams/{todoTeamId}/category")
public CategoryListResponse getCategoryList(@PathVariable Long todoTeamId){
return categoryGetUseCase.getCategoryList(todoTeamId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.pawith.todoapplication.dto.request.AuthorityChangeRequest;
import com.pawith.todoapplication.dto.response.ManageRegisterListResponse;
import com.pawith.todoapplication.dto.response.RegisterListResponse;
import com.pawith.todoapplication.dto.response.RegisterTermResponse;
import com.pawith.todoapplication.service.ChangeRegisterUseCase;
import com.pawith.todoapplication.service.RegistersGetUseCase;
import com.pawith.todoapplication.service.TodoTeamRegisterUseCase;
Expand All @@ -12,36 +13,43 @@

@RestController
@RequiredArgsConstructor
@RequestMapping("/registers")
@RequestMapping("/teams")
public class RegisterController {

private final UnregisterUseCase unregisterUseCase;
private final TodoTeamRegisterUseCase todoTeamRegisterUseCase;
private final RegistersGetUseCase registersGetUseCase;
private final ChangeRegisterUseCase changeRegisterUseCase;

@DeleteMapping("/{todoTeamId}")
@DeleteMapping("/{todoTeamId}/registers")
public void deleteRegister(@PathVariable Long todoTeamId) {
unregisterUseCase.unregisterTodoTeam(todoTeamId);
}

@PostMapping
@PostMapping("/registers")
public void postRegister(@RequestParam String todoTeamCode) {
todoTeamRegisterUseCase.registerTodoTeam(todoTeamCode);
}

@GetMapping("/{todoTeamId}")
@GetMapping("/{todoTeamId}/registers")
public RegisterListResponse getRegisters(@PathVariable Long todoTeamId){
return registersGetUseCase.getRegisters(todoTeamId);
}

@GetMapping("/{todoTeamId}/manage")
@GetMapping("/{todoTeamId}/registers/manage")
public ManageRegisterListResponse getRegistersForManage(@PathVariable Long todoTeamId){
return registersGetUseCase.getManageRegisters(todoTeamId);
}

@PutMapping("/{registerId}")
@GetMapping("/{todoTeamId}/registers/term")
public RegisterTermResponse getTodoRegisterTerm(@PathVariable Long todoTeamId){
return registersGetUseCase.getRegisterTerm(todoTeamId);
}

@PutMapping("/registers/{registerId}")
public void putAuthority(@PathVariable Long registerId, @RequestBody AuthorityChangeRequest authorityChangeRequest) {
changeRegisterUseCase.changeAuthority(registerId, authorityChangeRequest);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -13,65 +13,50 @@
import org.springframework.web.bind.annotation.*;

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

@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/todo")
@RequestMapping("/teams")
public class TodoController {
private final TodoGetUseCase todoGetUseCase;
private final TodoRateGetUseCase todoRateGetUseCase;
private final TodoCreateUseCase todoCreateUseCase;
private final RegistersGetUseCase registersGetUseCase;
private final TodoChangeUseCase todoChangeUseCase;

/**
* 리팩터링 전 : 동시 100명 요청 평균 426ms
* <br>리팩터링 후 : 동시 100명 요청 평균 67ms(535% 개선)
*/
@GetMapping("/progress/{teamId}")
public TodoProgressResponse getTodoProgress(@PathVariable Long teamId) {
return todoRateGetUseCase.getTodoProgress(teamId);
@GetMapping("/{todoTeamId}/todos/progress")
public TodoProgressResponse getTodoProgress(@PathVariable Long todoTeamId) {
return todoRateGetUseCase.getTodoProgress(todoTeamId);
}

/**
* 리팩터링 전 , 100명 동시 요청 테스트 평균 : 915ms
* <br>리팩터링 후 , 100명 동시 요청 테스트 평균 : 85ms(914% 성능개선)
*/
@GetMapping("/list/{teamId}")
public SliceResponse<TodoHomeResponse> getTodos(@PathVariable Long teamId, Pageable pageable) {
return todoGetUseCase.getTodoListByTodoTeamId(teamId, pageable);
@GetMapping("/{todoTeamId}/todos")
public SliceResponse<TodoHomeResponse> getTodos(@PathVariable Long todoTeamId, Pageable pageable) {
return todoGetUseCase.getTodoListByTodoTeamId(todoTeamId, pageable);
}

@PostMapping
@PostMapping("/todos")
public void postTodo(@RequestBody TodoCreateRequest todoCreateRequest){
todoCreateUseCase.createTodo(todoCreateRequest);
}


@GetMapping("/{categoryId}")
public TodoListResponse getTodoList(@PathVariable Long categoryId, @RequestParam("moveDate") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate moveDate){
@GetMapping("/category/{categoryId}/todos")
public TodoListResponse getTodosAboutCategorySubTodo(@PathVariable Long categoryId, @RequestParam("moveDate") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate moveDate){
return todoGetUseCase.getTodoListByCategoryId(categoryId, moveDate);
}

@GetMapping("/compare/{teamId}")
public TodoRateCompareResponse getWeekProgressCompare(@PathVariable Long teamId){
return todoRateGetUseCase.getWeekProgressCompare(teamId);
@GetMapping("/{todoTeamId}/todos/progress/compare")
public TodoRateCompareResponse getTodoWeekProgressCompare(@PathVariable Long todoTeamId){
return todoRateGetUseCase.getWeekProgressCompare(todoTeamId);
}

@GetMapping("/register/{teamId}")
public RegisterTermResponse getRegisterTerm(@PathVariable Long teamId){
return registersGetUseCase.getRegisterTerm(teamId);
}

@PutMapping("/change/date/{todoId}")
public void putScheduledDate(@PathVariable Long todoId, @RequestBody ScheduledDateChangeRequest scheduledDateChangeRequest){
@PutMapping("/todos/{todoId}/date")
public void putTodoScheduledDate(@PathVariable Long todoId, @RequestBody ScheduledDateChangeRequest scheduledDateChangeRequest){
todoChangeUseCase.changeScheduledDate(todoId, scheduledDateChangeRequest);
}

@PutMapping("/change/description/{todoId}")
public void putTodoName(@PathVariable Long todoId, @RequestBody TodoDescriptionChangeRequest todoDescriptionChangeRequest){
@PutMapping("/todos/{todoId}/description")
public void putTodoDescription(@PathVariable Long todoId, @RequestBody TodoDescriptionChangeRequest todoDescriptionChangeRequest){
todoChangeUseCase.changeTodoName(todoId, todoDescriptionChangeRequest);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/todo/team")
@RequestMapping("/teams")
public class TodoTeamController {
private final TodoTeamGetUseCase todoTeamGetUseCase;
private final TodoTeamRandomCodeGetUseCase todoTeamRandomCodeGetUseCase;
Expand All @@ -33,43 +33,35 @@ public class TodoTeamController {
* 리팩터링 전 : 100명 동시 요청 평균 202ms
* <br>리팩터링 후 : 100명 동시 요청 평균
*/
@GetMapping("/list")
@GetMapping
public SliceResponse<TodoTeamSimpleResponse> getTodoTeams(Pageable pageable) {
return todoTeamGetUseCase.getTodoTeams(PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(), Sort.by("id").descending()));
}

@GetMapping("/code")
@GetMapping("/codes/random")
public TodoTeamRandomCodeResponse getTodoTeamRandomCode() {
return todoTeamRandomCodeGetUseCase.generateRandomCode();
}

@GetMapping
public TodoTeamSearchInfoResponse getTodoTeamByCode(@RequestParam String code) {
@GetMapping("/codes/{code}")
public TodoTeamSearchInfoResponse getTodoTeamByCode(@PathVariable String code) {
return todoTeamGetUseCase.searchTodoTeamByCode(code);
}

/**
* 리팩터링 전 : 이미지 업로드 API + 팀 생성 API 100회 테스트 평균 : 160ms
* <br>리팩터링 후 : 이미지 업로드 비동기 + 팀 생성 API 100회 테스트 평균 98.3ms(60% 감소)
*/
@PostMapping(consumes = {MediaType.MULTIPART_FORM_DATA_VALUE})
public void postTodoTeam(@RequestPart("teamImageFile") MultipartFile teamImageFile,
@RequestPart("petimageFiles") List<MultipartFile> petImageFiles,
@RequestPart("todoTeamCreateInfo") TodoTeamCreateRequest todoTeamCreateInfo) {
todoTeamCreateUseCase.createTodoTeam(teamImageFile,petImageFiles, todoTeamCreateInfo);
}

/**
* 리팩터링 전 : 100명 동시 요청 평균 225ms
* <br>리팩터링 후 : 100명 동시 요청 평균 63ms(257% 감소)
*/
@GetMapping("/name")
public List<TodoTeamNameSimpleResponse> getTodoTeamName() {
return todoTeamGetUseCase.getTodoTeamName();
}

@GetMapping("/code/{teamId}")
public TodoTeamRandomCodeResponse getTodoTeamCode(@PathVariable Long teamId){
return todoTeamGetUseCase.getTodoTeamCode(teamId);
@GetMapping("/{todoTeamId}/codes")
public TodoTeamRandomCodeResponse getTodoTeamCode(@PathVariable Long todoTeamId){
return todoTeamGetUseCase.getTodoTeamCode(todoTeamId);
}
}
Loading
Loading