-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
779 additions
and
4 deletions.
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
src/main/java/com/trendithon/timetris/domain/mainpage/controller/CategoryController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package com.trendithon.timetris.domain.mainpage.controller; | ||
|
||
import com.trendithon.timetris.domain.mainpage.domain.Category; | ||
import com.trendithon.timetris.domain.mainpage.dto.CategoryCreateDTO; | ||
import com.trendithon.timetris.domain.mainpage.dto.CategoryRequestDTO; | ||
import com.trendithon.timetris.domain.mainpage.dto.CategoryViewDTO; | ||
import com.trendithon.timetris.domain.mainpage.service.CategoryService; | ||
import com.trendithon.timetris.global.exception.ApiResponse; | ||
import com.trendithon.timetris.global.exception.CustomException; | ||
import com.trendithon.timetris.global.exception.enums.ErrorStatus; | ||
import com.trendithon.timetris.global.exception.enums.SuccessStatus; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.security.core.Authentication; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.util.List; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/category") | ||
public class CategoryController { | ||
|
||
private final CategoryService categoryService; | ||
|
||
@GetMapping("/{userId}") | ||
public ApiResponse<List<Category>> readCategoryAll(Authentication authentication, | ||
@PathVariable long userId) | ||
{ | ||
List<Category> categoryList = categoryService.readCategoryAll(userId); | ||
return ApiResponse.success(SuccessStatus.OK, categoryList); | ||
} | ||
|
||
@PostMapping("") | ||
public ApiResponse createCategory(Authentication authentication, | ||
@RequestBody CategoryRequestDTO categoryRequestDTO) | ||
{ | ||
long userId = 1; | ||
Category category = categoryService.createCategory(userId, categoryRequestDTO); | ||
if (category == null){ | ||
throw new CustomException(ErrorStatus.INVALID_FORMAT_ERROR); | ||
} | ||
return ApiResponse.success(SuccessStatus.OK); | ||
} | ||
|
||
@PutMapping("/{categoryId}") | ||
public ApiResponse updateCategory(Authentication authentication, | ||
@PathVariable long categoryId, | ||
@RequestBody CategoryViewDTO categoryViewDTO) | ||
{ | ||
long userId = 1; | ||
categoryService.updateCategory(userId, categoryId, categoryViewDTO); | ||
return ApiResponse.success(SuccessStatus.OK); | ||
} | ||
|
||
@DeleteMapping("/{categoryId}") | ||
public ApiResponse deleteCategory(Authentication authentication, | ||
@PathVariable long categoryId) | ||
{ | ||
long userId = 1; | ||
categoryService.deleteCategory(userId, categoryId); | ||
return ApiResponse.success(SuccessStatus.OK); | ||
} | ||
|
||
} |
54 changes: 54 additions & 0 deletions
54
src/main/java/com/trendithon/timetris/domain/mainpage/controller/DoController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package com.trendithon.timetris.domain.mainpage.controller; | ||
|
||
import com.trendithon.timetris.domain.mainpage.domain.Do; | ||
import com.trendithon.timetris.domain.mainpage.dto.DoCreateDTO; | ||
import com.trendithon.timetris.domain.mainpage.dto.DoRequestDTO; | ||
import com.trendithon.timetris.domain.mainpage.dto.DoViewDTO; | ||
import com.trendithon.timetris.domain.mainpage.service.DoService; | ||
import com.trendithon.timetris.global.exception.ApiResponse; | ||
import com.trendithon.timetris.global.exception.CustomException; | ||
import com.trendithon.timetris.global.exception.enums.ErrorStatus; | ||
import com.trendithon.timetris.global.exception.enums.SuccessStatus; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.security.core.Authentication; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/do") | ||
public class DoController { | ||
|
||
private final DoService doService; | ||
|
||
@PostMapping("") | ||
public ApiResponse createDo(Authentication authentication, | ||
@RequestBody DoRequestDTO doRequestDTO) | ||
{ | ||
long userId = 1; | ||
Do done = doService.createDo(userId, doRequestDTO); | ||
if (done == null){ | ||
throw new CustomException(ErrorStatus.INVALID_FORMAT_ERROR); | ||
} | ||
return ApiResponse.success(SuccessStatus.OK); | ||
} | ||
|
||
@PutMapping("/{doId}") | ||
public ApiResponse updateDo(Authentication authentication, | ||
@PathVariable long doId, | ||
@RequestBody DoViewDTO doViewDTO) | ||
{ | ||
long userId = 1; | ||
doService.updateDo(userId, doId, doViewDTO); | ||
return ApiResponse.success(SuccessStatus.OK); | ||
} | ||
|
||
@DeleteMapping("/{doId}") | ||
public ApiResponse deleteDo(Authentication authentication, | ||
@PathVariable long doId) | ||
{ | ||
long userId = 1; | ||
doService.deleteDo(userId, doId); | ||
return ApiResponse.success(SuccessStatus.OK); | ||
} | ||
|
||
} |
31 changes: 31 additions & 0 deletions
31
src/main/java/com/trendithon/timetris/domain/mainpage/controller/MainPageController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.trendithon.timetris.domain.mainpage.controller; | ||
|
||
import com.trendithon.timetris.domain.mainpage.dto.MainPageDTO; | ||
import com.trendithon.timetris.domain.mainpage.service.MainPageService; | ||
import com.trendithon.timetris.global.exception.ApiResponse; | ||
import com.trendithon.timetris.global.exception.enums.SuccessStatus; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.security.core.Authentication; | ||
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; | ||
|
||
import java.time.LocalDate; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/main") | ||
public class MainPageController { | ||
|
||
private final MainPageService mainPageService; | ||
|
||
@GetMapping("/{userId}") | ||
public ApiResponse<MainPageDTO> getMainPage(Authentication authentication, | ||
@PathVariable long userId) | ||
{ | ||
MainPageDTO mainPageDTO = mainPageService.getMainPage(userId); | ||
return ApiResponse.success(SuccessStatus.OK, mainPageDTO); | ||
} | ||
|
||
} |
66 changes: 66 additions & 0 deletions
66
src/main/java/com/trendithon/timetris/domain/mainpage/controller/PlanController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package com.trendithon.timetris.domain.mainpage.controller; | ||
|
||
import com.trendithon.timetris.domain.mainpage.domain.Plan; | ||
import com.trendithon.timetris.domain.mainpage.dto.PlanCreateDTO; | ||
import com.trendithon.timetris.domain.mainpage.dto.PlanRequestDTO; | ||
import com.trendithon.timetris.domain.mainpage.dto.PlanViewDTO; | ||
import com.trendithon.timetris.domain.mainpage.service.PlanService; | ||
import com.trendithon.timetris.global.exception.ApiResponse; | ||
import com.trendithon.timetris.global.exception.CustomException; | ||
import com.trendithon.timetris.global.exception.enums.ErrorStatus; | ||
import com.trendithon.timetris.global.exception.enums.SuccessStatus; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.security.core.Authentication; | ||
import org.springframework.security.core.userdetails.UserDetails; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/plan") | ||
public class PlanController { | ||
|
||
private final PlanService planService; | ||
|
||
@PostMapping("") | ||
public ApiResponse createPlan(Authentication authentication, | ||
@RequestBody PlanRequestDTO planRequestDTO) | ||
{ | ||
long userId = 1; | ||
Plan plan = planService.createPlan(userId, planRequestDTO); | ||
if (plan == null){ | ||
throw new CustomException(ErrorStatus.INVALID_FORMAT_ERROR); | ||
} | ||
return ApiResponse.success(SuccessStatus.OK); | ||
} | ||
|
||
@PutMapping("/{planId}") | ||
public ApiResponse updatePlan(Authentication authentication, | ||
@PathVariable long planId, | ||
@RequestBody PlanViewDTO planViewDTO) | ||
{ | ||
long userId = 1; | ||
planService.updatePlan(userId, planId, planViewDTO); | ||
return ApiResponse.success(SuccessStatus.OK); | ||
} | ||
|
||
@DeleteMapping("/{planId}") | ||
public ApiResponse deletePlan(Authentication authentication, | ||
@PathVariable long planId) | ||
{ | ||
long userId = 1; | ||
planService.deletePlan(userId, planId); | ||
return ApiResponse.success(SuccessStatus.OK); | ||
} | ||
|
||
@PutMapping("/{planId}/check") | ||
public ApiResponse donePlan(Authentication authentication, | ||
@PathVariable long planId) | ||
{ | ||
long userId = 1; | ||
planService.donePlan(userId, planId); | ||
return ApiResponse.success(SuccessStatus.OK); | ||
} | ||
|
||
|
||
|
||
} |
54 changes: 54 additions & 0 deletions
54
src/main/java/com/trendithon/timetris/domain/mainpage/controller/SeeController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package com.trendithon.timetris.domain.mainpage.controller; | ||
|
||
import com.trendithon.timetris.domain.mainpage.domain.See; | ||
import com.trendithon.timetris.domain.mainpage.dto.SeeCreateDTO; | ||
import com.trendithon.timetris.domain.mainpage.dto.SeeRequestDTO; | ||
import com.trendithon.timetris.domain.mainpage.dto.SeeViewDTO; | ||
import com.trendithon.timetris.domain.mainpage.service.SeeService; | ||
import com.trendithon.timetris.global.exception.ApiResponse; | ||
import com.trendithon.timetris.global.exception.CustomException; | ||
import com.trendithon.timetris.global.exception.enums.ErrorStatus; | ||
import com.trendithon.timetris.global.exception.enums.SuccessStatus; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.security.core.Authentication; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/see") | ||
public class SeeController { | ||
|
||
private final SeeService seeService; | ||
|
||
@PostMapping("") | ||
public ApiResponse createSee(Authentication authentication, | ||
@RequestBody SeeRequestDTO seeRequestDTO) | ||
{ | ||
long userId = 1; | ||
See see = seeService.createSee(userId, seeRequestDTO); | ||
if (see == null){ | ||
throw new CustomException(ErrorStatus.SEE_NOT_FOUND_ERROR); | ||
} | ||
return ApiResponse.success(SuccessStatus.OK); | ||
} | ||
|
||
@PutMapping("/{seeId}") | ||
public ApiResponse updateSee(Authentication authentication, | ||
@PathVariable long seeId, | ||
@RequestBody SeeViewDTO seeViewDTO) | ||
{ | ||
long userId = 1; | ||
seeService.updateSee(userId, seeId, seeViewDTO); | ||
return ApiResponse.success(SuccessStatus.OK); | ||
} | ||
|
||
@DeleteMapping("/{seeId}") | ||
public ApiResponse deleteSee(Authentication authentication, | ||
@PathVariable long seeId) | ||
{ | ||
long userId = 1; | ||
seeService.deleteSee(userId, seeId); | ||
return ApiResponse.success(SuccessStatus.OK); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/main/java/com/trendithon/timetris/domain/mainpage/dto/CategoryRequestDTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.trendithon.timetris.domain.mainpage.dto; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@AllArgsConstructor @NoArgsConstructor | ||
public class CategoryRequestDTO { | ||
|
||
private String name; | ||
private String colorCode; | ||
|
||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/com/trendithon/timetris/domain/mainpage/dto/CategoryViewDTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,24 @@ | ||
package com.trendithon.timetris.domain.mainpage.dto; | ||
|
||
import com.trendithon.timetris.domain.mainpage.domain.Category; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@Builder | ||
@AllArgsConstructor @NoArgsConstructor | ||
public class CategoryViewDTO { | ||
|
||
private String name; | ||
private String colorCode; | ||
|
||
public static CategoryViewDTO of(Category category){ | ||
return CategoryViewDTO.builder() | ||
.name(category.getName()) | ||
.colorCode(category.getColorCode()) | ||
.build(); | ||
} | ||
|
||
} |
19 changes: 19 additions & 0 deletions
19
src/main/java/com/trendithon/timetris/domain/mainpage/dto/DoRequestDTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.trendithon.timetris.domain.mainpage.dto; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.time.LocalTime; | ||
|
||
@Getter | ||
@AllArgsConstructor @NoArgsConstructor | ||
public class DoRequestDTO { | ||
|
||
private String title; | ||
private LocalTime startTime; | ||
private LocalTime endTime; | ||
private long categoryId; | ||
private long userDateId; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/main/java/com/trendithon/timetris/domain/mainpage/dto/PlanRequestDTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.trendithon.timetris.domain.mainpage.dto; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.time.LocalTime; | ||
|
||
@Getter | ||
@AllArgsConstructor @NoArgsConstructor | ||
public class PlanRequestDTO { | ||
|
||
private String title; | ||
private LocalTime startTime; | ||
private LocalTime endTime; | ||
private boolean status; | ||
private long categoryId; | ||
private long userDateId; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.