작성일: 2023.06.26(월)
KT AIVLE AI 개발자 트랙 3기 과정의 마지막인 빅프로젝트를 진행하고 있습니다.
내 역할, 협업 내용, 나머지는 팀원 담당
@RestController
@RequiredArgsConstructor
@RequestMapping("/posts")
public class PostController {
private final PostService postService;
/**
* 게시글 등록
*/
@PostMapping("/new")
@ResponseStatus(HttpStatus.CREATED)
public void register(@Valid @RequestBody PostSaveDto postSaveDto){
Post post = Post.builder()
.title(postSaveDto.getTitle())
.content(postSaveDto.getContent())
.build();
postService.register(post);
}
/**
* 게시글 수정
*/
@ResponseStatus(HttpStatus.OK)
@PutMapping("/edit/{postId}")
public void update(@PathVariable("postId") Long postId,
@RequestBody PostUpdateDto postUpdateDto){
postService.update(postId, postUpdateDto);
}
/**
* 게시글 조회
*/
@GetMapping("/post/{postId}")
public ResponseEntity getInfo(@PathVariable("postId") Long postId){
return ResponseEntity.ok(postService.getPostInfo(postId));
}
/**
* 게시글 삭제
*/
@ResponseStatus(HttpStatus.OK)
@DeleteMapping("/post/{postId}")
@Transactional
public void delete(@PathVariable("postId") Long postId){
postService.delete(postId);
}
}
@RestController
@RequiredArgsConstructor
@RequestMapping("/comments")
public class CommentController {
private final CommentService commentService;
/**
* 댓글 등록
*/
@PostMapping("/{postId}")
@ResponseStatus(HttpStatus.CREATED)
public void commentSave(@PathVariable("postId") Long postId,
@RequestBody CommentSaveDto commentSaveDto){
Comment comment = Comment.builder()
.content(commentSaveDto.getContent())
.build();
commentService.save(postId, comment);
}
/**
* 댓글 수정
*/
@PutMapping("/{commentId}")
public void update(@PathVariable("commentId") Long commentId,
@RequestBody CommentUpdateDto commentUpdateDto){
commentService.update(commentId, commentUpdateDto);
}
/**
* 댓글 삭제
*/
@DeleteMapping("/{commentId}")
public void delete(@PathVariable("commentId") Long commentId){
commentService.remove(commentId);
}
}
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/users")
public class UserController {
private final UserService userService;
private final PasswordEncoder passwordEncoder;
/**
* 회원가입
*/
@PostMapping("/signup")
@ResponseStatus(HttpStatus.CREATED)
public void singUp(@RequestBody UserSignUpRequestDto userSignUpRequestDto) {
String encodedPassword = passwordEncoder.encode(userSignUpRequestDto.getPassword());
User user = User.builder()
.name(userSignUpRequestDto.getName())
.nickname(userSignUpRequestDto.getNickname())
.password(encodedPassword)
.serialNumber(userSignUpRequestDto.getSerialNumber())
.phoneNumber(userSignUpRequestDto.getPhoneNumber())
.email(userSignUpRequestDto.getEmail())
.build();
user.getRoles().add("USER");
userService.join(user);
}
/**
* 로그인
*/
@PostMapping("/login")
public TokenInfo login(@RequestBody UserLoginRequestDto userLoginRequestDto) {
TokenInfo tokenInfo = userService.login(userLoginRequestDto.getEmail(), userLoginRequestDto.getPassword());
return tokenInfo;
}
}
주말동안 진행된 사항들을 공유하고, 이번 스프린트(5주차)에 할 일들을 논의하는 시간을 가졌다.
이번주 목요일이 마지막 코칭 시간이므로 사실상 이번주에 구현을 마친다는 마음가짐으로 해야하지만, 계획대로 해나가고 있기 때문에 큰 어려움 없이 완성할 수 있을 것으로 생각한다.
오늘 가장 어려웠던 것은 git 정리... BE에서 나뉘어진 브랜치들을 통합하는 과정에서 시간이 오래걸렸다.
git은 쓸수록 쉬워지는 듯 하면서도 물음표가 더 늘어나는 느낌이다. 다행히 별 오류나 충돌없이 마쳤고, 이제 API 구현도 막바지이다. API 구현이 마무리되면 'API 문서'까지 만들어서 팀원에게 공유할 예정이다.