From 68bfd4f88627c98e2d5e67d2fdf94278a4c6e7ed Mon Sep 17 00:00:00 2001 From: sunandrabbit Date: Sat, 28 Sep 2024 14:36:48 +0900 Subject: [PATCH 01/51] =?UTF-8?q?fix=20:=20=EB=B3=80=EC=88=98=EB=AA=85=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../team1/BE/seamless/entity/ProjectEntity.java | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/main/java/team1/BE/seamless/entity/ProjectEntity.java b/src/main/java/team1/BE/seamless/entity/ProjectEntity.java index 7809614..03f9420 100644 --- a/src/main/java/team1/BE/seamless/entity/ProjectEntity.java +++ b/src/main/java/team1/BE/seamless/entity/ProjectEntity.java @@ -22,12 +22,12 @@ public ProjectEntity() { } - public ProjectEntity(String name, UserEntity user, + public ProjectEntity(String name, UserEntity userEntity, LocalDateTime startDate, LocalDateTime endDate) { this.name = name; this.isDelete = 0; - this.user = user; + this.userEntity = userEntity; this.startDate = startDate; this.endDate = endDate; } @@ -40,15 +40,12 @@ public ProjectEntity(String name, UserEntity user, @Column(name = "name") private String name; -// @Column(name = "view_type") -// private Object viewType; - @Column(name = "is_delete") private Integer isDelete; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "user_id") - private UserEntity user; + private UserEntity userEntity; @OneToMany(mappedBy = "projectEntity", cascade = CascadeType.ALL) private List memberEntities; @@ -79,8 +76,8 @@ public Integer getIsDelete() { return isDelete; } - public UserEntity getUser() { - return user; + public UserEntity getUserEntity() { + return userEntity; } public List getMemberEntities() { @@ -116,8 +113,8 @@ public void setIsDelete(Integer isDelete) { this.isDelete = isDelete; } - public void setUser(UserEntity user) { - this.user = user; + public void setUser(UserEntity userEntity) { + this.userEntity = userEntity; } public void setMemberEntities(List memberEntities) { From ac2c5f3f03e275dd2b56a12d9a5fbcd31a57501e Mon Sep 17 00:00:00 2001 From: sunandrabbit Date: Sat, 28 Sep 2024 23:11:01 +0900 Subject: [PATCH 02/51] =?UTF-8?q?fix=20:=20=EC=97=94=ED=8B=B0=ED=8B=B0?= =?UTF-8?q?=EC=9D=98=20=EC=A0=84=EC=B2=B4=EC=A0=81=EC=9D=B8=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BE/seamless/entity/ProjectEntity.java | 26 +++++++++---------- .../BE/seamless/entity/ProjectOption.java | 24 +++++++---------- .../seamless/entity/ProjectOptionDetail.java | 17 +++++++----- .../team1/BE/seamless/entity/TaskEntity.java | 4 +-- 4 files changed, 35 insertions(+), 36 deletions(-) diff --git a/src/main/java/team1/BE/seamless/entity/ProjectEntity.java b/src/main/java/team1/BE/seamless/entity/ProjectEntity.java index 03f9420..19e5a85 100644 --- a/src/main/java/team1/BE/seamless/entity/ProjectEntity.java +++ b/src/main/java/team1/BE/seamless/entity/ProjectEntity.java @@ -26,7 +26,7 @@ public ProjectEntity(String name, UserEntity userEntity, LocalDateTime startDate, LocalDateTime endDate) { this.name = name; - this.isDelete = 0; + this.isDeleted = false; this.userEntity = userEntity; this.startDate = startDate; this.endDate = endDate; @@ -40,8 +40,8 @@ public ProjectEntity(String name, UserEntity userEntity, @Column(name = "name") private String name; - @Column(name = "is_delete") - private Integer isDelete; + @Column(name = "is_deleted") + private boolean isDeleted; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "user_id") @@ -53,8 +53,8 @@ public ProjectEntity(String name, UserEntity userEntity, @OneToMany(mappedBy = "projectEntity", cascade = CascadeType.ALL) private List options; - @OneToOne(fetch = FetchType.LAZY, mappedBy = "projectEntity") - private TaskEntity taskEntity; + @OneToMany(mappedBy = "projectEntity", cascade = CascadeType.ALL) + private List taskEntities; @Column(name = "start_date") private LocalDateTime startDate; @@ -72,8 +72,8 @@ public String getName() { } - public Integer getIsDelete() { - return isDelete; + public boolean getIsDeleted() { + return isDeleted; } public UserEntity getUserEntity() { @@ -88,8 +88,8 @@ public List getOptions() { return options; } - public TaskEntity getTaskEntity() { - return taskEntity; + public List getTaskEntities() { + return taskEntities; } public LocalDateTime getStartDate() { @@ -109,8 +109,8 @@ public void setName(String name) { this.name = name; } - public void setIsDelete(Integer isDelete) { - this.isDelete = isDelete; + public void setIsDeleted(boolean isDeleted) { + this.isDeleted = isDeleted; } public void setUser(UserEntity userEntity) { @@ -125,8 +125,8 @@ public void setOptions(List options) { this.options = options; } - public void setTaskEntity(TaskEntity taskEntity) { - this.taskEntity = taskEntity; + public void setTaskEntity(List taskEntities) { + this.taskEntities = taskEntities; } public void setStartDate(LocalDateTime startDate) { diff --git a/src/main/java/team1/BE/seamless/entity/ProjectOption.java b/src/main/java/team1/BE/seamless/entity/ProjectOption.java index d681f74..7387592 100644 --- a/src/main/java/team1/BE/seamless/entity/ProjectOption.java +++ b/src/main/java/team1/BE/seamless/entity/ProjectOption.java @@ -20,9 +20,9 @@ public ProjectOption() { } - public ProjectOption(String name, Integer isDelete, ProjectEntity projectEntity) { + public ProjectOption(String name, ProjectEntity projectEntity) { this.name = name; - this.isDelete = isDelete; + this.isDeleted = false; this.projectEntity = projectEntity; } @@ -34,8 +34,8 @@ public ProjectOption(String name, Integer isDelete, ProjectEntity projectEntity) @Column(name = "name") private String name; - @Column(name = "is_delete") - private Integer isDelete; + @Column(name = "is_deleted") + private boolean isDeleted; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "project_id") @@ -52,8 +52,8 @@ public String getName() { return name; } - public Integer getIsDelete() { - return isDelete; + public boolean getIsDeleted() { + return isDeleted; } public ProjectEntity getProject() { @@ -64,16 +64,12 @@ public List getDetails() { return details; } - public void addDetail(ProjectOptionDetail detail) { - if (this.details == null) { - this.details = new ArrayList<>(); - } - this.details.add(detail); - detail.setOption(this); // 양방향 관계 설정 - } - public void setProject(ProjectEntity projectEntity) { this.projectEntity = projectEntity; } + public void setIsDeleted(boolean isDeleted) { + this.isDeleted = isDeleted; + } + } diff --git a/src/main/java/team1/BE/seamless/entity/ProjectOptionDetail.java b/src/main/java/team1/BE/seamless/entity/ProjectOptionDetail.java index e161de5..6a8fad1 100644 --- a/src/main/java/team1/BE/seamless/entity/ProjectOptionDetail.java +++ b/src/main/java/team1/BE/seamless/entity/ProjectOptionDetail.java @@ -16,11 +16,10 @@ public ProjectOptionDetail() { } - public ProjectOptionDetail(String name, String eventType, Integer isDelete, - ProjectOption option) { + public ProjectOptionDetail(String name, String eventType, ProjectOption option) { this.name = name; this.eventType = eventType; - this.isDelete = isDelete; + this.isDeleted = false; this.option = option; } @@ -35,8 +34,8 @@ public ProjectOptionDetail(String name, String eventType, Integer isDelete, @Column(name = "event_type") private String eventType; - @Column(name = "is_delete") - private Integer isDelete; + @Column(name = "is_deleted") + private boolean isDeleted; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "option_id") @@ -54,8 +53,8 @@ public String getEventType() { return eventType; } - public Integer getIsDelete() { - return isDelete; + public boolean getIsDeleted() { + return isDeleted; } public ProjectOption getOption() { @@ -66,4 +65,8 @@ public void setOption(ProjectOption option) { this.option = option; } + public void setIsDeleted(boolean isDeleted) { + this.isDeleted = isDeleted; + } + } diff --git a/src/main/java/team1/BE/seamless/entity/TaskEntity.java b/src/main/java/team1/BE/seamless/entity/TaskEntity.java index efb02be..9f8d287 100644 --- a/src/main/java/team1/BE/seamless/entity/TaskEntity.java +++ b/src/main/java/team1/BE/seamless/entity/TaskEntity.java @@ -47,12 +47,12 @@ public TaskEntity(String name, String remark, Integer progress, Integer isDelete @Column(name = "is_delete") private Integer isDelete; - @OneToOne(fetch = FetchType.LAZY) + @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "project_id") private ProjectEntity projectEntity; @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "guest_id") + @JoinColumn(name = "member_id") private MemberEntity owner; @Column(name = "start_date") From fd28308cc9ee5adc6a4bffaafe2def4a1ec05cfd Mon Sep 17 00:00:00 2001 From: sunandrabbit Date: Sat, 28 Sep 2024 23:19:40 +0900 Subject: [PATCH 03/51] =?UTF-8?q?fix=20:=20member=20=EB=A6=AC=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EC=A0=9C=EC=99=B8=20=EB=B0=8F=20Id=EB=A5=BC=20?= =?UTF-8?q?=EA=B0=80=EC=A0=B8=EC=98=A4=EB=8F=84=EB=A1=9D=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../team1/BE/seamless/DTO/ProjectDTO.java | 95 ++++--------------- 1 file changed, 16 insertions(+), 79 deletions(-) diff --git a/src/main/java/team1/BE/seamless/DTO/ProjectDTO.java b/src/main/java/team1/BE/seamless/DTO/ProjectDTO.java index 658fa64..b906c15 100644 --- a/src/main/java/team1/BE/seamless/DTO/ProjectDTO.java +++ b/src/main/java/team1/BE/seamless/DTO/ProjectDTO.java @@ -1,10 +1,5 @@ package team1.BE.seamless.DTO; -import team1.BE.seamless.entity.MemberEntity; -import team1.BE.seamless.entity.MemberEntity; -import team1.BE.seamless.entity.ProjectOption; -import team1.BE.seamless.entity.UserEntity; -import team1.BE.seamless.entity.UserEntity; import team1.BE.seamless.util.page.PageParam; import java.time.LocalDateTime; import java.util.ArrayList; @@ -20,48 +15,39 @@ public static class ProjectCreate { private String name; - private UserEntity user; + private Long userId; - private List guests; - - private List options; + private List optionIds; private LocalDateTime startDate; private LocalDateTime endDate; public ProjectCreate() { - this.guests = new ArrayList<>(); - this.options = new ArrayList<>(); + this.optionIds = new ArrayList<>(); } - public ProjectCreate(String name, UserEntity user, + public ProjectCreate(String name, Long userId, LocalDateTime startDate, LocalDateTime endDate, - List guests, - List options) { + List optionIds) { this.name = name; - this.user = user; + this.userId = userId; this.startDate = startDate; this.endDate = endDate; - this.guests = guests; - this.options = options; + this.optionIds = optionIds; } public String getName() { return name; } - public UserEntity getUser() { - return user; - } - - public List getGuests() { - return guests; + public Long getUserId() { + return userId; } - public List getOptions() { - return options; + public List getOptionIds() { + return optionIds; } public LocalDateTime getStartDate() { @@ -78,9 +64,7 @@ public static class ProjectUpdate { private String name; - private List guests; - - private List options; + private List optionIds; private LocalDateTime startDate; @@ -89,28 +73,19 @@ public static class ProjectUpdate { public ProjectUpdate() { } - public ProjectUpdate(String name, - LocalDateTime startDate, - LocalDateTime endDate, - List guests, - List options) { + public ProjectUpdate(String name, List optionIds, LocalDateTime startDate, LocalDateTime endDate) { this.name = name; + this.optionIds = optionIds; this.startDate = startDate; this.endDate = endDate; - this.guests = guests; - this.options = options; } public String getName() { return name; } - public List getGuests() { - return guests; - } - - public List getOptions() { - return options; + public List getOptionIds() { + return optionIds; } public LocalDateTime getStartDate() { @@ -123,44 +98,6 @@ public LocalDateTime getEndDate() { } -// public static class ProjectPeriod { -// -// private Long id; -// -// private String name; -// -// private LocalDateTime startDate; -// -// private LocalDateTime endDate; -// -// public ProjectPeriod() { -// } -// -// public ProjectPeriod(Long id,String name, LocalDateTime startDate, LocalDateTime endDate) { -// this.id = id; -// this.name = name; -// this.startDate = startDate; -// this.endDate = endDate; -// } -// -// public Long getId() { -// return id; -// } -// -// public String getName() { -// return name; -// } -// -// public LocalDateTime getStartDate() { -// return startDate; -// } -// -// public LocalDateTime getEndDate() { -// return endDate; -// } -// -// } - public interface ProjectPeriod { Long getId(); String getName(); From 1db6ad49b4c628dc5556186522647e8e0f05ea70 Mon Sep 17 00:00:00 2001 From: sunandrabbit Date: Sat, 28 Sep 2024 23:35:51 +0900 Subject: [PATCH 04/51] =?UTF-8?q?feat=20:=20validation=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../team1/BE/seamless/DTO/ProjectDTO.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/main/java/team1/BE/seamless/DTO/ProjectDTO.java b/src/main/java/team1/BE/seamless/DTO/ProjectDTO.java index b906c15..460657d 100644 --- a/src/main/java/team1/BE/seamless/DTO/ProjectDTO.java +++ b/src/main/java/team1/BE/seamless/DTO/ProjectDTO.java @@ -1,5 +1,9 @@ package team1.BE.seamless.DTO; +import jakarta.validation.constraints.AssertTrue; +import jakarta.validation.constraints.FutureOrPresent; +import jakarta.validation.constraints.NotNull; +import java.time.Duration; import team1.BE.seamless.util.page.PageParam; import java.time.LocalDateTime; import java.util.ArrayList; @@ -19,8 +23,11 @@ public static class ProjectCreate { private List optionIds; + @NotNull + @FutureOrPresent private LocalDateTime startDate; + @NotNull private LocalDateTime endDate; public ProjectCreate() { @@ -58,6 +65,16 @@ public LocalDateTime getEndDate() { return endDate; } + @AssertTrue + public boolean isEndDateAfterStartDate() { + return endDate.isAfter(startDate); + } + + @AssertTrue + public boolean isAtLeastOneDayDifference() { + return Duration.between(startDate, endDate).toDays() >= 1; + } + } public static class ProjectUpdate { @@ -66,8 +83,11 @@ public static class ProjectUpdate { private List optionIds; + @NotNull + @FutureOrPresent private LocalDateTime startDate; + @NotNull private LocalDateTime endDate; public ProjectUpdate() { @@ -96,6 +116,16 @@ public LocalDateTime getEndDate() { return endDate; } + @AssertTrue + public boolean isEndDateAfterStartDate() { + return endDate.isAfter(startDate); + } + + @AssertTrue + public boolean isAtLeastOneDayDifference() { + return Duration.between(startDate, endDate).toDays() >= 1; + } + } public interface ProjectPeriod { From afcb59080fc848a033529a751a8637a39c08de4f Mon Sep 17 00:00:00 2001 From: sunandrabbit Date: Sun, 29 Sep 2024 02:57:59 +0900 Subject: [PATCH 05/51] =?UTF-8?q?refactor=20:=20=ED=95=B4=EB=8B=B9=20User?= =?UTF-8?q?=EA=B0=80=20=EA=B0=80=EC=A7=80=EB=8A=94=20=ED=94=84=EB=A1=9C?= =?UTF-8?q?=EC=A0=9D=ED=8A=B8=EB=A7=8C=20=EB=B3=B4=EC=9D=B4=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ProjectController.java | 28 ++++++++------ .../BE/seamless/mapper/ProjectMapper.java | 12 ++++-- .../repository/ProjectRepository.java | 7 +++- .../BE/seamless/service/ProjectService.java | 37 +++++++++---------- 4 files changed, 48 insertions(+), 36 deletions(-) diff --git a/src/main/java/team1/BE/seamless/controller/ProjectController.java b/src/main/java/team1/BE/seamless/controller/ProjectController.java index 88639c4..172cac1 100644 --- a/src/main/java/team1/BE/seamless/controller/ProjectController.java +++ b/src/main/java/team1/BE/seamless/controller/ProjectController.java @@ -1,11 +1,15 @@ package team1.BE.seamless.controller; +import jakarta.servlet.http.HttpServletRequest; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpHeaders; +import org.springframework.web.bind.annotation.RequestHeader; import team1.BE.seamless.DTO.ProjectDTO; import team1.BE.seamless.DTO.ProjectDTO.ProjectPeriod; import team1.BE.seamless.entity.MemberEntity; import team1.BE.seamless.entity.ProjectEntity; import team1.BE.seamless.service.ProjectService; +import team1.BE.seamless.util.auth.ParsingPram; import team1.BE.seamless.util.page.ListResult; import team1.BE.seamless.util.page.PageMapper; import team1.BE.seamless.util.page.PageResult; @@ -28,40 +32,42 @@ public class ProjectController { private final ProjectService projectService; + private final ParsingPram parsingPram; @Autowired - public ProjectController(ProjectService projectService) { + public ProjectController(ProjectService projectService, ParsingPram parsingPram) { this.projectService = projectService; + this.parsingPram = parsingPram; } @Operation(summary = "프로젝트 리스트 조회") @GetMapping - public PageResult getProjectList(@Valid ProjectDTO.getList param) { - return PageMapper.toPageResult(projectService.getProjectList(param)); + public PageResult getProjectList(@Valid ProjectDTO.getList param, HttpServletRequest req) { + return PageMapper.toPageResult(projectService.getProjectList(param, parsingPram.getEmail(req))); } @Operation(summary = "프로젝트 조회") @GetMapping("/{project-id}") - public SingleResult getProject(@Valid @PathVariable long id) { - return new SingleResult<>(projectService.getProject(id)); + public SingleResult getProject(@Valid @PathVariable long id, HttpServletRequest req) { + return new SingleResult<>(projectService.getProject(id, parsingPram.getEmail(req))); } @Operation(summary = "프로젝트 기간 리스트 조회") @GetMapping("/periods") - public PageResult getProjectPeriod(@Valid ProjectDTO.getList param) { - return PageMapper.toPageResult(projectService.getProjectPeriod(param)); + public PageResult getProjectPeriod(@Valid ProjectDTO.getList param, HttpServletRequest req) { + return PageMapper.toPageResult(projectService.getProjectPeriod(param, parsingPram.getEmail(req))); } @Operation(summary = "프로젝트 멤버 조회") @GetMapping("/{project-id}/members") - public ListResult getProjectMembers(@Valid @PathVariable long id) { - return new ListResult<>(projectService.getProjectMembers(id)); + public ListResult getProjectMembers(@Valid @PathVariable long id, HttpServletRequest req) { + return new ListResult<>(projectService.getProjectMembers(id, parsingPram.getEmail(req))); } @Operation(summary = "프로젝트 생성") @PostMapping - public SingleResult createProject(@Valid @RequestBody ProjectDTO.ProjectCreate create) { - return new SingleResult<>(projectService.createProject(create)); + public SingleResult createProject(@Valid @RequestBody ProjectDTO.ProjectCreate create, HttpServletRequest req) { + return new SingleResult<>(projectService.createProject(create, parsingPram.getEmail(req))); } @Operation(summary = "프로젝트 설정 수정") diff --git a/src/main/java/team1/BE/seamless/mapper/ProjectMapper.java b/src/main/java/team1/BE/seamless/mapper/ProjectMapper.java index 5e78cef..c3198fa 100644 --- a/src/main/java/team1/BE/seamless/mapper/ProjectMapper.java +++ b/src/main/java/team1/BE/seamless/mapper/ProjectMapper.java @@ -1,15 +1,21 @@ package team1.BE.seamless.mapper; -import java.time.LocalDateTime; + import org.springframework.stereotype.Component; +import team1.BE.seamless.DTO.ProjectDTO; import team1.BE.seamless.entity.ProjectEntity; import team1.BE.seamless.entity.UserEntity; @Component public class ProjectMapper { - public ProjectEntity toEntity(String name, UserEntity user, LocalDateTime startDate, LocalDateTime endDate) { - return new ProjectEntity(name, user, startDate, endDate); + public ProjectEntity toEntity(ProjectDTO.ProjectCreate create, UserEntity userEntity) { + return new ProjectEntity( + create.getName(), + userEntity, + create.getStartDate(), + create.getEndDate() + ); } } diff --git a/src/main/java/team1/BE/seamless/repository/ProjectRepository.java b/src/main/java/team1/BE/seamless/repository/ProjectRepository.java index bffac28..17cc036 100644 --- a/src/main/java/team1/BE/seamless/repository/ProjectRepository.java +++ b/src/main/java/team1/BE/seamless/repository/ProjectRepository.java @@ -1,5 +1,6 @@ package team1.BE.seamless.repository; +import java.util.Optional; import team1.BE.seamless.DTO.ProjectDTO.ProjectPeriod; import team1.BE.seamless.entity.ProjectEntity; import org.springframework.data.domain.Page; @@ -9,7 +10,9 @@ @Repository public interface ProjectRepository extends JpaRepository { - Page findAll(Pageable pageable); + Page findAllByUserEntityEmail(Pageable pageable, String email); - Page findAllBy(Pageable pageable); + Optional findByIdAndUserEntityEmail(Long id, String email); + + Page findByUserEntityEmail(Pageable pageable, String email); } diff --git a/src/main/java/team1/BE/seamless/service/ProjectService.java b/src/main/java/team1/BE/seamless/service/ProjectService.java index 1c09a60..08d524f 100644 --- a/src/main/java/team1/BE/seamless/service/ProjectService.java +++ b/src/main/java/team1/BE/seamless/service/ProjectService.java @@ -9,8 +9,10 @@ import team1.BE.seamless.entity.MemberEntity; import team1.BE.seamless.entity.ProjectEntity; import team1.BE.seamless.entity.ProjectOption; +import team1.BE.seamless.entity.UserEntity; import team1.BE.seamless.mapper.ProjectMapper; import team1.BE.seamless.repository.ProjectRepository; +import team1.BE.seamless.repository.UserRepository; import team1.BE.seamless.util.errorException.BaseHandler; import java.util.List; import org.springframework.data.domain.Page; @@ -21,45 +23,40 @@ public class ProjectService { private final ProjectRepository projectRepository; + private final UserRepository userRepository; private final ProjectMapper projectMapper; @Autowired - public ProjectService(ProjectRepository projectRepository, ProjectMapper projectMapper) { + public ProjectService(ProjectRepository projectRepository, UserRepository userRepository, ProjectMapper projectMapper) { this.projectRepository = projectRepository; + this.userRepository = userRepository; this.projectMapper = projectMapper; } - public Page getProjectList(ProjectDTO.getList param) { - return projectRepository.findAll(param.toPageable()); + public Page getProjectList(ProjectDTO.getList param, String email) { + return projectRepository.findAllByUserEntityEmail(param.toPageable(), email); } - public ProjectEntity getProject(long get) { - ProjectEntity projectEntity = projectRepository.findById(get) + public ProjectEntity getProject(long id, String email) { + return projectRepository.findByIdAndUserEntityEmail(id, email) .orElseThrow(() -> new BaseHandler(HttpStatus.NOT_FOUND, "프로젝트가 존재하지 않음")); - return projectEntity; } - public List getProjectMembers(long get) { - ProjectEntity projectEntity = projectRepository.findById(get) + public List getProjectMembers(long id, String email) { + ProjectEntity projectEntity = projectRepository.findByIdAndUserEntityEmail(id, email) .orElseThrow(() -> new BaseHandler(HttpStatus.NOT_FOUND, "프로젝트가 존재하지 않음")); return projectEntity.getMemberEntities(); } - public Page getProjectPeriod(ProjectDTO.getList param) { - return projectRepository.findAllBy(param.toPageable()); + public Page getProjectPeriod(ProjectDTO.getList param, String email) { + return projectRepository.findByUserEntityEmail(param.toPageable(), email); } @Transactional - public ProjectEntity createProject(ProjectCreate create) { - ProjectEntity projectEntity = projectMapper.toEntity( - create.getName(), - create.getUser(), - create.getStartDate(), - create.getEndDate() - ); - - projectRepository.save(projectEntity); - return projectEntity; + public ProjectEntity createProject(ProjectCreate create, String email) { + UserEntity userEntity = userRepository.findByEmail(email) + .orElseThrow(() -> new BaseHandler(HttpStatus.NOT_FOUND, "사용자가 존재하지 않음")); + return projectRepository.save(projectMapper.toEntity(create,userEntity)); } @Transactional From 4c69f6b8f340e654f958f673801dbbebedb3f8fa Mon Sep 17 00:00:00 2001 From: Kim-DongHyuk <80240164+Kdonghs@users.noreply.github.com> Date: Tue, 1 Oct 2024 14:30:38 +0900 Subject: [PATCH 06/51] =?UTF-8?q?feat:=20=EC=9C=A0=EC=A0=80=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BE/seamless/controller/UserController.java | 7 +++++++ .../BE/seamless/repository/UserRepository.java | 1 + .../team1/BE/seamless/service/UserService.java | 14 ++++++++++++-- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/main/java/team1/BE/seamless/controller/UserController.java b/src/main/java/team1/BE/seamless/controller/UserController.java index 86e9387..a21671c 100644 --- a/src/main/java/team1/BE/seamless/controller/UserController.java +++ b/src/main/java/team1/BE/seamless/controller/UserController.java @@ -1,5 +1,6 @@ package team1.BE.seamless.controller; +import org.springframework.web.bind.annotation.DeleteMapping; import team1.BE.seamless.DTO.UserDTO.UserDetails; import team1.BE.seamless.DTO.UserDTO.UserSimple; import team1.BE.seamless.DTO.UserDTO.UserUpdate; @@ -41,4 +42,10 @@ public SingleResult updateUser(HttpServletRequest req, @Valid @Reque return new SingleResult<>(userService.updateUser(req,update)); } + @Operation(summary = "유저 정보 삭제") + @DeleteMapping + public SingleResult deleteUser(HttpServletRequest req) { + return new SingleResult<>(userService.deleteUser(req)); + } + } diff --git a/src/main/java/team1/BE/seamless/repository/UserRepository.java b/src/main/java/team1/BE/seamless/repository/UserRepository.java index 0d7a412..152493d 100644 --- a/src/main/java/team1/BE/seamless/repository/UserRepository.java +++ b/src/main/java/team1/BE/seamless/repository/UserRepository.java @@ -9,4 +9,5 @@ public interface UserRepository extends JpaRepository { Optional findByEmail(String email); + Optional findByEmailAndIsDelete(String email, Integer isDelete); } diff --git a/src/main/java/team1/BE/seamless/service/UserService.java b/src/main/java/team1/BE/seamless/service/UserService.java index 824b81a..5080c23 100644 --- a/src/main/java/team1/BE/seamless/service/UserService.java +++ b/src/main/java/team1/BE/seamless/service/UserService.java @@ -31,18 +31,28 @@ public UserService(UserRepository userRepository, UserMapper userMapper, } public UserDetails getUser(HttpServletRequest req) { - UserEntity user = userRepository.findByEmail(parsingPram.getEmail(req)) + UserEntity user = userRepository.findByEmailAndIsDelete(parsingPram.getEmail(req),0) .orElseThrow(() -> new BaseHandler(HttpStatus.NOT_FOUND, "해당 유저가 존재하지 않습니다.")); return userMapper.toUserDetails(user); } @Transactional public UserSimple updateUser(HttpServletRequest req, @Valid UserUpdate update) { - UserEntity user = userRepository.findByEmail(parsingPram.getEmail(req)) + UserEntity user = userRepository.findByEmailAndIsDelete(parsingPram.getEmail(req),0) .orElseThrow(() -> new BaseHandler(HttpStatus.NOT_FOUND, "해당 유저가 존재하지 않습니다.")); userMapper.toUpdate(user,update); return userMapper.toUserSimple(user); } + + @Transactional + public UserSimple deleteUser(HttpServletRequest req) { + UserEntity user = userRepository.findByEmailAndIsDelete(parsingPram.getEmail(req),0) + .orElseThrow(() -> new BaseHandler(HttpStatus.NOT_FOUND, "해당 유저가 존재하지 않습니다.")); + + user.setIsDelete(); + + return userMapper.toUserSimple(user); + } } From 5a003fa1c09d9c28a5a5e32ac988a408ff1cf6d7 Mon Sep 17 00:00:00 2001 From: Kim-DongHyuk <80240164+Kdonghs@users.noreply.github.com> Date: Tue, 1 Oct 2024 14:31:35 +0900 Subject: [PATCH 07/51] =?UTF-8?q?feat:=20=EC=9C=A0=EC=A0=80=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/team1/BE/seamless/service/AuthService.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/team1/BE/seamless/service/AuthService.java b/src/main/java/team1/BE/seamless/service/AuthService.java index 3442554..6a9e504 100644 --- a/src/main/java/team1/BE/seamless/service/AuthService.java +++ b/src/main/java/team1/BE/seamless/service/AuthService.java @@ -57,11 +57,17 @@ public OAuth2User loadUser(OAuth2UserRequest userRequest) throws OAuth2Authentic return new PrincipalDetails(user, oAuth2UserAttributes, userNameAttributeName); } + /** + * 유저 정보가 존재하지 않으면 파라미터로 유저 생성 + * 유저 정보가 있으면 로그인 + * 삭제여부는 서비스에서 검증 + * */ @Transactional protected UserEntity saveOrUpdate(OAuthAttributes attributes) { UserEntity user = userRepository.findByEmail(attributes.getEmail()) // 구글 사용자 정보 업데이트(이미 가입된 사용자) => 업데이트 // .map(entity -> entity.update(attributes.getName(), attributes.getPicture())) + // 가입되지 않은 사용자 => User 엔티티 생성 .orElse(userMapper.toEntity(attributes.getName(), attributes.getEmail(), attributes.getPicture())); From 0e86acb580954a5c5845d08b7f212a53f67ed3f2 Mon Sep 17 00:00:00 2001 From: Kim-DongHyuk <80240164+Kdonghs@users.noreply.github.com> Date: Tue, 1 Oct 2024 14:32:17 +0900 Subject: [PATCH 08/51] =?UTF-8?q?feat:=20=EC=8A=A4=ED=94=84=EB=A7=81=20?= =?UTF-8?q?=EC=8B=9C=ED=81=90=EB=A6=AC=ED=8B=B0=EC=97=90=EC=84=9C=20?= =?UTF-8?q?=ED=86=A0=ED=81=B0=20=EC=98=88=EC=99=B8=EC=B2=98=EB=A6=AC=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EC=9E=91=EC=84=B1=EC=A4=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../team1/BE/seamless/util/auth/JwtToken.java | 5 ++-- .../BE/seamless/util/auth/SecurityConfig.java | 19 +++++++++++---- .../CustomExceptionHandler.java | 9 ++++++- .../util/errorException/RuntimeHandler.java | 24 +++++++++++++++++++ .../errorException/SecurityEntryPoint.java | 24 +++++++++++++++++++ 5 files changed, 73 insertions(+), 8 deletions(-) create mode 100644 src/main/java/team1/BE/seamless/util/errorException/RuntimeHandler.java create mode 100644 src/main/java/team1/BE/seamless/util/errorException/SecurityEntryPoint.java diff --git a/src/main/java/team1/BE/seamless/util/auth/JwtToken.java b/src/main/java/team1/BE/seamless/util/auth/JwtToken.java index 2e0ec03..9e752e6 100644 --- a/src/main/java/team1/BE/seamless/util/auth/JwtToken.java +++ b/src/main/java/team1/BE/seamless/util/auth/JwtToken.java @@ -23,6 +23,7 @@ import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.authority.SimpleGrantedAuthority; import org.springframework.stereotype.Component; +import team1.BE.seamless.util.errorException.RuntimeHandler; @Component public class JwtToken { @@ -65,9 +66,9 @@ public Claims validateToken(String token) { .parseClaimsJws(token) .getBody(); } catch (ExpiredJwtException e) { - throw new BaseHandler(HttpStatus.UNAUTHORIZED, "만료된 토큰 입니다."); + throw new RuntimeHandler(HttpStatus.UNAUTHORIZED, "만료된 토큰 입니다."); } catch (JwtException e) { - throw new BaseHandler(HttpStatus.UNAUTHORIZED, "유효하지 않은 JWT 토큰입니다."); + throw new RuntimeHandler(HttpStatus.UNAUTHORIZED, "유효하지 않은 JWT 토큰입니다."); } } diff --git a/src/main/java/team1/BE/seamless/util/auth/SecurityConfig.java b/src/main/java/team1/BE/seamless/util/auth/SecurityConfig.java index ab06516..188dc83 100644 --- a/src/main/java/team1/BE/seamless/util/auth/SecurityConfig.java +++ b/src/main/java/team1/BE/seamless/util/auth/SecurityConfig.java @@ -1,8 +1,5 @@ package team1.BE.seamless.util.auth; -import team1.BE.seamless.service.AuthService; -import team1.BE.seamless.util.fiter.TokenAuthenticationFilter; -import team1.BE.seamless.util.fiter.TokenExceptionFilter; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -12,6 +9,10 @@ import org.springframework.security.config.http.SessionCreationPolicy; import org.springframework.security.web.SecurityFilterChain; import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; +import team1.BE.seamless.service.AuthService; +import team1.BE.seamless.util.errorException.SecurityEntryPoint; +import team1.BE.seamless.util.fiter.TokenAuthenticationFilter; +import team1.BE.seamless.util.fiter.TokenExceptionFilter; @Configuration @EnableWebSecurity @@ -21,15 +22,19 @@ public class SecurityConfig { private final OAuth2SuccessHandler successHandler; private final TokenAuthenticationFilter tokenAuthenticationFilter; private final TokenExceptionFilter tokenExceptionFilter; + private final SecurityEntryPoint SecurityException; + @Autowired public SecurityConfig(AuthService authService, OAuth2SuccessHandler successHandler, TokenAuthenticationFilter tokenAuthenticationFilter, - TokenExceptionFilter tokenExceptionFilter) { + TokenExceptionFilter tokenExceptionFilter, + SecurityEntryPoint SecurityException) { this.authService = authService; this.successHandler = successHandler; this.tokenAuthenticationFilter = tokenAuthenticationFilter; this.tokenExceptionFilter = tokenExceptionFilter; + this.SecurityException = SecurityException; } @Bean @@ -43,6 +48,7 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti .headers(c -> c.frameOptions().disable()) .sessionManagement(c -> c.sessionCreationPolicy(SessionCreationPolicy.STATELESS)) + .authorizeHttpRequests(request -> request // swagger .requestMatchers("/swagger", "/swagger-ui.html", "/swagger-ui/**", "/api-docs", @@ -64,9 +70,12 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti .successHandler(successHandler) ) - .addFilterAfter(tokenAuthenticationFilter, UsernamePasswordAuthenticationFilter.class) +// .exceptionHandling(handler -> handler.authenticationEntryPoint(SecurityException)) + + .addFilterBefore(tokenAuthenticationFilter, UsernamePasswordAuthenticationFilter.class) .addFilterBefore(tokenExceptionFilter, tokenAuthenticationFilter.getClass()); return http.build(); } + } diff --git a/src/main/java/team1/BE/seamless/util/errorException/CustomExceptionHandler.java b/src/main/java/team1/BE/seamless/util/errorException/CustomExceptionHandler.java index e6c8eb4..704c2e8 100644 --- a/src/main/java/team1/BE/seamless/util/errorException/CustomExceptionHandler.java +++ b/src/main/java/team1/BE/seamless/util/errorException/CustomExceptionHandler.java @@ -11,7 +11,6 @@ public class CustomExceptionHandler { // BaseHandler 예외처리 - @ExceptionHandler(ResponseStatusException.class) public final ResponseEntity handleResponseStatusException( ResponseStatusException ex, WebRequest request) { @@ -30,4 +29,12 @@ public final ResponseEntity handleMethodArgumentNotValidExceptio return new ResponseEntity<>(errorResponse, ex.getStatusCode()); } + // spring security 예외처리 + @ExceptionHandler(RuntimeHandler.class) + public ResponseEntity handleSignatureException(RuntimeHandler ex, + WebRequest request) { + StatusResponse errorResponse = new StatusResponse(ex.getStatus().value(), ex.getMessage()); + return new ResponseEntity<>(errorResponse, ex.getStatus()); + } + } diff --git a/src/main/java/team1/BE/seamless/util/errorException/RuntimeHandler.java b/src/main/java/team1/BE/seamless/util/errorException/RuntimeHandler.java new file mode 100644 index 0000000..8a3ac2e --- /dev/null +++ b/src/main/java/team1/BE/seamless/util/errorException/RuntimeHandler.java @@ -0,0 +1,24 @@ +package team1.BE.seamless.util.errorException; + +import org.springframework.http.HttpStatus; + +public class RuntimeHandler extends RuntimeException { + private final HttpStatus status; + private final String message; + + public RuntimeHandler(HttpStatus status, String message) { + super(message); + this.status = status; + this.message = message; + } + + public HttpStatus getStatus() { + return status; + } + + @Override + public String getMessage() { + return message; + } + +} diff --git a/src/main/java/team1/BE/seamless/util/errorException/SecurityEntryPoint.java b/src/main/java/team1/BE/seamless/util/errorException/SecurityEntryPoint.java new file mode 100644 index 0000000..a590aac --- /dev/null +++ b/src/main/java/team1/BE/seamless/util/errorException/SecurityEntryPoint.java @@ -0,0 +1,24 @@ +package team1.BE.seamless.util.errorException; + +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.security.core.AuthenticationException; +import org.springframework.security.web.AuthenticationEntryPoint; +import org.springframework.stereotype.Component; +import org.springframework.web.servlet.HandlerExceptionResolver; + +@Component +public class SecurityEntryPoint implements AuthenticationEntryPoint { + + private final HandlerExceptionResolver resolver; + + public SecurityEntryPoint(@Qualifier("handlerExceptionResolver") HandlerExceptionResolver resolver) { + this.resolver = resolver; + } + + @Override + public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) { + resolver.resolveException(request, response, null, authException); + } +} From d7b1e5cb3fefe5f23ebaf4543db7ea7fd40c8940 Mon Sep 17 00:00:00 2001 From: Kim-DongHyuk <80240164+Kdonghs@users.noreply.github.com> Date: Tue, 1 Oct 2024 17:48:46 +0900 Subject: [PATCH 09/51] =?UTF-8?q?feat:=20=EC=BD=94=EB=93=9C=EB=A1=9C=20?= =?UTF-8?q?=EB=A9=A4=EB=B2=84=20=ED=86=A0=ED=81=B0=20=EB=B0=98=ED=99=98(?= =?UTF-8?q?=EB=A9=A4=EB=B2=84=20=EC=BD=94=EB=93=9C=EB=A1=9C=20=EC=B0=B8?= =?UTF-8?q?=EC=97=AC)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../seamless/controller/AuthController.java | 23 ++++++-- .../team1/BE/seamless/entity/enums/Role.java | 3 +- .../BE/seamless/service/AuthService.java | 57 +++++++++++++++---- .../BE/seamless/util/auth/AesEncrypt.java | 47 +++++++++++++++ .../team1/BE/seamless/util/auth/JwtToken.java | 20 ++++++- .../BE/seamless/util/auth/SecurityConfig.java | 4 +- .../team1/BE/seamless/util/auth/Token.java | 18 ++++++ src/main/resources/application.properties | 3 +- 8 files changed, 153 insertions(+), 22 deletions(-) create mode 100644 src/main/java/team1/BE/seamless/util/auth/AesEncrypt.java create mode 100644 src/main/java/team1/BE/seamless/util/auth/Token.java diff --git a/src/main/java/team1/BE/seamless/controller/AuthController.java b/src/main/java/team1/BE/seamless/controller/AuthController.java index aa78f5c..a66c163 100644 --- a/src/main/java/team1/BE/seamless/controller/AuthController.java +++ b/src/main/java/team1/BE/seamless/controller/AuthController.java @@ -1,10 +1,16 @@ package team1.BE.seamless.controller; -import team1.BE.seamless.service.AuthService; +import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import team1.BE.seamless.service.AuthService; +import team1.BE.seamless.util.auth.Token; +import team1.BE.seamless.util.page.SingleResult; @Tag(name = "인증기능 구현") @RestController @@ -18,8 +24,15 @@ public AuthController(AuthService authService) { this.authService = authService; } -// @GetMapping("/login/oauth2/code/google") -// public SingleResult login(OAuth2AuthenticationToken authenticationToken) { -// return new SingleResult<>(null); -// } + @Operation(summary = "인증 코드로 멤버 토큰 반환") + @GetMapping("/memberCode") + public SingleResult memberCodeJoin(@Valid @RequestParam String memberCode) { + return new SingleResult<>(authService.memberCodeJoin(memberCode)); + } + + @Operation(summary = "인증 코드 생성(테스트용)") + @GetMapping("/memberCode/create") + public SingleResult memberCodeCreate(@Valid @RequestParam String memberCode) { + return new SingleResult<>(authService.memberCodeCreate(memberCode)); + } } diff --git a/src/main/java/team1/BE/seamless/entity/enums/Role.java b/src/main/java/team1/BE/seamless/entity/enums/Role.java index 0c794ab..4a2010b 100644 --- a/src/main/java/team1/BE/seamless/entity/enums/Role.java +++ b/src/main/java/team1/BE/seamless/entity/enums/Role.java @@ -2,7 +2,8 @@ public enum Role { ADMIN("ROLE_ADMIN", "관리자"), - USER("ROLE_USER", "사용자"); + USER("ROLE_USER", "사용자"), + MEMBER("ROLE_MEMBER", "프로젝트 멤버"); private final String key; private final String title; diff --git a/src/main/java/team1/BE/seamless/service/AuthService.java b/src/main/java/team1/BE/seamless/service/AuthService.java index 6a9e504..cd9a286 100644 --- a/src/main/java/team1/BE/seamless/service/AuthService.java +++ b/src/main/java/team1/BE/seamless/service/AuthService.java @@ -1,13 +1,9 @@ package team1.BE.seamless.service; -import team1.BE.seamless.DTO.AuthDTO; -import team1.BE.seamless.DTO.AuthDTO.OAuthAttributes; -import team1.BE.seamless.DTO.AuthDTO.PrincipalDetails; -import team1.BE.seamless.entity.UserEntity; -import team1.BE.seamless.mapper.UserMapper; -import team1.BE.seamless.repository.UserRepository; +import jakarta.validation.Valid; import java.util.Map; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; import org.springframework.security.oauth2.client.userinfo.DefaultOAuth2UserService; import org.springframework.security.oauth2.client.userinfo.OAuth2UserRequest; import org.springframework.security.oauth2.client.userinfo.OAuth2UserService; @@ -15,17 +11,38 @@ import org.springframework.security.oauth2.core.user.OAuth2User; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import team1.BE.seamless.DTO.AuthDTO; +import team1.BE.seamless.DTO.AuthDTO.OAuthAttributes; +import team1.BE.seamless.DTO.AuthDTO.PrincipalDetails; +import team1.BE.seamless.entity.MemberEntity; +import team1.BE.seamless.entity.UserEntity; +import team1.BE.seamless.mapper.UserMapper; +import team1.BE.seamless.repository.MemberRepository; +import team1.BE.seamless.repository.UserRepository; +import team1.BE.seamless.util.auth.AesEncrypt; +import team1.BE.seamless.util.auth.JwtToken; +import team1.BE.seamless.util.auth.Token; +import team1.BE.seamless.util.errorException.BaseHandler; @Service public class AuthService implements OAuth2UserService { private final UserRepository userRepository; + private final MemberRepository memberRepository; + private final UserMapper userMapper; + private final JwtToken jwtToken; + private final AesEncrypt aesEncrypt; + @Autowired - public AuthService(UserRepository userRepository, UserMapper userMapper) { + public AuthService(UserRepository userRepository, MemberRepository memberRepository, + UserMapper userMapper, JwtToken jwtToken, AesEncrypt aesEncrypt) { this.userRepository = userRepository; + this.memberRepository = memberRepository; this.userMapper = userMapper; + this.jwtToken = jwtToken; + this.aesEncrypt = aesEncrypt; } @Transactional @@ -58,10 +75,8 @@ public OAuth2User loadUser(OAuth2UserRequest userRequest) throws OAuth2Authentic } /** - * 유저 정보가 존재하지 않으면 파라미터로 유저 생성 - * 유저 정보가 있으면 로그인 - * 삭제여부는 서비스에서 검증 - * */ + * 유저 정보가 존재하지 않으면 파라미터로 유저 생성 유저 정보가 있으면 로그인 삭제여부는 서비스에서 검증 + */ @Transactional protected UserEntity saveOrUpdate(OAuthAttributes attributes) { UserEntity user = userRepository.findByEmail(attributes.getEmail()) @@ -74,4 +89,24 @@ protected UserEntity saveOrUpdate(OAuthAttributes attributes) { return userRepository.save(user); } + + public Token memberCodeJoin(@Valid String memberCode) { +// decode + String code=aesEncrypt.decrypt(memberCode); + +// 프로젝트, member가 존재하는지 검증 + MemberEntity member = memberRepository.findById(Long.parseLong(code)) + .orElseThrow(() -> new BaseHandler(HttpStatus.FORBIDDEN, "해당 멤버가 존재하지 않습니다.")); + +// 토큰 반환 + String token = jwtToken.createMemberToken(member); + + return new Token(token); + } + + public String memberCodeCreate(@Valid String memberCode) { +// ENCODE + String code=aesEncrypt.encrypt(memberCode); + return code; + } } \ No newline at end of file diff --git a/src/main/java/team1/BE/seamless/util/auth/AesEncrypt.java b/src/main/java/team1/BE/seamless/util/auth/AesEncrypt.java new file mode 100644 index 0000000..a6d5a7a --- /dev/null +++ b/src/main/java/team1/BE/seamless/util/auth/AesEncrypt.java @@ -0,0 +1,47 @@ +package team1.BE.seamless.util.auth; + +import java.util.Base64; +import javax.crypto.Cipher; +import javax.crypto.SecretKey; +import javax.crypto.spec.SecretKeySpec; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +@Component +public class AesEncrypt { + + private SecretKey secretKey; + private static final String ALGORITHM = "AES"; + private static final String TRANSFORMATION = "AES/ECB/PKCS5Padding"; + + public AesEncrypt(@Value("${code.secretKey}") String secretString) { + secretKey = new SecretKeySpec(secretString.getBytes(), "AES"); + } + + // 암호화 + public String encrypt(String data) { + byte[] encryptedBytes = null; + try { + Cipher cipher = Cipher.getInstance(TRANSFORMATION); + cipher.init(Cipher.ENCRYPT_MODE, secretKey); + encryptedBytes = cipher.doFinal(data.getBytes()); + } catch (Exception e) { + + } + return Base64.getEncoder().encodeToString(encryptedBytes); + } + + // 복호화 + public String decrypt(String encryptedData) { + byte[] decryptedBytes = null; + try { + Cipher cipher = Cipher.getInstance(TRANSFORMATION); + cipher.init(Cipher.DECRYPT_MODE, secretKey); + decryptedBytes = cipher.doFinal(Base64.getDecoder().decode(encryptedData)); + } catch (Exception e) { + + } + + return new String(decryptedBytes); + } +} diff --git a/src/main/java/team1/BE/seamless/util/auth/JwtToken.java b/src/main/java/team1/BE/seamless/util/auth/JwtToken.java index 9e752e6..c103f2b 100644 --- a/src/main/java/team1/BE/seamless/util/auth/JwtToken.java +++ b/src/main/java/team1/BE/seamless/util/auth/JwtToken.java @@ -1,8 +1,6 @@ package team1.BE.seamless.util.auth; -import team1.BE.seamless.DTO.AuthDTO.PrincipalDetails; -import team1.BE.seamless.util.errorException.BaseHandler; import io.jsonwebtoken.Claims; import io.jsonwebtoken.ExpiredJwtException; import io.jsonwebtoken.JwtException; @@ -23,6 +21,9 @@ import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.authority.SimpleGrantedAuthority; import org.springframework.stereotype.Component; +import team1.BE.seamless.DTO.AuthDTO.PrincipalDetails; +import team1.BE.seamless.entity.MemberEntity; +import team1.BE.seamless.entity.enums.Role; import team1.BE.seamless.util.errorException.RuntimeHandler; @Component @@ -58,6 +59,21 @@ public String createToken(Authentication authentication) { .compact(); } + public String createMemberToken(MemberEntity member) { + ZonedDateTime now = ZonedDateTime.now().withZoneSameInstant(ZoneId.of("UTC")); + ZonedDateTime expirationDateTime = now.plusSeconds(tokenExpTime); + + Claims claims = Jwts.claims(); + claims.put("authentication", Role.MEMBER.toString()); + claims.put("email", member.getEmail()); + return Jwts.builder() + .setClaims(claims) + .setIssuedAt(Date.from(now.toInstant())) + .setExpiration(Date.from(expirationDateTime.toInstant())) + .signWith(secretKey, SignatureAlgorithm.HS256) + .compact(); + } + public Claims validateToken(String token) { try { return Jwts.parserBuilder() diff --git a/src/main/java/team1/BE/seamless/util/auth/SecurityConfig.java b/src/main/java/team1/BE/seamless/util/auth/SecurityConfig.java index 188dc83..33101ce 100644 --- a/src/main/java/team1/BE/seamless/util/auth/SecurityConfig.java +++ b/src/main/java/team1/BE/seamless/util/auth/SecurityConfig.java @@ -53,14 +53,14 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti // swagger .requestMatchers("/swagger", "/swagger-ui.html", "/swagger-ui/**", "/api-docs", "/api-docs/**", "/v3/api-docs/**").permitAll() - .requestMatchers("/login/**", "/auth/**", "/oauth2/**") + .requestMatchers("/login/**", "/api/auth/**", "/oauth2/**") .permitAll() // 확장자 .requestMatchers("/", "/error", "/favicon.ico", "/**/*.png", "/**/*.gif", "/**/*.svg", "/**/*.jpg", "/**/*.html", "/**/*.css", "/**/*.js") .permitAll() // 인증, h2 - .requestMatchers("/auth/**", "/h2-console/**").permitAll() + .requestMatchers( "/h2-console/**").permitAll() .anyRequest() .authenticated() ) diff --git a/src/main/java/team1/BE/seamless/util/auth/Token.java b/src/main/java/team1/BE/seamless/util/auth/Token.java new file mode 100644 index 0000000..853dfe3 --- /dev/null +++ b/src/main/java/team1/BE/seamless/util/auth/Token.java @@ -0,0 +1,18 @@ +package team1.BE.seamless.util.auth; + +public class Token { + + private String token; + + public Token(String token) { + this.token = token; + } + + public String getToken() { + return token; + } + + public void setToken(String token) { + this.token = token; + } +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index cacc902..c84f0c7 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -14,8 +14,9 @@ spring.jpa.defer-datasource-initialization=true spring.jpa.properties.hibernate.format_sql=true spring.jpa.show-sql=true spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQLDialect -jwt.secretKey=testSecretKey20230327testSecretKey20230327testSecretKey20230327 +jwt.secretKey=KO)$*"g+zWechI9]KE|'irIM?ky--x/|p.K&>bA>Ef,gfD/)ekd/UcBE2kQ@BhE jwt.tokenExpTime=3600 +code.secretKey=ae2af8cfb8721e39189f6f5edc928589 spring.profiles.active=dev server.forward-headers-strategy=framework spring.profiles.include=oauth From 0103378539f1aa7390622a9a154071a00be89ebf Mon Sep 17 00:00:00 2001 From: Kim-DongHyuk <80240164+Kdonghs@users.noreply.github.com> Date: Tue, 1 Oct 2024 17:50:28 +0900 Subject: [PATCH 10/51] =?UTF-8?q?feat:=20=ED=94=84=EB=A1=9C=EC=A0=9D?= =?UTF-8?q?=ED=8A=B8=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EB=8D=B0=EC=9D=B4?= =?UTF-8?q?=ED=84=B0=20=EC=83=9D=EC=84=B1(=EC=9E=84=EC=8B=9C)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/team1/BE/seamless/init/InitData.java | 5 ++++- .../BE/seamless/init/ProjectCreator.java | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 src/main/java/team1/BE/seamless/init/ProjectCreator.java diff --git a/src/main/java/team1/BE/seamless/init/InitData.java b/src/main/java/team1/BE/seamless/init/InitData.java index 276e5c4..b4ce5aa 100644 --- a/src/main/java/team1/BE/seamless/init/InitData.java +++ b/src/main/java/team1/BE/seamless/init/InitData.java @@ -10,15 +10,18 @@ public class InitData { private final TestCreator testCreator; + private final ProjectCreator projectCreator; @Autowired - public InitData(TestCreator testCreator) { + public InitData(TestCreator testCreator, ProjectCreator projectCreator) { this.testCreator = testCreator; + this.projectCreator = projectCreator; } @PostConstruct public void init() { // 테스트 생성 testCreator.creator(); + projectCreator.creator(); } } diff --git a/src/main/java/team1/BE/seamless/init/ProjectCreator.java b/src/main/java/team1/BE/seamless/init/ProjectCreator.java new file mode 100644 index 0000000..a5fcd66 --- /dev/null +++ b/src/main/java/team1/BE/seamless/init/ProjectCreator.java @@ -0,0 +1,19 @@ +package team1.BE.seamless.init; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import team1.BE.seamless.service.ProjectService; + +@Component +public class ProjectCreator { + + private final ProjectService projectService; + + @Autowired + public ProjectCreator(ProjectService projectService) { + this.projectService = projectService; + } + + public void creator() { + } +} From 7dc9a7a0c9cded2b58e78a55ccee985aafdb87ae Mon Sep 17 00:00:00 2001 From: sunandrabbit Date: Thu, 3 Oct 2024 21:00:47 +0900 Subject: [PATCH 11/51] =?UTF-8?q?fix=20:=20=EB=B3=80=EC=88=98=EB=AA=85=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/team1/BE/seamless/entity/MemberEntity.java | 2 +- src/main/java/team1/BE/seamless/entity/UserEntity.java | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/team1/BE/seamless/entity/MemberEntity.java b/src/main/java/team1/BE/seamless/entity/MemberEntity.java index 60868ef..8c41f6e 100644 --- a/src/main/java/team1/BE/seamless/entity/MemberEntity.java +++ b/src/main/java/team1/BE/seamless/entity/MemberEntity.java @@ -37,7 +37,7 @@ public void setJoinNumber(String joinNumber) { @Id @GeneratedValue(strategy = GenerationType.AUTO) - @Column(name = "guest_id") + @Column(name = "member_id") private Long id; @Column(name = "email") diff --git a/src/main/java/team1/BE/seamless/entity/UserEntity.java b/src/main/java/team1/BE/seamless/entity/UserEntity.java index 5745f98..53af6db 100644 --- a/src/main/java/team1/BE/seamless/entity/UserEntity.java +++ b/src/main/java/team1/BE/seamless/entity/UserEntity.java @@ -1,5 +1,8 @@ package team1.BE.seamless.entity; +import jakarta.persistence.CascadeType; +import jakarta.persistence.OneToMany; +import java.util.List; import team1.BE.seamless.entity.enums.Role; import jakarta.persistence.Column; import jakarta.persistence.Entity; @@ -15,7 +18,7 @@ import org.springframework.data.annotation.LastModifiedDate; import org.springframework.data.jpa.domain.support.AuditingEntityListener; -@Entity(name = "users") +@Entity(name = "user_table") @EntityListeners(AuditingEntityListener.class) public class UserEntity { @@ -40,6 +43,9 @@ public class UserEntity { @Column private Integer isDelete; + @OneToMany(mappedBy = "userEntity", cascade = CascadeType.ALL) + private List projectEntities; + @CreatedDate private LocalDateTime createdAt; From 77fe94664dcdae2e5fafc53afa56df1ba05838fb Mon Sep 17 00:00:00 2001 From: sunandrabbit Date: Thu, 3 Oct 2024 21:01:05 +0900 Subject: [PATCH 12/51] =?UTF-8?q?feat=20:=20=EC=98=B5=EC=85=98=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/team1/BE/seamless/DTO/OptionDTO.java | 21 +++++++ .../team1/BE/seamless/DTO/ProjectDTO.java | 60 +++++++++++++++++-- .../controller/ProjectController.java | 8 +-- ...ectOptionDetail.java => OptionEntity.java} | 30 +++++----- .../BE/seamless/entity/ProjectEntity.java | 22 +++---- .../BE/seamless/entity/ProjectOption.java | 30 ++++++---- .../BE/seamless/mapper/ProjectMapper.java | 5 +- .../seamless/repository/OptionRepository.java | 15 +++++ .../repository/ProjectRepository.java | 2 +- .../BE/seamless/service/ProjectService.java | 35 +++++++++-- 10 files changed, 174 insertions(+), 54 deletions(-) create mode 100644 src/main/java/team1/BE/seamless/DTO/OptionDTO.java rename src/main/java/team1/BE/seamless/entity/{ProjectOptionDetail.java => OptionEntity.java} (59%) create mode 100644 src/main/java/team1/BE/seamless/repository/OptionRepository.java diff --git a/src/main/java/team1/BE/seamless/DTO/OptionDTO.java b/src/main/java/team1/BE/seamless/DTO/OptionDTO.java new file mode 100644 index 0000000..e681f9c --- /dev/null +++ b/src/main/java/team1/BE/seamless/DTO/OptionDTO.java @@ -0,0 +1,21 @@ +package team1.BE.seamless.DTO; + +import java.util.List; + +public class OptionDTO { + + private List optionNames; + + public OptionDTO(List optionNames) { + this.optionNames = optionNames; + } + + public List getOptionNames() { + return optionNames; + } + + public void setOptionNames(List optionNames) { + this.optionNames = optionNames; + } + +} diff --git a/src/main/java/team1/BE/seamless/DTO/ProjectDTO.java b/src/main/java/team1/BE/seamless/DTO/ProjectDTO.java index 460657d..ca84eb5 100644 --- a/src/main/java/team1/BE/seamless/DTO/ProjectDTO.java +++ b/src/main/java/team1/BE/seamless/DTO/ProjectDTO.java @@ -128,12 +128,62 @@ public boolean isAtLeastOneDayDifference() { } - public interface ProjectPeriod { - Long getId(); - String getName(); - LocalDateTime getStartDate(); - LocalDateTime getEndDate(); + public static class ProjectPeriod { + + private Long id; + + private String name; + + @NotNull + @FutureOrPresent + private LocalDateTime startDate; + + @NotNull + private LocalDateTime endDate; + + public ProjectPeriod() { + } + + public ProjectPeriod(String name, LocalDateTime startDate, LocalDateTime endDate) { + this.name = name; + this.startDate = startDate; + this.endDate = endDate; + } + + public Long getId() { + return id; + } + + public String getName() { + return name; + } + + public LocalDateTime getStartDate() { + return startDate; + } + + public LocalDateTime getEndDate() { + return endDate; + } + + @AssertTrue + public boolean isEndDateAfterStartDate() { + return endDate.isAfter(startDate); + } + + @AssertTrue + public boolean isAtLeastOneDayDifference() { + return Duration.between(startDate, endDate).toDays() >= 1; + } + } +// public interface ProjectPeriod { +// Long getId(); +// String getName(); +// LocalDateTime getStartDate(); +// LocalDateTime getEndDate(); +// } + } diff --git a/src/main/java/team1/BE/seamless/controller/ProjectController.java b/src/main/java/team1/BE/seamless/controller/ProjectController.java index 172cac1..56616ae 100644 --- a/src/main/java/team1/BE/seamless/controller/ProjectController.java +++ b/src/main/java/team1/BE/seamless/controller/ProjectController.java @@ -48,8 +48,8 @@ public PageResult getProjectList(@Valid ProjectDTO.getList param, @Operation(summary = "프로젝트 조회") @GetMapping("/{project-id}") - public SingleResult getProject(@Valid @PathVariable long id, HttpServletRequest req) { - return new SingleResult<>(projectService.getProject(id, parsingPram.getEmail(req))); + public SingleResult getProject(@Valid @PathVariable long id) { + return new SingleResult<>(projectService.getProject(id)); } @Operation(summary = "프로젝트 기간 리스트 조회") @@ -60,8 +60,8 @@ public PageResult getProjectPeriod(@Valid ProjectDTO.getList para @Operation(summary = "프로젝트 멤버 조회") @GetMapping("/{project-id}/members") - public ListResult getProjectMembers(@Valid @PathVariable long id, HttpServletRequest req) { - return new ListResult<>(projectService.getProjectMembers(id, parsingPram.getEmail(req))); + public ListResult getProjectMembers(@Valid @PathVariable long id) { + return new ListResult<>(projectService.getProjectMembers(id)); } @Operation(summary = "프로젝트 생성") diff --git a/src/main/java/team1/BE/seamless/entity/ProjectOptionDetail.java b/src/main/java/team1/BE/seamless/entity/OptionEntity.java similarity index 59% rename from src/main/java/team1/BE/seamless/entity/ProjectOptionDetail.java rename to src/main/java/team1/BE/seamless/entity/OptionEntity.java index 6a8fad1..b272cda 100644 --- a/src/main/java/team1/BE/seamless/entity/ProjectOptionDetail.java +++ b/src/main/java/team1/BE/seamless/entity/OptionEntity.java @@ -1,31 +1,30 @@ package team1.BE.seamless.entity; +import jakarta.persistence.CascadeType; import jakarta.persistence.Column; import jakarta.persistence.Entity; -import jakarta.persistence.FetchType; import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; import jakarta.persistence.Id; -import jakarta.persistence.JoinColumn; -import jakarta.persistence.ManyToOne; +import jakarta.persistence.OneToMany; +import java.util.List; -@Entity(name = "project_option_detail") -public class ProjectOptionDetail extends BaseEntity{ +@Entity(name = "option") +public class OptionEntity extends BaseEntity{ - public ProjectOptionDetail() { + public OptionEntity() { } - public ProjectOptionDetail(String name, String eventType, ProjectOption option) { + public OptionEntity(String name, String eventType) { this.name = name; this.eventType = eventType; this.isDeleted = false; - this.option = option; } @Id @GeneratedValue(strategy = GenerationType.AUTO) - @Column(name = "detail_id") + @Column(name = "option_id") private Long id; @Column(name = "name") @@ -37,9 +36,8 @@ public ProjectOptionDetail(String name, String eventType, ProjectOption option) @Column(name = "is_deleted") private boolean isDeleted; - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "option_id") - private ProjectOption option; + @OneToMany(mappedBy = "optionEntity", cascade = CascadeType.ALL ) + private List options; public Long getId() { return id; @@ -57,12 +55,12 @@ public boolean getIsDeleted() { return isDeleted; } - public ProjectOption getOption() { - return option; + public List getOptions() { + return options; } - public void setOption(ProjectOption option) { - this.option = option; + public void setOptions(List options) { + this.options = options; } public void setIsDeleted(boolean isDeleted) { diff --git a/src/main/java/team1/BE/seamless/entity/ProjectEntity.java b/src/main/java/team1/BE/seamless/entity/ProjectEntity.java index 19e5a85..7249436 100644 --- a/src/main/java/team1/BE/seamless/entity/ProjectEntity.java +++ b/src/main/java/team1/BE/seamless/entity/ProjectEntity.java @@ -10,7 +10,6 @@ import jakarta.persistence.JoinColumn; import jakarta.persistence.ManyToOne; import jakarta.persistence.OneToMany; -import jakarta.persistence.OneToOne; import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; @@ -19,17 +18,22 @@ public class ProjectEntity extends BaseEntity{ public ProjectEntity() { - + memberEntities = new ArrayList<>(); + projectOptions = new ArrayList<>(); + taskEntities = new ArrayList<>(); } - public ProjectEntity(String name, UserEntity userEntity, + public ProjectEntity(String name, UserEntity userEntity, List projectOptions, LocalDateTime startDate, LocalDateTime endDate) { this.name = name; this.isDeleted = false; this.userEntity = userEntity; + this.projectOptions = projectOptions; this.startDate = startDate; this.endDate = endDate; + memberEntities = new ArrayList<>(); + taskEntities = new ArrayList<>(); } @Id @@ -51,7 +55,7 @@ public ProjectEntity(String name, UserEntity userEntity, private List memberEntities; @OneToMany(mappedBy = "projectEntity", cascade = CascadeType.ALL) - private List options; + private List projectOptions; @OneToMany(mappedBy = "projectEntity", cascade = CascadeType.ALL) private List taskEntities; @@ -62,7 +66,6 @@ public ProjectEntity(String name, UserEntity userEntity, @Column(name = "end_date") private LocalDateTime endDate; - //Getters public Long getId() { return id; } @@ -84,8 +87,8 @@ public List getMemberEntities() { return memberEntities; } - public List getOptions() { - return options; + public List getProjectOptions() { + return projectOptions; } public List getTaskEntities() { @@ -100,7 +103,6 @@ public LocalDateTime getEndDate() { return endDate; } - //Setters public void setId(Long id) { this.id = id; } @@ -121,8 +123,8 @@ public void setMemberEntities(List memberEntities) { this.memberEntities = memberEntities; } - public void setOptions(List options) { - this.options = options; + public void setProjectOptions(List projectOptions) { + this.projectOptions = projectOptions; } public void setTaskEntity(List taskEntities) { diff --git a/src/main/java/team1/BE/seamless/entity/ProjectOption.java b/src/main/java/team1/BE/seamless/entity/ProjectOption.java index 7387592..393c186 100644 --- a/src/main/java/team1/BE/seamless/entity/ProjectOption.java +++ b/src/main/java/team1/BE/seamless/entity/ProjectOption.java @@ -1,6 +1,5 @@ package team1.BE.seamless.entity; -import jakarta.persistence.CascadeType; import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.FetchType; @@ -9,9 +8,6 @@ import jakarta.persistence.Id; import jakarta.persistence.JoinColumn; import jakarta.persistence.ManyToOne; -import jakarta.persistence.OneToMany; -import java.util.ArrayList; -import java.util.List; @Entity(name = "project_option") public class ProjectOption extends BaseEntity{ @@ -20,15 +16,22 @@ public ProjectOption() { } - public ProjectOption(String name, ProjectEntity projectEntity) { + public ProjectOption(String name, OptionEntity optionEntity) { + this.name = name; + this.isDeleted = false; + this.optionEntity = optionEntity; + } + + public ProjectOption(String name, ProjectEntity projectEntity, OptionEntity optionEntity) { this.name = name; this.isDeleted = false; this.projectEntity = projectEntity; + this.optionEntity = optionEntity; } @Id @GeneratedValue(strategy = GenerationType.AUTO) - @Column(name = "option_id") + @Column(name = "project_option_id") private Long id; @Column(name = "name") @@ -41,8 +44,9 @@ public ProjectOption(String name, ProjectEntity projectEntity) { @JoinColumn(name = "project_id") private ProjectEntity projectEntity; - @OneToMany(mappedBy = "option", cascade = CascadeType.ALL) - private List details; + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "option_id") + private OptionEntity optionEntity; public Long getId() { return id; @@ -60,14 +64,18 @@ public ProjectEntity getProject() { return projectEntity; } - public List getDetails() { - return details; + public OptionEntity getOptionEntity() { + return optionEntity; } - public void setProject(ProjectEntity projectEntity) { + public void setProjectEntity(ProjectEntity projectEntity) { this.projectEntity = projectEntity; } + public void setOptionEntity(OptionEntity optionEntity) { + this.optionEntity = optionEntity; + } + public void setIsDeleted(boolean isDeleted) { this.isDeleted = isDeleted; } diff --git a/src/main/java/team1/BE/seamless/mapper/ProjectMapper.java b/src/main/java/team1/BE/seamless/mapper/ProjectMapper.java index c3198fa..9ed4c64 100644 --- a/src/main/java/team1/BE/seamless/mapper/ProjectMapper.java +++ b/src/main/java/team1/BE/seamless/mapper/ProjectMapper.java @@ -1,18 +1,21 @@ package team1.BE.seamless.mapper; +import java.util.List; import org.springframework.stereotype.Component; import team1.BE.seamless.DTO.ProjectDTO; import team1.BE.seamless.entity.ProjectEntity; +import team1.BE.seamless.entity.ProjectOption; import team1.BE.seamless.entity.UserEntity; @Component public class ProjectMapper { - public ProjectEntity toEntity(ProjectDTO.ProjectCreate create, UserEntity userEntity) { + public ProjectEntity toEntity(ProjectDTO.ProjectCreate create, UserEntity userEntity, List projectOptions) { return new ProjectEntity( create.getName(), userEntity, + projectOptions, create.getStartDate(), create.getEndDate() ); diff --git a/src/main/java/team1/BE/seamless/repository/OptionRepository.java b/src/main/java/team1/BE/seamless/repository/OptionRepository.java new file mode 100644 index 0000000..e81d93d --- /dev/null +++ b/src/main/java/team1/BE/seamless/repository/OptionRepository.java @@ -0,0 +1,15 @@ +package team1.BE.seamless.repository; + + +import java.util.List; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; +import team1.BE.seamless.entity.OptionEntity; +import team1.BE.seamless.entity.ProjectEntity; + +@Repository +public interface OptionRepository extends JpaRepository { + + List findByIdIn(List ids); + +} diff --git a/src/main/java/team1/BE/seamless/repository/ProjectRepository.java b/src/main/java/team1/BE/seamless/repository/ProjectRepository.java index 17cc036..c1f15fc 100644 --- a/src/main/java/team1/BE/seamless/repository/ProjectRepository.java +++ b/src/main/java/team1/BE/seamless/repository/ProjectRepository.java @@ -12,7 +12,7 @@ public interface ProjectRepository extends JpaRepository { Page findAllByUserEntityEmail(Pageable pageable, String email); - Optional findByIdAndUserEntityEmail(Long id, String email); + Optional findById(Long id); Page findByUserEntityEmail(Pageable pageable, String email); } diff --git a/src/main/java/team1/BE/seamless/service/ProjectService.java b/src/main/java/team1/BE/seamless/service/ProjectService.java index 08d524f..c54255f 100644 --- a/src/main/java/team1/BE/seamless/service/ProjectService.java +++ b/src/main/java/team1/BE/seamless/service/ProjectService.java @@ -9,8 +9,10 @@ import team1.BE.seamless.entity.MemberEntity; import team1.BE.seamless.entity.ProjectEntity; import team1.BE.seamless.entity.ProjectOption; +import team1.BE.seamless.entity.OptionEntity; import team1.BE.seamless.entity.UserEntity; import team1.BE.seamless.mapper.ProjectMapper; +import team1.BE.seamless.repository.OptionRepository; import team1.BE.seamless.repository.ProjectRepository; import team1.BE.seamless.repository.UserRepository; import team1.BE.seamless.util.errorException.BaseHandler; @@ -24,12 +26,15 @@ public class ProjectService { private final ProjectRepository projectRepository; private final UserRepository userRepository; + private final OptionRepository optionRepository; private final ProjectMapper projectMapper; @Autowired - public ProjectService(ProjectRepository projectRepository, UserRepository userRepository, ProjectMapper projectMapper) { + public ProjectService(ProjectRepository projectRepository, UserRepository userRepository, + OptionRepository optionRepository, ProjectMapper projectMapper) { this.projectRepository = projectRepository; this.userRepository = userRepository; + this.optionRepository = optionRepository; this.projectMapper = projectMapper; } @@ -37,13 +42,13 @@ public Page getProjectList(ProjectDTO.getList param, String email return projectRepository.findAllByUserEntityEmail(param.toPageable(), email); } - public ProjectEntity getProject(long id, String email) { - return projectRepository.findByIdAndUserEntityEmail(id, email) + public ProjectEntity getProject(long id) { + return projectRepository.findById(id) .orElseThrow(() -> new BaseHandler(HttpStatus.NOT_FOUND, "프로젝트가 존재하지 않음")); } - public List getProjectMembers(long id, String email) { - ProjectEntity projectEntity = projectRepository.findByIdAndUserEntityEmail(id, email) + public List getProjectMembers(long id) { + ProjectEntity projectEntity = projectRepository.findById(id) .orElseThrow(() -> new BaseHandler(HttpStatus.NOT_FOUND, "프로젝트가 존재하지 않음")); return projectEntity.getMemberEntities(); } @@ -56,13 +61,31 @@ public Page getProjectPeriod(ProjectDTO.getList param, String ema public ProjectEntity createProject(ProjectCreate create, String email) { UserEntity userEntity = userRepository.findByEmail(email) .orElseThrow(() -> new BaseHandler(HttpStatus.NOT_FOUND, "사용자가 존재하지 않음")); - return projectRepository.save(projectMapper.toEntity(create,userEntity)); + List optionEntities = optionRepository.findByIdIn(create.getOptionIds()); + + List projectOptions = optionEntities.stream() + .map(optionEntity -> new ProjectOption(optionEntity.getName(), optionEntity)) + .toList(); + + ProjectEntity projectEntity = projectRepository.save(projectMapper.toEntity(create, userEntity, projectOptions)); + projectOptions.forEach(option -> option.setProjectEntity(projectEntity)); //ProjectOption에 Project 매핑 + return projectEntity; } @Transactional public ProjectEntity updateProject(long get, ProjectUpdate update) { ProjectEntity projectEntity = projectRepository.findById(get) .orElseThrow(() -> new BaseHandler(HttpStatus.NOT_FOUND, "프로젝트가 존재하지 않음")); + // 기존 옵션 목록 + List projectOptions = projectEntity.getProjectOptions(); + projectOptions.clear(); + + // 새로운 옵션 추가 + List optionEntities = optionRepository.findByIdIn(update.getOptionIds()); + for (OptionEntity optionEntity : optionEntities) { + ProjectOption projectOption = new ProjectOption(optionEntity.getName(), projectEntity, optionEntity); + projectOptions.add(projectOption); + } projectEntity.update( update.getName(), From 28a9406433d5762f4fd9fbf754a977489326db3f Mon Sep 17 00:00:00 2001 From: Kim-DongHyuk <80240164+Kdonghs@users.noreply.github.com> Date: Thu, 3 Oct 2024 23:24:16 +0900 Subject: [PATCH 13/51] =?UTF-8?q?fix:=20=EB=A9=A4=EB=B2=84=20=EC=97=94?= =?UTF-8?q?=ED=8B=B0=ED=8B=B0=EC=97=90=EC=84=9C=20joinNumber=EB=8A=94=20?= =?UTF-8?q?=EC=82=AC=EC=9A=A9=EB=90=98=EC=A7=80=20=EC=95=8A=EC=9D=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BE/seamless/entity/MemberEntity.java | 29 +++++++------------ 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/src/main/java/team1/BE/seamless/entity/MemberEntity.java b/src/main/java/team1/BE/seamless/entity/MemberEntity.java index 60868ef..5c76f2e 100644 --- a/src/main/java/team1/BE/seamless/entity/MemberEntity.java +++ b/src/main/java/team1/BE/seamless/entity/MemberEntity.java @@ -20,9 +20,8 @@ public MemberEntity() { } - public MemberEntity(String email, String joinNumber, Integer isDelete, ProjectEntity projectEntity) { + public MemberEntity(String email, Integer isDelete, ProjectEntity projectEntity) { this.email = email; - this.joinNumber = joinNumber; this.isDelete = isDelete; this.projectEntity = projectEntity; } @@ -31,10 +30,6 @@ public void setEmail(String email) { this.email = email; } - public void setJoinNumber(String joinNumber) { - this.joinNumber = joinNumber; - } - @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "guest_id") @@ -43,8 +38,8 @@ public void setJoinNumber(String joinNumber) { @Column(name = "email") private String email; - @Column(name = "join_number") - private String joinNumber; +// @Column(name = "join_number") +// private String joinNumber; @Column(name = "is_delete") private Integer isDelete; @@ -64,10 +59,6 @@ public String getEmail() { return email; } - public String getJoinNumber() { - return joinNumber; - } - public Integer getIsDelete() { return isDelete; } @@ -80,13 +71,13 @@ public List getTasks() { return taskEntities; } - public void addTask(TaskEntity taskEntity) { - if (this.taskEntities == null) { - this.taskEntities = new ArrayList<>(); - } - this.taskEntities.add(taskEntity); - taskEntity.setOwner(this); // 양방향 관계 설정 - } +// public void addTask(TaskEntity taskEntity) { +// if (this.taskEntities == null) { +// this.taskEntities = new ArrayList<>(); +// } +// this.taskEntities.add(taskEntity); +// taskEntity.setOwner(this); // 양방향 관계 설정 +// } public void setProject(ProjectEntity projectEntity) { this.projectEntity = projectEntity; From 9f41c0561cb643e7c6d063446b9a87bb62aeb8a4 Mon Sep 17 00:00:00 2001 From: Kim-DongHyuk <80240164+Kdonghs@users.noreply.github.com> Date: Fri, 4 Oct 2024 00:17:05 +0900 Subject: [PATCH 14/51] =?UTF-8?q?docs:=20README.md=20=EC=97=85=EB=8D=B0?= =?UTF-8?q?=EC=9D=B4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 58 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index f8b1932..8e0b03d 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,15 @@ - 이미지는 url 검사 - url패턴을 어길 시 400 - 유저 정보 삭제 + - soft delete - 코드로 참여 + - 코드로 인증 후 토큰 반환 + - 코드는 멤버id를 aes256으로 암호화 해서 코드 생성 + - 코드를 복호화해서 검증 + - 인증 후 멤버 이메일로 토큰 생성 + - 시큐리티 토큰 생성 예외처리 + - 기존 방식으로(@RestControllerAdvice)는 스프링 시큐리티 예외처리가 안됨 + - 다른 방법 찾는중(w5) - 프로젝트(김도헌) - 프로젝트 리스트 조회 - 프로젝트 기간 리스트 조회 @@ -77,32 +85,26 @@ - 태스크별 진행도 조회 - ... --- -# Week4 이슈 -- 프로젝트 빌드 실패 - - Task의 오류 - - 컴플리트 수행시 잘못된 수정(김도헌) - - 본인이 구현한 기능을 고려하지 않고 조서영이 작성한 Task(entity)로 대치 - - @Column 부재(조서영) - - 작성한 엔티티에 @Column이 없어서 테이블 생성 실패 - - taskRepository.deleteById의 구문 오류(조서영) - - 위 함수는 Task(entity)의 id만을 입력으로 받을 수 있다. - - 하지만 Long projectId, Long taskId라는 2개의 파라미터를 제공함으로서 JpaRepository가 빌드에 실패했다. - - projectEntity 오류 - - projectEntity(entity)의 Column중 하나인 viewType의 자료형을 object로 구현 - - Object로 구현시 Hibernate가 제대로 테이블을 생성할 수 없음 - - 해결(김동혁) - - 기존 김도헌이 작성한 Task(entity)로 변경 - - 기존(조서영)이 작성한 기능이 보다 김도헌이 작성한 기능의 복잡성을 고려함 - - 기존에 구현한 Task(controller, service, repository)는 주석 처리 - - projectEntity(entity)의 viewType은 삭제 - - 다양한 차트의 형태(간트, 칸반, 플로우...)의 상태를 정의하기 위해 고려한 컬럼 - - 하지만 기능의 모호성과 차후 업데이트로 반영할 수 있다는 점을 고려해 삭제 - - 당부사항(김동혁) - - 제발 빌드 및 실행에 대한 테스트를 진행하고 커밋을 진행할 것 - - Test(entity,controller,service,repository 등)을 참조해서 구현할 것 - - 파일의 명명 규칙을 준수할 것 - - Task(x) - - TaskEntity(0) +# 피드백 +- [3주차 리뷰](https://github.com/kakao-tech-campus-2nd-step3/Team1_BE/issues/13) +- [3주차 피드백](https://github.com/kakao-tech-campus-2nd-step3/Team1_BE/pull/11) +- [4주차 리뷰](https://github.com/kakao-tech-campus-2nd-step3/Team1_BE/issues/17) +- [4주차 멘토링](https://quickest-asterisk-75d.notion.site/Back-end_-323b0e20ae2b405189ffe5b7c4242e00) --- -# Week4 질문사항 -- \ No newline at end of file +# Issue +- [week4 프로젝트 빌드 실패](https://github.com/kakao-tech-campus-2nd-step3/Team1_BE/issues/27) +--- +# 질문사항 +- week3 + - 팀원마다 코드스타일이 다른경우 통일을 하나요? + - 프로젝트 시작 시 세팅은 어느정도로 하나요? + - 현재 팀원마다 각각 domain을 1개씩 담당하여 작업을 하고 있습니다. 이러한 경우 다른 팀원이 만들어야 하는 객체를 참조해야 되는 상황일 때,(저는 그냥 구현을 해버려서 conflict가 발생했습니다.) 구현을하지 않고 mock 혹은 fake 객체를 만들어 두고 작업을 하는 편인가요? + - 보통 이 정도 규모의 프로젝트를 분업하게 되면 어떠한 기준으로 작업을 분배하나요? + - conflict resolve시의 기준이 있나요? +- week4(멘토링) + - 유저 삭제시 인증 구현 방식 + - 다양한 소셜 로그인의 유저를 특정하는 방법 + - 메일 발송 방법 + - 코드 스타일 + - 동시성 처리 +- week5 \ No newline at end of file From e404492373d009fa37b7fbe234a6770b1a1b7f57 Mon Sep 17 00:00:00 2001 From: sunandrabbit Date: Fri, 4 Oct 2024 03:12:30 +0900 Subject: [PATCH 15/51] =?UTF-8?q?feat=20:=20=ED=94=84=EB=A1=9C=EC=A0=9D?= =?UTF-8?q?=ED=8A=B8=20=EB=8D=B0=EC=9D=B4=ED=84=B0=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/team1/BE/seamless/init/InitData.java | 5 +++- .../BE/seamless/init/ProjectCreator.java | 28 +++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 src/main/java/team1/BE/seamless/init/ProjectCreator.java diff --git a/src/main/java/team1/BE/seamless/init/InitData.java b/src/main/java/team1/BE/seamless/init/InitData.java index 276e5c4..ecc4e1d 100644 --- a/src/main/java/team1/BE/seamless/init/InitData.java +++ b/src/main/java/team1/BE/seamless/init/InitData.java @@ -10,15 +10,18 @@ public class InitData { private final TestCreator testCreator; + private final ProjectCreator projectCreator; @Autowired - public InitData(TestCreator testCreator) { + public InitData(TestCreator testCreator, ProjectCreator projectCreator) { this.testCreator = testCreator; + this.projectCreator = projectCreator; } @PostConstruct public void init() { // 테스트 생성 testCreator.creator(); +// projectCreator.creator(); } } diff --git a/src/main/java/team1/BE/seamless/init/ProjectCreator.java b/src/main/java/team1/BE/seamless/init/ProjectCreator.java new file mode 100644 index 0000000..c982d6d --- /dev/null +++ b/src/main/java/team1/BE/seamless/init/ProjectCreator.java @@ -0,0 +1,28 @@ +package team1.BE.seamless.init; + +import java.time.LocalDateTime; +import java.util.List; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import team1.BE.seamless.DTO.ProjectDTO.ProjectCreate; +import team1.BE.seamless.service.ProjectService; + +@Component +public class ProjectCreator { + + private final ProjectService projectService; + + @Autowired + public ProjectCreator(ProjectService projectService) { + this.projectService = projectService; + } + + public void creator() { + projectService.createProject(new ProjectCreate("프로젝트 이름1", 1L, + LocalDateTime.of(2024,10,1,0,0,0), + LocalDateTime.of(2024,10,3,0,0,0), + List.of(1L,2L,3L)), + "이메일1" + ); + } +} From b6e0a118b214c4215186597767fbb964de0e317a Mon Sep 17 00:00:00 2001 From: sunandrabbit Date: Fri, 4 Oct 2024 03:16:17 +0900 Subject: [PATCH 16/51] =?UTF-8?q?style=20:=20=EC=BB=A8=EB=B2=A4=EC=85=98?= =?UTF-8?q?=EC=97=90=20=EB=94=B0=EB=A5=B8=20=EC=BD=94=EB=93=9C=20=EC=8A=A4?= =?UTF-8?q?=ED=83=80=EC=9D=BC=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../team1/BE/seamless/DTO/ProjectDTO.java | 12 ++---- .../controller/ProjectController.java | 42 ++++++++++--------- .../BE/seamless/entity/OptionEntity.java | 4 +- .../BE/seamless/entity/ProjectEntity.java | 2 +- .../BE/seamless/entity/ProjectOption.java | 4 +- .../seamless/repository/OptionRepository.java | 1 - .../repository/ProjectRepository.java | 5 ++- .../BE/seamless/service/ProjectService.java | 19 +++++---- 8 files changed, 45 insertions(+), 44 deletions(-) diff --git a/src/main/java/team1/BE/seamless/DTO/ProjectDTO.java b/src/main/java/team1/BE/seamless/DTO/ProjectDTO.java index ca84eb5..209ec93 100644 --- a/src/main/java/team1/BE/seamless/DTO/ProjectDTO.java +++ b/src/main/java/team1/BE/seamless/DTO/ProjectDTO.java @@ -4,10 +4,10 @@ import jakarta.validation.constraints.FutureOrPresent; import jakarta.validation.constraints.NotNull; import java.time.Duration; -import team1.BE.seamless.util.page.PageParam; import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; +import team1.BE.seamless.util.page.PageParam; public class ProjectDTO { @@ -93,7 +93,8 @@ public static class ProjectUpdate { public ProjectUpdate() { } - public ProjectUpdate(String name, List optionIds, LocalDateTime startDate, LocalDateTime endDate) { + public ProjectUpdate(String name, List optionIds, LocalDateTime startDate, + LocalDateTime endDate) { this.name = name; this.optionIds = optionIds; this.startDate = startDate; @@ -178,12 +179,5 @@ public boolean isAtLeastOneDayDifference() { } -// public interface ProjectPeriod { -// Long getId(); -// String getName(); -// LocalDateTime getStartDate(); -// LocalDateTime getEndDate(); -// } - } diff --git a/src/main/java/team1/BE/seamless/controller/ProjectController.java b/src/main/java/team1/BE/seamless/controller/ProjectController.java index 56616ae..5964203 100644 --- a/src/main/java/team1/BE/seamless/controller/ProjectController.java +++ b/src/main/java/team1/BE/seamless/controller/ProjectController.java @@ -1,9 +1,18 @@ package team1.BE.seamless.controller; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.servlet.http.HttpServletRequest; +import jakarta.validation.Valid; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpHeaders; -import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; import team1.BE.seamless.DTO.ProjectDTO; import team1.BE.seamless.DTO.ProjectDTO.ProjectPeriod; import team1.BE.seamless.entity.MemberEntity; @@ -14,17 +23,6 @@ import team1.BE.seamless.util.page.PageMapper; import team1.BE.seamless.util.page.PageResult; import team1.BE.seamless.util.page.SingleResult; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import jakarta.validation.Valid; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; @Tag(name = "프로젝트") @RestController @@ -42,8 +40,10 @@ public ProjectController(ProjectService projectService, ParsingPram parsingPram) @Operation(summary = "프로젝트 리스트 조회") @GetMapping - public PageResult getProjectList(@Valid ProjectDTO.getList param, HttpServletRequest req) { - return PageMapper.toPageResult(projectService.getProjectList(param, parsingPram.getEmail(req))); + public PageResult getProjectList(@Valid ProjectDTO.getList param, + HttpServletRequest req) { + return PageMapper.toPageResult( + projectService.getProjectList(param, parsingPram.getEmail(req))); } @Operation(summary = "프로젝트 조회") @@ -54,8 +54,10 @@ public SingleResult getProject(@Valid @PathVariable long id) { @Operation(summary = "프로젝트 기간 리스트 조회") @GetMapping("/periods") - public PageResult getProjectPeriod(@Valid ProjectDTO.getList param, HttpServletRequest req) { - return PageMapper.toPageResult(projectService.getProjectPeriod(param, parsingPram.getEmail(req))); + public PageResult getProjectPeriod(@Valid ProjectDTO.getList param, + HttpServletRequest req) { + return PageMapper.toPageResult( + projectService.getProjectPeriod(param, parsingPram.getEmail(req))); } @Operation(summary = "프로젝트 멤버 조회") @@ -66,13 +68,15 @@ public ListResult getProjectMembers(@Valid @PathVariable long id) @Operation(summary = "프로젝트 생성") @PostMapping - public SingleResult createProject(@Valid @RequestBody ProjectDTO.ProjectCreate create, HttpServletRequest req) { + public SingleResult createProject( + @Valid @RequestBody ProjectDTO.ProjectCreate create, HttpServletRequest req) { return new SingleResult<>(projectService.createProject(create, parsingPram.getEmail(req))); } @Operation(summary = "프로젝트 설정 수정") @PutMapping("/{project-id}") - public SingleResult updateProject(@Valid @RequestBody ProjectDTO.ProjectUpdate update, + public SingleResult updateProject( + @Valid @RequestBody ProjectDTO.ProjectUpdate update, @PathVariable long id) { return new SingleResult<>(projectService.updateProject(id, update)); } diff --git a/src/main/java/team1/BE/seamless/entity/OptionEntity.java b/src/main/java/team1/BE/seamless/entity/OptionEntity.java index b272cda..3b44126 100644 --- a/src/main/java/team1/BE/seamless/entity/OptionEntity.java +++ b/src/main/java/team1/BE/seamless/entity/OptionEntity.java @@ -10,7 +10,7 @@ import java.util.List; @Entity(name = "option") -public class OptionEntity extends BaseEntity{ +public class OptionEntity extends BaseEntity { public OptionEntity() { @@ -36,7 +36,7 @@ public OptionEntity(String name, String eventType) { @Column(name = "is_deleted") private boolean isDeleted; - @OneToMany(mappedBy = "optionEntity", cascade = CascadeType.ALL ) + @OneToMany(mappedBy = "optionEntity", cascade = CascadeType.ALL) private List options; public Long getId() { diff --git a/src/main/java/team1/BE/seamless/entity/ProjectEntity.java b/src/main/java/team1/BE/seamless/entity/ProjectEntity.java index 7249436..f28d0e4 100644 --- a/src/main/java/team1/BE/seamless/entity/ProjectEntity.java +++ b/src/main/java/team1/BE/seamless/entity/ProjectEntity.java @@ -15,7 +15,7 @@ import java.util.List; @Entity(name = "project") -public class ProjectEntity extends BaseEntity{ +public class ProjectEntity extends BaseEntity { public ProjectEntity() { memberEntities = new ArrayList<>(); diff --git a/src/main/java/team1/BE/seamless/entity/ProjectOption.java b/src/main/java/team1/BE/seamless/entity/ProjectOption.java index 393c186..676fddf 100644 --- a/src/main/java/team1/BE/seamless/entity/ProjectOption.java +++ b/src/main/java/team1/BE/seamless/entity/ProjectOption.java @@ -10,7 +10,7 @@ import jakarta.persistence.ManyToOne; @Entity(name = "project_option") -public class ProjectOption extends BaseEntity{ +public class ProjectOption extends BaseEntity { public ProjectOption() { @@ -22,7 +22,7 @@ public ProjectOption(String name, OptionEntity optionEntity) { this.optionEntity = optionEntity; } - public ProjectOption(String name, ProjectEntity projectEntity, OptionEntity optionEntity) { + public ProjectOption(String name, ProjectEntity projectEntity, OptionEntity optionEntity) { this.name = name; this.isDeleted = false; this.projectEntity = projectEntity; diff --git a/src/main/java/team1/BE/seamless/repository/OptionRepository.java b/src/main/java/team1/BE/seamless/repository/OptionRepository.java index e81d93d..434e80d 100644 --- a/src/main/java/team1/BE/seamless/repository/OptionRepository.java +++ b/src/main/java/team1/BE/seamless/repository/OptionRepository.java @@ -5,7 +5,6 @@ import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; import team1.BE.seamless.entity.OptionEntity; -import team1.BE.seamless.entity.ProjectEntity; @Repository public interface OptionRepository extends JpaRepository { diff --git a/src/main/java/team1/BE/seamless/repository/ProjectRepository.java b/src/main/java/team1/BE/seamless/repository/ProjectRepository.java index c1f15fc..f1adb8c 100644 --- a/src/main/java/team1/BE/seamless/repository/ProjectRepository.java +++ b/src/main/java/team1/BE/seamless/repository/ProjectRepository.java @@ -1,15 +1,16 @@ package team1.BE.seamless.repository; import java.util.Optional; -import team1.BE.seamless.DTO.ProjectDTO.ProjectPeriod; -import team1.BE.seamless.entity.ProjectEntity; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; +import team1.BE.seamless.DTO.ProjectDTO.ProjectPeriod; +import team1.BE.seamless.entity.ProjectEntity; @Repository public interface ProjectRepository extends JpaRepository { + Page findAllByUserEntityEmail(Pageable pageable, String email); Optional findById(Long id); diff --git a/src/main/java/team1/BE/seamless/service/ProjectService.java b/src/main/java/team1/BE/seamless/service/ProjectService.java index c54255f..baa794e 100644 --- a/src/main/java/team1/BE/seamless/service/ProjectService.java +++ b/src/main/java/team1/BE/seamless/service/ProjectService.java @@ -1,25 +1,25 @@ package team1.BE.seamless.service; +import java.util.List; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.http.HttpStatus; +import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import team1.BE.seamless.DTO.ProjectDTO; import team1.BE.seamless.DTO.ProjectDTO.ProjectCreate; import team1.BE.seamless.DTO.ProjectDTO.ProjectPeriod; import team1.BE.seamless.DTO.ProjectDTO.ProjectUpdate; import team1.BE.seamless.entity.MemberEntity; +import team1.BE.seamless.entity.OptionEntity; import team1.BE.seamless.entity.ProjectEntity; import team1.BE.seamless.entity.ProjectOption; -import team1.BE.seamless.entity.OptionEntity; import team1.BE.seamless.entity.UserEntity; import team1.BE.seamless.mapper.ProjectMapper; import team1.BE.seamless.repository.OptionRepository; import team1.BE.seamless.repository.ProjectRepository; import team1.BE.seamless.repository.UserRepository; import team1.BE.seamless.util.errorException.BaseHandler; -import java.util.List; -import org.springframework.data.domain.Page; -import org.springframework.http.HttpStatus; -import org.springframework.stereotype.Service; @Service public class ProjectService { @@ -67,8 +67,10 @@ public ProjectEntity createProject(ProjectCreate create, String email) { .map(optionEntity -> new ProjectOption(optionEntity.getName(), optionEntity)) .toList(); - ProjectEntity projectEntity = projectRepository.save(projectMapper.toEntity(create, userEntity, projectOptions)); - projectOptions.forEach(option -> option.setProjectEntity(projectEntity)); //ProjectOption에 Project 매핑 + ProjectEntity projectEntity = projectRepository.save( + projectMapper.toEntity(create, userEntity, projectOptions)); + projectOptions.forEach( + option -> option.setProjectEntity(projectEntity)); //ProjectOption에 Project 매핑 return projectEntity; } @@ -83,7 +85,8 @@ public ProjectEntity updateProject(long get, ProjectUpdate update) { // 새로운 옵션 추가 List optionEntities = optionRepository.findByIdIn(update.getOptionIds()); for (OptionEntity optionEntity : optionEntities) { - ProjectOption projectOption = new ProjectOption(optionEntity.getName(), projectEntity, optionEntity); + ProjectOption projectOption = new ProjectOption(optionEntity.getName(), projectEntity, + optionEntity); projectOptions.add(projectOption); } From ba50fd1073abd9dbdfc1b0f5cce98b5ccf52abd2 Mon Sep 17 00:00:00 2001 From: sunandrabbit Date: Fri, 4 Oct 2024 05:06:52 +0900 Subject: [PATCH 17/51] =?UTF-8?q?feat=20:=20user=EC=99=80=20option?= =?UTF-8?q?=EC=97=90=20=EB=8C=80=ED=95=9C=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=EB=8D=B0=EC=9D=B4=ED=84=B0=20=EC=A3=BC=EC=9E=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/team1/BE/seamless/DTO/OptionDTO.java | 29 +++++++++++++------ .../java/team1/BE/seamless/init/InitData.java | 10 +++++-- .../team1/BE/seamless/init/OptionCreator.java | 23 +++++++++++++++ .../BE/seamless/init/ProjectCreator.java | 2 +- .../team1/BE/seamless/init/UserCreator.java | 21 ++++++++++++++ .../BE/seamless/mapper/OptionMapper.java | 16 ++++++++++ .../BE/seamless/service/OptionService.java | 28 ++++++++++++++++++ .../BE/seamless/service/UserService.java | 10 +++++++ 8 files changed, 127 insertions(+), 12 deletions(-) create mode 100644 src/main/java/team1/BE/seamless/init/OptionCreator.java create mode 100644 src/main/java/team1/BE/seamless/init/UserCreator.java create mode 100644 src/main/java/team1/BE/seamless/mapper/OptionMapper.java create mode 100644 src/main/java/team1/BE/seamless/service/OptionService.java diff --git a/src/main/java/team1/BE/seamless/DTO/OptionDTO.java b/src/main/java/team1/BE/seamless/DTO/OptionDTO.java index e681f9c..cb349b7 100644 --- a/src/main/java/team1/BE/seamless/DTO/OptionDTO.java +++ b/src/main/java/team1/BE/seamless/DTO/OptionDTO.java @@ -4,18 +4,29 @@ public class OptionDTO { - private List optionNames; + public static class OptionCreate{ - public OptionDTO(List optionNames) { - this.optionNames = optionNames; - } + private String name; - public List getOptionNames() { - return optionNames; - } + private String eventType; + + public OptionCreate() { + + } + + public OptionCreate(String name, String eventType) { + this.name = name; + this.eventType = eventType; + } + + public String getName() { + return name; + } + + public String getEventType() { + return eventType; + } - public void setOptionNames(List optionNames) { - this.optionNames = optionNames; } } diff --git a/src/main/java/team1/BE/seamless/init/InitData.java b/src/main/java/team1/BE/seamless/init/InitData.java index ecc4e1d..c8fa97e 100644 --- a/src/main/java/team1/BE/seamless/init/InitData.java +++ b/src/main/java/team1/BE/seamless/init/InitData.java @@ -11,17 +11,23 @@ public class InitData { private final TestCreator testCreator; private final ProjectCreator projectCreator; + private final UserCreator userCreator; + private final OptionCreator optionCreator; @Autowired - public InitData(TestCreator testCreator, ProjectCreator projectCreator) { + public InitData(TestCreator testCreator, ProjectCreator projectCreator, UserCreator userCreator, OptionCreator optionCreator) { this.testCreator = testCreator; this.projectCreator = projectCreator; + this.userCreator = userCreator; + this.optionCreator = optionCreator; } @PostConstruct public void init() { // 테스트 생성 testCreator.creator(); -// projectCreator.creator(); + projectCreator.creator(); + userCreator.creator(); + optionCreator.creator(); } } diff --git a/src/main/java/team1/BE/seamless/init/OptionCreator.java b/src/main/java/team1/BE/seamless/init/OptionCreator.java new file mode 100644 index 0000000..bed6653 --- /dev/null +++ b/src/main/java/team1/BE/seamless/init/OptionCreator.java @@ -0,0 +1,23 @@ +package team1.BE.seamless.init; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import team1.BE.seamless.DTO.OptionDTO.OptionCreate; +import team1.BE.seamless.service.OptionService; + +@Component +public class OptionCreator { + + private final OptionService optionService; + + @Autowired + public OptionCreator(OptionService optionService) { + this.optionService = optionService; + } + + public void creator() { + optionService.createOption(new OptionCreate("옵션1", "타입1")); + optionService.createOption(new OptionCreate("옵션2", "타입1")); + optionService.createOption(new OptionCreate("옵션3", "타입2")); + } +} diff --git a/src/main/java/team1/BE/seamless/init/ProjectCreator.java b/src/main/java/team1/BE/seamless/init/ProjectCreator.java index c982d6d..8bf5eb1 100644 --- a/src/main/java/team1/BE/seamless/init/ProjectCreator.java +++ b/src/main/java/team1/BE/seamless/init/ProjectCreator.java @@ -22,7 +22,7 @@ public void creator() { LocalDateTime.of(2024,10,1,0,0,0), LocalDateTime.of(2024,10,3,0,0,0), List.of(1L,2L,3L)), - "이메일1" + "user1@google.com" ); } } diff --git a/src/main/java/team1/BE/seamless/init/UserCreator.java b/src/main/java/team1/BE/seamless/init/UserCreator.java new file mode 100644 index 0000000..fba8e27 --- /dev/null +++ b/src/main/java/team1/BE/seamless/init/UserCreator.java @@ -0,0 +1,21 @@ +package team1.BE.seamless.init; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import team1.BE.seamless.DTO.UserDTO.UserSimple; +import team1.BE.seamless.service.UserService; + +@Component +public class UserCreator { + + private final UserService userService; + + @Autowired + public UserCreator(UserService userService) { + this.userService = userService; + } + + public void creator() { + userService.createUser(new UserSimple("사용자1","user1@google.com","userImage.jpg")); + } +} diff --git a/src/main/java/team1/BE/seamless/mapper/OptionMapper.java b/src/main/java/team1/BE/seamless/mapper/OptionMapper.java new file mode 100644 index 0000000..e9ae056 --- /dev/null +++ b/src/main/java/team1/BE/seamless/mapper/OptionMapper.java @@ -0,0 +1,16 @@ +package team1.BE.seamless.mapper; + +import org.springframework.stereotype.Component; +import team1.BE.seamless.DTO.OptionDTO.OptionCreate; +import team1.BE.seamless.entity.OptionEntity; + +@Component +public class OptionMapper { + + public OptionEntity toEntity(OptionCreate create) { + return new OptionEntity( + create.getName(), + create.getEventType() + ); + } +} diff --git a/src/main/java/team1/BE/seamless/service/OptionService.java b/src/main/java/team1/BE/seamless/service/OptionService.java new file mode 100644 index 0000000..d984f56 --- /dev/null +++ b/src/main/java/team1/BE/seamless/service/OptionService.java @@ -0,0 +1,28 @@ +package team1.BE.seamless.service; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import team1.BE.seamless.DTO.OptionDTO.OptionCreate; +import team1.BE.seamless.entity.OptionEntity; +import team1.BE.seamless.mapper.OptionMapper; +import team1.BE.seamless.repository.OptionRepository; + +@Service +public class OptionService { + + private OptionRepository optionRepository; + + private OptionMapper optionMapper; + + @Autowired + public OptionService(OptionRepository optionRepository, OptionMapper optionMapper) { + this.optionRepository = optionRepository; + this.optionMapper = optionMapper; + } + + @Transactional + public OptionEntity createOption(OptionCreate create) { + return optionRepository.save(optionMapper.toEntity(create)); + } +} diff --git a/src/main/java/team1/BE/seamless/service/UserService.java b/src/main/java/team1/BE/seamless/service/UserService.java index 824b81a..10171a6 100644 --- a/src/main/java/team1/BE/seamless/service/UserService.java +++ b/src/main/java/team1/BE/seamless/service/UserService.java @@ -45,4 +45,14 @@ public UserSimple updateUser(HttpServletRequest req, @Valid UserUpdate update) { return userMapper.toUserSimple(user); } + + @Transactional + public UserEntity createUser(@Valid UserSimple simple) { + return userRepository.findByEmail(simple.getEmail()) + .orElseGet(() -> userMapper.toEntity( + simple.getUsername(), + simple.getEmail(), + simple.getPicture() + )); + } } From c477a8bfd348458b1207b7fb34c5303b8ae20fdb Mon Sep 17 00:00:00 2001 From: sunandrabbit Date: Fri, 4 Oct 2024 05:14:39 +0900 Subject: [PATCH 18/51] =?UTF-8?q?fix=20:=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=EB=8D=B0=EC=9D=B4=ED=84=B0=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/team1/BE/seamless/init/InitData.java | 2 +- src/main/java/team1/BE/seamless/init/UserCreator.java | 2 +- src/main/java/team1/BE/seamless/service/UserService.java | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/team1/BE/seamless/init/InitData.java b/src/main/java/team1/BE/seamless/init/InitData.java index c8fa97e..37d1ad5 100644 --- a/src/main/java/team1/BE/seamless/init/InitData.java +++ b/src/main/java/team1/BE/seamless/init/InitData.java @@ -26,8 +26,8 @@ public InitData(TestCreator testCreator, ProjectCreator projectCreator, UserCrea public void init() { // 테스트 생성 testCreator.creator(); - projectCreator.creator(); userCreator.creator(); optionCreator.creator(); + projectCreator.creator(); } } diff --git a/src/main/java/team1/BE/seamless/init/UserCreator.java b/src/main/java/team1/BE/seamless/init/UserCreator.java index fba8e27..a52969d 100644 --- a/src/main/java/team1/BE/seamless/init/UserCreator.java +++ b/src/main/java/team1/BE/seamless/init/UserCreator.java @@ -16,6 +16,6 @@ public UserCreator(UserService userService) { } public void creator() { - userService.createUser(new UserSimple("사용자1","user1@google.com","userImage.jpg")); + userService.createUser(new UserSimple("사용자1","user1@google.com","user1Image.jpg")); } } diff --git a/src/main/java/team1/BE/seamless/service/UserService.java b/src/main/java/team1/BE/seamless/service/UserService.java index 10171a6..d615848 100644 --- a/src/main/java/team1/BE/seamless/service/UserService.java +++ b/src/main/java/team1/BE/seamless/service/UserService.java @@ -49,10 +49,11 @@ public UserSimple updateUser(HttpServletRequest req, @Valid UserUpdate update) { @Transactional public UserEntity createUser(@Valid UserSimple simple) { return userRepository.findByEmail(simple.getEmail()) - .orElseGet(() -> userMapper.toEntity( + .orElseGet(() -> userRepository.save( + userMapper.toEntity( simple.getUsername(), simple.getEmail(), simple.getPicture() - )); + ))); } } From f4a435be891dbf25824c7cacdde25883af108dff Mon Sep 17 00:00:00 2001 From: suno-boy Date: Fri, 4 Oct 2024 10:55:12 +0900 Subject: [PATCH 19/51] =?UTF-8?q?test:=20push=ED=85=8C=EC=8A=A4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/team1/BE/seamless/DTO/MemberRequestDTO.java | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 src/main/java/team1/BE/seamless/DTO/MemberRequestDTO.java diff --git a/src/main/java/team1/BE/seamless/DTO/MemberRequestDTO.java b/src/main/java/team1/BE/seamless/DTO/MemberRequestDTO.java new file mode 100644 index 0000000..6413fe1 --- /dev/null +++ b/src/main/java/team1/BE/seamless/DTO/MemberRequestDTO.java @@ -0,0 +1,4 @@ +package team1.BE.seamless.DTO; + +public class MemberRequestDTO { +} From 2db2280b95fb374dcda7722d69a2aa7fa168f46b Mon Sep 17 00:00:00 2001 From: suno-boy Date: Fri, 4 Oct 2024 10:56:29 +0900 Subject: [PATCH 20/51] test --- src/main/java/team1/BE/seamless/DTO/MemberRequestDTO.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/team1/BE/seamless/DTO/MemberRequestDTO.java b/src/main/java/team1/BE/seamless/DTO/MemberRequestDTO.java index 6413fe1..2084a4f 100644 --- a/src/main/java/team1/BE/seamless/DTO/MemberRequestDTO.java +++ b/src/main/java/team1/BE/seamless/DTO/MemberRequestDTO.java @@ -1,4 +1,5 @@ package team1.BE.seamless.DTO; public class MemberRequestDTO { + } From 97ebea60d72bad16ace4bc2c2823106b13d6970f Mon Sep 17 00:00:00 2001 From: seoyoung-dev Date: Thu, 3 Oct 2024 16:57:39 +0900 Subject: [PATCH 21/51] =?UTF-8?q?feat:=20isDeleted=20=EC=86=8D=EC=84=B1=20?= =?UTF-8?q?Boolean=20=ED=83=80=EC=9E=85=EC=9C=BC=EB=A1=9C=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/team1/BE/seamless/DTO/TaskDTO.java | 6 +++--- .../java/team1/BE/seamless/entity/TaskEntity.java | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/java/team1/BE/seamless/DTO/TaskDTO.java b/src/main/java/team1/BE/seamless/DTO/TaskDTO.java index 70c0b00..ef1c782 100644 --- a/src/main/java/team1/BE/seamless/DTO/TaskDTO.java +++ b/src/main/java/team1/BE/seamless/DTO/TaskDTO.java @@ -19,7 +19,7 @@ public class TaskDTO { @Min(value = 0, message = "삭제 여부는 0 또는 1입니다.") @Max(value = 1, message = "삭제 여부는 0 또는 1입니다.") - private Integer isDeleted; + private Boolean isDeleted; @NotNull(message = "프로젝트 아아디는 필수 입력 사항입니다.") private Long projectId; @@ -33,7 +33,7 @@ public class TaskDTO { @NotNull(message = "종료 시간은 필수 입력 사항입니다.") private LocalDateTime endDate; - public TaskDTO(String name, String remark, Integer progress, Integer isDeleted, Long projectId, + public TaskDTO(String name, String remark, Integer progress, Boolean isDeleted, Long projectId, Long ownerId, LocalDateTime startDate, LocalDateTime endDate) { this.name = name; this.remark = remark; @@ -57,7 +57,7 @@ public Integer getProgress() { return progress; } - public Integer getIsDeleted() { + public Boolean getIsDeleted() { return isDeleted; } diff --git a/src/main/java/team1/BE/seamless/entity/TaskEntity.java b/src/main/java/team1/BE/seamless/entity/TaskEntity.java index efb02be..0a0de80 100644 --- a/src/main/java/team1/BE/seamless/entity/TaskEntity.java +++ b/src/main/java/team1/BE/seamless/entity/TaskEntity.java @@ -18,12 +18,12 @@ public TaskEntity() { } - public TaskEntity(String name, String remark, Integer progress, Integer isDelete, ProjectEntity projectEntity, + public TaskEntity(String name, String remark, Integer progress, Boolean isDeleted, ProjectEntity projectEntity, MemberEntity owner, LocalDateTime startDate, LocalDateTime endDate) { this.name = name; this.remark = remark; this.progress = progress; - this.isDelete = isDelete; + this.isDeleted = isDeleted; this.projectEntity = projectEntity; this.owner = owner; this.startDate = startDate; @@ -44,8 +44,8 @@ public TaskEntity(String name, String remark, Integer progress, Integer isDelete @Column(name = "progress") private Integer progress; - @Column(name = "is_delete") - private Integer isDelete; + @Column(name = "is_deleted") + private Boolean isDeleted; @OneToOne(fetch = FetchType.LAZY) @JoinColumn(name = "project_id") @@ -77,8 +77,8 @@ public Integer getProgress() { return progress; } - public Integer getIsDelete() { - return isDelete; + public Boolean getIsDelete() { + return isDeleted; } public ProjectEntity getProject() { From ec554b8bec77e71e194862ef041d6a31666bfe8f Mon Sep 17 00:00:00 2001 From: seoyoung-dev Date: Thu, 3 Oct 2024 16:59:33 +0900 Subject: [PATCH 22/51] =?UTF-8?q?feat:=20=ED=83=9C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C=20=EC=8B=9C=20=EC=95=84=EC=9D=B4=EB=94=94=20?= =?UTF-8?q?=EB=B0=98=ED=99=98=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BE/seamless/controller/TaskController.java | 9 ++++----- .../team1/BE/seamless/service/TaskService.java | 16 ++++++++++------ 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/main/java/team1/BE/seamless/controller/TaskController.java b/src/main/java/team1/BE/seamless/controller/TaskController.java index 56d36f6..d08aa98 100644 --- a/src/main/java/team1/BE/seamless/controller/TaskController.java +++ b/src/main/java/team1/BE/seamless/controller/TaskController.java @@ -1,7 +1,6 @@ package team1.BE.seamless.controller; import jakarta.validation.Valid; -import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import team1.BE.seamless.DTO.TaskDTO; @@ -12,7 +11,6 @@ import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import team1.BE.seamless.util.page.ListResult; import team1.BE.seamless.util.page.SingleResult; @RestController @@ -25,13 +23,14 @@ public class TaskController { public TaskController(TaskService taskService) { this.taskService = taskService; } + @PostMapping("/{projectId}/task") public SingleResult createTask(@Valid @RequestBody TaskDTO req) { return new SingleResult<>(taskService.createTask(req)); } - @DeleteMapping - public void deleteTask(@PathVariable Long taskId) { - taskService.deleteTask(taskId); + @DeleteMapping("/task/{taskId}") + public SingleResult deleteTask(@PathVariable Long taskId) { + return new SingleResult<>(taskService.deleteTask(taskId)); } } \ No newline at end of file diff --git a/src/main/java/team1/BE/seamless/service/TaskService.java b/src/main/java/team1/BE/seamless/service/TaskService.java index c4bcf22..a01442f 100644 --- a/src/main/java/team1/BE/seamless/service/TaskService.java +++ b/src/main/java/team1/BE/seamless/service/TaskService.java @@ -7,6 +7,7 @@ import team1.BE.seamless.entity.MemberEntity; import team1.BE.seamless.entity.ProjectEntity; import team1.BE.seamless.entity.TaskEntity; +import team1.BE.seamless.repository.MemberRepository; import team1.BE.seamless.repository.ProjectRepository; import team1.BE.seamless.repository.TaskRepository; import team1.BE.seamless.util.errorException.BaseHandler; @@ -16,18 +17,19 @@ public class TaskService { private final TaskRepository taskRepository; private final ProjectRepository projectRepository; + private final MemberRepository memberRepository; @Autowired - public TaskService(TaskRepository taskRepository, ProjectRepository projectRepository) { + public TaskService(TaskRepository taskRepository, ProjectRepository projectRepository, MemberRepository memberRepository) { this.taskRepository = taskRepository; this.projectRepository = projectRepository; + this.memberRepository = memberRepository; } public TaskEntity createTask(TaskDTO req) { ProjectEntity projectEntity = projectRepository.findById(req.getProjectId()).orElseThrow(() -> new BaseHandler(HttpStatus.NOT_FOUND, "존재하지 않는 프로젝트")); - // Guest 기능 구현 이전 이기 때문에 Mock 데이터로 구현 - MemberEntity guestEntity = new MemberEntity("test@gmail.com", "1", 0, projectEntity); + MemberEntity memberEntity = memberRepository.findById(req.getOwnerId()).orElseThrow(() -> new BaseHandler(HttpStatus.NOT_FOUND, "존재하지 않는 멤버")); TaskEntity taskEntity = new TaskEntity( req.getName(), @@ -35,7 +37,7 @@ public TaskEntity createTask(TaskDTO req) { req.getProgress(), req.getIsDeleted(), projectEntity, - guestEntity, + memberEntity, req.getStartDate(), req.getEndDate() ); @@ -44,10 +46,12 @@ public TaskEntity createTask(TaskDTO req) { return taskEntity; } - public void deleteTask(Long taskId) { + public Long deleteTask(Long taskId) { TaskEntity taskEntity = taskRepository.findById(taskId) .orElseThrow(() -> new BaseHandler(HttpStatus.NOT_FOUND, "존재하지 않는 태스크")); - taskRepository.delete(taskEntity); + + return taskEntity.getId(); } + } From 23cf5aba47077fd02db072ffc0df034521bee903 Mon Sep 17 00:00:00 2001 From: seoyoung-dev Date: Thu, 3 Oct 2024 17:59:32 +0900 Subject: [PATCH 23/51] =?UTF-8?q?feat:=20isDeleted,=20progress=20=EC=86=8D?= =?UTF-8?q?=EC=84=B1=20=EC=97=94=ED=8B=B0=ED=8B=B0=20=EC=83=9D=EC=84=B1?= =?UTF-8?q?=EC=8B=9C=20=EA=B8=B0=EB=B3=B8=EA=B0=92=200=EC=9C=BC=EB=A1=9C?= =?UTF-8?q?=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/team1/BE/seamless/DTO/TaskDTO.java | 7 +++---- src/main/java/team1/BE/seamless/entity/TaskEntity.java | 6 +++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/main/java/team1/BE/seamless/DTO/TaskDTO.java b/src/main/java/team1/BE/seamless/DTO/TaskDTO.java index ef1c782..cba28bf 100644 --- a/src/main/java/team1/BE/seamless/DTO/TaskDTO.java +++ b/src/main/java/team1/BE/seamless/DTO/TaskDTO.java @@ -33,12 +33,11 @@ public class TaskDTO { @NotNull(message = "종료 시간은 필수 입력 사항입니다.") private LocalDateTime endDate; - public TaskDTO(String name, String remark, Integer progress, Boolean isDeleted, Long projectId, - Long ownerId, LocalDateTime startDate, LocalDateTime endDate) { + public TaskDTO(String name, String remark, Long projectId, Long ownerId, LocalDateTime startDate, LocalDateTime endDate) { this.name = name; this.remark = remark; - this.progress = progress; - this.isDeleted = isDeleted; + this.progress = 0; + this.isDeleted = false; this.projectId = projectId; this.ownerId = ownerId; this.startDate = startDate; diff --git a/src/main/java/team1/BE/seamless/entity/TaskEntity.java b/src/main/java/team1/BE/seamless/entity/TaskEntity.java index 0a0de80..e0468e2 100644 --- a/src/main/java/team1/BE/seamless/entity/TaskEntity.java +++ b/src/main/java/team1/BE/seamless/entity/TaskEntity.java @@ -42,10 +42,10 @@ public TaskEntity(String name, String remark, Integer progress, Boolean isDelete private String remark; @Column(name = "progress") - private Integer progress; + private Integer progress = 0; @Column(name = "is_deleted") - private Boolean isDeleted; + private Boolean isDeleted = false; @OneToOne(fetch = FetchType.LAZY) @JoinColumn(name = "project_id") @@ -77,7 +77,7 @@ public Integer getProgress() { return progress; } - public Boolean getIsDelete() { + public Boolean getIsDeleted() { return isDeleted; } From c243e5cbfea2af996adad8a48ea9581a6ce9e7fe Mon Sep 17 00:00:00 2001 From: seoyoung-dev Date: Thu, 3 Oct 2024 21:49:51 +0900 Subject: [PATCH 24/51] =?UTF-8?q?feat:=20=ED=83=9C=EC=8A=A4=ED=81=AC=20?= =?UTF-8?q?=EC=97=94=ED=8B=B0=ED=8B=B0=20=EC=83=9D=EC=84=B1=20=EC=8B=9C=20?= =?UTF-8?q?mapper=20=EC=82=AC=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../team1/BE/seamless/entity/TaskEntity.java | 19 +++++++++++++++---- .../team1/BE/seamless/mapper/TaskMapper.java | 16 ++++++++++++++++ 2 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 src/main/java/team1/BE/seamless/mapper/TaskMapper.java diff --git a/src/main/java/team1/BE/seamless/entity/TaskEntity.java b/src/main/java/team1/BE/seamless/entity/TaskEntity.java index e0468e2..6a89ae3 100644 --- a/src/main/java/team1/BE/seamless/entity/TaskEntity.java +++ b/src/main/java/team1/BE/seamless/entity/TaskEntity.java @@ -18,18 +18,29 @@ public TaskEntity() { } - public TaskEntity(String name, String remark, Integer progress, Boolean isDeleted, ProjectEntity projectEntity, - MemberEntity owner, LocalDateTime startDate, LocalDateTime endDate) { + public TaskEntity(String name, String remark, ProjectEntity projectEntity, MemberEntity owner, LocalDateTime startDate, LocalDateTime endDate) { this.name = name; this.remark = remark; - this.progress = progress; - this.isDeleted = isDeleted; + this.progress = 0; + this.isDeleted = false; this.projectEntity = projectEntity; this.owner = owner; this.startDate = startDate; this.endDate = endDate; } +// public TaskEntity(String name, String remark, Integer progress, Boolean isDeleted, ProjectEntity projectEntity, +// MemberEntity owner, LocalDateTime startDate, LocalDateTime endDate) { +// this.name = name; +// this.remark = remark; +// this.progress = progress; +// this.isDeleted = isDeleted; +// this.projectEntity = projectEntity; +// this.owner = owner; +// this.startDate = startDate; +// this.endDate = endDate; +// } + @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "task_id") diff --git a/src/main/java/team1/BE/seamless/mapper/TaskMapper.java b/src/main/java/team1/BE/seamless/mapper/TaskMapper.java new file mode 100644 index 0000000..540dd0c --- /dev/null +++ b/src/main/java/team1/BE/seamless/mapper/TaskMapper.java @@ -0,0 +1,16 @@ +package team1.BE.seamless.mapper; + +import java.time.LocalDateTime; +import org.springframework.stereotype.Component; +import team1.BE.seamless.entity.MemberEntity; +import team1.BE.seamless.entity.ProjectEntity; +import team1.BE.seamless.entity.TaskEntity; + +@Component +public class TaskMapper { + + public TaskEntity toEntity(String name, String remark, ProjectEntity projectEntity, + MemberEntity memberEntity, LocalDateTime startDate, LocalDateTime endDate) { + return new TaskEntity(name, remark, projectEntity, memberEntity, startDate, endDate); + } +} From ee1ef9c04a98508ff37b8169e66125d5cc30d07a Mon Sep 17 00:00:00 2001 From: seoyoung-dev Date: Thu, 3 Oct 2024 21:50:23 +0900 Subject: [PATCH 25/51] =?UTF-8?q?feat:=20=ED=94=84=EB=A1=9C=EC=A0=9D?= =?UTF-8?q?=ED=8A=B8=EC=99=80=20=ED=83=9C=EC=8A=A4=ED=81=AC=20=EA=B4=80?= =?UTF-8?q?=EA=B3=84=20=EC=9D=BC=EB=8C=80=EB=8B=A4=EB=A1=9C=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/team1/BE/seamless/service/TaskService.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/team1/BE/seamless/service/TaskService.java b/src/main/java/team1/BE/seamless/service/TaskService.java index a01442f..53567db 100644 --- a/src/main/java/team1/BE/seamless/service/TaskService.java +++ b/src/main/java/team1/BE/seamless/service/TaskService.java @@ -7,6 +7,7 @@ import team1.BE.seamless.entity.MemberEntity; import team1.BE.seamless.entity.ProjectEntity; import team1.BE.seamless.entity.TaskEntity; +import team1.BE.seamless.mapper.TaskMapper; import team1.BE.seamless.repository.MemberRepository; import team1.BE.seamless.repository.ProjectRepository; import team1.BE.seamless.repository.TaskRepository; @@ -18,12 +19,14 @@ public class TaskService { private final TaskRepository taskRepository; private final ProjectRepository projectRepository; private final MemberRepository memberRepository; + private final TaskMapper taskMapper; @Autowired - public TaskService(TaskRepository taskRepository, ProjectRepository projectRepository, MemberRepository memberRepository) { + public TaskService(TaskRepository taskRepository, ProjectRepository projectRepository, MemberRepository memberRepository, TaskMapper taskMapper) { this.taskRepository = taskRepository; this.projectRepository = projectRepository; this.memberRepository = memberRepository; + this.taskMapper = taskMapper; } public TaskEntity createTask(TaskDTO req) { @@ -31,11 +34,9 @@ public TaskEntity createTask(TaskDTO req) { MemberEntity memberEntity = memberRepository.findById(req.getOwnerId()).orElseThrow(() -> new BaseHandler(HttpStatus.NOT_FOUND, "존재하지 않는 멤버")); - TaskEntity taskEntity = new TaskEntity( + TaskEntity taskEntity = taskMapper.toEntity( req.getName(), req.getRemark(), - req.getProgress(), - req.getIsDeleted(), projectEntity, memberEntity, req.getStartDate(), From 693c91309493cce3fb92fdb839efabd5c4a10989 Mon Sep 17 00:00:00 2001 From: seoyoung-dev Date: Thu, 3 Oct 2024 21:57:25 +0900 Subject: [PATCH 26/51] =?UTF-8?q?feat:=20(=EC=9E=AC=EC=BB=A4=EB=B0=8B)=20?= =?UTF-8?q?=ED=94=84=EB=A1=9C=EC=A0=9D=ED=8A=B8=EC=99=80=20=ED=83=9C?= =?UTF-8?q?=EC=8A=A4=ED=81=AC=20=EA=B4=80=EA=B3=84=20=EC=9D=BC=EB=8C=80?= =?UTF-8?q?=EB=8B=A4=EB=A1=9C=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/team1/BE/seamless/entity/TaskEntity.java | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/src/main/java/team1/BE/seamless/entity/TaskEntity.java b/src/main/java/team1/BE/seamless/entity/TaskEntity.java index 6a89ae3..2547cfc 100644 --- a/src/main/java/team1/BE/seamless/entity/TaskEntity.java +++ b/src/main/java/team1/BE/seamless/entity/TaskEntity.java @@ -8,7 +8,6 @@ import jakarta.persistence.Id; import jakarta.persistence.JoinColumn; import jakarta.persistence.ManyToOne; -import jakarta.persistence.OneToOne; import java.time.LocalDateTime; @Entity(name = "task") @@ -29,18 +28,6 @@ public TaskEntity(String name, String remark, ProjectEntity projectEntity, Membe this.endDate = endDate; } -// public TaskEntity(String name, String remark, Integer progress, Boolean isDeleted, ProjectEntity projectEntity, -// MemberEntity owner, LocalDateTime startDate, LocalDateTime endDate) { -// this.name = name; -// this.remark = remark; -// this.progress = progress; -// this.isDeleted = isDeleted; -// this.projectEntity = projectEntity; -// this.owner = owner; -// this.startDate = startDate; -// this.endDate = endDate; -// } - @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "task_id") @@ -58,7 +45,7 @@ public TaskEntity(String name, String remark, ProjectEntity projectEntity, Membe @Column(name = "is_deleted") private Boolean isDeleted = false; - @OneToOne(fetch = FetchType.LAZY) + @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "project_id") private ProjectEntity projectEntity; From 3759243c5c36a63999730867c5e418b963940874 Mon Sep 17 00:00:00 2001 From: seoyoung-dev Date: Fri, 4 Oct 2024 00:09:26 +0900 Subject: [PATCH 27/51] =?UTF-8?q?feat:=20=ED=94=84=EB=A1=9C=EC=A0=9D?= =?UTF-8?q?=ED=8A=B8=20ID=EB=A1=9C=20=ED=83=9C=EC=8A=A4=ED=81=AC=20?= =?UTF-8?q?=EB=A6=AC=EC=8A=A4=ED=8A=B8=20=EC=A1=B0=ED=9A=8C=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../team1/BE/seamless/controller/TaskController.java | 8 ++++++++ .../team1/BE/seamless/repository/TaskRepository.java | 4 ++++ src/main/java/team1/BE/seamless/service/TaskService.java | 9 ++++++++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/main/java/team1/BE/seamless/controller/TaskController.java b/src/main/java/team1/BE/seamless/controller/TaskController.java index d08aa98..bbb4f9b 100644 --- a/src/main/java/team1/BE/seamless/controller/TaskController.java +++ b/src/main/java/team1/BE/seamless/controller/TaskController.java @@ -1,6 +1,8 @@ package team1.BE.seamless.controller; import jakarta.validation.Valid; +import java.util.List; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import team1.BE.seamless.DTO.TaskDTO; @@ -24,6 +26,12 @@ public TaskController(TaskService taskService) { this.taskService = taskService; } + @GetMapping("/{projectId}/task") + public List getTaskList(@PathVariable Long projectId) { + List taskList = taskService.getTaskList(projectId); + return taskList; + } + @PostMapping("/{projectId}/task") public SingleResult createTask(@Valid @RequestBody TaskDTO req) { return new SingleResult<>(taskService.createTask(req)); diff --git a/src/main/java/team1/BE/seamless/repository/TaskRepository.java b/src/main/java/team1/BE/seamless/repository/TaskRepository.java index cdc4cdc..7a63c9e 100644 --- a/src/main/java/team1/BE/seamless/repository/TaskRepository.java +++ b/src/main/java/team1/BE/seamless/repository/TaskRepository.java @@ -1,9 +1,13 @@ package team1.BE.seamless.repository; +import java.util.List; +import team1.BE.seamless.entity.ProjectEntity; import team1.BE.seamless.entity.TaskEntity; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; @Repository public interface TaskRepository extends JpaRepository { + + List findByProjectEntity(ProjectEntity projectEntity); } diff --git a/src/main/java/team1/BE/seamless/service/TaskService.java b/src/main/java/team1/BE/seamless/service/TaskService.java index 53567db..7e7994b 100644 --- a/src/main/java/team1/BE/seamless/service/TaskService.java +++ b/src/main/java/team1/BE/seamless/service/TaskService.java @@ -1,5 +1,6 @@ package team1.BE.seamless.service; +import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Service; @@ -29,6 +30,12 @@ public TaskService(TaskRepository taskRepository, ProjectRepository projectRepos this.taskMapper = taskMapper; } + public List getTaskList(Long projectId) { + ProjectEntity projectEntity = projectRepository.findById(projectId).orElseThrow(() -> new BaseHandler(HttpStatus.NOT_FOUND, "존재하지 않는 프로젝트")); + + return taskRepository.findByProjectEntity(projectEntity); + } + public TaskEntity createTask(TaskDTO req) { ProjectEntity projectEntity = projectRepository.findById(req.getProjectId()).orElseThrow(() -> new BaseHandler(HttpStatus.NOT_FOUND, "존재하지 않는 프로젝트")); @@ -50,8 +57,8 @@ public TaskEntity createTask(TaskDTO req) { public Long deleteTask(Long taskId) { TaskEntity taskEntity = taskRepository.findById(taskId) .orElseThrow(() -> new BaseHandler(HttpStatus.NOT_FOUND, "존재하지 않는 태스크")); - taskRepository.delete(taskEntity); + taskRepository.delete(taskEntity); return taskEntity.getId(); } From 1831dc262df60670788278aa9bdc90e967814c9e Mon Sep 17 00:00:00 2001 From: seoyoung-dev Date: Fri, 4 Oct 2024 01:58:51 +0900 Subject: [PATCH 28/51] =?UTF-8?q?feat:=20=ED=83=9C=EC=8A=A4=ED=81=AC=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../seamless/controller/TaskController.java | 13 +++++++--- .../team1/BE/seamless/entity/TaskEntity.java | 25 +++++++++++++++++-- .../BE/seamless/service/TaskService.java | 25 ++++++++++++++++++- 3 files changed, 56 insertions(+), 7 deletions(-) diff --git a/src/main/java/team1/BE/seamless/controller/TaskController.java b/src/main/java/team1/BE/seamless/controller/TaskController.java index bbb4f9b..091bc3b 100644 --- a/src/main/java/team1/BE/seamless/controller/TaskController.java +++ b/src/main/java/team1/BE/seamless/controller/TaskController.java @@ -1,9 +1,9 @@ package team1.BE.seamless.controller; import jakarta.validation.Valid; -import java.util.List; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; import team1.BE.seamless.DTO.TaskDTO; import team1.BE.seamless.entity.TaskEntity; @@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import team1.BE.seamless.util.page.ListResult; import team1.BE.seamless.util.page.SingleResult; @RestController @@ -27,9 +28,8 @@ public TaskController(TaskService taskService) { } @GetMapping("/{projectId}/task") - public List getTaskList(@PathVariable Long projectId) { - List taskList = taskService.getTaskList(projectId); - return taskList; + public ListResult getTaskList(@PathVariable Long projectId) { + return new ListResult<>(taskService.getTaskList(projectId)); } @PostMapping("/{projectId}/task") @@ -37,6 +37,11 @@ public SingleResult createTask(@Valid @RequestBody TaskDTO req) { return new SingleResult<>(taskService.createTask(req)); } + @PutMapping("/task/{taskId}") + public SingleResult updateTask(@PathVariable Long taskId, @Valid @RequestBody TaskDTO req) { + return new SingleResult<>(taskService.updateTask(taskId, req)); + } + @DeleteMapping("/task/{taskId}") public SingleResult deleteTask(@PathVariable Long taskId) { return new SingleResult<>(taskService.deleteTask(taskId)); diff --git a/src/main/java/team1/BE/seamless/entity/TaskEntity.java b/src/main/java/team1/BE/seamless/entity/TaskEntity.java index 2547cfc..2104678 100644 --- a/src/main/java/team1/BE/seamless/entity/TaskEntity.java +++ b/src/main/java/team1/BE/seamless/entity/TaskEntity.java @@ -17,7 +17,8 @@ public TaskEntity() { } - public TaskEntity(String name, String remark, ProjectEntity projectEntity, MemberEntity owner, LocalDateTime startDate, LocalDateTime endDate) { + public TaskEntity(String name, String remark, ProjectEntity projectEntity, MemberEntity owner, + LocalDateTime startDate, LocalDateTime endDate) { this.name = name; this.remark = remark; this.progress = 0; @@ -28,6 +29,19 @@ public TaskEntity(String name, String remark, ProjectEntity projectEntity, Membe this.endDate = endDate; } + public TaskEntity(String name, String remark, Integer progress, Boolean isDeleted, + ProjectEntity projectEntity, MemberEntity owner, LocalDateTime startDate, + LocalDateTime endDate) { + this.name = name; + this.remark = remark; + this.progress = progress; + this.isDeleted = isDeleted; + this.projectEntity = projectEntity; + this.owner = owner; + this.startDate = startDate; + this.endDate = endDate; + } + @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "task_id") @@ -50,7 +64,7 @@ public TaskEntity(String name, String remark, ProjectEntity projectEntity, Membe private ProjectEntity projectEntity; @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "guest_id") + @JoinColumn(name = "member_id") private MemberEntity owner; @Column(name = "start_date") @@ -103,4 +117,11 @@ public void setProject(ProjectEntity projectEntity) { this.projectEntity = projectEntity; } + public TaskEntity update(String name, String remark, Integer progress, Boolean isDeleted, + ProjectEntity projectEntity, MemberEntity owner, LocalDateTime startDate, + LocalDateTime endDate) { + return new TaskEntity(name, remark, progress, isDeleted, projectEntity, owner, startDate, + endDate); + } + } diff --git a/src/main/java/team1/BE/seamless/service/TaskService.java b/src/main/java/team1/BE/seamless/service/TaskService.java index 7e7994b..f0b6118 100644 --- a/src/main/java/team1/BE/seamless/service/TaskService.java +++ b/src/main/java/team1/BE/seamless/service/TaskService.java @@ -4,6 +4,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import team1.BE.seamless.DTO.TaskDTO; import team1.BE.seamless.entity.MemberEntity; import team1.BE.seamless.entity.ProjectEntity; @@ -54,6 +55,29 @@ public TaskEntity createTask(TaskDTO req) { return taskEntity; } + @Transactional + public TaskEntity updateTask(Long taskId, TaskDTO req) { + TaskEntity taskEntity = taskRepository.findById(taskId).orElseThrow(() -> new BaseHandler(HttpStatus.NOT_FOUND, "존재하지 않는 태스크")); + + ProjectEntity projectEntity = projectRepository.findById(req.getProjectId()).orElseThrow(() -> new BaseHandler(HttpStatus.NOT_FOUND, "존재하지 않는 프로젝트")); + + MemberEntity memberEntity = memberRepository.findById(req.getOwnerId()).orElseThrow(() -> new BaseHandler(HttpStatus.NOT_FOUND, "존재하지 않는 멤버")); + + TaskEntity updatedTask = taskEntity.update( + req.getName(), + req.getRemark(), + req.getProgress(), + req.getIsDeleted(), + projectEntity, + memberEntity, + req.getStartDate(), + req.getEndDate() + ); + + taskRepository.save(updatedTask); + return updatedTask; + } + public Long deleteTask(Long taskId) { TaskEntity taskEntity = taskRepository.findById(taskId) .orElseThrow(() -> new BaseHandler(HttpStatus.NOT_FOUND, "존재하지 않는 태스크")); @@ -61,5 +85,4 @@ public Long deleteTask(Long taskId) { taskRepository.delete(taskEntity); return taskEntity.getId(); } - } From d4eb04e47072052704e737a46081f4be8dc993c2 Mon Sep 17 00:00:00 2001 From: seoyoung-dev Date: Fri, 4 Oct 2024 02:04:37 +0900 Subject: [PATCH 29/51] =?UTF-8?q?feat:=20=ED=83=9C=EC=8A=A4=ED=81=AC=20?= =?UTF-8?q?=EB=8B=A8=EA=B1=B4=20=EC=A1=B0=ED=9A=8C=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/team1/BE/seamless/controller/TaskController.java | 5 +++++ src/main/java/team1/BE/seamless/service/TaskService.java | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/team1/BE/seamless/controller/TaskController.java b/src/main/java/team1/BE/seamless/controller/TaskController.java index 091bc3b..2f621bf 100644 --- a/src/main/java/team1/BE/seamless/controller/TaskController.java +++ b/src/main/java/team1/BE/seamless/controller/TaskController.java @@ -27,6 +27,11 @@ public TaskController(TaskService taskService) { this.taskService = taskService; } + @GetMapping("/task/{taskId}") + public SingleResult getTask(@PathVariable Long taskId) { + return new SingleResult<>(taskService.getTask(taskId)); + } + @GetMapping("/{projectId}/task") public ListResult getTaskList(@PathVariable Long projectId) { return new ListResult<>(taskService.getTaskList(projectId)); diff --git a/src/main/java/team1/BE/seamless/service/TaskService.java b/src/main/java/team1/BE/seamless/service/TaskService.java index f0b6118..27105b5 100644 --- a/src/main/java/team1/BE/seamless/service/TaskService.java +++ b/src/main/java/team1/BE/seamless/service/TaskService.java @@ -31,6 +31,10 @@ public TaskService(TaskRepository taskRepository, ProjectRepository projectRepos this.taskMapper = taskMapper; } + public TaskEntity getTask(Long taskId) { + return taskRepository.findById(taskId).orElseThrow(() -> new BaseHandler(HttpStatus.NOT_FOUND, "존재하지 않는 태스크")); + } + public List getTaskList(Long projectId) { ProjectEntity projectEntity = projectRepository.findById(projectId).orElseThrow(() -> new BaseHandler(HttpStatus.NOT_FOUND, "존재하지 않는 프로젝트")); @@ -85,4 +89,4 @@ public Long deleteTask(Long taskId) { taskRepository.delete(taskEntity); return taskEntity.getId(); } -} +} \ No newline at end of file From 3aec562d90ace3ea38c61d2afda50097665c4a78 Mon Sep 17 00:00:00 2001 From: seoyoung-dev Date: Fri, 4 Oct 2024 02:54:32 +0900 Subject: [PATCH 30/51] =?UTF-8?q?feat:=20swagger=20=EC=84=A4=EB=AA=85=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/team1/BE/seamless/controller/TaskController.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/team1/BE/seamless/controller/TaskController.java b/src/main/java/team1/BE/seamless/controller/TaskController.java index 2f621bf..b2a33ac 100644 --- a/src/main/java/team1/BE/seamless/controller/TaskController.java +++ b/src/main/java/team1/BE/seamless/controller/TaskController.java @@ -1,5 +1,7 @@ package team1.BE.seamless.controller; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; @@ -16,6 +18,7 @@ import team1.BE.seamless.util.page.ListResult; import team1.BE.seamless.util.page.SingleResult; +@Tag(name = "태스크") @RestController @RequestMapping("/api/project") public class TaskController { @@ -27,26 +30,31 @@ public TaskController(TaskService taskService) { this.taskService = taskService; } + @Operation(summary = "태스크 단건 조회") @GetMapping("/task/{taskId}") public SingleResult getTask(@PathVariable Long taskId) { return new SingleResult<>(taskService.getTask(taskId)); } + @Operation(summary = "프로젝트 아이디로 태스크 리스트 조회 ") @GetMapping("/{projectId}/task") public ListResult getTaskList(@PathVariable Long projectId) { return new ListResult<>(taskService.getTaskList(projectId)); } + @Operation(summary = "태스크 생성") @PostMapping("/{projectId}/task") public SingleResult createTask(@Valid @RequestBody TaskDTO req) { return new SingleResult<>(taskService.createTask(req)); } + @Operation(summary = "태스크 수정") @PutMapping("/task/{taskId}") public SingleResult updateTask(@PathVariable Long taskId, @Valid @RequestBody TaskDTO req) { return new SingleResult<>(taskService.updateTask(taskId, req)); } + @Operation(summary = "태스크 삭제") @DeleteMapping("/task/{taskId}") public SingleResult deleteTask(@PathVariable Long taskId) { return new SingleResult<>(taskService.deleteTask(taskId)); From 8b602bcdf1c4c25aea30a5e8d5f68207e71f3f4e Mon Sep 17 00:00:00 2001 From: seoyoung-dev Date: Fri, 4 Oct 2024 03:15:59 +0900 Subject: [PATCH 31/51] =?UTF-8?q?docs:=20README.md=20=EA=B5=AC=ED=98=84=20?= =?UTF-8?q?=EC=82=AC=ED=95=AD=20=EB=B0=8F=20=EC=84=A4=EB=AA=85=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f8b1932..c0e5d67 100644 --- a/README.md +++ b/README.md @@ -68,9 +68,18 @@ - 프로젝트 내 게스트 추가 - 프로젝트 코드 메일로 전달 - 태스크(조서영) + - 태스크 리스트 조회(프로젝트 아이디를 이용) + - 태스트 단건 조회 - 태스크 생성 - - 태스크 삭제 + - isDeleted와 progress 생성시 기본값인 0으로 설정 + - 프로젝트id, 태스크를 수행할 멤버(팀원)id, 제목, 본문,시작일, 종료일을 입력받아서 -> + dto에서 시작일, 종료일 검증 -> + 토큰내 이메일과 프로젝트id로 프로젝트를 불러오기 -> + 멤버(팀원)존재 검증 -> + task객체 생성 (미완) + 저장 - 태스크 수정 + - 태스트 삭제 - 이벤트 - 독려 이메일 전달 - 각 게스트별 진행도 조회 From 174652e52baa9bed05d864cbaa4b084f68fa8f9b Mon Sep 17 00:00:00 2001 From: Kim-DongHyuk <80240164+Kdonghs@users.noreply.github.com> Date: Fri, 4 Oct 2024 15:23:11 +0900 Subject: [PATCH 32/51] =?UTF-8?q?feat:=20=ED=83=9C=EC=8A=A4=ED=81=AC=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1,=20=EC=88=98=EC=A0=95,=20=EC=82=AD=EC=A0=9C?= =?UTF-8?q?=20=EC=88=98=EC=A0=95=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/team1/BE/seamless/DTO/TaskDTO.java | 132 +++++++++++------- .../seamless/controller/TaskController.java | 36 +++-- .../team1/BE/seamless/entity/TaskEntity.java | 41 +++--- .../team1/BE/seamless/mapper/TaskMapper.java | 26 +++- .../repository/ProjectRepository.java | 2 + .../seamless/repository/TaskRepository.java | 3 + .../BE/seamless/service/TaskService.java | 100 +++++++------ .../team1/BE/seamless/util/auth/JwtToken.java | 5 + .../BE/seamless/util/auth/ParsingPram.java | 7 + 9 files changed, 226 insertions(+), 126 deletions(-) diff --git a/src/main/java/team1/BE/seamless/DTO/TaskDTO.java b/src/main/java/team1/BE/seamless/DTO/TaskDTO.java index cba28bf..cd16022 100644 --- a/src/main/java/team1/BE/seamless/DTO/TaskDTO.java +++ b/src/main/java/team1/BE/seamless/DTO/TaskDTO.java @@ -1,78 +1,108 @@ package team1.BE.seamless.DTO; -import jakarta.validation.constraints.Max; -import jakarta.validation.constraints.Min; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; import java.time.LocalDateTime; +import org.springframework.http.HttpStatus; +import team1.BE.seamless.util.errorException.BaseHandler; public class TaskDTO { - @NotBlank(message = "이름은 필수 입력 사항입니다.") - private String name; + public static class Create { - private String remark; + @NotBlank(message = "이름은 필수 입력 사항입니다.") + private String name; - @Min(value = 0, message = "진행률의 최솟값은 0입니다.") - @Max(value = 100, message = "진행률의 최댓값은 100입니다.") - private Integer progress; + private String remark; - @Min(value = 0, message = "삭제 여부는 0 또는 1입니다.") - @Max(value = 1, message = "삭제 여부는 0 또는 1입니다.") - private Boolean isDeleted; + private Long memberId; - @NotNull(message = "프로젝트 아아디는 필수 입력 사항입니다.") - private Long projectId; + @NotNull(message = "시작 시간은 필수 입력 사항입니다.") + private LocalDateTime startDate; - @NotNull(message = "프로젝트 담당자 아이디는 필수 입력 사항입니다.") - private Long ownerId; // 프로젝트 담당자 + @NotNull(message = "종료 시간은 필수 입력 사항입니다.") + private LocalDateTime endDate; - @NotNull(message = "시작 시간은 필수 입력 사항입니다.") - private LocalDateTime startDate; + public Create(String name, String remark, Long memberId, LocalDateTime startDate, + LocalDateTime endDate) { + if (startDate.isBefore(endDate)) { + throw new BaseHandler(HttpStatus.FORBIDDEN, "종료시간은 시작시간보다 이전일 수 없습니다."); + } + this.name = name; + this.remark = remark; + this.memberId = memberId; + this.startDate = startDate; + this.endDate = endDate; + } - @NotNull(message = "종료 시간은 필수 입력 사항입니다.") - private LocalDateTime endDate; + public @NotBlank(message = "이름은 필수 입력 사항입니다.") String getName() { + return name; + } - public TaskDTO(String name, String remark, Long projectId, Long ownerId, LocalDateTime startDate, LocalDateTime endDate) { - this.name = name; - this.remark = remark; - this.progress = 0; - this.isDeleted = false; - this.projectId = projectId; - this.ownerId = ownerId; - this.startDate = startDate; - this.endDate = endDate; - } + public String getRemark() { + return remark; + } - public String getName() { - return name; - } + public Long getMemberId() { + return memberId; + } - public String getRemark() { - return remark; - } + public @NotNull(message = "시작 시간은 필수 입력 사항입니다.") LocalDateTime getStartDate() { + return startDate; + } - public Integer getProgress() { - return progress; + public @NotNull(message = "종료 시간은 필수 입력 사항입니다.") LocalDateTime getEndDate() { + return endDate; + } } - public Boolean getIsDeleted() { - return isDeleted; - } + public static class Update { - public Long getProjectId() { - return projectId; - } + private String name; - public Long getOwnerId() { - return ownerId; - } + private String remark; - public LocalDateTime getStartDate() { - return startDate; - } + private Integer progress; + + private Long memberId; + + private LocalDateTime startDate; + + private LocalDateTime endDate; + + public Update(String name, String remark, Integer progress, Long memberId, + LocalDateTime startDate, + LocalDateTime endDate) { + this.name = name; + this.remark = remark; + this.progress = progress; + this.memberId = memberId; + this.startDate = startDate; + this.endDate = endDate; + } + + public String getName() { + return name; + } + + public String getRemark() { + return remark; + } + + public Integer getProgress() { + return progress; + } + + public Long getMemberId() { + return memberId; + } + + public LocalDateTime getStartDate() { + return startDate; + } - public LocalDateTime getEndDate() { - return endDate; + public LocalDateTime getEndDate() { + return endDate; + } } } diff --git a/src/main/java/team1/BE/seamless/controller/TaskController.java b/src/main/java/team1/BE/seamless/controller/TaskController.java index b2a33ac..1e7383e 100644 --- a/src/main/java/team1/BE/seamless/controller/TaskController.java +++ b/src/main/java/team1/BE/seamless/controller/TaskController.java @@ -2,19 +2,20 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.servlet.http.HttpServletRequest; import jakarta.validation.Valid; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; import team1.BE.seamless.DTO.TaskDTO; import team1.BE.seamless.entity.TaskEntity; import team1.BE.seamless.service.TaskService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; import team1.BE.seamless.util.page.ListResult; import team1.BE.seamless.util.page.SingleResult; @@ -42,21 +43,34 @@ public ListResult getTaskList(@PathVariable Long projectId) { return new ListResult<>(taskService.getTaskList(projectId)); } + /** + * 팀장만 태스크를 생성할 수 있음 + * */ @Operation(summary = "태스크 생성") @PostMapping("/{projectId}/task") - public SingleResult createTask(@Valid @RequestBody TaskDTO req) { - return new SingleResult<>(taskService.createTask(req)); + public SingleResult createTask(HttpServletRequest req, + @Valid @PathVariable Long projectId, @Valid @RequestBody TaskDTO.Create create) { + return new SingleResult<>(taskService.createTask(req, projectId, create)); } + /** + * 멤버도 코드로 프로젝트 참여에 성공하면 토큰을 반환함 + * 태스크 수정은 팀장, 태스크를 수행하고 있는 팀원이 가능함 + * 태스크의 멤버를 수정하는 건 팀장만 가능 + * */ @Operation(summary = "태스크 수정") @PutMapping("/task/{taskId}") - public SingleResult updateTask(@PathVariable Long taskId, @Valid @RequestBody TaskDTO req) { - return new SingleResult<>(taskService.updateTask(taskId, req)); + public SingleResult updateTask(HttpServletRequest req, @Valid @PathVariable Long taskId, + @Valid @RequestBody TaskDTO.Update update) { + return new SingleResult<>(taskService.updateTask(req, taskId, update)); } + /** + * 팀장만 태스크를 삭제할 수 있음 + * */ @Operation(summary = "태스크 삭제") @DeleteMapping("/task/{taskId}") - public SingleResult deleteTask(@PathVariable Long taskId) { - return new SingleResult<>(taskService.deleteTask(taskId)); + public SingleResult deleteTask(HttpServletRequest req, @PathVariable Long taskId) { + return new SingleResult<>(taskService.deleteTask(req, taskId)); } } \ No newline at end of file diff --git a/src/main/java/team1/BE/seamless/entity/TaskEntity.java b/src/main/java/team1/BE/seamless/entity/TaskEntity.java index 2104678..a9356b7 100644 --- a/src/main/java/team1/BE/seamless/entity/TaskEntity.java +++ b/src/main/java/team1/BE/seamless/entity/TaskEntity.java @@ -29,19 +29,6 @@ public TaskEntity(String name, String remark, ProjectEntity projectEntity, Membe this.endDate = endDate; } - public TaskEntity(String name, String remark, Integer progress, Boolean isDeleted, - ProjectEntity projectEntity, MemberEntity owner, LocalDateTime startDate, - LocalDateTime endDate) { - this.name = name; - this.remark = remark; - this.progress = progress; - this.isDeleted = isDeleted; - this.projectEntity = projectEntity; - this.owner = owner; - this.startDate = startDate; - this.endDate = endDate; - } - @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "task_id") @@ -59,7 +46,7 @@ public TaskEntity(String name, String remark, Integer progress, Boolean isDelete @Column(name = "is_deleted") private Boolean isDeleted = false; - @ManyToOne(fetch = FetchType.LAZY) + @ManyToOne(fetch = FetchType.EAGER) @JoinColumn(name = "project_id") private ProjectEntity projectEntity; @@ -113,15 +100,27 @@ public void setOwner(MemberEntity owner) { this.owner = owner; } - public void setProject(ProjectEntity projectEntity) { - this.projectEntity = projectEntity; + public void setName(String name) { + this.name = name; } - public TaskEntity update(String name, String remark, Integer progress, Boolean isDeleted, - ProjectEntity projectEntity, MemberEntity owner, LocalDateTime startDate, - LocalDateTime endDate) { - return new TaskEntity(name, remark, progress, isDeleted, projectEntity, owner, startDate, - endDate); + public void setRemark(String remark) { + this.remark = remark; + } + + public void setProgress(Integer progress) { + this.progress = progress; } + public void setStartDate(LocalDateTime startDate) { + this.startDate = startDate; + } + + public void setEndDate(LocalDateTime endDate) { + this.endDate = endDate; + } + + public void setDeleted(Boolean deleted) { + isDeleted = deleted; + } } diff --git a/src/main/java/team1/BE/seamless/mapper/TaskMapper.java b/src/main/java/team1/BE/seamless/mapper/TaskMapper.java index 540dd0c..0f8eba0 100644 --- a/src/main/java/team1/BE/seamless/mapper/TaskMapper.java +++ b/src/main/java/team1/BE/seamless/mapper/TaskMapper.java @@ -1,16 +1,34 @@ package team1.BE.seamless.mapper; -import java.time.LocalDateTime; import org.springframework.stereotype.Component; +import team1.BE.seamless.DTO.TaskDTO; +import team1.BE.seamless.DTO.TaskDTO.Create; +import team1.BE.seamless.DTO.TaskDTO.Update; import team1.BE.seamless.entity.MemberEntity; import team1.BE.seamless.entity.ProjectEntity; import team1.BE.seamless.entity.TaskEntity; +import team1.BE.seamless.util.Util; @Component public class TaskMapper { - public TaskEntity toEntity(String name, String remark, ProjectEntity projectEntity, - MemberEntity memberEntity, LocalDateTime startDate, LocalDateTime endDate) { - return new TaskEntity(name, remark, projectEntity, memberEntity, startDate, endDate); + public TaskEntity toEntity(ProjectEntity project, MemberEntity member, Create create) { + return new TaskEntity( + create.getName(), + create.getRemark(), + project, + member, + create.getStartDate(), + create.getEndDate()); + } + + public TaskEntity toUpdate(TaskEntity task, Update update) { + task.setName(Util.isNull(update.getName()) ? task.getName() : update.getName()); + task.setRemark(Util.isNull(update.getRemark()) ? task.getRemark() : update.getRemark()); + task.setProgress(Util.isNull(update.getProgress().toString()) ? task.getProgress() : update.getProgress()); + task.setStartDate(Util.isNull(update.getStartDate().toString()) ? task.getStartDate() : update.getStartDate()); + task.setEndDate(Util.isNull(update.getEndDate().toString()) ? task.getEndDate() : update.getEndDate()); + + return task; } } diff --git a/src/main/java/team1/BE/seamless/repository/ProjectRepository.java b/src/main/java/team1/BE/seamless/repository/ProjectRepository.java index bffac28..8895e68 100644 --- a/src/main/java/team1/BE/seamless/repository/ProjectRepository.java +++ b/src/main/java/team1/BE/seamless/repository/ProjectRepository.java @@ -1,5 +1,6 @@ package team1.BE.seamless.repository; +import java.util.Optional; import team1.BE.seamless.DTO.ProjectDTO.ProjectPeriod; import team1.BE.seamless.entity.ProjectEntity; import org.springframework.data.domain.Page; @@ -12,4 +13,5 @@ public interface ProjectRepository extends JpaRepository { Page findAll(Pageable pageable); Page findAllBy(Pageable pageable); + Optional findByIdAndUserEmail(Long id, String email); } diff --git a/src/main/java/team1/BE/seamless/repository/TaskRepository.java b/src/main/java/team1/BE/seamless/repository/TaskRepository.java index 7a63c9e..6f130ab 100644 --- a/src/main/java/team1/BE/seamless/repository/TaskRepository.java +++ b/src/main/java/team1/BE/seamless/repository/TaskRepository.java @@ -1,6 +1,7 @@ package team1.BE.seamless.repository; import java.util.List; +import java.util.Optional; import team1.BE.seamless.entity.ProjectEntity; import team1.BE.seamless.entity.TaskEntity; import org.springframework.data.jpa.repository.JpaRepository; @@ -10,4 +11,6 @@ public interface TaskRepository extends JpaRepository { List findByProjectEntity(ProjectEntity projectEntity); + + Optional findByIdAndProjectEntityUserEmail(Long id, String email); } diff --git a/src/main/java/team1/BE/seamless/service/TaskService.java b/src/main/java/team1/BE/seamless/service/TaskService.java index 27105b5..0b8ecaf 100644 --- a/src/main/java/team1/BE/seamless/service/TaskService.java +++ b/src/main/java/team1/BE/seamless/service/TaskService.java @@ -1,18 +1,23 @@ package team1.BE.seamless.service; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.validation.Valid; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import team1.BE.seamless.DTO.TaskDTO; +import team1.BE.seamless.DTO.TaskDTO.Create; +import team1.BE.seamless.DTO.TaskDTO.Update; import team1.BE.seamless.entity.MemberEntity; import team1.BE.seamless.entity.ProjectEntity; import team1.BE.seamless.entity.TaskEntity; +import team1.BE.seamless.entity.enums.Role; import team1.BE.seamless.mapper.TaskMapper; import team1.BE.seamless.repository.MemberRepository; import team1.BE.seamless.repository.ProjectRepository; import team1.BE.seamless.repository.TaskRepository; +import team1.BE.seamless.util.auth.ParsingPram; import team1.BE.seamless.util.errorException.BaseHandler; @Service @@ -22,71 +27,88 @@ public class TaskService { private final ProjectRepository projectRepository; private final MemberRepository memberRepository; private final TaskMapper taskMapper; + private final ParsingPram parsingPram; @Autowired - public TaskService(TaskRepository taskRepository, ProjectRepository projectRepository, MemberRepository memberRepository, TaskMapper taskMapper) { + public TaskService(TaskRepository taskRepository, ProjectRepository projectRepository, + MemberRepository memberRepository, TaskMapper taskMapper, ParsingPram parsingPram) { this.taskRepository = taskRepository; this.projectRepository = projectRepository; this.memberRepository = memberRepository; this.taskMapper = taskMapper; + this.parsingPram = parsingPram; } public TaskEntity getTask(Long taskId) { - return taskRepository.findById(taskId).orElseThrow(() -> new BaseHandler(HttpStatus.NOT_FOUND, "존재하지 않는 태스크")); + return taskRepository.findById(taskId) + .orElseThrow(() -> new BaseHandler(HttpStatus.NOT_FOUND, "존재하지 않는 태스크")); } public List getTaskList(Long projectId) { - ProjectEntity projectEntity = projectRepository.findById(projectId).orElseThrow(() -> new BaseHandler(HttpStatus.NOT_FOUND, "존재하지 않는 프로젝트")); + ProjectEntity projectEntity = projectRepository.findById(projectId) + .orElseThrow(() -> new BaseHandler(HttpStatus.NOT_FOUND, "존재하지 않는 프로젝트")); return taskRepository.findByProjectEntity(projectEntity); } - public TaskEntity createTask(TaskDTO req) { - ProjectEntity projectEntity = projectRepository.findById(req.getProjectId()).orElseThrow(() -> new BaseHandler(HttpStatus.NOT_FOUND, "존재하지 않는 프로젝트")); + public TaskEntity createTask(HttpServletRequest req, @Valid Long projectId, Create create) { + ProjectEntity project = projectRepository.findByIdAndUserEmail(projectId,parsingPram.getEmail(req)) + .orElseThrow(() -> new BaseHandler(HttpStatus.NOT_FOUND, "존재하지 않는 프로젝트")); + +// 태스크의 일정 검증 + if (project.getStartDate().isBefore(create.getStartDate()) || project.getStartDate().isAfter(create.getEndDate())){ + throw new BaseHandler(HttpStatus.FORBIDDEN,"태스크는 프로젝트의 기한을 넘어설 수 없습니다."); + } - MemberEntity memberEntity = memberRepository.findById(req.getOwnerId()).orElseThrow(() -> new BaseHandler(HttpStatus.NOT_FOUND, "존재하지 않는 멤버")); + MemberEntity member = memberRepository.findById(create.getMemberId()) + .orElseThrow(() -> new BaseHandler(HttpStatus.NOT_FOUND, "존재하지 않는 멤버")); - TaskEntity taskEntity = taskMapper.toEntity( - req.getName(), - req.getRemark(), - projectEntity, - memberEntity, - req.getStartDate(), - req.getEndDate() - ); + TaskEntity taskEntity = taskMapper.toEntity(project,member,create); taskRepository.save(taskEntity); return taskEntity; } @Transactional - public TaskEntity updateTask(Long taskId, TaskDTO req) { - TaskEntity taskEntity = taskRepository.findById(taskId).orElseThrow(() -> new BaseHandler(HttpStatus.NOT_FOUND, "존재하지 않는 태스크")); - - ProjectEntity projectEntity = projectRepository.findById(req.getProjectId()).orElseThrow(() -> new BaseHandler(HttpStatus.NOT_FOUND, "존재하지 않는 프로젝트")); - - MemberEntity memberEntity = memberRepository.findById(req.getOwnerId()).orElseThrow(() -> new BaseHandler(HttpStatus.NOT_FOUND, "존재하지 않는 멤버")); - - TaskEntity updatedTask = taskEntity.update( - req.getName(), - req.getRemark(), - req.getProgress(), - req.getIsDeleted(), - projectEntity, - memberEntity, - req.getStartDate(), - req.getEndDate() - ); - - taskRepository.save(updatedTask); - return updatedTask; + public TaskEntity updateTask(HttpServletRequest req, @Valid Long taskId, @Valid Update update) { + TaskEntity task = taskRepository.findById(taskId) + .orElseThrow(() -> new BaseHandler(HttpStatus.NOT_FOUND, "존재하지 않는 태스크")); + +// 태스크의 일정 검증 + if (task.getProject().getStartDate().isBefore(update.getStartDate()) || task.getProject().getStartDate().isAfter(update.getEndDate())){ + throw new BaseHandler(HttpStatus.FORBIDDEN,"태스크는 프로젝트의 기한을 넘어설 수 없습니다."); + } + +// 수정 권한이 있는지 검증 +// 팀장 + if (parsingPram.getRole(req).equals(Role.USER.toString())){ + if (!task.getProject().getUser().getEmail().equals(parsingPram.getEmail(req))){ + throw new BaseHandler(HttpStatus.UNAUTHORIZED,"태스크 수정 권한이 없습니다."); + } +// 멤버 변경 + MemberEntity member = memberRepository.findById(update.getMemberId()) + .orElseThrow(() -> new BaseHandler(HttpStatus.NOT_FOUND, "존재하지 않는 멤버")); + + task.setOwner(member); + } +// 팀원 + if (parsingPram.getRole(req).equals(Role.USER.toString())){ + if (!task.getOwner().getEmail().equals(parsingPram.getEmail(req))){ + throw new BaseHandler(HttpStatus.UNAUTHORIZED,"태스크 수정 권한이 없습니다."); + } + } + + taskMapper.toUpdate(task,update); + return task; } - public Long deleteTask(Long taskId) { - TaskEntity taskEntity = taskRepository.findById(taskId) + @Transactional + public Long deleteTask(HttpServletRequest req, Long taskId) { + TaskEntity task = taskRepository.findByIdAndProjectEntityUserEmail(taskId, parsingPram.getEmail(req)) .orElseThrow(() -> new BaseHandler(HttpStatus.NOT_FOUND, "존재하지 않는 태스크")); - taskRepository.delete(taskEntity); - return taskEntity.getId(); + task.setDeleted(true); + + return task.getId(); } } \ No newline at end of file diff --git a/src/main/java/team1/BE/seamless/util/auth/JwtToken.java b/src/main/java/team1/BE/seamless/util/auth/JwtToken.java index 2e0ec03..5159403 100644 --- a/src/main/java/team1/BE/seamless/util/auth/JwtToken.java +++ b/src/main/java/team1/BE/seamless/util/auth/JwtToken.java @@ -88,4 +88,9 @@ public String getEmail(String token) { return claims.get("email", String.class); } + public String getRole(String token) { + Claims claims = validateToken(token); + return claims.get("authentication", String.class); + } + } diff --git a/src/main/java/team1/BE/seamless/util/auth/ParsingPram.java b/src/main/java/team1/BE/seamless/util/auth/ParsingPram.java index bffecf4..c826e34 100644 --- a/src/main/java/team1/BE/seamless/util/auth/ParsingPram.java +++ b/src/main/java/team1/BE/seamless/util/auth/ParsingPram.java @@ -3,6 +3,7 @@ import jakarta.servlet.http.HttpServletRequest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import team1.BE.seamless.entity.enums.Role; @Component public class ParsingPram { @@ -22,4 +23,10 @@ public String getEmail(HttpServletRequest request) { return jwtToken.getEmail(token); } + public String getRole(HttpServletRequest request) { + String token = request.getHeader(AUTHORIZATION_HEADER); + token = token.substring(7); + return jwtToken.getRole(token); + } + } From 81e9dbd0c26524ea3fabeb70d2614bf3d8b59cf6 Mon Sep 17 00:00:00 2001 From: Kim-DongHyuk <80240164+Kdonghs@users.noreply.github.com> Date: Fri, 4 Oct 2024 15:26:23 +0900 Subject: [PATCH 33/51] =?UTF-8?q?feat:=20=EB=A7=A4=ED=95=91=20=EC=88=98?= =?UTF-8?q?=EC=A0=95(=ED=83=9C=EC=8A=A4=ED=81=ACn:=ED=94=84=EB=A1=9C?= =?UTF-8?q?=EC=A0=9D=ED=8A=B81)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BE/seamless/entity/ProjectEntity.java | 26 +++---------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/src/main/java/team1/BE/seamless/entity/ProjectEntity.java b/src/main/java/team1/BE/seamless/entity/ProjectEntity.java index 7809614..275bf68 100644 --- a/src/main/java/team1/BE/seamless/entity/ProjectEntity.java +++ b/src/main/java/team1/BE/seamless/entity/ProjectEntity.java @@ -56,8 +56,8 @@ public ProjectEntity(String name, UserEntity user, @OneToMany(mappedBy = "projectEntity", cascade = CascadeType.ALL) private List options; - @OneToOne(fetch = FetchType.LAZY, mappedBy = "projectEntity") - private TaskEntity taskEntity; + @OneToMany(mappedBy = "projectEntity", cascade = CascadeType.ALL) + private List taskEntity; @Column(name = "start_date") private LocalDateTime startDate; @@ -91,7 +91,7 @@ public List getOptions() { return options; } - public TaskEntity getTaskEntity() { + public List getTaskEntity() { return taskEntity; } @@ -103,10 +103,6 @@ public LocalDateTime getEndDate() { return endDate; } - //Setters - public void setId(Long id) { - this.id = id; - } public void setName(String name) { this.name = name; @@ -116,22 +112,6 @@ public void setIsDelete(Integer isDelete) { this.isDelete = isDelete; } - public void setUser(UserEntity user) { - this.user = user; - } - - public void setMemberEntities(List memberEntities) { - this.memberEntities = memberEntities; - } - - public void setOptions(List options) { - this.options = options; - } - - public void setTaskEntity(TaskEntity taskEntity) { - this.taskEntity = taskEntity; - } - public void setStartDate(LocalDateTime startDate) { this.startDate = startDate; } From ab62589e84f317533b611f9c8f639b6b25f23624 Mon Sep 17 00:00:00 2001 From: Kim-DongHyuk <80240164+Kdonghs@users.noreply.github.com> Date: Fri, 4 Oct 2024 15:26:43 +0900 Subject: [PATCH 34/51] =?UTF-8?q?feat:=20=EB=A7=A4=ED=95=91=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=EC=97=90=20=EB=94=B0=EB=A5=B8=20getTaskList=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/team1/BE/seamless/service/TaskService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/team1/BE/seamless/service/TaskService.java b/src/main/java/team1/BE/seamless/service/TaskService.java index 0b8ecaf..89f7c6c 100644 --- a/src/main/java/team1/BE/seamless/service/TaskService.java +++ b/src/main/java/team1/BE/seamless/service/TaskService.java @@ -48,7 +48,7 @@ public List getTaskList(Long projectId) { ProjectEntity projectEntity = projectRepository.findById(projectId) .orElseThrow(() -> new BaseHandler(HttpStatus.NOT_FOUND, "존재하지 않는 프로젝트")); - return taskRepository.findByProjectEntity(projectEntity); + return projectEntity.getTaskEntity(); } public TaskEntity createTask(HttpServletRequest req, @Valid Long projectId, Create create) { From 8a1134ed1ec96dd8e45b5ae76408dc60572f777d Mon Sep 17 00:00:00 2001 From: Kim-DongHyuk <80240164+Kdonghs@users.noreply.github.com> Date: Fri, 4 Oct 2024 15:31:37 +0900 Subject: [PATCH 35/51] =?UTF-8?q?feat:=20=EC=83=88=EB=A1=9C=EC=9A=B4=20Rol?= =?UTF-8?q?e=EC=B6=94=EA=B0=80=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/team1/BE/seamless/service/TaskService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/team1/BE/seamless/service/TaskService.java b/src/main/java/team1/BE/seamless/service/TaskService.java index 89f7c6c..fe39d43 100644 --- a/src/main/java/team1/BE/seamless/service/TaskService.java +++ b/src/main/java/team1/BE/seamless/service/TaskService.java @@ -92,7 +92,7 @@ public TaskEntity updateTask(HttpServletRequest req, @Valid Long taskId, @Valid task.setOwner(member); } // 팀원 - if (parsingPram.getRole(req).equals(Role.USER.toString())){ + if (parsingPram.getRole(req).equals(Role.MEMBER.toString())){ if (!task.getOwner().getEmail().equals(parsingPram.getEmail(req))){ throw new BaseHandler(HttpStatus.UNAUTHORIZED,"태스크 수정 권한이 없습니다."); } From 7e01f9757c63c570245d9604f64b19bbb869c5af Mon Sep 17 00:00:00 2001 From: Kim-DongHyuk <80240164+Kdonghs@users.noreply.github.com> Date: Fri, 4 Oct 2024 18:00:09 +0900 Subject: [PATCH 36/51] =?UTF-8?q?feat:=20JoinNumber=EB=8A=94=20=EB=AF=B8?= =?UTF-8?q?=EC=82=AC=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/team1/BE/seamless/service/MemberService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/team1/BE/seamless/service/MemberService.java b/src/main/java/team1/BE/seamless/service/MemberService.java index 6c5afdc..1440951 100644 --- a/src/main/java/team1/BE/seamless/service/MemberService.java +++ b/src/main/java/team1/BE/seamless/service/MemberService.java @@ -31,7 +31,7 @@ public MemberEntity addMember(MemberEntity member, Long projectId) { public MemberEntity updateMember(Long id, MemberEntity memberDetails) { MemberEntity member = memberRepository.findById(id).orElseThrow(() -> new RuntimeException("Member not found")); member.setEmail(memberDetails.getEmail()); - member.setJoinNumber(memberDetails.getJoinNumber()); +// member.setJoinNumber(memberDetails.getJoinNumber()); return memberRepository.save(member); } } From f21aa341ada5e72b9b46bd68eada537d5df65e29 Mon Sep 17 00:00:00 2001 From: Kim-DongHyuk <80240164+Kdonghs@users.noreply.github.com> Date: Fri, 4 Oct 2024 18:00:21 +0900 Subject: [PATCH 37/51] =?UTF-8?q?feat:=20=ED=95=84=EB=93=9C=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=EC=9E=90=20=EC=82=AC=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../team1/BE/seamless/entity/ProjectEntity.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/team1/BE/seamless/entity/ProjectEntity.java b/src/main/java/team1/BE/seamless/entity/ProjectEntity.java index f28d0e4..9480ac6 100644 --- a/src/main/java/team1/BE/seamless/entity/ProjectEntity.java +++ b/src/main/java/team1/BE/seamless/entity/ProjectEntity.java @@ -18,9 +18,9 @@ public class ProjectEntity extends BaseEntity { public ProjectEntity() { - memberEntities = new ArrayList<>(); - projectOptions = new ArrayList<>(); - taskEntities = new ArrayList<>(); +// memberEntities = new ArrayList<>(); +// projectOptions = new ArrayList<>(); +// taskEntities = new ArrayList<>(); } public ProjectEntity(String name, UserEntity userEntity, List projectOptions, @@ -32,8 +32,8 @@ public ProjectEntity(String name, UserEntity userEntity, List pro this.projectOptions = projectOptions; this.startDate = startDate; this.endDate = endDate; - memberEntities = new ArrayList<>(); - taskEntities = new ArrayList<>(); +// memberEntities = new ArrayList<>(); +// taskEntities = new ArrayList<>(); } @Id @@ -52,13 +52,13 @@ public ProjectEntity(String name, UserEntity userEntity, List pro private UserEntity userEntity; @OneToMany(mappedBy = "projectEntity", cascade = CascadeType.ALL) - private List memberEntities; + private List memberEntities = new ArrayList<>(); @OneToMany(mappedBy = "projectEntity", cascade = CascadeType.ALL) - private List projectOptions; + private List projectOptions = new ArrayList<>(); @OneToMany(mappedBy = "projectEntity", cascade = CascadeType.ALL) - private List taskEntities; + private List taskEntities = new ArrayList<>(); @Column(name = "start_date") private LocalDateTime startDate; From 78be9aa47d0f5659e744f887549916e3d3d5ceda Mon Sep 17 00:00:00 2001 From: Kim-DongHyuk <80240164+Kdonghs@users.noreply.github.com> Date: Fri, 4 Oct 2024 18:00:58 +0900 Subject: [PATCH 38/51] =?UTF-8?q?feat:=20=ED=95=84=EB=93=9C=EB=AA=85=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=EC=9C=BC=EB=A1=9C=20=EC=9D=B8=ED=95=9C=20?= =?UTF-8?q?=EB=A6=AC=ED=8F=AC=EC=A7=80=ED=86=A0=EB=A6=AC=20=ED=95=A8?= =?UTF-8?q?=EC=88=98=EB=AA=85=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../team1/BE/seamless/repository/ProjectRepository.java | 2 +- .../java/team1/BE/seamless/repository/TaskRepository.java | 2 +- src/main/java/team1/BE/seamless/service/TaskService.java | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/team1/BE/seamless/repository/ProjectRepository.java b/src/main/java/team1/BE/seamless/repository/ProjectRepository.java index 9134187..dd4507f 100644 --- a/src/main/java/team1/BE/seamless/repository/ProjectRepository.java +++ b/src/main/java/team1/BE/seamless/repository/ProjectRepository.java @@ -13,7 +13,7 @@ public interface ProjectRepository extends JpaRepository { Page findAll(Pageable pageable); Page findAllBy(Pageable pageable); - Optional findByIdAndUserEmail(Long id, String email); + Optional findByIdAndUserEntityEmail(Long id, String email); Page findAllByUserEntityEmail(Pageable pageable, String email); Optional findById(Long id); diff --git a/src/main/java/team1/BE/seamless/repository/TaskRepository.java b/src/main/java/team1/BE/seamless/repository/TaskRepository.java index 6f130ab..8f51291 100644 --- a/src/main/java/team1/BE/seamless/repository/TaskRepository.java +++ b/src/main/java/team1/BE/seamless/repository/TaskRepository.java @@ -12,5 +12,5 @@ public interface TaskRepository extends JpaRepository { List findByProjectEntity(ProjectEntity projectEntity); - Optional findByIdAndProjectEntityUserEmail(Long id, String email); + Optional findByIdAndProjectEntityUserEntityEmail(Long id, String email); } diff --git a/src/main/java/team1/BE/seamless/service/TaskService.java b/src/main/java/team1/BE/seamless/service/TaskService.java index fe39d43..7af9b93 100644 --- a/src/main/java/team1/BE/seamless/service/TaskService.java +++ b/src/main/java/team1/BE/seamless/service/TaskService.java @@ -48,11 +48,11 @@ public List getTaskList(Long projectId) { ProjectEntity projectEntity = projectRepository.findById(projectId) .orElseThrow(() -> new BaseHandler(HttpStatus.NOT_FOUND, "존재하지 않는 프로젝트")); - return projectEntity.getTaskEntity(); + return projectEntity.getTaskEntities(); } public TaskEntity createTask(HttpServletRequest req, @Valid Long projectId, Create create) { - ProjectEntity project = projectRepository.findByIdAndUserEmail(projectId,parsingPram.getEmail(req)) + ProjectEntity project = projectRepository.findByIdAndUserEntityEmail(projectId,parsingPram.getEmail(req)) .orElseThrow(() -> new BaseHandler(HttpStatus.NOT_FOUND, "존재하지 않는 프로젝트")); // 태스크의 일정 검증 @@ -82,7 +82,7 @@ public TaskEntity updateTask(HttpServletRequest req, @Valid Long taskId, @Valid // 수정 권한이 있는지 검증 // 팀장 if (parsingPram.getRole(req).equals(Role.USER.toString())){ - if (!task.getProject().getUser().getEmail().equals(parsingPram.getEmail(req))){ + if (!task.getProject().getUserEntity().getEmail().equals(parsingPram.getEmail(req))){ throw new BaseHandler(HttpStatus.UNAUTHORIZED,"태스크 수정 권한이 없습니다."); } // 멤버 변경 @@ -104,7 +104,7 @@ public TaskEntity updateTask(HttpServletRequest req, @Valid Long taskId, @Valid @Transactional public Long deleteTask(HttpServletRequest req, Long taskId) { - TaskEntity task = taskRepository.findByIdAndProjectEntityUserEmail(taskId, parsingPram.getEmail(req)) + TaskEntity task = taskRepository.findByIdAndProjectEntityUserEntityEmail(taskId, parsingPram.getEmail(req)) .orElseThrow(() -> new BaseHandler(HttpStatus.NOT_FOUND, "존재하지 않는 태스크")); task.setDeleted(true); From fc79f24f37e7731d4b515eb74912ccbbafef8207 Mon Sep 17 00:00:00 2001 From: Kim-DongHyuk <80240164+Kdonghs@users.noreply.github.com> Date: Fri, 4 Oct 2024 18:26:14 +0900 Subject: [PATCH 39/51] =?UTF-8?q?feat:=20=ED=8C=80=EC=9B=90=20=EC=B4=88?= =?UTF-8?q?=EB=8C=80=20=EB=A7=81=ED=81=AC=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/AttendUrlController.java | 37 ++++++++++++---- .../BE/seamless/service/AttendURLService.java | 42 +++++++++++++++++-- .../BE/seamless/service/UserService.java | 2 +- src/main/java/team1/BE/seamless/util/URL.java | 5 +++ 4 files changed, 72 insertions(+), 14 deletions(-) create mode 100644 src/main/java/team1/BE/seamless/util/URL.java diff --git a/src/main/java/team1/BE/seamless/controller/AttendUrlController.java b/src/main/java/team1/BE/seamless/controller/AttendUrlController.java index a083bcb..4013e67 100644 --- a/src/main/java/team1/BE/seamless/controller/AttendUrlController.java +++ b/src/main/java/team1/BE/seamless/controller/AttendUrlController.java @@ -2,6 +2,8 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.validation.Valid; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import team1.BE.seamless.DTO.AttendUrlResponseDTO; @@ -18,17 +20,34 @@ @RestController public class AttendUrlController { + private final AttendURLService attendURLService; + @Autowired - AttendURLService attendURLService; + public AttendUrlController(AttendURLService attendURLService) { + this.attendURLService = attendURLService; + } + +// @Operation(summary = "팀장이 참여링크 생성 버튼을 누르면 링크 생성") +// @PostMapping("/api/project/{project_id}/invite-link") +// public SingleResult generateInviteLink( +// @PathVariable("project_id") String projectId, +// @RequestBody Map body) { +// String expirationDate = body.get("expirationDate"); +// AttendUrlResponseDTO attendUrlResponseDTO = +// new AttendUrlResponseDTO(attendURLService.generateAttendURL(projectId, expirationDate)); +// return new SingleResult<>(attendUrlResponseDTO); +// } - @Operation(summary = "팀장이 참여링크 생성 버튼을 누르면 링크 생성") + /** + * 팉장의 토큰과 프로젝트id로 프로젝트 존재 검증 + * 프로젝트id + " " + exp로 코드 생성 + * 코드를 양방향 암호화 + * ex) http://localhost:8080/api/memverInvite?code="123456" + * 검증시 코드를 복호화 해서 프로젝트id와 exp를 검증(server less) + * */ + @Operation(summary = "팀원초대 링크 생성") @PostMapping("/api/project/{project_id}/invite-link") - public SingleResult generateInviteLink( - @PathVariable("project_id") String projectId, - @RequestBody Map body) { - String expirationDate = body.get("expirationDate"); - AttendUrlResponseDTO attendUrlResponseDTO = - new AttendUrlResponseDTO(attendURLService.generateAttendURL(projectId, expirationDate)); - return new SingleResult<>(attendUrlResponseDTO); + public SingleResult generateInviteLink(HttpServletRequest req, @Valid @PathVariable("project_id") Long projectId){ + return new SingleResult<>(attendURLService.generateAttendURL(req, projectId)); } } \ No newline at end of file diff --git a/src/main/java/team1/BE/seamless/service/AttendURLService.java b/src/main/java/team1/BE/seamless/service/AttendURLService.java index f570936..d5ff192 100644 --- a/src/main/java/team1/BE/seamless/service/AttendURLService.java +++ b/src/main/java/team1/BE/seamless/service/AttendURLService.java @@ -1,13 +1,47 @@ package team1.BE.seamless.service; +import static team1.BE.seamless.util.URL.DEFAULTURL; + +import jakarta.servlet.http.HttpServletRequest; +import jakarta.validation.Valid; +import java.time.LocalDateTime; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; import org.springframework.stereotype.Service; -import java.util.UUID; +import team1.BE.seamless.entity.ProjectEntity; +import team1.BE.seamless.repository.ProjectRepository; +import team1.BE.seamless.util.auth.AesEncrypt; +import team1.BE.seamless.util.auth.ParsingPram; +import team1.BE.seamless.util.errorException.BaseHandler; @Service public class AttendURLService { - public String generateAttendURL(String projectId, String expirationDate) { - String generatedUrl = "https://seamless.com/invite?code=" + UUID.randomUUID().toString() + "&project_id=" + projectId + "&expires=" + expirationDate; - return generatedUrl; + private final ProjectRepository projectRepository; + private final ParsingPram parsingPram; + private final AesEncrypt aesEncrypt; + + @Autowired + public AttendURLService(ProjectRepository projectRepository, ParsingPram parsingPram, + AesEncrypt aesEncrypt) { + this.projectRepository = projectRepository; + this.parsingPram = parsingPram; + this.aesEncrypt = aesEncrypt; + } + + public String generateAttendURL(HttpServletRequest req, @Valid Long projectId) { + ProjectEntity project = projectRepository.findByIdAndUserEntityEmail(projectId, + parsingPram.getEmail(req)) + .orElseThrow(() -> new BaseHandler(HttpStatus.NOT_FOUND, "프로젝트가 존재하지 않음")); + +// 코드는 프로젝트id + exp로 구성 +// exp는 1일로 가정 + String code = aesEncrypt.encrypt(project.getId() +" " + LocalDateTime.now().plusDays(1).toString()); + return DEFAULTURL + "invite?code=" + code; } + +// public String generateAttendURL(String projectId, String expirationDate) { +// String generatedUrl = "https://seamless.com/invite?code=" + UUID.randomUUID().toString() + "&project_id=" + projectId + "&expires=" + expirationDate; +// return generatedUrl; +// } } diff --git a/src/main/java/team1/BE/seamless/service/UserService.java b/src/main/java/team1/BE/seamless/service/UserService.java index 9ea9659..a61fc51 100644 --- a/src/main/java/team1/BE/seamless/service/UserService.java +++ b/src/main/java/team1/BE/seamless/service/UserService.java @@ -37,7 +37,7 @@ public UserDetails getUser(HttpServletRequest req) { } @Transactional - public UserSimple updateUser(HttpServletRequest req, @Valid UserUpdate update) { + public UserSimple xupdateUser(HttpServletRequest req, @Valid UserUpdate update) { UserEntity user = userRepository.findByEmail(parsingPram.getEmail(req)) .orElseThrow(() -> new BaseHandler(HttpStatus.NOT_FOUND, "해당 유저가 존재하지 않습니다.")); diff --git a/src/main/java/team1/BE/seamless/util/URL.java b/src/main/java/team1/BE/seamless/util/URL.java new file mode 100644 index 0000000..3306af8 --- /dev/null +++ b/src/main/java/team1/BE/seamless/util/URL.java @@ -0,0 +1,5 @@ +package team1.BE.seamless.util; + +public class URL { +public static String DEFAULTURL = "http://localhost:8080/"; +} From 33ab3f90ff8ddb4e11ef790ac0cab31878b44dff Mon Sep 17 00:00:00 2001 From: suno-boy Date: Fri, 4 Oct 2024 20:49:34 +0900 Subject: [PATCH 40/51] =?UTF-8?q?fix:=20MemberEntity=20=ED=95=84=EB=93=9C?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BE/seamless/entity/MemberEntity.java | 50 +++++++++++++++++-- 1 file changed, 45 insertions(+), 5 deletions(-) diff --git a/src/main/java/team1/BE/seamless/entity/MemberEntity.java b/src/main/java/team1/BE/seamless/entity/MemberEntity.java index 60868ef..16cd975 100644 --- a/src/main/java/team1/BE/seamless/entity/MemberEntity.java +++ b/src/main/java/team1/BE/seamless/entity/MemberEntity.java @@ -20,13 +20,32 @@ public MemberEntity() { } - public MemberEntity(String email, String joinNumber, Integer isDelete, ProjectEntity projectEntity) { + public MemberEntity(String name, String role, String email, String imageURL) { + this.name = name; + this.role = role; + this.email = email; + this.imageURL = imageURL; + } + + public MemberEntity(String name, String role, String email, ProjectEntity projectEntity) {//Task 오류나서 생성자 새로 만들어놓음 + this.name = name; + this.role = role; this.email = email; - this.joinNumber = joinNumber; - this.isDelete = isDelete; this.projectEntity = projectEntity; } + public String getRole() { + return role; + } + + public String getName() { + return name; + } + + public String getImageURL() { + return imageURL; + } + public void setEmail(String email) { this.email = email; } @@ -37,7 +56,7 @@ public void setJoinNumber(String joinNumber) { @Id @GeneratedValue(strategy = GenerationType.AUTO) - @Column(name = "guest_id") + @Column(name = "member_id") private Long id; @Column(name = "email") @@ -49,11 +68,32 @@ public void setJoinNumber(String joinNumber) { @Column(name = "is_delete") private Integer isDelete; + @Column(name = "role") + private String role; + + public void setRole(String role) { + this.role = role; + } + + public void setName(String name) { + this.name = name; + } + + public void setImageURL(String imageURL) { + this.imageURL = imageURL; + } + + @Column(name = "name") + private String name; + + @Column(name = "imageURL") + private String imageURL; + @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "project_id") private ProjectEntity projectEntity; - @OneToMany(mappedBy = "owner", cascade = CascadeType.ALL) + @OneToMany(mappedBy = "owner") private List taskEntities; public Long getId() { From 4ab415e891781ac0acdc332c1329151221536873 Mon Sep 17 00:00:00 2001 From: suno-boy Date: Fri, 4 Oct 2024 20:50:21 +0900 Subject: [PATCH 41/51] =?UTF-8?q?feat:=20=EC=9C=A0=ED=9A=A8=EC=84=B1=20?= =?UTF-8?q?=EA=B2=80=EC=A6=9D=20=ED=8F=AC=ED=95=A8=ED=95=9C=20Member?= =?UTF-8?q?=EC=9A=94=EC=B2=AD=20DTO=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BE/seamless/DTO/MemberRequestDTO.java | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/src/main/java/team1/BE/seamless/DTO/MemberRequestDTO.java b/src/main/java/team1/BE/seamless/DTO/MemberRequestDTO.java index 2084a4f..2063774 100644 --- a/src/main/java/team1/BE/seamless/DTO/MemberRequestDTO.java +++ b/src/main/java/team1/BE/seamless/DTO/MemberRequestDTO.java @@ -1,5 +1,67 @@ package team1.BE.seamless.DTO; +import jakarta.validation.constraints.Email; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.Size; +import team1.BE.seamless.util.page.PageParam; + public class MemberRequestDTO { + public static class getMemberList extends PageParam { + + } + + @NotBlank(message = "이름은 필수 입력 사항입니다.") + @Size(max = 15, message = "이름은 공백 포함 최대 15글자까지 가능합니다.") + private String name; + + @NotBlank(message = "역할은 필수 입력 사항입니다.") + @Size(max = 15, message = "역할은 공백 포함 최대 15글자까지 가능합니다.") + private String role; + + @Email(message = "유효한 이메일 주소를 입력해주세요.") + @NotBlank(message = "이메일은 필수 입력 사항입니다.") + private String email; + + private String imageURL; + + public MemberRequestDTO() {} + + public MemberRequestDTO(String name, String role, String email, String imageURL) { + this.name = name; + this.role = role; + this.email = email; + this.imageURL = imageURL; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getRole() { + return role; + } + + public void setRole(String role) { + this.role = role; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getImageURL() { + return imageURL; + } + public void setImageURL(String imageURL) { + this.imageURL = imageURL; + } } From e86b4a37d2e7a0b25594fbb631746418656fc104 Mon Sep 17 00:00:00 2001 From: suno-boy Date: Fri, 4 Oct 2024 20:50:46 +0900 Subject: [PATCH 42/51] =?UTF-8?q?fix:=20Task=EC=84=9C=EB=B9=84=EC=8A=A4=20?= =?UTF-8?q?=EC=B6=A9=EB=8F=8C=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/team1/BE/seamless/service/TaskService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/team1/BE/seamless/service/TaskService.java b/src/main/java/team1/BE/seamless/service/TaskService.java index c4bcf22..b1970c4 100644 --- a/src/main/java/team1/BE/seamless/service/TaskService.java +++ b/src/main/java/team1/BE/seamless/service/TaskService.java @@ -27,7 +27,7 @@ public TaskEntity createTask(TaskDTO req) { ProjectEntity projectEntity = projectRepository.findById(req.getProjectId()).orElseThrow(() -> new BaseHandler(HttpStatus.NOT_FOUND, "존재하지 않는 프로젝트")); // Guest 기능 구현 이전 이기 때문에 Mock 데이터로 구현 - MemberEntity guestEntity = new MemberEntity("test@gmail.com", "1", 0, projectEntity); + MemberEntity guestEntity = new MemberEntity("test@gmail.com", "1", "", projectEntity); TaskEntity taskEntity = new TaskEntity( req.getName(), From 4b110a0944511bdbbe10686d261fc5e44a5ad313 Mon Sep 17 00:00:00 2001 From: suno-boy Date: Fri, 4 Oct 2024 20:51:44 +0900 Subject: [PATCH 43/51] =?UTF-8?q?feat:=20member=20CRUD=20=EC=97=85?= =?UTF-8?q?=EA=B7=B8=EB=A0=88=EC=9D=B4=EB=93=9C=20=EB=B0=8F=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../seamless/DTO/MemberDetailResponseDTO.java | 73 ++++++++++++++++ .../seamless/controller/MemberController.java | 55 +++++++++--- .../BE/seamless/mapper/MemberMapper.java | 32 +++++++ .../BE/seamless/service/MemberService.java | 85 ++++++++++++++++--- 4 files changed, 218 insertions(+), 27 deletions(-) create mode 100644 src/main/java/team1/BE/seamless/DTO/MemberDetailResponseDTO.java create mode 100644 src/main/java/team1/BE/seamless/mapper/MemberMapper.java diff --git a/src/main/java/team1/BE/seamless/DTO/MemberDetailResponseDTO.java b/src/main/java/team1/BE/seamless/DTO/MemberDetailResponseDTO.java new file mode 100644 index 0000000..850ea86 --- /dev/null +++ b/src/main/java/team1/BE/seamless/DTO/MemberDetailResponseDTO.java @@ -0,0 +1,73 @@ +package team1.BE.seamless.DTO; + +import team1.BE.seamless.entity.ProjectEntity; +import team1.BE.seamless.entity.TaskEntity; + +import java.util.List; + +public class MemberDetailResponseDTO { + private String email; + private String role; + private String name; + private String imageURL; + private ProjectEntity projectEntity; + private List taskEntities; + + public MemberDetailResponseDTO(String email, String role, String name, + String imageURL, ProjectEntity projectEntity, List taskEntities) { + this.email = email; + this.role = role; + this.name = name; + this.imageURL = imageURL; + this.projectEntity = projectEntity; + this.taskEntities = taskEntities; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getRole() { + return role; + } + + public void setRole(String role) { + this.role = role; + } + + public String getImageURL() { + return imageURL; + } + + public void setImageURL(String imageURL) { + this.imageURL = imageURL; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public ProjectEntity getProjectEntity() { + return projectEntity; + } + + public void setProjectEntity(ProjectEntity projectEntity) { + this.projectEntity = projectEntity; + } + + public List getTaskEntities() { + return taskEntities; + } + + public void setTaskEntities(List taskEntities) { + this.taskEntities = taskEntities; + } +} diff --git a/src/main/java/team1/BE/seamless/controller/MemberController.java b/src/main/java/team1/BE/seamless/controller/MemberController.java index 57bc2c7..b6e299d 100644 --- a/src/main/java/team1/BE/seamless/controller/MemberController.java +++ b/src/main/java/team1/BE/seamless/controller/MemberController.java @@ -2,39 +2,66 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import team1.BE.seamless.DTO.MemberRequestDTO; import team1.BE.seamless.DTO.MemberResponseDTO; import team1.BE.seamless.entity.MemberEntity; import team1.BE.seamless.service.MemberService; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.ResponseEntity; +import jakarta.validation.Valid; import org.springframework.web.bind.annotation.*; +import team1.BE.seamless.util.page.PageMapper; +import team1.BE.seamless.util.page.PageResult; import team1.BE.seamless.util.page.SingleResult; + @Tag(name = "팀원 관리") @RequestMapping("/api/project/{project_id}/member") @RestController public class MemberController { - @Autowired + MemberService memberService; -// @Operation(summary = "팀원 삭제") -// @DeleteMapping("/{member_id}") -// public SingleResult deleteMember(@PathVariable("project_id") Long projectId, @PathVariable("member_id") Long memberId) { -// memberService.deleteMember(memberId); -// return new SingleResult<>(new MemberResponseDTO("팀원(" + memberId + ")이 삭제되었습니다.")); -// } + @Autowired + MemberController(MemberService memberService) { + this.memberService = memberService; + } + + @Operation(summary = "팀원 개별 조회") + @GetMapping("/{member_id}") + public SingleResult getMember(@PathVariable("member_id") Long memberId) { + return new SingleResult<>(memberService.getMember(memberId)); + } + + @Operation(summary = "팀원 전체 조회") + @GetMapping + public PageResult getMemberList(@Valid MemberRequestDTO.getMemberList memberListRequestDTO) { + return PageMapper.toPageResult(memberService.getMemberList(memberListRequestDTO)); + } + @Operation(summary = "새 팀원 추가") @PostMapping - public SingleResult addMember(@PathVariable("project_id") Long projectId, @RequestBody MemberEntity member) { - MemberEntity newMember = memberService.addMember(member, projectId); - return new SingleResult<>(new MemberResponseDTO("새 팀원이 추가되었습니다.")); + public SingleResult createMember( + @PathVariable("project_id") Long projectId, + @Valid @RequestBody MemberRequestDTO memberRequestDTO) { + + MemberResponseDTO newMember = memberService.createMember(memberRequestDTO, projectId); + return new SingleResult<>(newMember); } @Operation(summary = "팀원 정보 수정") @PutMapping("/{member_id}") - public SingleResult updateMember(@PathVariable("project_id") Long projectId, @PathVariable("member_id") Long memberId, @RequestBody MemberEntity memberDetails) { - MemberEntity updatedMember = memberService.updateMember(memberId, memberDetails); - return new SingleResult<>(new MemberResponseDTO("팀원 정보가 업데이트 되었습니다.")); + public SingleResult updateMember( + @PathVariable("member_id") Long memberId + , @RequestBody MemberRequestDTO memberRequestDTO) { + MemberResponseDTO updatedMember = memberService.updateMember(memberId, memberRequestDTO); + return new SingleResult<>(updatedMember); + } + + @Operation(summary = "팀원 삭제") + @DeleteMapping("/{member_id}") + public SingleResult deleteMember(@PathVariable("member_id") Long memberId) { + MemberResponseDTO memberResponseDTO = memberService.deleteMember(memberId); + return new SingleResult<>(memberResponseDTO); } } diff --git a/src/main/java/team1/BE/seamless/mapper/MemberMapper.java b/src/main/java/team1/BE/seamless/mapper/MemberMapper.java new file mode 100644 index 0000000..96349e4 --- /dev/null +++ b/src/main/java/team1/BE/seamless/mapper/MemberMapper.java @@ -0,0 +1,32 @@ +package team1.BE.seamless.mapper; + +import org.springframework.stereotype.Component; +import team1.BE.seamless.DTO.MemberRequestDTO; +import team1.BE.seamless.entity.MemberEntity; +import java.util.Optional; + +@Component +public class MemberMapper { + + public MemberEntity toMemberEntity(MemberRequestDTO memberRequestDTO) { + + MemberEntity memberEntity = new MemberEntity( + memberRequestDTO.getName(), + memberRequestDTO.getRole(), + memberRequestDTO.getEmail(), + memberRequestDTO.getImageURL() + ); + + return memberEntity; + } + + public MemberEntity toMemberUpdateEntity(MemberRequestDTO memberRequestDTO, Optional existingMemberEntity) { + MemberEntity updatedMember = existingMemberEntity.get(); // 이걸 먼저 해야 정보가 먼저 변경됨. + updatedMember.setName(memberRequestDTO.getName()); // 세터없이 구현이 어렵다고 판단함. -> 기존 멤버의 정보를 유지해야하기 때문. + updatedMember.setRole(memberRequestDTO.getRole()); + updatedMember.setEmail(memberRequestDTO.getEmail()); + updatedMember.setImageURL(memberRequestDTO.getImageURL()); + return updatedMember; + } + +} diff --git a/src/main/java/team1/BE/seamless/service/MemberService.java b/src/main/java/team1/BE/seamless/service/MemberService.java index 6c5afdc..b14921a 100644 --- a/src/main/java/team1/BE/seamless/service/MemberService.java +++ b/src/main/java/team1/BE/seamless/service/MemberService.java @@ -1,37 +1,96 @@ package team1.BE.seamless.service; +import org.springframework.data.domain.Page; +import org.springframework.http.HttpStatus; +import org.springframework.http.HttpStatusCode; import org.springframework.transaction.annotation.Transactional; +import team1.BE.seamless.DTO.MemberRequestDTO; +import team1.BE.seamless.DTO.MemberResponseDTO; import team1.BE.seamless.entity.MemberEntity; import team1.BE.seamless.entity.ProjectEntity; +import team1.BE.seamless.mapper.MemberMapper; import team1.BE.seamless.repository.MemberRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import team1.BE.seamless.repository.ProjectRepository; +import team1.BE.seamless.util.errorException.BaseHandler; +import team1.BE.seamless.util.page.PageResult; + +import java.lang.reflect.Member; +import java.util.Optional; + +import static ch.qos.logback.core.util.AggregationType.NOT_FOUND; @Service public class MemberService { - @Autowired private final MemberRepository memberRepository; - public MemberService(MemberRepository memberRepository) { + private final MemberMapper memberMapper; + + private final ProjectRepository projectRepository; + + @Autowired + public MemberService(MemberRepository memberRepository, MemberMapper memberMapper, ProjectRepository projectRepository) { this.memberRepository = memberRepository; + this.memberMapper = memberMapper; + this.projectRepository = projectRepository; } - public void deleteMember(Long id) { - memberRepository.deleteById(id); + public MemberEntity getMember(Long memberId) { + Optional memberEntity = memberRepository.findById(memberId); + if (memberEntity.isPresent()) { + return memberEntity.get(); + } + else { + throw new BaseHandler(HttpStatus.NOT_FOUND, "프로젝트가 존재하지 않음"); + } } - public MemberEntity addMember(MemberEntity member, Long projectId) { -// member.setProject(new ProjectEntity(projectId)); -// return memberRepository.save(member); - return null; + public Page getMemberList(MemberRequestDTO.getMemberList memberListRequestDTO) { + return memberRepository.findAll(memberListRequestDTO.toPageable()); + } + + public MemberResponseDTO createMember(MemberRequestDTO memberRequestDTO, Long projectId) { + Optional projectEntity = projectRepository.findById(projectId); + if(projectEntity.isPresent()) { + MemberEntity memberEntity = memberMapper.toMemberEntity(memberRequestDTO); + memberEntity.setProject(projectEntity.get()); // 코드 구조상 어쩔 수 없이 setter 사용..(get메서드가 Optional기능이라 이렇게 함) + memberRepository.save(memberEntity); + // memberRepository.save(memberEntity) 리턴값은 MemberEntity임 JPA 기능임! + MemberResponseDTO memberResponseDTO = new MemberResponseDTO("팀원이 추가되었습니다."); + return memberResponseDTO; + } + else { + throw new BaseHandler(HttpStatus.NOT_FOUND, "해당하는 프로젝트가 존재하지 않습니다."); + } + } @Transactional - public MemberEntity updateMember(Long id, MemberEntity memberDetails) { - MemberEntity member = memberRepository.findById(id).orElseThrow(() -> new RuntimeException("Member not found")); - member.setEmail(memberDetails.getEmail()); - member.setJoinNumber(memberDetails.getJoinNumber()); - return memberRepository.save(member); + public MemberResponseDTO updateMember(Long memberId, MemberRequestDTO memberRequestDTO) { + Optional existingMemberEntity = memberRepository.findById(memberId); + if(existingMemberEntity.isPresent()) { + MemberEntity updatedMember = memberMapper.toMemberUpdateEntity(memberRequestDTO,existingMemberEntity); + memberRepository.save(updatedMember); + MemberResponseDTO memberResponseDTO = new MemberResponseDTO("팀원 정보가 성공적으로 변경되었습니다."); + return memberResponseDTO; + } + else { + throw new BaseHandler(HttpStatus.NOT_FOUND,"해당하는 팀원이 존재하지 않습니다."); + } + } + + + public MemberResponseDTO deleteMember(Long memberId) { + Optional existingMemberEntity = memberRepository.findById(memberId); + if(existingMemberEntity.isPresent()) { + String name = existingMemberEntity.get().getName(); + memberRepository.delete(existingMemberEntity.get()); + return new MemberResponseDTO("팀원 (" + name + ")이 팀에서 삭제되었습니다."); + } + else { + throw new BaseHandler(HttpStatus.NOT_FOUND,"해당하는 팀원이 존재하지 않습니다."); + } } } From ca4525c054e8548257d717462332611bf9ae60aa Mon Sep 17 00:00:00 2001 From: Kim-DongHyuk <80240164+Kdonghs@users.noreply.github.com> Date: Fri, 4 Oct 2024 21:40:36 +0900 Subject: [PATCH 44/51] =?UTF-8?q?feat:=20=EB=A9=A4=EB=B2=84=20crud=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BE/seamless/DTO/MemberRequestDTO.java | 112 ++++++++++------ .../seamless/controller/MemberController.java | 54 ++++---- .../BE/seamless/entity/MemberEntity.java | 75 +++++++---- .../BE/seamless/mapper/MemberMapper.java | 35 ++--- .../seamless/repository/MemberRepository.java | 5 + .../BE/seamless/service/MemberService.java | 124 ++++++++++-------- 6 files changed, 244 insertions(+), 161 deletions(-) diff --git a/src/main/java/team1/BE/seamless/DTO/MemberRequestDTO.java b/src/main/java/team1/BE/seamless/DTO/MemberRequestDTO.java index 2063774..1da9d2d 100644 --- a/src/main/java/team1/BE/seamless/DTO/MemberRequestDTO.java +++ b/src/main/java/team1/BE/seamless/DTO/MemberRequestDTO.java @@ -10,58 +10,84 @@ public static class getMemberList extends PageParam { } - @NotBlank(message = "이름은 필수 입력 사항입니다.") - @Size(max = 15, message = "이름은 공백 포함 최대 15글자까지 가능합니다.") - private String name; - - @NotBlank(message = "역할은 필수 입력 사항입니다.") - @Size(max = 15, message = "역할은 공백 포함 최대 15글자까지 가능합니다.") - private String role; - - @Email(message = "유효한 이메일 주소를 입력해주세요.") - @NotBlank(message = "이메일은 필수 입력 사항입니다.") - private String email; - - private String imageURL; + public static class CreateMember { + @NotBlank(message = "이름은 필수 입력 사항입니다.") + @Size(max = 15, message = "이름은 공백 포함 최대 15글자까지 가능합니다.") + private String name; + + @NotBlank(message = "역할은 필수 입력 사항입니다.") + @Size(max = 15, message = "역할은 공백 포함 최대 15글자까지 가능합니다.") + private String role; + + @Email(message = "유효한 이메일 주소를 입력해주세요.") + @NotBlank(message = "이메일은 필수 입력 사항입니다.") + private String email; + + private String imageURL; + + public CreateMember() { + } + + public CreateMember(String name, String role, String email, String imageURL) { + this.name = name; + this.role = role; + this.email = email; + this.imageURL = imageURL; + } + + public String getName() { + return name; + } + + public String getRole() { + return role; + } + + public String getEmail() { + return email; + } + + public String getImageURL() { + return imageURL; + } + } - public MemberRequestDTO() {} + public static class UpdateMember { + @Size(max = 15, message = "이름은 공백 포함 최대 15글자까지 가능합니다.") + private String name; - public MemberRequestDTO(String name, String role, String email, String imageURL) { - this.name = name; - this.role = role; - this.email = email; - this.imageURL = imageURL; - } + @Size(max = 15, message = "역할은 공백 포함 최대 15글자까지 가능합니다.") + private String role; - public String getName() { - return name; - } + @Email(message = "유효한 이메일 주소를 입력해주세요.") + private String email; - public void setName(String name) { - this.name = name; - } + private String imageURL; - public String getRole() { - return role; - } + public UpdateMember() { + } - public void setRole(String role) { - this.role = role; - } + public UpdateMember(String name, String role, String email, String imageURL) { + this.name = name; + this.role = role; + this.email = email; + this.imageURL = imageURL; + } - public String getEmail() { - return email; - } + public String getName() { + return name; + } - public void setEmail(String email) { - this.email = email; - } + public String getRole() { + return role; + } - public String getImageURL() { - return imageURL; - } + public String getEmail() { + return email; + } - public void setImageURL(String imageURL) { - this.imageURL = imageURL; + public String getImageURL() { + return imageURL; + } } } diff --git a/src/main/java/team1/BE/seamless/controller/MemberController.java b/src/main/java/team1/BE/seamless/controller/MemberController.java index b6e299d..a9dacdf 100644 --- a/src/main/java/team1/BE/seamless/controller/MemberController.java +++ b/src/main/java/team1/BE/seamless/controller/MemberController.java @@ -2,13 +2,20 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; import team1.BE.seamless.DTO.MemberRequestDTO; import team1.BE.seamless.DTO.MemberResponseDTO; import team1.BE.seamless.entity.MemberEntity; import team1.BE.seamless.service.MemberService; -import org.springframework.beans.factory.annotation.Autowired; -import jakarta.validation.Valid; -import org.springframework.web.bind.annotation.*; import team1.BE.seamless.util.page.PageMapper; import team1.BE.seamless.util.page.PageResult; import team1.BE.seamless.util.page.SingleResult; @@ -28,40 +35,43 @@ public class MemberController { @Operation(summary = "팀원 개별 조회") @GetMapping("/{member_id}") - public SingleResult getMember(@PathVariable("member_id") Long memberId) { - return new SingleResult<>(memberService.getMember(memberId)); + public SingleResult getMember(@Valid @PathVariable("project_id") Long projectId, + @Valid @PathVariable("member_id") Long memberId) { + return new SingleResult<>(memberService.getMember(projectId, memberId)); } @Operation(summary = "팀원 전체 조회") @GetMapping - public PageResult getMemberList(@Valid MemberRequestDTO.getMemberList memberListRequestDTO) { - return PageMapper.toPageResult(memberService.getMemberList(memberListRequestDTO)); + public PageResult getMemberList(@Valid @PathVariable("project_id") Long projectId, + @Valid MemberRequestDTO.getMemberList memberListRequestDTO) { + return PageMapper.toPageResult( + memberService.getMemberList(projectId, memberListRequestDTO)); } @Operation(summary = "새 팀원 추가") @PostMapping - public SingleResult createMember( - @PathVariable("project_id") Long projectId, - @Valid @RequestBody MemberRequestDTO memberRequestDTO) { - - MemberResponseDTO newMember = memberService.createMember(memberRequestDTO, projectId); - return new SingleResult<>(newMember); + public SingleResult createMember( + @PathVariable("project_id") Long projectId, + @Valid @RequestBody MemberRequestDTO.CreateMember Create) { + return new SingleResult<>(memberService.createMember(projectId, Create)); } @Operation(summary = "팀원 정보 수정") @PutMapping("/{member_id}") - public SingleResult updateMember( - @PathVariable("member_id") Long memberId - , @RequestBody MemberRequestDTO memberRequestDTO) { - MemberResponseDTO updatedMember = memberService.updateMember(memberId, memberRequestDTO); - return new SingleResult<>(updatedMember); + public SingleResult updateMember( + @PathVariable("project_id") Long projectId, + @PathVariable("member_id") Long memberId + , @RequestBody MemberRequestDTO.UpdateMember update) { + return new SingleResult<>(memberService.updateMember(projectId, memberId, update)); } - @Operation(summary = "팀원 삭제") + @Operation(summary = "팀원 삭제") @DeleteMapping("/{member_id}") - public SingleResult deleteMember(@PathVariable("member_id") Long memberId) { - MemberResponseDTO memberResponseDTO = memberService.deleteMember(memberId); - return new SingleResult<>(memberResponseDTO); + public SingleResult deleteMember( + @PathVariable("project_id") Long projectId, + @PathVariable("member_id") Long memberId) { + + return new SingleResult<>(memberService.deleteMember(projectId, memberId)); } } diff --git a/src/main/java/team1/BE/seamless/entity/MemberEntity.java b/src/main/java/team1/BE/seamless/entity/MemberEntity.java index b1022b6..597ff32 100644 --- a/src/main/java/team1/BE/seamless/entity/MemberEntity.java +++ b/src/main/java/team1/BE/seamless/entity/MemberEntity.java @@ -20,22 +20,20 @@ public MemberEntity() { } - public MemberEntity(String name, String role, String email, String imageURL) { - this.name = name; - this.role = role; - this.email = email; - this.imageURL = imageURL; - } +// public MemberEntity(String name, String role, String email, String imageURL) { +// this.name = name; +// this.role = role; +// this.email = email; +// this.imageURL = imageURL; +// } - public MemberEntity(String name, String role, String email, ProjectEntity projectEntity) {//Task 오류나서 생성자 새로 만들어놓음 + public MemberEntity(String name, String role, String email, String imageURL,ProjectEntity projectEntity) {//Task 오류나서 생성자 새로 만들어놓음 this.name = name; this.role = role; this.email = email; + this.imageURL = imageURL; this.projectEntity = projectEntity; - } - - public void setEmail(String email) { - this.email = email; + this.isDelete = false; } @Id @@ -46,11 +44,8 @@ public void setEmail(String email) { @Column(name = "email") private String email; - @Column(name = "join_number") - private String joinNumber; - @Column(name = "is_delete") - private Integer isDelete; + private Boolean isDelete; @Column(name = "role") private String role; @@ -66,7 +61,7 @@ public void setEmail(String email) { private ProjectEntity projectEntity; @OneToMany(mappedBy = "owner") - private List taskEntities; + private List taskEntities = new ArrayList<>(); public Long getId() { return id; @@ -76,28 +71,58 @@ public String getEmail() { return email; } - public Integer getIsDelete() { + public Boolean getIsDelete() { return isDelete; } - public ProjectEntity getProject() { + public String getRole() { + return role; + } + + public String getName() { + return name; + } + + public String getImageURL() { + return imageURL; + } + + public ProjectEntity getProjectEntity() { return projectEntity; } - public List getTasks() { + public List getTaskEntities() { return taskEntities; } -// public void addTask(TaskEntity taskEntity) { + public void setName(String name) { + this.name = name; + } + + public void setRole(String role) { + this.role = role; + } + + public void setEmail(String email) { + this.email = email; + } + + public void setImageURL(String imageURL) { + this.imageURL = imageURL; + } + + public void setDelete(Boolean delete) { + isDelete = delete; + } + + // public void addTask(TaskEntity taskEntity) { // if (this.taskEntities == null) { // this.taskEntities = new ArrayList<>(); // } // this.taskEntities.add(taskEntity); // taskEntity.setOwner(this); // 양방향 관계 설정 // } - - public void setProject(ProjectEntity projectEntity) { - this.projectEntity = projectEntity; - } - +// public void setEmail(String email) { +// this.email = email; +// } } diff --git a/src/main/java/team1/BE/seamless/mapper/MemberMapper.java b/src/main/java/team1/BE/seamless/mapper/MemberMapper.java index 96349e4..a06d309 100644 --- a/src/main/java/team1/BE/seamless/mapper/MemberMapper.java +++ b/src/main/java/team1/BE/seamless/mapper/MemberMapper.java @@ -1,32 +1,33 @@ package team1.BE.seamless.mapper; +import java.util.Optional; import org.springframework.stereotype.Component; import team1.BE.seamless.DTO.MemberRequestDTO; +import team1.BE.seamless.DTO.MemberRequestDTO.CreateMember; +import team1.BE.seamless.DTO.MemberRequestDTO.UpdateMember; import team1.BE.seamless.entity.MemberEntity; -import java.util.Optional; +import team1.BE.seamless.entity.ProjectEntity; @Component public class MemberMapper { - public MemberEntity toMemberEntity(MemberRequestDTO memberRequestDTO) { - - MemberEntity memberEntity = new MemberEntity( - memberRequestDTO.getName(), - memberRequestDTO.getRole(), - memberRequestDTO.getEmail(), - memberRequestDTO.getImageURL() - ); + public MemberEntity toEntity(CreateMember create, ProjectEntity project) { - return memberEntity; + return new MemberEntity( + create.getName(), + create.getRole(), + create.getEmail(), + create.getImageURL(), + project + ); } - public MemberEntity toMemberUpdateEntity(MemberRequestDTO memberRequestDTO, Optional existingMemberEntity) { - MemberEntity updatedMember = existingMemberEntity.get(); // 이걸 먼저 해야 정보가 먼저 변경됨. - updatedMember.setName(memberRequestDTO.getName()); // 세터없이 구현이 어렵다고 판단함. -> 기존 멤버의 정보를 유지해야하기 때문. - updatedMember.setRole(memberRequestDTO.getRole()); - updatedMember.setEmail(memberRequestDTO.getEmail()); - updatedMember.setImageURL(memberRequestDTO.getImageURL()); - return updatedMember; + public MemberEntity toUpdate(MemberEntity member, UpdateMember update) { + member.setEmail(update.getEmail()); + member.setImageURL(update.getImageURL()); + member.setRole(update.getRole()); + member.setName(update.getName()); + return member; } } diff --git a/src/main/java/team1/BE/seamless/repository/MemberRepository.java b/src/main/java/team1/BE/seamless/repository/MemberRepository.java index 6a7b532..cc763ed 100644 --- a/src/main/java/team1/BE/seamless/repository/MemberRepository.java +++ b/src/main/java/team1/BE/seamless/repository/MemberRepository.java @@ -1,5 +1,8 @@ package team1.BE.seamless.repository; +import java.util.Optional; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; import team1.BE.seamless.entity.MemberEntity; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; @@ -7,4 +10,6 @@ @Repository public interface MemberRepository extends JpaRepository { + Optional findByIdAndProjectEntityIdAndIsDeleteFalse(Long id, Long projectId); + Page findAllByProjectEntityIdAndIsDeleteFalse(Long projectId, Pageable pageable); } diff --git a/src/main/java/team1/BE/seamless/service/MemberService.java b/src/main/java/team1/BE/seamless/service/MemberService.java index b14921a..860fa64 100644 --- a/src/main/java/team1/BE/seamless/service/MemberService.java +++ b/src/main/java/team1/BE/seamless/service/MemberService.java @@ -1,25 +1,22 @@ package team1.BE.seamless.service; +import jakarta.validation.Valid; +import java.util.Optional; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.http.HttpStatus; -import org.springframework.http.HttpStatusCode; +import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import team1.BE.seamless.DTO.MemberRequestDTO; +import team1.BE.seamless.DTO.MemberRequestDTO.CreateMember; +import team1.BE.seamless.DTO.MemberRequestDTO.UpdateMember; +import team1.BE.seamless.DTO.MemberRequestDTO.getMemberList; import team1.BE.seamless.DTO.MemberResponseDTO; import team1.BE.seamless.entity.MemberEntity; import team1.BE.seamless.entity.ProjectEntity; import team1.BE.seamless.mapper.MemberMapper; import team1.BE.seamless.repository.MemberRepository; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; import team1.BE.seamless.repository.ProjectRepository; import team1.BE.seamless.util.errorException.BaseHandler; -import team1.BE.seamless.util.page.PageResult; - -import java.lang.reflect.Member; -import java.util.Optional; - -import static ch.qos.logback.core.util.AggregationType.NOT_FOUND; @Service public class MemberService { @@ -37,60 +34,79 @@ public MemberService(MemberRepository memberRepository, MemberMapper memberMappe this.projectRepository = projectRepository; } - public MemberEntity getMember(Long memberId) { - Optional memberEntity = memberRepository.findById(memberId); - if (memberEntity.isPresent()) { - return memberEntity.get(); - } - else { - throw new BaseHandler(HttpStatus.NOT_FOUND, "프로젝트가 존재하지 않음"); - } + public MemberEntity getMember(Long projectId, Long memberId) { +// Optional memberEntity = memberRepository.findById(memberId); +// if (memberEntity.isPresent()) { +// return memberEntity.get(); +// } +// else { +// throw new BaseHandler(HttpStatus.NOT_FOUND, "프로젝트가 존재하지 않음"); +// } + return memberRepository.findByIdAndProjectEntityIdAndIsDeleteFalse(memberId, projectId) + .orElseThrow(()-> new BaseHandler(HttpStatus.NOT_FOUND, "해당 멤버가 존재하지 않습니다.")); } - public Page getMemberList(MemberRequestDTO.getMemberList memberListRequestDTO) { - return memberRepository.findAll(memberListRequestDTO.toPageable()); + public Page getMemberList(@Valid Long projectId, getMemberList memberListRequestDTO) { + return memberRepository.findAllByProjectEntityIdAndIsDeleteFalse(projectId, memberListRequestDTO.toPageable()); } - public MemberResponseDTO createMember(MemberRequestDTO memberRequestDTO, Long projectId) { - Optional projectEntity = projectRepository.findById(projectId); - if(projectEntity.isPresent()) { - MemberEntity memberEntity = memberMapper.toMemberEntity(memberRequestDTO); - memberEntity.setProject(projectEntity.get()); // 코드 구조상 어쩔 수 없이 setter 사용..(get메서드가 Optional기능이라 이렇게 함) - memberRepository.save(memberEntity); - // memberRepository.save(memberEntity) 리턴값은 MemberEntity임 JPA 기능임! - MemberResponseDTO memberResponseDTO = new MemberResponseDTO("팀원이 추가되었습니다."); - return memberResponseDTO; - } - else { - throw new BaseHandler(HttpStatus.NOT_FOUND, "해당하는 프로젝트가 존재하지 않습니다."); - } + public MemberEntity createMember(Long projectId, CreateMember create) { +// Optional projectEntity = projectRepository.findById(projectId); +// if(projectEntity.isPresent()) { +// MemberEntity memberEntity = memberMapper.toMemberEntity(memberRequestDTO); +// memberEntity.setProject(projectEntity.get()); // 코드 구조상 어쩔 수 없이 setter 사용..(get메서드가 Optional기능이라 이렇게 함) +// memberRepository.save(memberEntity); +// // memberRepository.save(memberEntity) 리턴값은 MemberEntity임 JPA 기능임! +// MemberResponseDTO memberResponseDTO = new MemberResponseDTO("팀원이 추가되었습니다."); +// return memberResponseDTO; +// } +// else { +// throw new BaseHandler(HttpStatus.NOT_FOUND, "해당하는 프로젝트가 존재하지 않습니다."); +// } + ProjectEntity project = projectRepository.findById(projectId) + .orElseThrow(()-> new BaseHandler(HttpStatus.NOT_FOUND, "해당 프로젝트가 존재하지 않습니다.")); + + MemberEntity member = memberMapper.toEntity(create, project); + memberRepository.save(member); + return member; } @Transactional - public MemberResponseDTO updateMember(Long memberId, MemberRequestDTO memberRequestDTO) { - Optional existingMemberEntity = memberRepository.findById(memberId); - if(existingMemberEntity.isPresent()) { - MemberEntity updatedMember = memberMapper.toMemberUpdateEntity(memberRequestDTO,existingMemberEntity); - memberRepository.save(updatedMember); - MemberResponseDTO memberResponseDTO = new MemberResponseDTO("팀원 정보가 성공적으로 변경되었습니다."); - return memberResponseDTO; - } - else { - throw new BaseHandler(HttpStatus.NOT_FOUND,"해당하는 팀원이 존재하지 않습니다."); - } + public MemberEntity updateMember(Long projectId, Long memberId, UpdateMember update) { +// Optional existingMemberEntity = memberRepository.findById(memberId); +// if(existingMemberEntity.isPresent()) { +// MemberEntity updatedMember = memberMapper.toMemberUpdateEntity(memberRequestDTO,existingMemberEntity); +// memberRepository.save(updatedMember); +// MemberResponseDTO memberResponseDTO = new MemberResponseDTO("팀원 정보가 성공적으로 변경되었습니다."); +// return memberResponseDTO; +// } +// else { +// throw new BaseHandler(HttpStatus.NOT_FOUND,"해당하는 팀원이 존재하지 않습니다."); +// } + MemberEntity member = memberRepository.findByIdAndProjectEntityIdAndIsDeleteFalse(memberId, projectId) + .orElseThrow(()-> new BaseHandler(HttpStatus.NOT_FOUND, "해당 멤버가 존재하지 않습니다.")); + + memberMapper.toUpdate(member,update); + return member; } +@Transactional + public MemberEntity deleteMember(Long projectId, Long memberId) { +// Optional existingMemberEntity = memberRepository.findById(memberId); +// if(existingMemberEntity.isPresent()) { +// String name = existingMemberEntity.get().getName(); +// memberRepository.delete(existingMemberEntity.get()); +// return new MemberResponseDTO("팀원 (" + name + ")이 팀에서 삭제되었습니다."); +// } +// else { +// throw new BaseHandler(HttpStatus.NOT_FOUND,"해당하는 팀원이 존재하지 않습니다."); +// } + MemberEntity member = memberRepository.findByIdAndProjectEntityIdAndIsDeleteFalse(memberId, projectId) + .orElseThrow(()-> new BaseHandler(HttpStatus.NOT_FOUND, "해당 멤버가 존재하지 않습니다.")); + + member.setDelete(true); - public MemberResponseDTO deleteMember(Long memberId) { - Optional existingMemberEntity = memberRepository.findById(memberId); - if(existingMemberEntity.isPresent()) { - String name = existingMemberEntity.get().getName(); - memberRepository.delete(existingMemberEntity.get()); - return new MemberResponseDTO("팀원 (" + name + ")이 팀에서 삭제되었습니다."); - } - else { - throw new BaseHandler(HttpStatus.NOT_FOUND,"해당하는 팀원이 존재하지 않습니다."); - } + return member; } } From 84f51e1ff2ba09858a2d39c24875cac2ceb2d6e3 Mon Sep 17 00:00:00 2001 From: Kim-DongHyuk <80240164+Kdonghs@users.noreply.github.com> Date: Fri, 4 Oct 2024 21:40:49 +0900 Subject: [PATCH 45/51] =?UTF-8?q?fix:=20=EC=98=A4=ED=83=80=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/team1/BE/seamless/service/UserService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/team1/BE/seamless/service/UserService.java b/src/main/java/team1/BE/seamless/service/UserService.java index a61fc51..9ea9659 100644 --- a/src/main/java/team1/BE/seamless/service/UserService.java +++ b/src/main/java/team1/BE/seamless/service/UserService.java @@ -37,7 +37,7 @@ public UserDetails getUser(HttpServletRequest req) { } @Transactional - public UserSimple xupdateUser(HttpServletRequest req, @Valid UserUpdate update) { + public UserSimple updateUser(HttpServletRequest req, @Valid UserUpdate update) { UserEntity user = userRepository.findByEmail(parsingPram.getEmail(req)) .orElseThrow(() -> new BaseHandler(HttpStatus.NOT_FOUND, "해당 유저가 존재하지 않습니다.")); From 51ea572b36cc44bbb78b5e77ba41ab05f31e2688 Mon Sep 17 00:00:00 2001 From: Kim-DongHyuk <80240164+Kdonghs@users.noreply.github.com> Date: Fri, 4 Oct 2024 21:51:53 +0900 Subject: [PATCH 46/51] =?UTF-8?q?fix:=20=ED=83=9C=EC=8A=A4=ED=81=AC=20?= =?UTF-8?q?=EB=A6=AC=EC=8A=A4=ED=8A=B8=20=EB=B6=88=EB=9F=AC=EC=98=A4?= =?UTF-8?q?=EB=8A=94=20=EA=B8=B0=EB=8A=A5=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/team1/BE/seamless/DTO/TaskDTO.java | 4 ++++ .../BE/seamless/controller/TaskController.java | 6 ++++-- .../BE/seamless/repository/TaskRepository.java | 6 ++++++ .../team1/BE/seamless/service/TaskService.java | 14 ++++++-------- 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/main/java/team1/BE/seamless/DTO/TaskDTO.java b/src/main/java/team1/BE/seamless/DTO/TaskDTO.java index cd16022..3a269b6 100644 --- a/src/main/java/team1/BE/seamless/DTO/TaskDTO.java +++ b/src/main/java/team1/BE/seamless/DTO/TaskDTO.java @@ -5,8 +5,12 @@ import java.time.LocalDateTime; import org.springframework.http.HttpStatus; import team1.BE.seamless.util.errorException.BaseHandler; +import team1.BE.seamless.util.page.PageParam; public class TaskDTO { + public static class getList extends PageParam { + + } public static class Create { diff --git a/src/main/java/team1/BE/seamless/controller/TaskController.java b/src/main/java/team1/BE/seamless/controller/TaskController.java index 1e7383e..c2db8b4 100644 --- a/src/main/java/team1/BE/seamless/controller/TaskController.java +++ b/src/main/java/team1/BE/seamless/controller/TaskController.java @@ -17,6 +17,8 @@ import team1.BE.seamless.entity.TaskEntity; import team1.BE.seamless.service.TaskService; import team1.BE.seamless.util.page.ListResult; +import team1.BE.seamless.util.page.PageMapper; +import team1.BE.seamless.util.page.PageResult; import team1.BE.seamless.util.page.SingleResult; @Tag(name = "태스크") @@ -39,8 +41,8 @@ public SingleResult getTask(@PathVariable Long taskId) { @Operation(summary = "프로젝트 아이디로 태스크 리스트 조회 ") @GetMapping("/{projectId}/task") - public ListResult getTaskList(@PathVariable Long projectId) { - return new ListResult<>(taskService.getTaskList(projectId)); + public PageResult getTaskList(@PathVariable Long projectId, @Valid TaskDTO.getList param) { + return PageMapper.toPageResult(taskService.getTaskList(projectId, param)); } /** diff --git a/src/main/java/team1/BE/seamless/repository/TaskRepository.java b/src/main/java/team1/BE/seamless/repository/TaskRepository.java index 8f51291..e99d156 100644 --- a/src/main/java/team1/BE/seamless/repository/TaskRepository.java +++ b/src/main/java/team1/BE/seamless/repository/TaskRepository.java @@ -2,6 +2,8 @@ import java.util.List; import java.util.Optional; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; import team1.BE.seamless.entity.ProjectEntity; import team1.BE.seamless.entity.TaskEntity; import org.springframework.data.jpa.repository.JpaRepository; @@ -10,6 +12,10 @@ @Repository public interface TaskRepository extends JpaRepository { + Optional findByIdAndIsDeletedFalse(Long id); + + Page findAllByProjectIdAndIsDeletedFalse(Long projectId, Pageable pageable); + List findByProjectEntity(ProjectEntity projectEntity); Optional findByIdAndProjectEntityUserEntityEmail(Long id, String email); diff --git a/src/main/java/team1/BE/seamless/service/TaskService.java b/src/main/java/team1/BE/seamless/service/TaskService.java index 7af9b93..76344cc 100644 --- a/src/main/java/team1/BE/seamless/service/TaskService.java +++ b/src/main/java/team1/BE/seamless/service/TaskService.java @@ -2,13 +2,14 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.validation.Valid; -import java.util.List; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import team1.BE.seamless.DTO.TaskDTO.Create; import team1.BE.seamless.DTO.TaskDTO.Update; +import team1.BE.seamless.DTO.TaskDTO.getList; import team1.BE.seamless.entity.MemberEntity; import team1.BE.seamless.entity.ProjectEntity; import team1.BE.seamless.entity.TaskEntity; @@ -40,15 +41,12 @@ public TaskService(TaskRepository taskRepository, ProjectRepository projectRepos } public TaskEntity getTask(Long taskId) { - return taskRepository.findById(taskId) + return taskRepository.findByIdAndIsDeletedFalse(taskId) .orElseThrow(() -> new BaseHandler(HttpStatus.NOT_FOUND, "존재하지 않는 태스크")); } - public List getTaskList(Long projectId) { - ProjectEntity projectEntity = projectRepository.findById(projectId) - .orElseThrow(() -> new BaseHandler(HttpStatus.NOT_FOUND, "존재하지 않는 프로젝트")); - - return projectEntity.getTaskEntities(); + public Page getTaskList(Long projectId, getList param) { + return taskRepository.findAllByProjectIdAndIsDeletedFalse(projectId, param.toPageable()); } public TaskEntity createTask(HttpServletRequest req, @Valid Long projectId, Create create) { @@ -71,7 +69,7 @@ public TaskEntity createTask(HttpServletRequest req, @Valid Long projectId, Crea @Transactional public TaskEntity updateTask(HttpServletRequest req, @Valid Long taskId, @Valid Update update) { - TaskEntity task = taskRepository.findById(taskId) + TaskEntity task = taskRepository.findByIdAndIsDeletedFalse(taskId) .orElseThrow(() -> new BaseHandler(HttpStatus.NOT_FOUND, "존재하지 않는 태스크")); // 태스크의 일정 검증 From 9f8c3723d55979cc0587cca50c1a524300bc2f0f Mon Sep 17 00:00:00 2001 From: Kim-DongHyuk <80240164+Kdonghs@users.noreply.github.com> Date: Fri, 4 Oct 2024 21:52:25 +0900 Subject: [PATCH 47/51] =?UTF-8?q?fix:=20=EC=9C=A0=EC=A0=80=20isDelete=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/team1/BE/seamless/entity/UserEntity.java | 10 +++++----- .../team1/BE/seamless/repository/UserRepository.java | 4 ++-- .../java/team1/BE/seamless/service/UserService.java | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main/java/team1/BE/seamless/entity/UserEntity.java b/src/main/java/team1/BE/seamless/entity/UserEntity.java index 53af6db..a0238d6 100644 --- a/src/main/java/team1/BE/seamless/entity/UserEntity.java +++ b/src/main/java/team1/BE/seamless/entity/UserEntity.java @@ -41,7 +41,7 @@ public class UserEntity { @NotNull @Column - private Integer isDelete; + private Boolean isDelete; @OneToMany(mappedBy = "userEntity", cascade = CascadeType.ALL) private List projectEntities; @@ -60,7 +60,7 @@ public UserEntity(String name, String email, String picture) { this.name = name; this.email = email; this.picture = picture; - this.isDelete = 0; + this.isDelete = false; this.role = Role.USER; } @@ -80,11 +80,11 @@ public String getPicture() { return picture; } - public @NotNull Role getRole() { + public Role getRole() { return role; } - public @NotNull Integer getIsDelete() { + public Boolean getIsDelete() { return isDelete; } @@ -97,7 +97,7 @@ public LocalDateTime getUpdatedAt() { } public void setIsDelete() { - this.isDelete = 1; + this.isDelete = true; } public UserEntity update(String name, String picture) { diff --git a/src/main/java/team1/BE/seamless/repository/UserRepository.java b/src/main/java/team1/BE/seamless/repository/UserRepository.java index 152493d..311e6b9 100644 --- a/src/main/java/team1/BE/seamless/repository/UserRepository.java +++ b/src/main/java/team1/BE/seamless/repository/UserRepository.java @@ -8,6 +8,6 @@ @Repository public interface UserRepository extends JpaRepository { - Optional findByEmail(String email); - Optional findByEmailAndIsDelete(String email, Integer isDelete); + Optional findByEmailAndIsDeleteFalse(String email); + Optional findByEmailAndIsDeleteFalse(String email, Integer isDelete); } diff --git a/src/main/java/team1/BE/seamless/service/UserService.java b/src/main/java/team1/BE/seamless/service/UserService.java index 9ea9659..3583935 100644 --- a/src/main/java/team1/BE/seamless/service/UserService.java +++ b/src/main/java/team1/BE/seamless/service/UserService.java @@ -31,14 +31,14 @@ public UserService(UserRepository userRepository, UserMapper userMapper, } public UserDetails getUser(HttpServletRequest req) { - UserEntity user = userRepository.findByEmail(parsingPram.getEmail(req)) + UserEntity user = userRepository.findByEmailAndIsDeleteFalse(parsingPram.getEmail(req)) .orElseThrow(() -> new BaseHandler(HttpStatus.NOT_FOUND, "해당 유저가 존재하지 않습니다.")); return userMapper.toUserDetails(user); } @Transactional public UserSimple updateUser(HttpServletRequest req, @Valid UserUpdate update) { - UserEntity user = userRepository.findByEmail(parsingPram.getEmail(req)) + UserEntity user = userRepository.findByEmailAndIsDeleteFalse(parsingPram.getEmail(req)) .orElseThrow(() -> new BaseHandler(HttpStatus.NOT_FOUND, "해당 유저가 존재하지 않습니다.")); userMapper.toUpdate(user,update); @@ -48,7 +48,7 @@ public UserSimple updateUser(HttpServletRequest req, @Valid UserUpdate update) { @Transactional public UserSimple deleteUser(HttpServletRequest req) { - UserEntity user = userRepository.findByEmailAndIsDelete(parsingPram.getEmail(req),0) + UserEntity user = userRepository.findByEmailAndIsDeleteFalse(parsingPram.getEmail(req),0) .orElseThrow(() -> new BaseHandler(HttpStatus.NOT_FOUND, "해당 유저가 존재하지 않습니다.")); user.setIsDelete(); @@ -58,7 +58,7 @@ public UserSimple deleteUser(HttpServletRequest req) { @Transactional public UserEntity createUser(@Valid UserSimple simple) { - return userRepository.findByEmail(simple.getEmail()) + return userRepository.findByEmailAndIsDeleteFalse(simple.getEmail()) .orElseGet(() -> userRepository.save( userMapper.toEntity( simple.getUsername(), From 471f82d76331b154e116f7416ad1e1e984efd5ac Mon Sep 17 00:00:00 2001 From: Kim-DongHyuk <80240164+Kdonghs@users.noreply.github.com> Date: Fri, 4 Oct 2024 21:59:38 +0900 Subject: [PATCH 48/51] =?UTF-8?q?fix:=20=ED=94=84=EB=A1=9C=EC=A0=9D?= =?UTF-8?q?=ED=8A=B8=20isDelete=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BE/seamless/repository/ProjectRepository.java | 11 +++++------ .../team1/BE/seamless/repository/TaskRepository.java | 8 ++------ .../team1/BE/seamless/service/ProjectService.java | 7 ++++--- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/src/main/java/team1/BE/seamless/repository/ProjectRepository.java b/src/main/java/team1/BE/seamless/repository/ProjectRepository.java index dd4507f..9642c0a 100644 --- a/src/main/java/team1/BE/seamless/repository/ProjectRepository.java +++ b/src/main/java/team1/BE/seamless/repository/ProjectRepository.java @@ -10,13 +10,12 @@ @Repository public interface ProjectRepository extends JpaRepository { - Page findAll(Pageable pageable); - Page findAllBy(Pageable pageable); - Optional findByIdAndUserEntityEmail(Long id, String email); - Page findAllByUserEntityEmail(Pageable pageable, String email); + Page findAllByIsDeletedFalse(Pageable pageable); + Optional findByIdAndUserEntityEmailAndIsDeletedFalse(Long id, String email); + Page findAllByUserEntityEmailAndIsDeletedFalse(Pageable pageable, String email); - Optional findById(Long id); + Optional findByIdAndIsDeletedFalse(Long id); - Page findByUserEntityEmail(Pageable pageable, String email); + Page findByUserEntityEmailAndIsDeletedFalse(Pageable pageable, String email); } diff --git a/src/main/java/team1/BE/seamless/repository/TaskRepository.java b/src/main/java/team1/BE/seamless/repository/TaskRepository.java index e99d156..093511e 100644 --- a/src/main/java/team1/BE/seamless/repository/TaskRepository.java +++ b/src/main/java/team1/BE/seamless/repository/TaskRepository.java @@ -1,13 +1,11 @@ package team1.BE.seamless.repository; -import java.util.List; import java.util.Optional; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; -import team1.BE.seamless.entity.ProjectEntity; -import team1.BE.seamless.entity.TaskEntity; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; +import team1.BE.seamless.entity.TaskEntity; @Repository public interface TaskRepository extends JpaRepository { @@ -16,7 +14,5 @@ public interface TaskRepository extends JpaRepository { Page findAllByProjectIdAndIsDeletedFalse(Long projectId, Pageable pageable); - List findByProjectEntity(ProjectEntity projectEntity); - - Optional findByIdAndProjectEntityUserEntityEmail(Long id, String email); + Optional findByIdAndProjectEntityUserEntityEmail(Long id, String email); } diff --git a/src/main/java/team1/BE/seamless/service/ProjectService.java b/src/main/java/team1/BE/seamless/service/ProjectService.java index baa794e..755970f 100644 --- a/src/main/java/team1/BE/seamless/service/ProjectService.java +++ b/src/main/java/team1/BE/seamless/service/ProjectService.java @@ -39,7 +39,7 @@ public ProjectService(ProjectRepository projectRepository, UserRepository userRe } public Page getProjectList(ProjectDTO.getList param, String email) { - return projectRepository.findAllByUserEntityEmail(param.toPageable(), email); + return projectRepository.findAllByUserEntityEmailAndIsDeletedFalse(param.toPageable(), email); } public ProjectEntity getProject(long id) { @@ -54,13 +54,14 @@ public List getProjectMembers(long id) { } public Page getProjectPeriod(ProjectDTO.getList param, String email) { - return projectRepository.findByUserEntityEmail(param.toPageable(), email); + return projectRepository.findByUserEntityEmailAndIsDeletedFalse(param.toPageable(), email); } @Transactional public ProjectEntity createProject(ProjectCreate create, String email) { - UserEntity userEntity = userRepository.findByEmail(email) + UserEntity userEntity = userRepository.findByEmailAndIsDeleteFalse(email) .orElseThrow(() -> new BaseHandler(HttpStatus.NOT_FOUND, "사용자가 존재하지 않음")); + List optionEntities = optionRepository.findByIdIn(create.getOptionIds()); List projectOptions = optionEntities.stream() From 3e920fb42825ed1875edf485af1d267df8323f1c Mon Sep 17 00:00:00 2001 From: Kim-DongHyuk <80240164+Kdonghs@users.noreply.github.com> Date: Fri, 4 Oct 2024 22:01:03 +0900 Subject: [PATCH 49/51] =?UTF-8?q?fix:=20=ED=95=A8=EC=88=98=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/team1/BE/seamless/service/TaskService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/team1/BE/seamless/service/TaskService.java b/src/main/java/team1/BE/seamless/service/TaskService.java index 76344cc..988b906 100644 --- a/src/main/java/team1/BE/seamless/service/TaskService.java +++ b/src/main/java/team1/BE/seamless/service/TaskService.java @@ -50,7 +50,7 @@ public Page getTaskList(Long projectId, getList param) { } public TaskEntity createTask(HttpServletRequest req, @Valid Long projectId, Create create) { - ProjectEntity project = projectRepository.findByIdAndUserEntityEmail(projectId,parsingPram.getEmail(req)) + ProjectEntity project = projectRepository.findByIdAndUserEntityEmailAndIsDeletedFalse(projectId,parsingPram.getEmail(req)) .orElseThrow(() -> new BaseHandler(HttpStatus.NOT_FOUND, "존재하지 않는 프로젝트")); // 태스크의 일정 검증 From d3040696a467d094509820a32942f37f22c6805c Mon Sep 17 00:00:00 2001 From: Kim-DongHyuk <80240164+Kdonghs@users.noreply.github.com> Date: Fri, 4 Oct 2024 22:01:44 +0900 Subject: [PATCH 50/51] =?UTF-8?q?style:=20=EC=BD=94=EB=93=9C=20=EC=8A=A4?= =?UTF-8?q?=ED=83=80=EC=9D=BC=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BE/seamless/DTO/AttendUrlResponseDTO.java | 4 ++- .../java/team1/BE/seamless/DTO/AuthDTO.java | 2 +- .../BE/seamless/DTO/InviteRequestDTO.java | 5 ++- .../seamless/DTO/MemberDetailResponseDTO.java | 6 ++-- .../BE/seamless/DTO/MemberRequestDTO.java | 3 ++ .../BE/seamless/DTO/MemberResponseDTO.java | 1 + .../java/team1/BE/seamless/DTO/OptionDTO.java | 4 +-- .../java/team1/BE/seamless/DTO/TaskDTO.java | 1 + .../java/team1/BE/seamless/DTO/UserDTO.java | 5 +-- .../controller/AttendUrlController.java | 22 +++++-------- .../seamless/controller/MemberController.java | 1 - .../controller/ProjectInviteController.java | 10 ++++-- .../seamless/controller/TaskController.java | 17 +++++----- .../seamless/controller/TestController.java | 12 +++---- .../seamless/controller/UserController.java | 16 +++++----- .../BE/seamless/entity/MemberEntity.java | 6 ++-- .../team1/BE/seamless/entity/UserEntity.java | 6 ++-- .../java/team1/BE/seamless/init/InitData.java | 3 +- .../BE/seamless/init/ProjectCreator.java | 8 ++--- .../team1/BE/seamless/init/TestCreator.java | 4 +-- .../team1/BE/seamless/init/UserCreator.java | 2 +- .../BE/seamless/mapper/MemberMapper.java | 2 -- .../BE/seamless/mapper/ProjectMapper.java | 3 +- .../team1/BE/seamless/mapper/TaskMapper.java | 10 +++--- .../team1/BE/seamless/mapper/UserMapper.java | 2 +- .../seamless/repository/MemberRepository.java | 4 ++- .../repository/ProjectRepository.java | 6 ++-- .../seamless/repository/TestRepository.java | 3 +- .../seamless/repository/UserRepository.java | 3 +- .../BE/seamless/service/AttendURLService.java | 3 +- .../BE/seamless/service/AuthService.java | 4 +-- .../BE/seamless/service/MemberService.java | 29 +++++++++-------- .../service/ProjectInviteService.java | 1 + .../BE/seamless/service/ProjectService.java | 3 +- .../BE/seamless/service/TaskService.java | 32 +++++++++++-------- .../BE/seamless/service/TestService.java | 10 +++--- .../BE/seamless/service/UserService.java | 24 +++++++------- src/main/java/team1/BE/seamless/util/URL.java | 3 +- .../BE/seamless/util/auth/ParsingPram.java | 1 - .../BE/seamless/util/auth/SecurityConfig.java | 21 ++++++------ .../util/errorException/RuntimeHandler.java | 1 + .../errorException/SecurityEntryPoint.java | 6 ++-- .../util/fiter/TokenAuthenticationFilter.java | 2 +- .../util/fiter/TokenExceptionFilter.java | 2 +- .../BE/seamless/util/page/ListResult.java | 2 +- 45 files changed, 171 insertions(+), 144 deletions(-) diff --git a/src/main/java/team1/BE/seamless/DTO/AttendUrlResponseDTO.java b/src/main/java/team1/BE/seamless/DTO/AttendUrlResponseDTO.java index 39733ab..de44b5c 100644 --- a/src/main/java/team1/BE/seamless/DTO/AttendUrlResponseDTO.java +++ b/src/main/java/team1/BE/seamless/DTO/AttendUrlResponseDTO.java @@ -1,9 +1,11 @@ package team1.BE.seamless.DTO; public class AttendUrlResponseDTO { + String attendUrl; - public AttendUrlResponseDTO() {} + public AttendUrlResponseDTO() { + } public AttendUrlResponseDTO(String attendUrl) { this.attendUrl = attendUrl; diff --git a/src/main/java/team1/BE/seamless/DTO/AuthDTO.java b/src/main/java/team1/BE/seamless/DTO/AuthDTO.java index ada7f58..ffcf0d6 100644 --- a/src/main/java/team1/BE/seamless/DTO/AuthDTO.java +++ b/src/main/java/team1/BE/seamless/DTO/AuthDTO.java @@ -1,6 +1,5 @@ package team1.BE.seamless.DTO; -import team1.BE.seamless.entity.UserEntity; import java.util.Collection; import java.util.Collections; import java.util.Map; @@ -8,6 +7,7 @@ import org.springframework.security.core.authority.SimpleGrantedAuthority; import org.springframework.security.core.userdetails.UserDetails; import org.springframework.security.oauth2.core.user.OAuth2User; +import team1.BE.seamless.entity.UserEntity; public class AuthDTO { diff --git a/src/main/java/team1/BE/seamless/DTO/InviteRequestDTO.java b/src/main/java/team1/BE/seamless/DTO/InviteRequestDTO.java index 1a2980f..3d0a775 100644 --- a/src/main/java/team1/BE/seamless/DTO/InviteRequestDTO.java +++ b/src/main/java/team1/BE/seamless/DTO/InviteRequestDTO.java @@ -1,11 +1,14 @@ package team1.BE.seamless.DTO; + // 팀원이 초대링크에 해당하는 페이지에서 이름, 이메일을 작성하여 // 요청을 보낼 때의 DTO public class InviteRequestDTO { + private Integer projectId; private String email; - public InviteRequestDTO() {} + public InviteRequestDTO() { + } public InviteRequestDTO(Integer projectId, String email) { this.projectId = projectId; diff --git a/src/main/java/team1/BE/seamless/DTO/MemberDetailResponseDTO.java b/src/main/java/team1/BE/seamless/DTO/MemberDetailResponseDTO.java index 850ea86..73ef5ce 100644 --- a/src/main/java/team1/BE/seamless/DTO/MemberDetailResponseDTO.java +++ b/src/main/java/team1/BE/seamless/DTO/MemberDetailResponseDTO.java @@ -1,11 +1,11 @@ package team1.BE.seamless.DTO; +import java.util.List; import team1.BE.seamless.entity.ProjectEntity; import team1.BE.seamless.entity.TaskEntity; -import java.util.List; - public class MemberDetailResponseDTO { + private String email; private String role; private String name; @@ -14,7 +14,7 @@ public class MemberDetailResponseDTO { private List taskEntities; public MemberDetailResponseDTO(String email, String role, String name, - String imageURL, ProjectEntity projectEntity, List taskEntities) { + String imageURL, ProjectEntity projectEntity, List taskEntities) { this.email = email; this.role = role; this.name = name; diff --git a/src/main/java/team1/BE/seamless/DTO/MemberRequestDTO.java b/src/main/java/team1/BE/seamless/DTO/MemberRequestDTO.java index 1da9d2d..5c58e4b 100644 --- a/src/main/java/team1/BE/seamless/DTO/MemberRequestDTO.java +++ b/src/main/java/team1/BE/seamless/DTO/MemberRequestDTO.java @@ -6,11 +6,13 @@ import team1.BE.seamless.util.page.PageParam; public class MemberRequestDTO { + public static class getMemberList extends PageParam { } public static class CreateMember { + @NotBlank(message = "이름은 필수 입력 사항입니다.") @Size(max = 15, message = "이름은 공백 포함 최대 15글자까지 가능합니다.") private String name; @@ -53,6 +55,7 @@ public String getImageURL() { } public static class UpdateMember { + @Size(max = 15, message = "이름은 공백 포함 최대 15글자까지 가능합니다.") private String name; diff --git a/src/main/java/team1/BE/seamless/DTO/MemberResponseDTO.java b/src/main/java/team1/BE/seamless/DTO/MemberResponseDTO.java index 096c156..2bb798a 100644 --- a/src/main/java/team1/BE/seamless/DTO/MemberResponseDTO.java +++ b/src/main/java/team1/BE/seamless/DTO/MemberResponseDTO.java @@ -1,6 +1,7 @@ package team1.BE.seamless.DTO; public class MemberResponseDTO { + private String message; public MemberResponseDTO(String message) { diff --git a/src/main/java/team1/BE/seamless/DTO/OptionDTO.java b/src/main/java/team1/BE/seamless/DTO/OptionDTO.java index cb349b7..4f0b6ac 100644 --- a/src/main/java/team1/BE/seamless/DTO/OptionDTO.java +++ b/src/main/java/team1/BE/seamless/DTO/OptionDTO.java @@ -1,10 +1,8 @@ package team1.BE.seamless.DTO; -import java.util.List; - public class OptionDTO { - public static class OptionCreate{ + public static class OptionCreate { private String name; diff --git a/src/main/java/team1/BE/seamless/DTO/TaskDTO.java b/src/main/java/team1/BE/seamless/DTO/TaskDTO.java index 3a269b6..28a1933 100644 --- a/src/main/java/team1/BE/seamless/DTO/TaskDTO.java +++ b/src/main/java/team1/BE/seamless/DTO/TaskDTO.java @@ -8,6 +8,7 @@ import team1.BE.seamless.util.page.PageParam; public class TaskDTO { + public static class getList extends PageParam { } diff --git a/src/main/java/team1/BE/seamless/DTO/UserDTO.java b/src/main/java/team1/BE/seamless/DTO/UserDTO.java index 684feef..8af7845 100644 --- a/src/main/java/team1/BE/seamless/DTO/UserDTO.java +++ b/src/main/java/team1/BE/seamless/DTO/UserDTO.java @@ -5,11 +5,12 @@ public class UserDTO { - public static class UserUpdate{ + public static class UserUpdate { + private String username; @Pattern(regexp = "^(https?:\\/\\/)?([a-zA-Z0-9_-]+\\.)+[a-zA-Z]{2,6}(:[0-9]{1,5})?(\\/.*)?$", - message = "사진은 URL이여야 합니다.") + message = "사진은 URL이여야 합니다.") private String picture; public UserUpdate() { diff --git a/src/main/java/team1/BE/seamless/controller/AttendUrlController.java b/src/main/java/team1/BE/seamless/controller/AttendUrlController.java index 4013e67..bc4e9a7 100644 --- a/src/main/java/team1/BE/seamless/controller/AttendUrlController.java +++ b/src/main/java/team1/BE/seamless/controller/AttendUrlController.java @@ -4,18 +4,13 @@ import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.servlet.http.HttpServletRequest; import jakarta.validation.Valid; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import team1.BE.seamless.DTO.AttendUrlResponseDTO; -import team1.BE.seamless.service.AttendURLService; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RestController; +import team1.BE.seamless.service.AttendURLService; import team1.BE.seamless.util.page.SingleResult; -import java.util.Map; - @Tag(name = "참여 링크 생성") @RestController public class AttendUrlController { @@ -39,15 +34,14 @@ public AttendUrlController(AttendURLService attendURLService) { // } /** - * 팉장의 토큰과 프로젝트id로 프로젝트 존재 검증 - * 프로젝트id + " " + exp로 코드 생성 - * 코드를 양방향 암호화 - * ex) http://localhost:8080/api/memverInvite?code="123456" - * 검증시 코드를 복호화 해서 프로젝트id와 exp를 검증(server less) - * */ + * 팉장의 토큰과 프로젝트id로 프로젝트 존재 검증 프로젝트id + " " + exp로 코드 생성 코드를 양방향 암호화 ex) + * http://localhost:8080/api/memverInvite?code="123456" 검증시 코드를 복호화 해서 프로젝트id와 exp를 검증(server + * less) + */ @Operation(summary = "팀원초대 링크 생성") @PostMapping("/api/project/{project_id}/invite-link") - public SingleResult generateInviteLink(HttpServletRequest req, @Valid @PathVariable("project_id") Long projectId){ + public SingleResult generateInviteLink(HttpServletRequest req, + @Valid @PathVariable("project_id") Long projectId) { return new SingleResult<>(attendURLService.generateAttendURL(req, projectId)); } } \ No newline at end of file diff --git a/src/main/java/team1/BE/seamless/controller/MemberController.java b/src/main/java/team1/BE/seamless/controller/MemberController.java index a9dacdf..1cdf351 100644 --- a/src/main/java/team1/BE/seamless/controller/MemberController.java +++ b/src/main/java/team1/BE/seamless/controller/MemberController.java @@ -13,7 +13,6 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import team1.BE.seamless.DTO.MemberRequestDTO; -import team1.BE.seamless.DTO.MemberResponseDTO; import team1.BE.seamless.entity.MemberEntity; import team1.BE.seamless.service.MemberService; import team1.BE.seamless.util.page.PageMapper; diff --git a/src/main/java/team1/BE/seamless/controller/ProjectInviteController.java b/src/main/java/team1/BE/seamless/controller/ProjectInviteController.java index d394331..8a3b139 100644 --- a/src/main/java/team1/BE/seamless/controller/ProjectInviteController.java +++ b/src/main/java/team1/BE/seamless/controller/ProjectInviteController.java @@ -1,10 +1,14 @@ package team1.BE.seamless.controller; // 팀원이 초대링크에 해당하는 페이지에서 이름, 이메일을 작성하여 // 요청을 보낼 때의 컨트롤러 계층 + import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; +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 team1.BE.seamless.DTO.InviteRequestDTO; import team1.BE.seamless.service.ProjectInviteService; import team1.BE.seamless.util.page.SingleResult; @@ -21,7 +25,9 @@ public class ProjectInviteController { @PostMapping("/invite") public SingleResult inviteMemberToProject(@RequestBody InviteRequestDTO inviteRequest) { try { - String message = "You have been invited to join the project with ID: " + inviteRequest.getProjectId() + "\nAnd Participation code: "; + String message = + "You have been invited to join the project with ID: " + inviteRequest.getProjectId() + + "\nAnd Participation code: "; inviteService.sendProjectInvite(inviteRequest.getEmail(), message); return new SingleResult<>("프로젝트 초대 요청이 성공적으로 처리되었습니다."); } catch (Exception e) { diff --git a/src/main/java/team1/BE/seamless/controller/TaskController.java b/src/main/java/team1/BE/seamless/controller/TaskController.java index c2db8b4..409a853 100644 --- a/src/main/java/team1/BE/seamless/controller/TaskController.java +++ b/src/main/java/team1/BE/seamless/controller/TaskController.java @@ -16,7 +16,6 @@ import team1.BE.seamless.DTO.TaskDTO; import team1.BE.seamless.entity.TaskEntity; import team1.BE.seamless.service.TaskService; -import team1.BE.seamless.util.page.ListResult; import team1.BE.seamless.util.page.PageMapper; import team1.BE.seamless.util.page.PageResult; import team1.BE.seamless.util.page.SingleResult; @@ -41,13 +40,14 @@ public SingleResult getTask(@PathVariable Long taskId) { @Operation(summary = "프로젝트 아이디로 태스크 리스트 조회 ") @GetMapping("/{projectId}/task") - public PageResult getTaskList(@PathVariable Long projectId, @Valid TaskDTO.getList param) { + public PageResult getTaskList(@PathVariable Long projectId, + @Valid TaskDTO.getList param) { return PageMapper.toPageResult(taskService.getTaskList(projectId, param)); } /** * 팀장만 태스크를 생성할 수 있음 - * */ + */ @Operation(summary = "태스크 생성") @PostMapping("/{projectId}/task") public SingleResult createTask(HttpServletRequest req, @@ -56,20 +56,19 @@ public SingleResult createTask(HttpServletRequest req, } /** - * 멤버도 코드로 프로젝트 참여에 성공하면 토큰을 반환함 - * 태스크 수정은 팀장, 태스크를 수행하고 있는 팀원이 가능함 - * 태스크의 멤버를 수정하는 건 팀장만 가능 - * */ + * 멤버도 코드로 프로젝트 참여에 성공하면 토큰을 반환함 태스크 수정은 팀장, 태스크를 수행하고 있는 팀원이 가능함 태스크의 멤버를 수정하는 건 팀장만 가능 + */ @Operation(summary = "태스크 수정") @PutMapping("/task/{taskId}") - public SingleResult updateTask(HttpServletRequest req, @Valid @PathVariable Long taskId, + public SingleResult updateTask(HttpServletRequest req, + @Valid @PathVariable Long taskId, @Valid @RequestBody TaskDTO.Update update) { return new SingleResult<>(taskService.updateTask(req, taskId, update)); } /** * 팀장만 태스크를 삭제할 수 있음 - * */ + */ @Operation(summary = "태스크 삭제") @DeleteMapping("/task/{taskId}") public SingleResult deleteTask(HttpServletRequest req, @PathVariable Long taskId) { diff --git a/src/main/java/team1/BE/seamless/controller/TestController.java b/src/main/java/team1/BE/seamless/controller/TestController.java index 5e65b8e..d28158b 100644 --- a/src/main/java/team1/BE/seamless/controller/TestController.java +++ b/src/main/java/team1/BE/seamless/controller/TestController.java @@ -1,11 +1,5 @@ package team1.BE.seamless.controller; -import team1.BE.seamless.DTO.TestDTO; -import team1.BE.seamless.entity.TestEntity; -import team1.BE.seamless.service.TestService; -import team1.BE.seamless.util.page.PageMapper; -import team1.BE.seamless.util.page.PageResult; -import team1.BE.seamless.util.page.SingleResult; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; @@ -16,6 +10,12 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import team1.BE.seamless.DTO.TestDTO; +import team1.BE.seamless.entity.TestEntity; +import team1.BE.seamless.service.TestService; +import team1.BE.seamless.util.page.PageMapper; +import team1.BE.seamless.util.page.PageResult; +import team1.BE.seamless.util.page.SingleResult; @Tag(name = "참조") @RestController diff --git a/src/main/java/team1/BE/seamless/controller/UserController.java b/src/main/java/team1/BE/seamless/controller/UserController.java index a21671c..4171bae 100644 --- a/src/main/java/team1/BE/seamless/controller/UserController.java +++ b/src/main/java/team1/BE/seamless/controller/UserController.java @@ -1,21 +1,21 @@ package team1.BE.seamless.controller; -import org.springframework.web.bind.annotation.DeleteMapping; -import team1.BE.seamless.DTO.UserDTO.UserDetails; -import team1.BE.seamless.DTO.UserDTO.UserSimple; -import team1.BE.seamless.DTO.UserDTO.UserUpdate; -import team1.BE.seamless.service.UserService; -import team1.BE.seamless.util.page.SingleResult; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.servlet.http.HttpServletRequest; import jakarta.validation.Valid; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import team1.BE.seamless.DTO.UserDTO.UserDetails; +import team1.BE.seamless.DTO.UserDTO.UserSimple; +import team1.BE.seamless.DTO.UserDTO.UserUpdate; +import team1.BE.seamless.service.UserService; +import team1.BE.seamless.util.page.SingleResult; @Tag(name = "유저 구현") @RestController @@ -38,8 +38,8 @@ public SingleResult getUser(HttpServletRequest req) { @Operation(summary = "유저 정보 수정") @PutMapping public SingleResult updateUser(HttpServletRequest req, @Valid @RequestBody - UserUpdate update) { - return new SingleResult<>(userService.updateUser(req,update)); + UserUpdate update) { + return new SingleResult<>(userService.updateUser(req, update)); } @Operation(summary = "유저 정보 삭제") diff --git a/src/main/java/team1/BE/seamless/entity/MemberEntity.java b/src/main/java/team1/BE/seamless/entity/MemberEntity.java index 597ff32..20544e8 100644 --- a/src/main/java/team1/BE/seamless/entity/MemberEntity.java +++ b/src/main/java/team1/BE/seamless/entity/MemberEntity.java @@ -1,6 +1,5 @@ package team1.BE.seamless.entity; -import jakarta.persistence.CascadeType; import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.FetchType; @@ -14,7 +13,7 @@ import java.util.List; @Entity(name = "member") -public class MemberEntity extends BaseEntity{ +public class MemberEntity extends BaseEntity { public MemberEntity() { @@ -27,7 +26,8 @@ public MemberEntity() { // this.imageURL = imageURL; // } - public MemberEntity(String name, String role, String email, String imageURL,ProjectEntity projectEntity) {//Task 오류나서 생성자 새로 만들어놓음 + public MemberEntity(String name, String role, String email, String imageURL, + ProjectEntity projectEntity) {//Task 오류나서 생성자 새로 만들어놓음 this.name = name; this.role = role; this.email = email; diff --git a/src/main/java/team1/BE/seamless/entity/UserEntity.java b/src/main/java/team1/BE/seamless/entity/UserEntity.java index a0238d6..618ed85 100644 --- a/src/main/java/team1/BE/seamless/entity/UserEntity.java +++ b/src/main/java/team1/BE/seamless/entity/UserEntity.java @@ -1,9 +1,6 @@ package team1.BE.seamless.entity; import jakarta.persistence.CascadeType; -import jakarta.persistence.OneToMany; -import java.util.List; -import team1.BE.seamless.entity.enums.Role; import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.EntityListeners; @@ -12,11 +9,14 @@ import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; import jakarta.persistence.Id; +import jakarta.persistence.OneToMany; import jakarta.validation.constraints.NotNull; import java.time.LocalDateTime; +import java.util.List; import org.springframework.data.annotation.CreatedDate; import org.springframework.data.annotation.LastModifiedDate; import org.springframework.data.jpa.domain.support.AuditingEntityListener; +import team1.BE.seamless.entity.enums.Role; @Entity(name = "user_table") @EntityListeners(AuditingEntityListener.class) diff --git a/src/main/java/team1/BE/seamless/init/InitData.java b/src/main/java/team1/BE/seamless/init/InitData.java index 37d1ad5..3ac6d89 100644 --- a/src/main/java/team1/BE/seamless/init/InitData.java +++ b/src/main/java/team1/BE/seamless/init/InitData.java @@ -15,7 +15,8 @@ public class InitData { private final OptionCreator optionCreator; @Autowired - public InitData(TestCreator testCreator, ProjectCreator projectCreator, UserCreator userCreator, OptionCreator optionCreator) { + public InitData(TestCreator testCreator, ProjectCreator projectCreator, UserCreator userCreator, + OptionCreator optionCreator) { this.testCreator = testCreator; this.projectCreator = projectCreator; this.userCreator = userCreator; diff --git a/src/main/java/team1/BE/seamless/init/ProjectCreator.java b/src/main/java/team1/BE/seamless/init/ProjectCreator.java index 8bf5eb1..e7bb1b3 100644 --- a/src/main/java/team1/BE/seamless/init/ProjectCreator.java +++ b/src/main/java/team1/BE/seamless/init/ProjectCreator.java @@ -19,10 +19,10 @@ public ProjectCreator(ProjectService projectService) { public void creator() { projectService.createProject(new ProjectCreate("프로젝트 이름1", 1L, - LocalDateTime.of(2024,10,1,0,0,0), - LocalDateTime.of(2024,10,3,0,0,0), - List.of(1L,2L,3L)), + LocalDateTime.of(2024, 10, 1, 0, 0, 0), + LocalDateTime.of(2024, 10, 3, 0, 0, 0), + List.of(1L, 2L, 3L)), "user1@google.com" - ); + ); } } diff --git a/src/main/java/team1/BE/seamless/init/TestCreator.java b/src/main/java/team1/BE/seamless/init/TestCreator.java index f0d48b3..b020209 100644 --- a/src/main/java/team1/BE/seamless/init/TestCreator.java +++ b/src/main/java/team1/BE/seamless/init/TestCreator.java @@ -1,9 +1,9 @@ package team1.BE.seamless.init; -import team1.BE.seamless.DTO.TestDTO.create; -import team1.BE.seamless.service.TestService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import team1.BE.seamless.DTO.TestDTO.create; +import team1.BE.seamless.service.TestService; @Component public class TestCreator { diff --git a/src/main/java/team1/BE/seamless/init/UserCreator.java b/src/main/java/team1/BE/seamless/init/UserCreator.java index a52969d..fcd5b5d 100644 --- a/src/main/java/team1/BE/seamless/init/UserCreator.java +++ b/src/main/java/team1/BE/seamless/init/UserCreator.java @@ -16,6 +16,6 @@ public UserCreator(UserService userService) { } public void creator() { - userService.createUser(new UserSimple("사용자1","user1@google.com","user1Image.jpg")); + userService.createUser(new UserSimple("사용자1", "user1@google.com", "user1Image.jpg")); } } diff --git a/src/main/java/team1/BE/seamless/mapper/MemberMapper.java b/src/main/java/team1/BE/seamless/mapper/MemberMapper.java index a06d309..bd927ce 100644 --- a/src/main/java/team1/BE/seamless/mapper/MemberMapper.java +++ b/src/main/java/team1/BE/seamless/mapper/MemberMapper.java @@ -1,8 +1,6 @@ package team1.BE.seamless.mapper; -import java.util.Optional; import org.springframework.stereotype.Component; -import team1.BE.seamless.DTO.MemberRequestDTO; import team1.BE.seamless.DTO.MemberRequestDTO.CreateMember; import team1.BE.seamless.DTO.MemberRequestDTO.UpdateMember; import team1.BE.seamless.entity.MemberEntity; diff --git a/src/main/java/team1/BE/seamless/mapper/ProjectMapper.java b/src/main/java/team1/BE/seamless/mapper/ProjectMapper.java index 9ed4c64..6163912 100644 --- a/src/main/java/team1/BE/seamless/mapper/ProjectMapper.java +++ b/src/main/java/team1/BE/seamless/mapper/ProjectMapper.java @@ -11,7 +11,8 @@ @Component public class ProjectMapper { - public ProjectEntity toEntity(ProjectDTO.ProjectCreate create, UserEntity userEntity, List projectOptions) { + public ProjectEntity toEntity(ProjectDTO.ProjectCreate create, UserEntity userEntity, + List projectOptions) { return new ProjectEntity( create.getName(), userEntity, diff --git a/src/main/java/team1/BE/seamless/mapper/TaskMapper.java b/src/main/java/team1/BE/seamless/mapper/TaskMapper.java index 0f8eba0..8e04337 100644 --- a/src/main/java/team1/BE/seamless/mapper/TaskMapper.java +++ b/src/main/java/team1/BE/seamless/mapper/TaskMapper.java @@ -1,7 +1,6 @@ package team1.BE.seamless.mapper; import org.springframework.stereotype.Component; -import team1.BE.seamless.DTO.TaskDTO; import team1.BE.seamless.DTO.TaskDTO.Create; import team1.BE.seamless.DTO.TaskDTO.Update; import team1.BE.seamless.entity.MemberEntity; @@ -25,9 +24,12 @@ public TaskEntity toEntity(ProjectEntity project, MemberEntity member, Create cr public TaskEntity toUpdate(TaskEntity task, Update update) { task.setName(Util.isNull(update.getName()) ? task.getName() : update.getName()); task.setRemark(Util.isNull(update.getRemark()) ? task.getRemark() : update.getRemark()); - task.setProgress(Util.isNull(update.getProgress().toString()) ? task.getProgress() : update.getProgress()); - task.setStartDate(Util.isNull(update.getStartDate().toString()) ? task.getStartDate() : update.getStartDate()); - task.setEndDate(Util.isNull(update.getEndDate().toString()) ? task.getEndDate() : update.getEndDate()); + task.setProgress(Util.isNull(update.getProgress().toString()) ? task.getProgress() + : update.getProgress()); + task.setStartDate(Util.isNull(update.getStartDate().toString()) ? task.getStartDate() + : update.getStartDate()); + task.setEndDate( + Util.isNull(update.getEndDate().toString()) ? task.getEndDate() : update.getEndDate()); return task; } diff --git a/src/main/java/team1/BE/seamless/mapper/UserMapper.java b/src/main/java/team1/BE/seamless/mapper/UserMapper.java index 1deb3c3..c549255 100644 --- a/src/main/java/team1/BE/seamless/mapper/UserMapper.java +++ b/src/main/java/team1/BE/seamless/mapper/UserMapper.java @@ -1,11 +1,11 @@ package team1.BE.seamless.mapper; +import org.springframework.stereotype.Component; import team1.BE.seamless.DTO.UserDTO.UserDetails; import team1.BE.seamless.DTO.UserDTO.UserSimple; import team1.BE.seamless.DTO.UserDTO.UserUpdate; import team1.BE.seamless.entity.UserEntity; import team1.BE.seamless.util.Util; -import org.springframework.stereotype.Component; @Component public class UserMapper { diff --git a/src/main/java/team1/BE/seamless/repository/MemberRepository.java b/src/main/java/team1/BE/seamless/repository/MemberRepository.java index cc763ed..d0c86a7 100644 --- a/src/main/java/team1/BE/seamless/repository/MemberRepository.java +++ b/src/main/java/team1/BE/seamless/repository/MemberRepository.java @@ -3,13 +3,15 @@ import java.util.Optional; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; -import team1.BE.seamless.entity.MemberEntity; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; +import team1.BE.seamless.entity.MemberEntity; @Repository public interface MemberRepository extends JpaRepository { + Optional findByIdAndProjectEntityIdAndIsDeleteFalse(Long id, Long projectId); + Page findAllByProjectEntityIdAndIsDeleteFalse(Long projectId, Pageable pageable); } diff --git a/src/main/java/team1/BE/seamless/repository/ProjectRepository.java b/src/main/java/team1/BE/seamless/repository/ProjectRepository.java index 9642c0a..4674197 100644 --- a/src/main/java/team1/BE/seamless/repository/ProjectRepository.java +++ b/src/main/java/team1/BE/seamless/repository/ProjectRepository.java @@ -1,18 +1,20 @@ package team1.BE.seamless.repository; import java.util.Optional; -import team1.BE.seamless.DTO.ProjectDTO.ProjectPeriod; -import team1.BE.seamless.entity.ProjectEntity; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; +import team1.BE.seamless.DTO.ProjectDTO.ProjectPeriod; +import team1.BE.seamless.entity.ProjectEntity; @Repository public interface ProjectRepository extends JpaRepository { Page findAllByIsDeletedFalse(Pageable pageable); + Optional findByIdAndUserEntityEmailAndIsDeletedFalse(Long id, String email); + Page findAllByUserEntityEmailAndIsDeletedFalse(Pageable pageable, String email); Optional findByIdAndIsDeletedFalse(Long id); diff --git a/src/main/java/team1/BE/seamless/repository/TestRepository.java b/src/main/java/team1/BE/seamless/repository/TestRepository.java index 0505ac9..b1d2131 100644 --- a/src/main/java/team1/BE/seamless/repository/TestRepository.java +++ b/src/main/java/team1/BE/seamless/repository/TestRepository.java @@ -1,12 +1,13 @@ package team1.BE.seamless.repository; -import team1.BE.seamless.entity.TestEntity; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; +import team1.BE.seamless.entity.TestEntity; @Repository public interface TestRepository extends JpaRepository { + Page findAll(Pageable pageable); } diff --git a/src/main/java/team1/BE/seamless/repository/UserRepository.java b/src/main/java/team1/BE/seamless/repository/UserRepository.java index 311e6b9..199d21f 100644 --- a/src/main/java/team1/BE/seamless/repository/UserRepository.java +++ b/src/main/java/team1/BE/seamless/repository/UserRepository.java @@ -1,13 +1,14 @@ package team1.BE.seamless.repository; -import team1.BE.seamless.entity.UserEntity; import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; +import team1.BE.seamless.entity.UserEntity; @Repository public interface UserRepository extends JpaRepository { Optional findByEmailAndIsDeleteFalse(String email); + Optional findByEmailAndIsDeleteFalse(String email, Integer isDelete); } diff --git a/src/main/java/team1/BE/seamless/service/AttendURLService.java b/src/main/java/team1/BE/seamless/service/AttendURLService.java index d5ff192..bc96f20 100644 --- a/src/main/java/team1/BE/seamless/service/AttendURLService.java +++ b/src/main/java/team1/BE/seamless/service/AttendURLService.java @@ -36,7 +36,8 @@ public String generateAttendURL(HttpServletRequest req, @Valid Long projectId) { // 코드는 프로젝트id + exp로 구성 // exp는 1일로 가정 - String code = aesEncrypt.encrypt(project.getId() +" " + LocalDateTime.now().plusDays(1).toString()); + String code = aesEncrypt.encrypt( + project.getId() + " " + LocalDateTime.now().plusDays(1).toString()); return DEFAULTURL + "invite?code=" + code; } diff --git a/src/main/java/team1/BE/seamless/service/AuthService.java b/src/main/java/team1/BE/seamless/service/AuthService.java index cd9a286..ac80bba 100644 --- a/src/main/java/team1/BE/seamless/service/AuthService.java +++ b/src/main/java/team1/BE/seamless/service/AuthService.java @@ -92,7 +92,7 @@ protected UserEntity saveOrUpdate(OAuthAttributes attributes) { public Token memberCodeJoin(@Valid String memberCode) { // decode - String code=aesEncrypt.decrypt(memberCode); + String code = aesEncrypt.decrypt(memberCode); // 프로젝트, member가 존재하는지 검증 MemberEntity member = memberRepository.findById(Long.parseLong(code)) @@ -106,7 +106,7 @@ public Token memberCodeJoin(@Valid String memberCode) { public String memberCodeCreate(@Valid String memberCode) { // ENCODE - String code=aesEncrypt.encrypt(memberCode); + String code = aesEncrypt.encrypt(memberCode); return code; } } \ No newline at end of file diff --git a/src/main/java/team1/BE/seamless/service/MemberService.java b/src/main/java/team1/BE/seamless/service/MemberService.java index 860fa64..e46727f 100644 --- a/src/main/java/team1/BE/seamless/service/MemberService.java +++ b/src/main/java/team1/BE/seamless/service/MemberService.java @@ -1,7 +1,6 @@ package team1.BE.seamless.service; import jakarta.validation.Valid; -import java.util.Optional; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.http.HttpStatus; @@ -10,7 +9,6 @@ import team1.BE.seamless.DTO.MemberRequestDTO.CreateMember; import team1.BE.seamless.DTO.MemberRequestDTO.UpdateMember; import team1.BE.seamless.DTO.MemberRequestDTO.getMemberList; -import team1.BE.seamless.DTO.MemberResponseDTO; import team1.BE.seamless.entity.MemberEntity; import team1.BE.seamless.entity.ProjectEntity; import team1.BE.seamless.mapper.MemberMapper; @@ -28,7 +26,8 @@ public class MemberService { private final ProjectRepository projectRepository; @Autowired - public MemberService(MemberRepository memberRepository, MemberMapper memberMapper, ProjectRepository projectRepository) { + public MemberService(MemberRepository memberRepository, MemberMapper memberMapper, + ProjectRepository projectRepository) { this.memberRepository = memberRepository; this.memberMapper = memberMapper; this.projectRepository = projectRepository; @@ -43,11 +42,13 @@ public MemberEntity getMember(Long projectId, Long memberId) { // throw new BaseHandler(HttpStatus.NOT_FOUND, "프로젝트가 존재하지 않음"); // } return memberRepository.findByIdAndProjectEntityIdAndIsDeleteFalse(memberId, projectId) - .orElseThrow(()-> new BaseHandler(HttpStatus.NOT_FOUND, "해당 멤버가 존재하지 않습니다.")); + .orElseThrow(() -> new BaseHandler(HttpStatus.NOT_FOUND, "해당 멤버가 존재하지 않습니다.")); } - public Page getMemberList(@Valid Long projectId, getMemberList memberListRequestDTO) { - return memberRepository.findAllByProjectEntityIdAndIsDeleteFalse(projectId, memberListRequestDTO.toPageable()); + public Page getMemberList(@Valid Long projectId, + getMemberList memberListRequestDTO) { + return memberRepository.findAllByProjectEntityIdAndIsDeleteFalse(projectId, + memberListRequestDTO.toPageable()); } public MemberEntity createMember(Long projectId, CreateMember create) { @@ -64,7 +65,7 @@ public MemberEntity createMember(Long projectId, CreateMember create) { // throw new BaseHandler(HttpStatus.NOT_FOUND, "해당하는 프로젝트가 존재하지 않습니다."); // } ProjectEntity project = projectRepository.findById(projectId) - .orElseThrow(()-> new BaseHandler(HttpStatus.NOT_FOUND, "해당 프로젝트가 존재하지 않습니다.")); + .orElseThrow(() -> new BaseHandler(HttpStatus.NOT_FOUND, "해당 프로젝트가 존재하지 않습니다.")); MemberEntity member = memberMapper.toEntity(create, project); memberRepository.save(member); @@ -84,14 +85,15 @@ public MemberEntity updateMember(Long projectId, Long memberId, UpdateMember upd // else { // throw new BaseHandler(HttpStatus.NOT_FOUND,"해당하는 팀원이 존재하지 않습니다."); // } - MemberEntity member = memberRepository.findByIdAndProjectEntityIdAndIsDeleteFalse(memberId, projectId) - .orElseThrow(()-> new BaseHandler(HttpStatus.NOT_FOUND, "해당 멤버가 존재하지 않습니다.")); + MemberEntity member = memberRepository.findByIdAndProjectEntityIdAndIsDeleteFalse(memberId, + projectId) + .orElseThrow(() -> new BaseHandler(HttpStatus.NOT_FOUND, "해당 멤버가 존재하지 않습니다.")); - memberMapper.toUpdate(member,update); + memberMapper.toUpdate(member, update); return member; } -@Transactional + @Transactional public MemberEntity deleteMember(Long projectId, Long memberId) { // Optional existingMemberEntity = memberRepository.findById(memberId); // if(existingMemberEntity.isPresent()) { @@ -102,8 +104,9 @@ public MemberEntity deleteMember(Long projectId, Long memberId) { // else { // throw new BaseHandler(HttpStatus.NOT_FOUND,"해당하는 팀원이 존재하지 않습니다."); // } - MemberEntity member = memberRepository.findByIdAndProjectEntityIdAndIsDeleteFalse(memberId, projectId) - .orElseThrow(()-> new BaseHandler(HttpStatus.NOT_FOUND, "해당 멤버가 존재하지 않습니다.")); + MemberEntity member = memberRepository.findByIdAndProjectEntityIdAndIsDeleteFalse(memberId, + projectId) + .orElseThrow(() -> new BaseHandler(HttpStatus.NOT_FOUND, "해당 멤버가 존재하지 않습니다.")); member.setDelete(true); diff --git a/src/main/java/team1/BE/seamless/service/ProjectInviteService.java b/src/main/java/team1/BE/seamless/service/ProjectInviteService.java index 5fd2bac..816b8c4 100644 --- a/src/main/java/team1/BE/seamless/service/ProjectInviteService.java +++ b/src/main/java/team1/BE/seamless/service/ProjectInviteService.java @@ -1,6 +1,7 @@ package team1.BE.seamless.service; // 팀원이 초대링크에 해당하는 페이지에서 이름, 이메일을 작성하여 // 요청을 보낼 때의 서비스 계층 + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.mail.SimpleMailMessage; import org.springframework.mail.javamail.JavaMailSender; diff --git a/src/main/java/team1/BE/seamless/service/ProjectService.java b/src/main/java/team1/BE/seamless/service/ProjectService.java index 755970f..ec679be 100644 --- a/src/main/java/team1/BE/seamless/service/ProjectService.java +++ b/src/main/java/team1/BE/seamless/service/ProjectService.java @@ -39,7 +39,8 @@ public ProjectService(ProjectRepository projectRepository, UserRepository userRe } public Page getProjectList(ProjectDTO.getList param, String email) { - return projectRepository.findAllByUserEntityEmailAndIsDeletedFalse(param.toPageable(), email); + return projectRepository.findAllByUserEntityEmailAndIsDeletedFalse(param.toPageable(), + email); } public ProjectEntity getProject(long id) { diff --git a/src/main/java/team1/BE/seamless/service/TaskService.java b/src/main/java/team1/BE/seamless/service/TaskService.java index 988b906..c088c47 100644 --- a/src/main/java/team1/BE/seamless/service/TaskService.java +++ b/src/main/java/team1/BE/seamless/service/TaskService.java @@ -50,18 +50,20 @@ public Page getTaskList(Long projectId, getList param) { } public TaskEntity createTask(HttpServletRequest req, @Valid Long projectId, Create create) { - ProjectEntity project = projectRepository.findByIdAndUserEntityEmailAndIsDeletedFalse(projectId,parsingPram.getEmail(req)) + ProjectEntity project = projectRepository.findByIdAndUserEntityEmailAndIsDeletedFalse( + projectId, parsingPram.getEmail(req)) .orElseThrow(() -> new BaseHandler(HttpStatus.NOT_FOUND, "존재하지 않는 프로젝트")); // 태스크의 일정 검증 - if (project.getStartDate().isBefore(create.getStartDate()) || project.getStartDate().isAfter(create.getEndDate())){ - throw new BaseHandler(HttpStatus.FORBIDDEN,"태스크는 프로젝트의 기한을 넘어설 수 없습니다."); + if (project.getStartDate().isBefore(create.getStartDate()) || project.getStartDate() + .isAfter(create.getEndDate())) { + throw new BaseHandler(HttpStatus.FORBIDDEN, "태스크는 프로젝트의 기한을 넘어설 수 없습니다."); } MemberEntity member = memberRepository.findById(create.getMemberId()) .orElseThrow(() -> new BaseHandler(HttpStatus.NOT_FOUND, "존재하지 않는 멤버")); - TaskEntity taskEntity = taskMapper.toEntity(project,member,create); + TaskEntity taskEntity = taskMapper.toEntity(project, member, create); taskRepository.save(taskEntity); return taskEntity; @@ -73,15 +75,16 @@ public TaskEntity updateTask(HttpServletRequest req, @Valid Long taskId, @Valid .orElseThrow(() -> new BaseHandler(HttpStatus.NOT_FOUND, "존재하지 않는 태스크")); // 태스크의 일정 검증 - if (task.getProject().getStartDate().isBefore(update.getStartDate()) || task.getProject().getStartDate().isAfter(update.getEndDate())){ - throw new BaseHandler(HttpStatus.FORBIDDEN,"태스크는 프로젝트의 기한을 넘어설 수 없습니다."); + if (task.getProject().getStartDate().isBefore(update.getStartDate()) || task.getProject() + .getStartDate().isAfter(update.getEndDate())) { + throw new BaseHandler(HttpStatus.FORBIDDEN, "태스크는 프로젝트의 기한을 넘어설 수 없습니다."); } // 수정 권한이 있는지 검증 // 팀장 - if (parsingPram.getRole(req).equals(Role.USER.toString())){ - if (!task.getProject().getUserEntity().getEmail().equals(parsingPram.getEmail(req))){ - throw new BaseHandler(HttpStatus.UNAUTHORIZED,"태스크 수정 권한이 없습니다."); + if (parsingPram.getRole(req).equals(Role.USER.toString())) { + if (!task.getProject().getUserEntity().getEmail().equals(parsingPram.getEmail(req))) { + throw new BaseHandler(HttpStatus.UNAUTHORIZED, "태스크 수정 권한이 없습니다."); } // 멤버 변경 MemberEntity member = memberRepository.findById(update.getMemberId()) @@ -90,19 +93,20 @@ public TaskEntity updateTask(HttpServletRequest req, @Valid Long taskId, @Valid task.setOwner(member); } // 팀원 - if (parsingPram.getRole(req).equals(Role.MEMBER.toString())){ - if (!task.getOwner().getEmail().equals(parsingPram.getEmail(req))){ - throw new BaseHandler(HttpStatus.UNAUTHORIZED,"태스크 수정 권한이 없습니다."); + if (parsingPram.getRole(req).equals(Role.MEMBER.toString())) { + if (!task.getOwner().getEmail().equals(parsingPram.getEmail(req))) { + throw new BaseHandler(HttpStatus.UNAUTHORIZED, "태스크 수정 권한이 없습니다."); } } - taskMapper.toUpdate(task,update); + taskMapper.toUpdate(task, update); return task; } @Transactional public Long deleteTask(HttpServletRequest req, Long taskId) { - TaskEntity task = taskRepository.findByIdAndProjectEntityUserEntityEmail(taskId, parsingPram.getEmail(req)) + TaskEntity task = taskRepository.findByIdAndProjectEntityUserEntityEmail(taskId, + parsingPram.getEmail(req)) .orElseThrow(() -> new BaseHandler(HttpStatus.NOT_FOUND, "존재하지 않는 태스크")); task.setDeleted(true); diff --git a/src/main/java/team1/BE/seamless/service/TestService.java b/src/main/java/team1/BE/seamless/service/TestService.java index 6392aac..ff0f9af 100644 --- a/src/main/java/team1/BE/seamless/service/TestService.java +++ b/src/main/java/team1/BE/seamless/service/TestService.java @@ -1,16 +1,16 @@ package team1.BE.seamless.service; +import jakarta.validation.Valid; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.http.HttpStatus; +import org.springframework.stereotype.Service; import team1.BE.seamless.DTO.TestDTO.create; import team1.BE.seamless.DTO.TestDTO.getList; import team1.BE.seamless.entity.TestEntity; import team1.BE.seamless.mapper.TestMapper; import team1.BE.seamless.repository.TestRepository; import team1.BE.seamless.util.errorException.BaseHandler; -import jakarta.validation.Valid; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Page; -import org.springframework.http.HttpStatus; -import org.springframework.stereotype.Service; @Service public class TestService { diff --git a/src/main/java/team1/BE/seamless/service/UserService.java b/src/main/java/team1/BE/seamless/service/UserService.java index 3583935..04679c9 100644 --- a/src/main/java/team1/BE/seamless/service/UserService.java +++ b/src/main/java/team1/BE/seamless/service/UserService.java @@ -1,5 +1,11 @@ package team1.BE.seamless.service; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.validation.Valid; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import team1.BE.seamless.DTO.UserDTO.UserDetails; import team1.BE.seamless.DTO.UserDTO.UserSimple; import team1.BE.seamless.DTO.UserDTO.UserUpdate; @@ -8,12 +14,6 @@ import team1.BE.seamless.repository.UserRepository; import team1.BE.seamless.util.auth.ParsingPram; import team1.BE.seamless.util.errorException.BaseHandler; -import jakarta.servlet.http.HttpServletRequest; -import jakarta.validation.Valid; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; @Service public class UserService { @@ -41,14 +41,14 @@ public UserSimple updateUser(HttpServletRequest req, @Valid UserUpdate update) { UserEntity user = userRepository.findByEmailAndIsDeleteFalse(parsingPram.getEmail(req)) .orElseThrow(() -> new BaseHandler(HttpStatus.NOT_FOUND, "해당 유저가 존재하지 않습니다.")); - userMapper.toUpdate(user,update); + userMapper.toUpdate(user, update); return userMapper.toUserSimple(user); } @Transactional public UserSimple deleteUser(HttpServletRequest req) { - UserEntity user = userRepository.findByEmailAndIsDeleteFalse(parsingPram.getEmail(req),0) + UserEntity user = userRepository.findByEmailAndIsDeleteFalse(parsingPram.getEmail(req), 0) .orElseThrow(() -> new BaseHandler(HttpStatus.NOT_FOUND, "해당 유저가 존재하지 않습니다.")); user.setIsDelete(); @@ -61,9 +61,9 @@ public UserEntity createUser(@Valid UserSimple simple) { return userRepository.findByEmailAndIsDeleteFalse(simple.getEmail()) .orElseGet(() -> userRepository.save( userMapper.toEntity( - simple.getUsername(), - simple.getEmail(), - simple.getPicture() - ))); + simple.getUsername(), + simple.getEmail(), + simple.getPicture() + ))); } } diff --git a/src/main/java/team1/BE/seamless/util/URL.java b/src/main/java/team1/BE/seamless/util/URL.java index 3306af8..90a6443 100644 --- a/src/main/java/team1/BE/seamless/util/URL.java +++ b/src/main/java/team1/BE/seamless/util/URL.java @@ -1,5 +1,6 @@ package team1.BE.seamless.util; public class URL { -public static String DEFAULTURL = "http://localhost:8080/"; + + public static String DEFAULTURL = "http://localhost:8080/"; } diff --git a/src/main/java/team1/BE/seamless/util/auth/ParsingPram.java b/src/main/java/team1/BE/seamless/util/auth/ParsingPram.java index c826e34..95c0ad0 100644 --- a/src/main/java/team1/BE/seamless/util/auth/ParsingPram.java +++ b/src/main/java/team1/BE/seamless/util/auth/ParsingPram.java @@ -3,7 +3,6 @@ import jakarta.servlet.http.HttpServletRequest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import team1.BE.seamless.entity.enums.Role; @Component public class ParsingPram { diff --git a/src/main/java/team1/BE/seamless/util/auth/SecurityConfig.java b/src/main/java/team1/BE/seamless/util/auth/SecurityConfig.java index 33101ce..fabd190 100644 --- a/src/main/java/team1/BE/seamless/util/auth/SecurityConfig.java +++ b/src/main/java/team1/BE/seamless/util/auth/SecurityConfig.java @@ -48,21 +48,20 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti .headers(c -> c.frameOptions().disable()) .sessionManagement(c -> c.sessionCreationPolicy(SessionCreationPolicy.STATELESS)) - .authorizeHttpRequests(request -> request // swagger - .requestMatchers("/swagger", "/swagger-ui.html", "/swagger-ui/**", "/api-docs", - "/api-docs/**", "/v3/api-docs/**").permitAll() - .requestMatchers("/login/**", "/api/auth/**", "/oauth2/**") - .permitAll() + .requestMatchers("/swagger", "/swagger-ui.html", "/swagger-ui/**", "/api-docs", + "/api-docs/**", "/v3/api-docs/**").permitAll() + .requestMatchers("/login/**", "/api/auth/**", "/oauth2/**") + .permitAll() // 확장자 - .requestMatchers("/", "/error", "/favicon.ico", "/**/*.png", "/**/*.gif", - "/**/*.svg", "/**/*.jpg", "/**/*.html", "/**/*.css", "/**/*.js") - .permitAll() + .requestMatchers("/", "/error", "/favicon.ico", "/**/*.png", "/**/*.gif", + "/**/*.svg", "/**/*.jpg", "/**/*.html", "/**/*.css", "/**/*.js") + .permitAll() // 인증, h2 - .requestMatchers( "/h2-console/**").permitAll() - .anyRequest() - .authenticated() + .requestMatchers("/h2-console/**").permitAll() + .anyRequest() + .authenticated() ) .oauth2Login(oauth -> oauth diff --git a/src/main/java/team1/BE/seamless/util/errorException/RuntimeHandler.java b/src/main/java/team1/BE/seamless/util/errorException/RuntimeHandler.java index 8a3ac2e..fd710be 100644 --- a/src/main/java/team1/BE/seamless/util/errorException/RuntimeHandler.java +++ b/src/main/java/team1/BE/seamless/util/errorException/RuntimeHandler.java @@ -3,6 +3,7 @@ import org.springframework.http.HttpStatus; public class RuntimeHandler extends RuntimeException { + private final HttpStatus status; private final String message; diff --git a/src/main/java/team1/BE/seamless/util/errorException/SecurityEntryPoint.java b/src/main/java/team1/BE/seamless/util/errorException/SecurityEntryPoint.java index a590aac..530c9bd 100644 --- a/src/main/java/team1/BE/seamless/util/errorException/SecurityEntryPoint.java +++ b/src/main/java/team1/BE/seamless/util/errorException/SecurityEntryPoint.java @@ -13,12 +13,14 @@ public class SecurityEntryPoint implements AuthenticationEntryPoint { private final HandlerExceptionResolver resolver; - public SecurityEntryPoint(@Qualifier("handlerExceptionResolver") HandlerExceptionResolver resolver) { + public SecurityEntryPoint( + @Qualifier("handlerExceptionResolver") HandlerExceptionResolver resolver) { this.resolver = resolver; } @Override - public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) { + public void commence(HttpServletRequest request, HttpServletResponse response, + AuthenticationException authException) { resolver.resolveException(request, response, null, authException); } } diff --git a/src/main/java/team1/BE/seamless/util/fiter/TokenAuthenticationFilter.java b/src/main/java/team1/BE/seamless/util/fiter/TokenAuthenticationFilter.java index 722e505..d08da0a 100644 --- a/src/main/java/team1/BE/seamless/util/fiter/TokenAuthenticationFilter.java +++ b/src/main/java/team1/BE/seamless/util/fiter/TokenAuthenticationFilter.java @@ -1,6 +1,5 @@ package team1.BE.seamless.util.fiter; -import team1.BE.seamless.util.auth.JwtToken; import jakarta.servlet.FilterChain; import jakarta.servlet.ServletException; import jakarta.servlet.http.HttpServletRequest; @@ -12,6 +11,7 @@ import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.stereotype.Component; import org.springframework.web.filter.OncePerRequestFilter; +import team1.BE.seamless.util.auth.JwtToken; @Component public class TokenAuthenticationFilter extends OncePerRequestFilter { diff --git a/src/main/java/team1/BE/seamless/util/fiter/TokenExceptionFilter.java b/src/main/java/team1/BE/seamless/util/fiter/TokenExceptionFilter.java index 72c9fa6..db47c0b 100644 --- a/src/main/java/team1/BE/seamless/util/fiter/TokenExceptionFilter.java +++ b/src/main/java/team1/BE/seamless/util/fiter/TokenExceptionFilter.java @@ -1,6 +1,5 @@ package team1.BE.seamless.util.fiter; -import team1.BE.seamless.util.errorException.BaseHandler; import io.jsonwebtoken.ExpiredJwtException; import jakarta.servlet.FilterChain; import jakarta.servlet.ServletException; @@ -11,6 +10,7 @@ import org.springframework.security.oauth2.jwt.JwtException; import org.springframework.stereotype.Component; import org.springframework.web.filter.OncePerRequestFilter; +import team1.BE.seamless.util.errorException.BaseHandler; @Component public class TokenExceptionFilter extends OncePerRequestFilter { diff --git a/src/main/java/team1/BE/seamless/util/page/ListResult.java b/src/main/java/team1/BE/seamless/util/page/ListResult.java index 5761676..31c87d8 100644 --- a/src/main/java/team1/BE/seamless/util/page/ListResult.java +++ b/src/main/java/team1/BE/seamless/util/page/ListResult.java @@ -1,9 +1,9 @@ package team1.BE.seamless.util.page; -import team1.BE.seamless.util.errorException.BaseResult; import java.util.ArrayList; import java.util.Collection; import java.util.List; +import team1.BE.seamless.util.errorException.BaseResult; public class ListResult extends BaseResult { From 851ae215c60e5b4d09c73ea60143412fad81e81d Mon Sep 17 00:00:00 2001 From: Kim-DongHyuk <80240164+Kdonghs@users.noreply.github.com> Date: Fri, 4 Oct 2024 22:04:38 +0900 Subject: [PATCH 51/51] =?UTF-8?q?fix:=20=ED=95=84=EC=9A=94=ED=95=9C=20?= =?UTF-8?q?=ED=95=A8=EC=88=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/team1/BE/seamless/repository/UserRepository.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/team1/BE/seamless/repository/UserRepository.java b/src/main/java/team1/BE/seamless/repository/UserRepository.java index 199d21f..6505b88 100644 --- a/src/main/java/team1/BE/seamless/repository/UserRepository.java +++ b/src/main/java/team1/BE/seamless/repository/UserRepository.java @@ -8,6 +8,7 @@ @Repository public interface UserRepository extends JpaRepository { + Optional findByEmail(String email); Optional findByEmailAndIsDeleteFalse(String email); Optional findByEmailAndIsDeleteFalse(String email, Integer isDelete);