-
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
5 changed files
with
104 additions
and
3 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
src/main/java/modernfarmer/server/farmususer/user/controller/OnBoardingController.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,40 @@ | ||
package modernfarmer.server.farmususer.user.controller; | ||
|
||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import modernfarmer.server.farmususer.user.dto.request.OnBoardingMotivationRequest; | ||
import modernfarmer.server.farmususer.user.dto.response.ResponseDto; | ||
import modernfarmer.server.farmususer.user.service.OnBoardingService; | ||
import modernfarmer.server.farmususer.user.util.JwtTokenProvider; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.validation.annotation.Validated; | ||
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 javax.servlet.http.HttpServletRequest; | ||
|
||
@Slf4j | ||
@RestController | ||
@RequestMapping("/api/user") | ||
public class OnBoardingController { | ||
|
||
private final JwtTokenProvider jwtTokenProvider; | ||
private final OnBoardingService onBoardingService; | ||
|
||
@Autowired | ||
public OnBoardingController( JwtTokenProvider jwtTokenProvider,OnBoardingService onBoardingService){ | ||
this.jwtTokenProvider = jwtTokenProvider; | ||
this.onBoardingService = onBoardingService; | ||
} | ||
|
||
@PostMapping(value = "/motivation") | ||
public ResponseDto onBoardingMotivation(HttpServletRequest request, @Validated @RequestBody OnBoardingMotivationRequest onBoardingMotivationRequest) { | ||
|
||
String userId = jwtTokenProvider.getUserId(request); | ||
|
||
ResponseDto responseDto = onBoardingService.onBoardingMotivation(Long.valueOf(userId), onBoardingMotivationRequest.getMotivation()); | ||
|
||
return responseDto; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...ain/java/modernfarmer/server/farmususer/user/dto/request/OnBoardingMotivationRequest.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 modernfarmer.server.farmususer.user.dto.request; | ||
|
||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import javax.validation.constraints.NotNull; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class OnBoardingMotivationRequest { | ||
|
||
|
||
@NotNull(message = "null 값을 가지면 안됩니다.") | ||
private String motivation; | ||
} |
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
36 changes: 36 additions & 0 deletions
36
src/main/java/modernfarmer/server/farmususer/user/service/OnBoardingService.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,36 @@ | ||
package modernfarmer.server.farmususer.user.service; | ||
|
||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import modernfarmer.server.farmususer.user.dto.response.ResponseDto; | ||
import modernfarmer.server.farmususer.user.repository.UserRepository; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Service; | ||
|
||
|
||
import javax.transaction.Transactional; | ||
|
||
@Transactional | ||
@Slf4j | ||
@Service | ||
public class OnBoardingService { | ||
public UserRepository userRepository; | ||
|
||
@Autowired | ||
public OnBoardingService(UserRepository userRepository) { | ||
this.userRepository = userRepository; | ||
} | ||
|
||
public ResponseDto onBoardingMotivation(Long userId, String motivation){ | ||
|
||
userRepository.insertUserMotivation(userId, motivation); | ||
|
||
ResponseDto responseDto = ResponseDto.builder() | ||
.message("OK") | ||
.code(200) | ||
.build(); | ||
|
||
return responseDto; | ||
} | ||
|
||
} |
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