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

Feature/hyeyeon step1 #8

Open
wants to merge 12 commits into
base: base/hyeyeon
Choose a base branch
from
Open

Conversation

MilanoBeer
Copy link

DB 테이블

  • 사용자, 캘린더, Todo 총 3개의 테이블을 생성하여 관리했습니다.

사용자 관리

  • jwt, springsecurity를 활용하여 사용자 인증,인가관리를 하려고 했습니다.
  • 대략적인 원리를 이해하고 기능구현에는 성공했지만, 구체적인 작동원리는 이해하지 못해서 공부가 필요합니다.

Validation 구현

  • 일정정보인 todo를 생성할 때, 일정의 시작날짜와 끝나는 날짜간의 선후관계를 검증하도록 했습니다.
  • validation은 컨트롤러에서 검증 후 반환합니다.
  • CreateTodoReqeust와 EditTodoReqeust 두 개 타입을 모두 받습니다.
  • todo 생성에서 검증해야할 다른 사항을 고민해보았는데, 더 떠오른게 없었습니다

알림설정

  • todo 일정에 따라 알림설정 기능을 구현하려 스프링 스케줄러를 비롯해 방법을 고민하고 찾아보았지만, 현재 지식과 시간안에서는 역량부족으로 생각되어 포기했습니다.

Todo Entity 수정

  • Todo의 대부분 필드가 수정가능해서 어떻게 처리할지 고민했습니다.
  • 프론트에서 모든 필드정보를 보내고, 모든 필드를 set메소드를 통해 업데이트 하는 방법으로 구현했습니다.
  • entity를 새로 생성해서 할당하거나, 변한값을 찾아서 업데이트하는 방법 등 생각해보았는데, 비효율적인 작업이 추가된다고 생각했습니다.
  • 개별적으로 수정 메소드를 만드는게 Setter어노테이션 처리와 유사해지는게 아닌가 생각했지만, Setter로 열어두는 것과 개별 메소드를 만드는 것은 의미적으로 다르다고 생각하여 그렇게 진행했습니다.

테스트 코드 작성 관련

  • 테스트 코드 작성 진행에 어려움이 있었는데, 다음 진행에 어려움이 있어서 중단하였습니다.

- todo 도메인
  - controller, entity, repository, service 패키지 추가
 - user 도메인
  - controller, entity, repository, service 패키지 추가
- 각 Entity간의 연관관계를 정의하고 연결
- Todo일정을 등록할 때, startDay와 endDay간의 시간을 비교하여 검증하도록 Validator 구현
- 각 Entity에 대해 기본적인 생성기능 구현
- target type에 따라 구분하여 날짜 선후관계 검증
- jwt, spring security를 활용한 사용자 인증
- 생성, 수정, 삭제기능 구현
- setTodoName -> editTodoName형식으로 api 의미를 분명히 하기 위해 수정
- @EnableJpaAudting 어노테이션 추가
Copy link
Member

@VSFe VSFe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

몸풀기적인 Step이라, 간단하게 리뷰해보았습니다~
고민은 다음 스텝부터 본격적으로 ㅎㅎ;;;;;

implementation 'org.springframework.boot:spring-boot-starter-security'

// JWT
implementation group: 'io.jsonwebtoken', name: 'jjwt-api', version: '0.11.2'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

형식을 위쪽이랑 똑같이 작성하면 좋겠네요.

    implementation 'io.jsonwebtoken:jjwt-api:0.11.2'

@RequiredArgsConstructor
public class CalendarEntityController {

private final CalendarService calendarService;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

공백이 두칸이네요


public record CreateCalendarRequest(Long userId, String calendarName) {

public static CreateCalendarRequest create (Long userId, String calendarName) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이름 alias는 좋지만, 일일히 만들기엔 (특히 dto의 수가 많아진다면) 조금 불편할 것 같긴 하네요.

import lombok.AllArgsConstructor;
import lombok.Getter;

@AllArgsConstructor
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RequiredArgsConstructor


import java.io.IOException;

/**
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?


@Transactional
public Todo getTodoEntity(CalendarEntity calendarEntity, Long todoId) {
List<Todo> todos = todoRepository.findAllByCalendarEntity(calendarEntity);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Read만 하고 있다면, @Transactional(ReadOnly = true) 로 바꿔주세요.

* @param calendarId
* @param todoId
*/
public void deleteTodo(Long userId, Long calendarId, Long todoId) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오히려 @Transactional은 이쪽이 더 필요하겠네요.

todo.editEndTime(endTime);
todo.editTodoMemo(todoMemo);
todo.editAllDayFlag(allDayFlag);
todo.editRepeatFlag(repeatFlag);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

edit를 했는데 persist/save를 하진 않았네요?

@Column(name = "todo_id")
private Long id;

@Size(max=50)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기는 글자수 제한이 있지만, 입력값에 대한 Validation은 없던 것 같아요.


public static CreateTodoRequest create(
Long userId, Long calendarId,
String todoName, Date startDay, Time startTime,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • LocalDateTime 이던, OffsetDateTime 이던, 구체적인 시간 클래스를 받는게 더 나을 것 같습니다. (굳이 Day와 Time을 분리할 필요도 없어보여요.)
  • userId, calendarId가 non-Null임을 보장해야 할 필요가 있어보입니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants