-
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.
Merge branch 'dev' into feature_6/farmclub-기본-api
# Conflicts: # src/main/java/com/modernfarmer/farmusspring/global/common/security/SecurityConfig.java
- Loading branch information
Showing
19 changed files
with
573 additions
and
8 deletions.
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
...m/modernfarmer/farmusspring/domain/myveggiegarden/controller/MyVeggieDiaryController.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,58 @@ | ||
package com.modernfarmer.farmusspring.domain.myveggiegarden.controller; | ||
|
||
import com.modernfarmer.farmusspring.domain.myveggiegarden.dto.response.CheckTodayDiaryResponse; | ||
import com.modernfarmer.farmusspring.domain.myveggiegarden.dto.response.SelectDiaryOneResponse; | ||
import com.modernfarmer.farmusspring.domain.myveggiegarden.dto.response.SelectMyVeggieListResponse; | ||
import com.modernfarmer.farmusspring.domain.myveggiegarden.entity.MyVeggie; | ||
import com.modernfarmer.farmusspring.domain.myveggiegarden.service.MyVeggieDiaryService; | ||
import com.modernfarmer.farmusspring.domain.myveggiegarden.service.MyVeggieGardenService; | ||
import com.modernfarmer.farmusspring.global.response.BaseResponseDto; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.web.bind.annotation.*; | ||
import org.springframework.web.multipart.MultipartFile; | ||
|
||
import java.io.IOException; | ||
|
||
@Slf4j | ||
@RequiredArgsConstructor | ||
@RestController | ||
@RequestMapping("/api/my-veggie/diary") | ||
public class MyVeggieDiaryController { | ||
|
||
private final MyVeggieDiaryService myVeggieDiaryService; | ||
|
||
@PostMapping(value = "/", produces = MediaType.APPLICATION_JSON_VALUE) | ||
public BaseResponseDto<Void> settingMyVeggieDiary( | ||
@RequestPart(value = "file", required = false) MultipartFile multipartFile, | ||
@RequestParam("content") String content, | ||
@RequestParam("isOpen") boolean isOpen, | ||
@RequestParam("state") String state, | ||
@RequestParam("myVeggieId") Long myVeggieId | ||
) throws IOException { | ||
return myVeggieDiaryService.settingMyVeggieDiary( | ||
multipartFile, | ||
content, | ||
isOpen, | ||
state, | ||
myVeggieId | ||
); | ||
} | ||
|
||
@GetMapping(value = "/{myVeggieId}/check") | ||
public BaseResponseDto<CheckTodayDiaryResponse> checkTodayDiary( | ||
@PathVariable("myVeggieId") Long myVeggieId | ||
) { | ||
return myVeggieDiaryService.checkTodayDiary(MyVeggie.builder().id(myVeggieId).build()); | ||
} | ||
|
||
@GetMapping(value = "/{myVeggieId}/one") | ||
public BaseResponseDto<SelectDiaryOneResponse> selectDiaryOne( | ||
@PathVariable("myVeggieId") Long myVeggieId | ||
) { | ||
return myVeggieDiaryService.selectDiaryOne(MyVeggie.builder().id(myVeggieId).build()); | ||
} | ||
|
||
|
||
} |
44 changes: 44 additions & 0 deletions
44
.../modernfarmer/farmusspring/domain/myveggiegarden/controller/MyVeggieGardenController.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,44 @@ | ||
package com.modernfarmer.farmusspring.domain.myveggiegarden.controller; | ||
|
||
import com.modernfarmer.farmusspring.domain.auth.entity.CustomUser; | ||
|
||
import com.modernfarmer.farmusspring.domain.myveggiegarden.dto.request.SettingMyVeggieRequest; | ||
import com.modernfarmer.farmusspring.domain.myveggiegarden.service.MyVeggieGardenService; | ||
import com.modernfarmer.farmusspring.global.response.BaseResponseDto; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.security.core.annotation.AuthenticationPrincipal; | ||
import org.springframework.validation.annotation.Validated; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
|
||
@Slf4j | ||
@RequiredArgsConstructor | ||
@RestController | ||
@RequestMapping("/api/my-veggie") | ||
public class MyVeggieGardenController { | ||
|
||
private final MyVeggieGardenService myVeggieGardenService; | ||
|
||
@PostMapping(value = "/") | ||
public BaseResponseDto<Void> settingMyVeggie( | ||
@AuthenticationPrincipal CustomUser user, | ||
@Validated @RequestBody SettingMyVeggieRequest settingMyVeggi | ||
){ | ||
return myVeggieGardenService.settingMyVeggie( | ||
user.getUserId(), | ||
settingMyVeggi | ||
); | ||
} | ||
|
||
@GetMapping(value = "/simple-list") | ||
public BaseResponseDto<Void> selectMyVeggieList( | ||
@AuthenticationPrincipal CustomUser user | ||
){ | ||
return myVeggieGardenService.selectMyVeggieList(user.getUserId()); | ||
} | ||
|
||
|
||
|
||
|
||
} |
28 changes: 28 additions & 0 deletions
28
...modernfarmer/farmusspring/domain/myveggiegarden/controller/MyVeggieRoutineController.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,28 @@ | ||
package com.modernfarmer.farmusspring.domain.myveggiegarden.controller; | ||
|
||
import com.modernfarmer.farmusspring.domain.myveggiegarden.dto.request.SettingMyVeggieRoutineReqeuest; | ||
import com.modernfarmer.farmusspring.domain.myveggiegarden.service.MyVeggieRoutineService; | ||
import com.modernfarmer.farmusspring.global.response.BaseResponseDto; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.validation.annotation.Validated; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
|
||
@Slf4j | ||
@RequiredArgsConstructor | ||
@RestController | ||
@RequestMapping("/api/my-veggie/routine") | ||
public class MyVeggieRoutineController { | ||
|
||
private final MyVeggieRoutineService myVeggieRoutineService; | ||
|
||
@PostMapping(value = "") | ||
public BaseResponseDto<Void> settingMyVeggieRoutine( | ||
@Validated @RequestBody SettingMyVeggieRoutineReqeuest settingMyVeggieRoutineReqeuest | ||
) { | ||
|
||
return myVeggieRoutineService.settingMyVeggieRoutine(settingMyVeggieRoutineReqeuest); | ||
|
||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...m/modernfarmer/farmusspring/domain/myveggiegarden/dto/request/SettingMyVeggieRequest.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,24 @@ | ||
package com.modernfarmer.farmusspring.domain.myveggiegarden.dto.request; | ||
|
||
|
||
import jakarta.validation.constraints.NotNull; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.util.Date; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class SettingMyVeggieRequest { | ||
|
||
@NotNull(message = "null 값을 가지면 안됩니다.") | ||
private String nickname; | ||
|
||
@NotNull(message = "null 값을 가지면 안됩니다.") | ||
private Date birh; | ||
|
||
@NotNull(message = "null 값을 가지면 안됩니다.") | ||
private Long veggiInfoId; | ||
} |
24 changes: 24 additions & 0 deletions
24
...farmer/farmusspring/domain/myveggiegarden/dto/request/SettingMyVeggieRoutineReqeuest.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,24 @@ | ||
package com.modernfarmer.farmusspring.domain.myveggiegarden.dto.request; | ||
|
||
|
||
import jakarta.validation.constraints.NotNull; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class SettingMyVeggieRoutineReqeuest { | ||
|
||
@NotNull(message = "null 값을 가지면 안됩니다.") | ||
private String content; | ||
|
||
private boolean notify; | ||
|
||
private int period; | ||
|
||
@NotNull(message = "null 값을 가지면 안됩니다.") | ||
private Long myVeggieId; | ||
|
||
} |
14 changes: 14 additions & 0 deletions
14
...modernfarmer/farmusspring/domain/myveggiegarden/dto/response/CheckTodayDiaryResponse.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.modernfarmer.farmusspring.domain.myveggiegarden.dto.response; | ||
|
||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@NoArgsConstructor | ||
@AllArgsConstructor(staticName = "of") | ||
@Getter | ||
public class CheckTodayDiaryResponse { | ||
|
||
private boolean state; | ||
} |
17 changes: 17 additions & 0 deletions
17
.../modernfarmer/farmusspring/domain/myveggiegarden/dto/response/SelectDiaryOneResponse.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,17 @@ | ||
package com.modernfarmer.farmusspring.domain.myveggiegarden.dto.response; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.util.Date; | ||
|
||
@NoArgsConstructor | ||
@AllArgsConstructor(staticName = "of") | ||
@Getter | ||
public class SelectDiaryOneResponse { | ||
|
||
private String image; | ||
private String content; | ||
private String date; | ||
} |
15 changes: 15 additions & 0 deletions
15
...m/modernfarmer/farmusspring/domain/myveggiegarden/dto/response/SelectMyVeggieListDto.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,15 @@ | ||
package com.modernfarmer.farmusspring.domain.myveggiegarden.dto.response; | ||
|
||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Getter | ||
public class SelectMyVeggieListDto { | ||
|
||
public Long myVeggieId; | ||
public String nickname; | ||
} |
18 changes: 18 additions & 0 deletions
18
...ernfarmer/farmusspring/domain/myveggiegarden/dto/response/SelectMyVeggieListResponse.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,18 @@ | ||
package com.modernfarmer.farmusspring.domain.myveggiegarden.dto.response; | ||
|
||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.util.List; | ||
|
||
@NoArgsConstructor | ||
@AllArgsConstructor(staticName = "of") | ||
@Getter | ||
|
||
public class SelectMyVeggieListResponse { | ||
|
||
List<SelectMyVeggieListDto> simpleMyVeggieList; | ||
|
||
} |
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
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
15 changes: 15 additions & 0 deletions
15
...om/modernfarmer/farmusspring/domain/myveggiegarden/exception/MyVeggieGardenErrorCode.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,15 @@ | ||
package com.modernfarmer.farmusspring.domain.myveggiegarden.exception; | ||
|
||
import com.modernfarmer.farmusspring.global.response.ResponseCode; | ||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Getter | ||
@RequiredArgsConstructor | ||
public enum MyVeggieGardenErrorCode implements ResponseCode { | ||
|
||
; | ||
|
||
private final int code; | ||
private final String message; | ||
} |
15 changes: 15 additions & 0 deletions
15
...rnfarmer/farmusspring/domain/myveggiegarden/exception/MyVeggieGardenExceptionHandler.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,15 @@ | ||
package com.modernfarmer.farmusspring.domain.myveggiegarden.exception; | ||
|
||
import com.modernfarmer.farmusspring.domain.test.exception.TestException; | ||
import com.modernfarmer.farmusspring.global.response.BaseResponseDto; | ||
import jakarta.servlet.http.HttpServletRequest; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.web.bind.annotation.ExceptionHandler; | ||
import org.springframework.web.bind.annotation.RestControllerAdvice; | ||
|
||
@Slf4j | ||
@RestControllerAdvice(basePackages = "com.modernfarmer.farmusspring.domain.test") | ||
public class MyVeggieGardenExceptionHandler { | ||
|
||
|
||
} |
15 changes: 15 additions & 0 deletions
15
.../modernfarmer/farmusspring/domain/myveggiegarden/exception/MyVeggieGardenSuccessCode.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,15 @@ | ||
package com.modernfarmer.farmusspring.domain.myveggiegarden.exception; | ||
|
||
import com.modernfarmer.farmusspring.global.response.ResponseCode; | ||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Getter | ||
@RequiredArgsConstructor | ||
public enum MyVeggieGardenSuccessCode implements ResponseCode { | ||
|
||
|
||
NOT_FOUND_DIARY(3000, "해당 일기가 존재하지 않습니다."); | ||
private final int code; | ||
private final String message; | ||
} |
34 changes: 34 additions & 0 deletions
34
...va/com/modernfarmer/farmusspring/domain/myveggiegarden/repository/MyVeggieRepository.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,34 @@ | ||
package com.modernfarmer.farmusspring.domain.myveggiegarden.repository; | ||
|
||
|
||
import com.modernfarmer.farmusspring.domain.myveggiegarden.entity.Diary; | ||
import com.modernfarmer.farmusspring.domain.myveggiegarden.entity.MyVeggie; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.query.Param; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
@Repository | ||
public interface MyVeggieRepository extends JpaRepository<MyVeggie, Long> { | ||
|
||
Optional<MyVeggie> findById(Long id); | ||
|
||
@Query("SELECT d FROM diary AS d WHERE d.myVeggie = :myVeggie ORDER BY d.createdDate DESC") | ||
List<Diary> findDiariesByMyVeggie(MyVeggie myVeggie); | ||
|
||
@Query("SELECT d FROM diary AS d WHERE d.myVeggie = :myVeggie AND FUNCTION('DATE', d.createdDate) = CURRENT_DATE ") | ||
Diary findDiariesByMyVeggieAndToday(MyVeggie myVeggie); | ||
|
||
@Query("SELECT mv FROM my_veggie AS mv JOIN FETCH mv.user WHERE mv.user.id = :userId") | ||
List<MyVeggie> findMyVeggieUserId(@Param("userId") Long userId); | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
} |
Oops, something went wrong.