From ce28970f7e25cb6d9b7d2dc8ed6e6e5fa61173fc Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Sun, 30 Jan 2022 21:11:27 +0900 Subject: [PATCH 001/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20createDate=20?= =?UTF-8?q?=EC=BB=AC=EB=9F=BC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/walkhub/walkhub/domain/rank/domain/SchoolRankInfo.java | 2 ++ .../com/walkhub/walkhub/domain/rank/domain/UserRankInfo.java | 3 +++ 2 files changed, 5 insertions(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/domain/SchoolRankInfo.java b/src/main/java/com/walkhub/walkhub/domain/rank/domain/SchoolRankInfo.java index e7d8e954e..5c3943803 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/domain/SchoolRankInfo.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/domain/SchoolRankInfo.java @@ -6,6 +6,7 @@ import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.Table; +import java.time.LocalDateTime; @Getter @Immutable @@ -19,5 +20,6 @@ public class SchoolRankInfo { private String logoImageUrl; private Integer walkCount; private Integer ranking; + private LocalDateTime createDate; } diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/domain/UserRankInfo.java b/src/main/java/com/walkhub/walkhub/domain/rank/domain/UserRankInfo.java index 4349d92c9..2a86d0c76 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/domain/UserRankInfo.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/domain/UserRankInfo.java @@ -8,6 +8,7 @@ import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.Table; +import java.time.LocalDateTime; @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) @@ -33,4 +34,6 @@ public class UserRankInfo { private String agencyCode; + private LocalDateTime createDate; + } From 769d96666e12157356da772d6c70aa71d2c9ac25 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Sun, 30 Jan 2022 21:12:02 +0900 Subject: [PATCH 002/522] =?UTF-8?q?=F0=9F=93=91=20::=20UserRankRepositoryC?= =?UTF-8?q?ustom=20Interface=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/repository/UserRankRepositoryCustom.java | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustom.java diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustom.java b/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustom.java new file mode 100644 index 000000000..8e0b33315 --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustom.java @@ -0,0 +1,10 @@ +package com.walkhub.walkhub.domain.rank.domain.repository; + +import com.walkhub.walkhub.domain.rank.domain.UserRankInfo; + +import java.util.List; + +public interface UserRankRepositoryCustom { + UserRankInfo getMyRankByAccountId(String accountId); + List getUserRankListByAgencyCodeAndClassNum(String agencyCode, String classNum, String dateType); +} From 0b6c0e33b9973172a397715cbf3404023b24e879 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Sun, 30 Jan 2022 22:30:59 +0900 Subject: [PATCH 003/522] =?UTF-8?q?=F0=9F=93=91=20::=20UserRankListRespons?= =?UTF-8?q?e=20DTO?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/response/UserRankListResponse.java | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/main/java/com/walkhub/walkhub/domain/rank/presentation/dto/response/UserRankListResponse.java diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/presentation/dto/response/UserRankListResponse.java b/src/main/java/com/walkhub/walkhub/domain/rank/presentation/dto/response/UserRankListResponse.java new file mode 100644 index 000000000..ab693cbc8 --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/rank/presentation/dto/response/UserRankListResponse.java @@ -0,0 +1,38 @@ +package com.walkhub.walkhub.domain.rank.presentation.dto.response; + +import com.querydsl.core.annotations.QueryProjection; +import lombok.Builder; +import lombok.Getter; + +import java.util.List; + +@Getter +@Builder +public class UserRankListResponse { + + private final UserRankResponse myRank; + private final List rankList; + + @Getter + @Builder + public static class UserRankResponse { + private final String accountId; + private final String name; + private final Integer grade; + private final Integer classNum; + private final Integer ranking; + private final String profileImageUrl; + private final Long walkCount; + + @QueryProjection + public UserRankResponse(String accountId, String name, Integer grade, Integer classNum, Integer ranking, String profileImageUrl, Long walkCount) { + this.accountId = accountId; + this.name = name; + this.grade = grade; + this.classNum = classNum; + this.ranking = ranking; + this.profileImageUrl = profileImageUrl; + this.walkCount = walkCount; + } + } +} From 33fc0ac05b7afa0fba7589aea230979639d415b4 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Sun, 30 Jan 2022 22:31:15 +0900 Subject: [PATCH 004/522] =?UTF-8?q?=F0=9F=93=91=20::=20UserRankRepositoryC?= =?UTF-8?q?ustomImpl?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UserRankRepositoryCustomImpl.java | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustomImpl.java diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustomImpl.java new file mode 100644 index 000000000..4e9de8f12 --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustomImpl.java @@ -0,0 +1,37 @@ +package com.walkhub.walkhub.domain.rank.domain.repository; + +import com.querydsl.core.types.dsl.BooleanExpression; +import com.querydsl.jpa.impl.JPAQueryFactory; +import com.walkhub.walkhub.domain.rank.domain.QUserRankInfo; +import com.walkhub.walkhub.domain.rank.domain.UserRankInfo; +import com.walkhub.walkhub.domain.rank.presentation.dto.response.QUserRankListResponse_UserRankResponse; +import lombok.RequiredArgsConstructor; + +import java.util.List; + +import static com.walkhub.walkhub.domain.rank.domain.QUserRankInfo.*; + +@RequiredArgsConstructor +public class UserRankRepositoryCustomImpl implements UserRankRepositoryCustom{ + + private final JPAQueryFactory queryFactory; + + @Override + public UserRankInfo getMyRankByAccountId(String accountId) { + return queryFactory + .select(new QUserRankListResponse_UserRankResponse( + + )) + .from(userRankInfo) + .where(userRankInfo.accountId.eq(accountId)) + .fetchOne(); + } + + @Override + public List getUserRankListByAgencyCodeAndClassNum(String agencyCode, String classNum, String dateType) { + /*return queryFactory + .select(userRankInfo) + .where(userRankInfo.agencyCode.eq(agencyCode))*/ + return null; + } +} From 4fd37dd15bb6baa1725d40f973205d2211c105ee Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Thu, 10 Feb 2022 15:49:12 +0900 Subject: [PATCH 005/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20UserRepositor?= =?UTF-8?q?yCustom=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../walkhub/domain/user/domain/repository/UserRepository.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepository.java b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepository.java index 6a1554b57..2874e6d38 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepository.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepository.java @@ -5,7 +5,7 @@ import java.util.Optional; -public interface UserRepository extends CrudRepository { +public interface UserRepository extends CrudRepository, UserRepositoryCustom { Optional findByAccountId(String accountId); Optional findByPhoneNumber(String phoneNumber); } From 64758fcc7ebc5000ae0281e15ec04b2359e31da8 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Thu, 10 Feb 2022 15:49:44 +0900 Subject: [PATCH 006/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20QueryUserList?= =?UTF-8?q?Response=20=EB=9D=BC=EC=9A=B0=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 --- .../presentation/TeacherController.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/TeacherController.java b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/TeacherController.java index c026c2f03..7e954c675 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/TeacherController.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/TeacherController.java @@ -2,20 +2,11 @@ import com.walkhub.walkhub.domain.teacher.presentation.dto.request.CreateClassRequest; import com.walkhub.walkhub.domain.teacher.presentation.dto.response.CodeResponse; -import com.walkhub.walkhub.domain.teacher.service.CreateClassService; -import com.walkhub.walkhub.domain.teacher.service.DeleteClassService; -import com.walkhub.walkhub.domain.teacher.service.RefreshClassCodeService; -import com.walkhub.walkhub.domain.teacher.service.VerificationCodeService; +import com.walkhub.walkhub.domain.teacher.presentation.dto.response.QueryUserListResponse; +import com.walkhub.walkhub.domain.teacher.service.*; import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.PatchMapping; -import org.springframework.web.bind.annotation.PathVariable; -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.ResponseStatus; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import javax.validation.Valid; @@ -28,6 +19,7 @@ public class TeacherController { private final VerificationCodeService verificationCodeService; private final DeleteClassService deleteClassService; private final RefreshClassCodeService refreshClassCodeService; + private final QueryUserListService queryUserListService; @ResponseStatus(HttpStatus.CREATED) @PostMapping("/classes") @@ -52,4 +44,12 @@ public CodeResponse refreshClassCode() { return refreshClassCodeService.execute(); } + @GetMapping("/users") + public QueryUserListResponse queryUserList(@RequestParam Integer page, + @RequestParam String scope, + @RequestParam String sort, + @RequestParam Integer grade, + @RequestParam Integer classNum) { + return queryUserListService.execute(page, scope, sort, grade, classNum); + } } From 0a50c15a646570c05f9bd13741b978767d1e6830 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Thu, 10 Feb 2022 15:50:54 +0900 Subject: [PATCH 007/522] =?UTF-8?q?=F0=9F=93=91=20::=20QueryUserListRespon?= =?UTF-8?q?se=20DTO?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/response/QueryUserListResponse.java | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/QueryUserListResponse.java diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/QueryUserListResponse.java b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/QueryUserListResponse.java new file mode 100644 index 000000000..7ddb7dac6 --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/QueryUserListResponse.java @@ -0,0 +1,39 @@ +package com.walkhub.walkhub.domain.teacher.presentation.dto.response; + +import com.querydsl.core.annotations.QueryProjection; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Getter +@Builder +public class QueryUserListResponse { + + private List userList; + + @Getter + @NoArgsConstructor + @Builder + public static class UserListInfo { + private Long userId; + private String name; + private String profileImageUrl; + private Integer grade; + private Integer classNum; + private Integer number; + private Boolean isTeacher; + + @QueryProjection + public UserListInfo(Long userId, String name, String profileImageUrl, Integer grade, Integer classNum, Integer number, Boolean isTeacher) { + this.userId = userId; + this.name = name; + this.profileImageUrl = profileImageUrl; + this.grade = grade; + this.classNum = classNum; + this.number = number; + this.isTeacher = isTeacher; + } + } +} From 6098581083fcc0120d52c538c5a8fe5e6b1a9506 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Thu, 10 Feb 2022 15:51:10 +0900 Subject: [PATCH 008/522] =?UTF-8?q?=F0=9F=93=91=20::=20QueryUserListServic?= =?UTF-8?q?e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../teacher/service/QueryUserListService.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/main/java/com/walkhub/walkhub/domain/teacher/service/QueryUserListService.java diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/service/QueryUserListService.java b/src/main/java/com/walkhub/walkhub/domain/teacher/service/QueryUserListService.java new file mode 100644 index 000000000..d4c15d2a3 --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/service/QueryUserListService.java @@ -0,0 +1,20 @@ +package com.walkhub.walkhub.domain.teacher.service; + +import com.walkhub.walkhub.domain.teacher.presentation.dto.response.QueryUserListResponse; +import com.walkhub.walkhub.domain.user.domain.repository.UserRepository; +import com.walkhub.walkhub.domain.user.facade.UserFacade; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +@RequiredArgsConstructor +@Service +public class QueryUserListService { + private final UserRepository userRepository; + private final UserFacade userFacade; + + public QueryUserListResponse execute(Integer page, String scope, String sort, Integer grade, Integer classNum) { + return QueryUserListResponse.builder() + .userList(userRepository.queryUserList(page, scope, sort, grade, classNum, userFacade.getCurrentUser())) + .build(); + } +} From ec6f019d5e951d403f94cb73633a0eddff590efb Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Thu, 10 Feb 2022 15:51:27 +0900 Subject: [PATCH 009/522] =?UTF-8?q?=F0=9F=93=91=20::=20UserRepositoryCusto?= =?UTF-8?q?m=20Interface?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../user/domain/repository/UserRepositoryCustom.java | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustom.java diff --git a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustom.java b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustom.java new file mode 100644 index 000000000..401bddddf --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustom.java @@ -0,0 +1,10 @@ +package com.walkhub.walkhub.domain.user.domain.repository; + +import com.walkhub.walkhub.domain.teacher.presentation.dto.response.QueryUserListResponse; +import com.walkhub.walkhub.domain.user.domain.User; + +import java.util.List; + +public interface UserRepositoryCustom { + List queryUserList(Integer page, String scope, String sort, Integer grade, Integer classNum, User currentUser); +} From 6622d1b26245138b4e3214197d0c5c0c5f3fa6fc Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Thu, 10 Feb 2022 15:51:45 +0900 Subject: [PATCH 010/522] =?UTF-8?q?=F0=9F=93=91=20::=20UserRepositoryCusto?= =?UTF-8?q?mImpl?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/UserRepositoryCustomImpl.java | 101 ++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java diff --git a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java new file mode 100644 index 000000000..545ed2f0b --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java @@ -0,0 +1,101 @@ +package com.walkhub.walkhub.domain.user.domain.repository; + +import com.querydsl.core.BooleanBuilder; +import com.querydsl.core.types.OrderSpecifier; +import com.querydsl.core.types.dsl.BooleanExpression; +import com.querydsl.jpa.impl.JPAQueryFactory; +import com.walkhub.walkhub.domain.teacher.presentation.dto.response.QQueryUserListResponse_UserListInfo; +import com.walkhub.walkhub.domain.teacher.presentation.dto.response.QueryUserListResponse; +import com.walkhub.walkhub.domain.user.domain.User; +import com.walkhub.walkhub.domain.user.facade.GroupFacade; +import com.walkhub.walkhub.domain.user.facade.UserFacade; +import com.walkhub.walkhub.global.enums.Authority; +import com.walkhub.walkhub.global.querydsl.QuerydslUtil; +import lombok.RequiredArgsConstructor; + +import java.util.List; + +import static com.walkhub.walkhub.domain.exercise.domain.QExerciseAnalysis.exerciseAnalysis; +import static com.walkhub.walkhub.domain.user.domain.QUser.user; + +@RequiredArgsConstructor +public class UserRepositoryCustomImpl implements UserRepositoryCustom { + private final JPAQueryFactory queryFactory; + private final QuerydslUtil querydslUtil; + private final GroupFacade groupFacade; + + @Override + public List queryUserList(Integer page, String scope, String sort, Integer grade, Integer classNum, User currentUser) { + return queryFactory + .select(new QQueryUserListResponse_UserListInfo( + user.id.as("userId"), + user.name, + user.profileImageUrl, + user.group.grade, + user.group.classNum, + user.number, + user.authority.eq(Authority.TEACHER).as("isTeacher") + )) + .from(user) + .leftJoin(exerciseAnalysis.user, user) + .where( + user.school.eq(groupFacade.getGroup(currentUser.getId()).getSchool()), + buildFilteringCondition(scope), + gradeAndClassNumEq(grade, classNum) + ) + .offset(page * 100) + .limit(100) + .orderBy(buildSortCondition(sort)) + .fetch(); + } + + private BooleanBuilder gradeAndClassNumEq(Integer grade, Integer classNum) { + return gradeEq(grade).and(classNumEq(classNum)); + } + + private BooleanBuilder gradeEq(Integer grade) { + return querydslUtil.nullSafeBuilder(() -> user.group.grade.eq(grade)); + } + + private BooleanBuilder classNumEq(Integer classNum) { + return querydslUtil.nullSafeBuilder(() -> user.group.classNum.eq(classNum)); + } + + private BooleanExpression buildFilteringCondition(String scope) { + switch (scope) { + case "ALL": + return user.authority.eq(Authority.TEACHER).and(user.authority.eq(Authority.USER)); + case "STUDENT": + return user.authority.eq(Authority.USER); + case "TEACHER": + return user.authority.eq(Authority.TEACHER); + default: + return null; + } + } + + private OrderSpecifier[] buildSortCondition(String sort) { + switch (sort) { + case "NAME": + return new OrderSpecifier[]{ + user.name.asc() + }; + case "GCN": + return new OrderSpecifier[]{ + user.group.grade.asc(), + user.group.classNum.asc(), + user.number.asc() + }; + case "WALK_COUNT": + return new OrderSpecifier[]{ + exerciseAnalysis.walkCount.desc() + }; + case "DISTANCE": + return new OrderSpecifier[]{ + exerciseAnalysis.distance.desc() + }; + default: + return null; + } + } +} From 092081e4d436dfed1f16a8225bedc205d5b74212 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Thu, 10 Feb 2022 15:52:03 +0900 Subject: [PATCH 011/522] =?UTF-8?q?=F0=9F=93=91=20::=20querydsl=20util?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../walkhub/global/querydsl/QuerydslUtil.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/main/java/com/walkhub/walkhub/global/querydsl/QuerydslUtil.java diff --git a/src/main/java/com/walkhub/walkhub/global/querydsl/QuerydslUtil.java b/src/main/java/com/walkhub/walkhub/global/querydsl/QuerydslUtil.java new file mode 100644 index 000000000..209476891 --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/global/querydsl/QuerydslUtil.java @@ -0,0 +1,18 @@ +package com.walkhub.walkhub.global.querydsl; + +import com.querydsl.core.BooleanBuilder; +import com.querydsl.core.types.dsl.BooleanExpression; +import org.springframework.stereotype.Component; + +import java.util.function.Supplier; + +@Component +public class QuerydslUtil { + public BooleanBuilder nullSafeBuilder(Supplier f) { + try { + return new BooleanBuilder(f.get()); + } catch (IllegalArgumentException e) { + return new BooleanBuilder(); + } + } +} From 17d9b57021e0f5e1490d000dc05b3d5390a314a1 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Thu, 10 Feb 2022 16:04:11 +0900 Subject: [PATCH 012/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20group=20->=20?= =?UTF-8?q?section=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/repository/UserRepositoryCustomImpl.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java index eb2bb7a67..5ff601142 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java @@ -30,8 +30,8 @@ public List queryUserList(Integer page, Stri user.id.as("userId"), user.name, user.profileImageUrl, - user.group.grade, - user.group.classNum, + user.section.grade, + user.section.classNum, user.number, user.authority.eq(Authority.TEACHER).as("isTeacher") )) @@ -53,11 +53,11 @@ private BooleanBuilder gradeAndClassNumEq(Integer grade, Integer classNum) { } private BooleanBuilder gradeEq(Integer grade) { - return querydslUtil.nullSafeBuilder(() -> user.group.grade.eq(grade)); + return querydslUtil.nullSafeBuilder(() -> user.section.grade.eq(grade)); } private BooleanBuilder classNumEq(Integer classNum) { - return querydslUtil.nullSafeBuilder(() -> user.group.classNum.eq(classNum)); + return querydslUtil.nullSafeBuilder(() -> user.section.classNum.eq(classNum)); } private BooleanExpression buildFilteringCondition(String scope) { @@ -81,8 +81,8 @@ private OrderSpecifier[] buildSortCondition(String sort) { }; case "GCN": return new OrderSpecifier[]{ - user.group.grade.asc(), - user.group.classNum.asc(), + user.section.grade.asc(), + user.section.classNum.asc(), user.number.asc() }; case "WALK_COUNT": From 7c6716ecebf8fb8d8867ce7c29afcb62b8901169 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Thu, 10 Feb 2022 16:32:21 +0900 Subject: [PATCH 013/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20leftjoin=20on?= =?UTF-8?q?=EC=A0=88=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../user/domain/repository/UserRepositoryCustomImpl.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java index 5ff601142..4794ddf9f 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java @@ -4,6 +4,7 @@ import com.querydsl.core.types.OrderSpecifier; import com.querydsl.core.types.dsl.BooleanExpression; import com.querydsl.jpa.impl.JPAQueryFactory; +import com.walkhub.walkhub.domain.exercise.domain.QExerciseAnalysis; import com.walkhub.walkhub.domain.teacher.presentation.dto.response.QQueryUserListResponse_UserListInfo; import com.walkhub.walkhub.domain.teacher.presentation.dto.response.QueryUserListResponse; import com.walkhub.walkhub.domain.user.domain.User; @@ -36,9 +37,10 @@ public List queryUserList(Integer page, Stri user.authority.eq(Authority.TEACHER).as("isTeacher") )) .from(user) - .leftJoin(exerciseAnalysis.user, user) + .leftJoin(exerciseAnalysis) + .on(exerciseAnalysis.user.eq(user)) .where( - user.school.eq(sectionFacade.getSectionById(currentUser.getId()).getSchool()), + user.school.eq(currentUser.getSchool()), buildFilteringCondition(scope), gradeAndClassNumEq(grade, classNum) ) From f572bb9b96043bfcf10aa30bfaa433e19a176018 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Thu, 10 Feb 2022 18:37:38 +0900 Subject: [PATCH 014/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20grade,=20clas?= =?UTF-8?q?sNum=20null=20=ED=97=88=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/teacher/presentation/TeacherController.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/TeacherController.java b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/TeacherController.java index 5c06ffe30..cd5113896 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/TeacherController.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/TeacherController.java @@ -64,8 +64,8 @@ public CodeResponse refreshClassCode() { public QueryUserListResponse queryUserList(@RequestParam Integer page, @RequestParam String scope, @RequestParam String sort, - @RequestParam Integer grade, - @RequestParam Integer classNum) { + @RequestParam(required = false) Integer grade, + @RequestParam(required = false) Integer classNum) { return queryUserListService.execute(page, scope, sort, grade, classNum); } From 9897117fe8561b6c81ce708bf52a0ea45beeb177 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Thu, 10 Feb 2022 18:38:13 +0900 Subject: [PATCH 015/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20is=5Fteacher?= =?UTF-8?q?=20=EC=A0=95=EB=A0=AC=EC=A1=B0=EA=B1=B4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/repository/UserRepositoryCustomImpl.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java index 4794ddf9f..8a8d919c3 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java @@ -65,7 +65,7 @@ private BooleanBuilder classNumEq(Integer classNum) { private BooleanExpression buildFilteringCondition(String scope) { switch (scope) { case "ALL": - return user.authority.eq(Authority.TEACHER).and(user.authority.eq(Authority.USER)); + return user.authority.eq(Authority.TEACHER).or(user.authority.eq(Authority.USER)); case "STUDENT": return user.authority.eq(Authority.USER); case "TEACHER": @@ -79,21 +79,24 @@ private OrderSpecifier[] buildSortCondition(String sort) { switch (sort) { case "NAME": return new OrderSpecifier[]{ - user.name.asc() + user.name.asc(), user.authority.asc() }; case "GCN": return new OrderSpecifier[]{ user.section.grade.asc(), user.section.classNum.asc(), - user.number.asc() + user.number.asc(), + user.authority.asc() }; case "WALK_COUNT": return new OrderSpecifier[]{ - exerciseAnalysis.walkCount.desc() + exerciseAnalysis.walkCount.desc(), + user.authority.asc() }; case "DISTANCE": return new OrderSpecifier[]{ - exerciseAnalysis.distance.desc() + exerciseAnalysis.distance.desc(), + user.authority.asc() }; default: return null; From 29ede7396a90c517ed81343dc0a743e9de52e5e3 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Thu, 10 Feb 2022 18:40:02 +0900 Subject: [PATCH 016/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20codesmell=20?= =?UTF-8?q?=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../user/domain/repository/UserRepositoryCustomImpl.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java index 8a8d919c3..28813b6f8 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java @@ -4,7 +4,6 @@ import com.querydsl.core.types.OrderSpecifier; import com.querydsl.core.types.dsl.BooleanExpression; import com.querydsl.jpa.impl.JPAQueryFactory; -import com.walkhub.walkhub.domain.exercise.domain.QExerciseAnalysis; import com.walkhub.walkhub.domain.teacher.presentation.dto.response.QQueryUserListResponse_UserListInfo; import com.walkhub.walkhub.domain.teacher.presentation.dto.response.QueryUserListResponse; import com.walkhub.walkhub.domain.user.domain.User; @@ -99,7 +98,7 @@ private OrderSpecifier[] buildSortCondition(String sort) { user.authority.asc() }; default: - return null; + return new OrderSpecifier[] {}; } } } From cdc328c59c7d772e6f470b088bb45883ec5c8110 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Thu, 10 Feb 2022 18:47:48 +0900 Subject: [PATCH 017/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20bug=20?= =?UTF-8?q?=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../user/domain/repository/UserRepositoryCustomImpl.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java index 28813b6f8..4d128d89f 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java @@ -25,6 +25,7 @@ public class UserRepositoryCustomImpl implements UserRepositoryCustom { @Override public List queryUserList(Integer page, String scope, String sort, Integer grade, Integer classNum, User currentUser) { + Long size = 4L; return queryFactory .select(new QQueryUserListResponse_UserListInfo( user.id.as("userId"), @@ -43,8 +44,8 @@ public List queryUserList(Integer page, Stri buildFilteringCondition(scope), gradeAndClassNumEq(grade, classNum) ) - .offset(page * 100) - .limit(100) + .offset((long)page * size) + .limit(size) .orderBy(buildSortCondition(sort)) .fetch(); } From 4779d9e4ce27efbb011f225b1b3b2bd4f75b7c1c Mon Sep 17 00:00:00 2001 From: lyutvs Date: Thu, 10 Feb 2022 22:43:24 +0900 Subject: [PATCH 018/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F::=20dailyWalkCountGo?= =?UTF-8?q?al?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/walkhub/walkhub/domain/user/domain/User.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/user/domain/User.java b/src/main/java/com/walkhub/walkhub/domain/user/domain/User.java index 9ef6cd709..362e62129 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/domain/User.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/domain/User.java @@ -95,10 +95,14 @@ public class User extends BaseTimeEntity { @JoinColumn(name = "max_level_id") private CalorieLevel maxLevel; + @NotNull + @ColumnDefault("10000") + private Integer dailyWalkCountGoal; + @Builder public User(Long id, String accountId, String password, String phoneNumber, String name, Authority authority, Group group, School school, boolean isMeasuring, - Integer weight, BigDecimal height, Sex sex, Badge badge, String deviceToken) { + Integer weight, BigDecimal height, Sex sex, Badge badge, String deviceToken, Integer dailyWalkCountGoal) { this.id = id; this.accountId = accountId; this.password = password; @@ -112,6 +116,7 @@ public User(Long id, String accountId, String password, String phoneNumber, Stri this.sex = sex; this.badge = badge; this.deviceToken = deviceToken; + this.dailyWalkCountGoal = dailyWalkCountGoal; } public void setDeviceToken(String deviceToken) { From 3f43442c74e641df735ee85ecc48246b9a3f414a Mon Sep 17 00:00:00 2001 From: lyutvs Date: Thu, 10 Feb 2022 22:43:36 +0900 Subject: [PATCH 019/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F::=20ExerciseAnalysis?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exercise/domain/ExerciseAnalysis.java | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/ExerciseAnalysis.java b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/ExerciseAnalysis.java index 1e7483270..34e92e6d4 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/ExerciseAnalysis.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/ExerciseAnalysis.java @@ -8,7 +8,9 @@ import lombok.NoArgsConstructor; import javax.persistence.*; +import javax.validation.constraints.NotNull; import java.time.LocalDate; +import java.time.LocalDateTime; @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) @@ -19,30 +21,44 @@ public class ExerciseAnalysis { @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; - @Column(nullable = false) + @NotNull private Integer calorie; - @Column(nullable = false) + @NotNull private Integer walkCount; - @Column(nullable = false) + @NotNull private Integer distance; - @Column(nullable = false) + @NotNull private LocalDate date; + @NotNull + private Long levelId; + + @NotNull + private Integer foodCalorie; + + @NotNull + private LocalDateTime walkTime; + @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "user_id", nullable = false) private User user; + @Builder public ExerciseAnalysis(Integer calorie, Integer walkCount, - Integer distance, LocalDate date, User user) { + Integer distance, LocalDate date, User user, Long levelId, + Integer foodCalorie, LocalDateTime walkTime) { this.calorie = calorie; this.walkCount = walkCount; this.distance = distance; this.date = date; this.user = user; + this.levelId = levelId; + this.foodCalorie = foodCalorie; + this.walkTime = walkTime; } public void updateExerciseAnalysis(SaveExerciseAnalysisRequest request) { From ad2bb6576631c053cebd094170d402d41618af99 Mon Sep 17 00:00:00 2001 From: lyutvs Date: Thu, 10 Feb 2022 22:43:54 +0900 Subject: [PATCH 020/522] =?UTF-8?q?=F0=9F=93=91::=20QueryExericiseAnalysis?= =?UTF-8?q?Response?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../QueryExerciseAnalysisResponse.java | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/response/QueryExerciseAnalysisResponse.java diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/response/QueryExerciseAnalysisResponse.java b/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/response/QueryExerciseAnalysisResponse.java new file mode 100644 index 000000000..08812657a --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/response/QueryExerciseAnalysisResponse.java @@ -0,0 +1,35 @@ +package com.walkhub.walkhub.domain.exercise.presentation.dto.response; + + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; + +import java.time.LocalDateTime; +import java.util.List; + +@Getter +@AllArgsConstructor +public class QueryExerciseAnalysisResponse { + + private final List exerciseAnalysisResponses; + + @Getter + @Builder + public static class ExerciseAnalysisResponse { + private final Long levelId; + private final Integer foodCalorie; + private final List walkCountList; + private final Integer dailyWalkCountGoal; + private final Integer walkCount; + private final Integer calorie; + private final Integer distance; + private final LocalDateTime walkTime; + } + + @Getter + @Builder + public static class WalkCountListResponse { + private final Integer walkCount; + } +} From 404e34702ccc1a0a8559bf45279315ff7b5c468a Mon Sep 17 00:00:00 2001 From: lyutvs Date: Thu, 10 Feb 2022 22:44:12 +0900 Subject: [PATCH 021/522] =?UTF-8?q?=F0=9F=93=91::=20QueryExerciseAnalysisS?= =?UTF-8?q?ervice?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/QueryExerciseAnalysisService.java | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/main/java/com/walkhub/walkhub/domain/exercise/service/QueryExerciseAnalysisService.java diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/service/QueryExerciseAnalysisService.java b/src/main/java/com/walkhub/walkhub/domain/exercise/service/QueryExerciseAnalysisService.java new file mode 100644 index 000000000..4ee00e544 --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/service/QueryExerciseAnalysisService.java @@ -0,0 +1,39 @@ +package com.walkhub.walkhub.domain.exercise.service; + +import com.walkhub.walkhub.domain.exercise.domain.repository.ExerciseAnalysisRepository; +import com.walkhub.walkhub.domain.exercise.presentation.dto.response.QueryExerciseAnalysisResponse; +import com.walkhub.walkhub.domain.user.domain.User; +import com.walkhub.walkhub.domain.user.facade.UserFacade; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; +import java.util.stream.Collectors; + +@RequiredArgsConstructor +@Service +public class QueryExerciseAnalysisService { + + private final ExerciseAnalysisRepository exerciseAnalysisRepository; + private final UserFacade userFacade; + + @Transactional(readOnly = true) + public QueryExerciseAnalysisResponse execute() { + User user = userFacade.getCurrentUser(); + List queryExerciseAnalysisResponseList = + exerciseAnalysisRepository.findExerciseAnalysisByUser(user) + .stream() + .map(exerciseAnalysis -> QueryExerciseAnalysisResponse.ExerciseAnalysisResponse.builder() + .levelId(exerciseAnalysis.getLevelId()) + .foodCalorie(exerciseAnalysis.getFoodCalorie()) + .dailyWalkCountGoal(user.getDailyWalkCountGoal()) + .walkCount(exerciseAnalysis.getWalkCount()) + .calorie(exerciseAnalysis.getCalorie()) + .distance(exerciseAnalysis.getDistance()) + .build()) + .collect(Collectors.toList()); + + return new QueryExerciseAnalysisResponse(queryExerciseAnalysisResponseList); + } +} \ No newline at end of file From cfae014d2da5b7d82bb990be7124964299b840ef Mon Sep 17 00:00:00 2001 From: lyutvs Date: Thu, 10 Feb 2022 22:44:42 +0900 Subject: [PATCH 022/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F::=20ExerciseAnalysis?= =?UTF-8?q?Repository?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exercise/domain/repository/ExerciseAnalysisRepository.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepository.java b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepository.java index 2b3f1a9f0..feb93563c 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepository.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepository.java @@ -5,8 +5,10 @@ import org.springframework.data.repository.CrudRepository; import java.time.LocalDate; +import java.util.List; import java.util.Optional; public interface ExerciseAnalysisRepository extends CrudRepository { Optional findByUserAndDate(User user, LocalDate date); + List findExerciseAnalysisByUser(User user); } From 08bf8ff28c5549deceab1cdacc8a2f9a4c08ab83 Mon Sep 17 00:00:00 2001 From: lyutvs Date: Thu, 10 Feb 2022 22:44:53 +0900 Subject: [PATCH 023/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F::=20ExerciseControll?= =?UTF-8?q?er?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exercise/presentation/ExerciseController.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/ExerciseController.java b/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/ExerciseController.java index 31afcc83f..f4664a96e 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/ExerciseController.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/ExerciseController.java @@ -5,10 +5,8 @@ import com.walkhub.walkhub.domain.exercise.presentation.dto.request.SaveExerciseAnalysisRequest; import com.walkhub.walkhub.domain.exercise.presentation.dto.request.SaveLocationRequest; import com.walkhub.walkhub.domain.exercise.presentation.dto.response.CreateExerciseResponse; -import com.walkhub.walkhub.domain.exercise.service.CreateExerciseService; -import com.walkhub.walkhub.domain.exercise.service.FinishExerciseService; -import com.walkhub.walkhub.domain.exercise.service.SaveLocationService; -import com.walkhub.walkhub.domain.exercise.service.SaveOrUpdateExerciseAnalysisService; +import com.walkhub.walkhub.domain.exercise.presentation.dto.response.QueryExerciseAnalysisResponse; +import com.walkhub.walkhub.domain.exercise.service.*; import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.*; @@ -24,6 +22,7 @@ public class ExerciseController { private final FinishExerciseService finishExerciseService; private final SaveLocationService saveLocationService; private final SaveOrUpdateExerciseAnalysisService saveOrUpdateExerciseAnalysisService; + private final QueryExerciseAnalysisService queryExerciseAnalysisService; @ResponseStatus(HttpStatus.CREATED) @PostMapping @@ -51,4 +50,9 @@ public void saveOrUpdateTodayExercise(@RequestBody @Valid SaveExerciseAnalysisRe saveOrUpdateExerciseAnalysisService.execute(request); } + @GetMapping("/analysis") + public QueryExerciseAnalysisResponse setQueryExerciseAnalysis() { + return queryExerciseAnalysisService.execute(); + } + } From f3c9459a0eda9fbf33cf63032f5a844de992aa69 Mon Sep 17 00:00:00 2001 From: lyutvs Date: Thu, 10 Feb 2022 22:50:23 +0900 Subject: [PATCH 024/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F::=20User?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/walkhub/walkhub/domain/user/domain/User.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/user/domain/User.java b/src/main/java/com/walkhub/walkhub/domain/user/domain/User.java index a77e0d4c6..9326b2f88 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/domain/User.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/domain/User.java @@ -100,9 +100,9 @@ public class User extends BaseTimeEntity { private Integer dailyWalkCountGoal; @Builder - public User(Integer calorie, Integer walkCount, - Integer distance, LocalDate date, User user, Long levelId, - Integer foodCalorie, LocalDateTime walkTime) { + public User(Long id, String accountId, String password, String phoneNumber, String name, + Authority authority, Section section, School school, boolean isMeasuring, + Integer weight, BigDecimal height, Sex sex, Badge badge, String deviceToken, Integer dailyWalkCountGoal) { this.id = id; this.accountId = accountId; this.password = password; From 383d6e352c05da25066b1d90c9f7ac2be4e80b6c Mon Sep 17 00:00:00 2001 From: lyutvs Date: Fri, 11 Feb 2022 01:47:46 +0900 Subject: [PATCH 025/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F::=20=ED=96=89=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 --- .../domain/exercise/presentation/ExerciseController.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/ExerciseController.java b/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/ExerciseController.java index 88c07d5fb..b65b26a9f 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/ExerciseController.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/ExerciseController.java @@ -60,11 +60,10 @@ public void saveOrUpdateTodayExercise(@RequestBody @Valid SaveExerciseAnalysisRe @GetMapping("/analysis") public QueryExerciseAnalysisResponse setQueryExerciseAnalysis() { return queryExerciseAnalysisService.execute(); - } - + } + @GetMapping("/lists") public ExerciseListResponse queryExerciseList() { return queryExerciseListService.execute(); } - } From b82198333ddf21cbb77ab2b75e02f39592706a98 Mon Sep 17 00:00:00 2001 From: lyutvs Date: Fri, 11 Feb 2022 01:47:58 +0900 Subject: [PATCH 026/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F::=20findByUser?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exercise/domain/repository/ExerciseAnalysisRepository.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepository.java b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepository.java index feb93563c..4c61e8dde 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepository.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepository.java @@ -10,5 +10,5 @@ public interface ExerciseAnalysisRepository extends CrudRepository { Optional findByUserAndDate(User user, LocalDate date); - List findExerciseAnalysisByUser(User user); + List findByUser(User user); } From b3ea3a484f51ab12cef9047b068b7652fbfd9bb8 Mon Sep 17 00:00:00 2001 From: lyutvs Date: Fri, 11 Feb 2022 02:20:09 +0900 Subject: [PATCH 027/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F::=20=EC=9E=84?= =?UTF-8?q?=ED=8F=AC=ED=8A=B8=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/exercise/domain/ExerciseAnalysis.java | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/ExerciseAnalysis.java b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/ExerciseAnalysis.java index 34e92e6d4..850524c24 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/ExerciseAnalysis.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/ExerciseAnalysis.java @@ -10,7 +10,6 @@ import javax.persistence.*; import javax.validation.constraints.NotNull; import java.time.LocalDate; -import java.time.LocalDateTime; @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) @@ -33,15 +32,6 @@ public class ExerciseAnalysis { @NotNull private LocalDate date; - @NotNull - private Long levelId; - - @NotNull - private Integer foodCalorie; - - @NotNull - private LocalDateTime walkTime; - @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "user_id", nullable = false) private User user; @@ -49,16 +39,12 @@ public class ExerciseAnalysis { @Builder public ExerciseAnalysis(Integer calorie, Integer walkCount, - Integer distance, LocalDate date, User user, Long levelId, - Integer foodCalorie, LocalDateTime walkTime) { + Integer distance, LocalDate date, User user) { this.calorie = calorie; this.walkCount = walkCount; this.distance = distance; this.date = date; this.user = user; - this.levelId = levelId; - this.foodCalorie = foodCalorie; - this.walkTime = walkTime; } public void updateExerciseAnalysis(SaveExerciseAnalysisRequest request) { From 2602d04ca98ca7cba12bf64aa2f3bf73569a2767 Mon Sep 17 00:00:00 2001 From: lyutvs Date: Fri, 11 Feb 2022 02:20:21 +0900 Subject: [PATCH 028/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F::=20=ED=95=84?= =?UTF-8?q?=EC=9A=94=EC=97=86=EB=8A=94=EA=B1=B0=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/response/QueryExerciseAnalysisResponse.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/response/QueryExerciseAnalysisResponse.java b/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/response/QueryExerciseAnalysisResponse.java index 08812657a..21cbcc59f 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/response/QueryExerciseAnalysisResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/response/QueryExerciseAnalysisResponse.java @@ -12,13 +12,11 @@ @AllArgsConstructor public class QueryExerciseAnalysisResponse { - private final List exerciseAnalysisResponses; + private final List exerciseAnalysisList; @Getter @Builder public static class ExerciseAnalysisResponse { - private final Long levelId; - private final Integer foodCalorie; private final List walkCountList; private final Integer dailyWalkCountGoal; private final Integer walkCount; From ad198c298c5467ff478f04fe57c3ec23ac42f98b Mon Sep 17 00:00:00 2001 From: lyutvs Date: Fri, 11 Feb 2022 02:20:51 +0900 Subject: [PATCH 029/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F::=20=EC=9E=84?= =?UTF-8?q?=ED=8F=AC=ED=8A=B8=20=EC=A0=95=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/QueryExerciseAnalysisService.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/service/QueryExerciseAnalysisService.java b/src/main/java/com/walkhub/walkhub/domain/exercise/service/QueryExerciseAnalysisService.java index 4ee00e544..3e899797a 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/service/QueryExerciseAnalysisService.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/service/QueryExerciseAnalysisService.java @@ -2,6 +2,8 @@ import com.walkhub.walkhub.domain.exercise.domain.repository.ExerciseAnalysisRepository; import com.walkhub.walkhub.domain.exercise.presentation.dto.response.QueryExerciseAnalysisResponse; +import com.walkhub.walkhub.domain.exercise.presentation.dto.response.QueryExerciseAnalysisResponse.ExerciseAnalysisResponse; +import com.walkhub.walkhub.domain.user.domain.CalorieLevel; import com.walkhub.walkhub.domain.user.domain.User; import com.walkhub.walkhub.domain.user.facade.UserFacade; import lombok.RequiredArgsConstructor; @@ -19,14 +21,12 @@ public class QueryExerciseAnalysisService { private final UserFacade userFacade; @Transactional(readOnly = true) - public QueryExerciseAnalysisResponse execute() { + public QueryExerciseAnalysisResponse execute(CalorieLevel calorieLevel) { User user = userFacade.getCurrentUser(); - List queryExerciseAnalysisResponseList = - exerciseAnalysisRepository.findExerciseAnalysisByUser(user) + List queryExerciseAnalysisResponseList = + exerciseAnalysisRepository.findByUser(user) .stream() - .map(exerciseAnalysis -> QueryExerciseAnalysisResponse.ExerciseAnalysisResponse.builder() - .levelId(exerciseAnalysis.getLevelId()) - .foodCalorie(exerciseAnalysis.getFoodCalorie()) + .map(exerciseAnalysis -> ExerciseAnalysisResponse.builder() .dailyWalkCountGoal(user.getDailyWalkCountGoal()) .walkCount(exerciseAnalysis.getWalkCount()) .calorie(exerciseAnalysis.getCalorie()) From 006fd398c93f8274346036982adca2260b20b10a Mon Sep 17 00:00:00 2001 From: lyutvs Date: Fri, 11 Feb 2022 02:26:38 +0900 Subject: [PATCH 030/522] =?UTF-8?q?=F0=9F=90=9B::=20codesmell?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/exercise/service/QueryExerciseAnalysisService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/service/QueryExerciseAnalysisService.java b/src/main/java/com/walkhub/walkhub/domain/exercise/service/QueryExerciseAnalysisService.java index 3e899797a..b5a4321a3 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/service/QueryExerciseAnalysisService.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/service/QueryExerciseAnalysisService.java @@ -21,7 +21,7 @@ public class QueryExerciseAnalysisService { private final UserFacade userFacade; @Transactional(readOnly = true) - public QueryExerciseAnalysisResponse execute(CalorieLevel calorieLevel) { + public QueryExerciseAnalysisResponse execute() { User user = userFacade.getCurrentUser(); List queryExerciseAnalysisResponseList = exerciseAnalysisRepository.findByUser(user) From 97cb61cfaacbfbf42e0b14ce915d351443a3c543 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Fri, 11 Feb 2022 12:23:32 +0900 Subject: [PATCH 031/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20Noargsconstru?= =?UTF-8?q?ctor=20=EC=A0=9C=EA=B1=B0,=20final=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/dto/response/QueryUserListResponse.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/QueryUserListResponse.java b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/QueryUserListResponse.java index 7ddb7dac6..171e29e51 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/QueryUserListResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/QueryUserListResponse.java @@ -11,10 +11,9 @@ @Builder public class QueryUserListResponse { - private List userList; + private final List userList; @Getter - @NoArgsConstructor @Builder public static class UserListInfo { private Long userId; From 0b16787afa66841d45ddda8cdd26870dafdba998 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Fri, 11 Feb 2022 12:26:42 +0900 Subject: [PATCH 032/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20codesmell=20?= =?UTF-8?q?=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../teacher/presentation/dto/response/QueryUserListResponse.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/QueryUserListResponse.java b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/QueryUserListResponse.java index 171e29e51..0d7a4b2d0 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/QueryUserListResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/QueryUserListResponse.java @@ -3,7 +3,6 @@ import com.querydsl.core.annotations.QueryProjection; import lombok.Builder; import lombok.Getter; -import lombok.NoArgsConstructor; import java.util.List; From 616a952d3ce9a62c7cbf7839202601a932e88e24 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Fri, 11 Feb 2022 12:28:20 +0900 Subject: [PATCH 033/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20=ED=95=84?= =?UTF-8?q?=EC=9A=94=EC=97=86=EB=8A=94=20=EC=BD=94=EB=93=9C=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/user/domain/repository/UserRepositoryCustomImpl.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java index 4d128d89f..849bbcd90 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java @@ -25,7 +25,6 @@ public class UserRepositoryCustomImpl implements UserRepositoryCustom { @Override public List queryUserList(Integer page, String scope, String sort, Integer grade, Integer classNum, User currentUser) { - Long size = 4L; return queryFactory .select(new QQueryUserListResponse_UserListInfo( user.id.as("userId"), From 07f17ca9015299a19c23a06f97d1dced2dab5f38 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Fri, 11 Feb 2022 12:53:33 +0900 Subject: [PATCH 034/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20final=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 --- .../dto/response/QueryUserListResponse.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/QueryUserListResponse.java b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/QueryUserListResponse.java index 0d7a4b2d0..5c2aa6eb3 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/QueryUserListResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/QueryUserListResponse.java @@ -15,13 +15,13 @@ public class QueryUserListResponse { @Getter @Builder public static class UserListInfo { - private Long userId; - private String name; - private String profileImageUrl; - private Integer grade; - private Integer classNum; - private Integer number; - private Boolean isTeacher; + private final Long userId; + private final String name; + private final String profileImageUrl; + private final Integer grade; + private final Integer classNum; + private final Integer number; + private final Boolean isTeacher; @QueryProjection public UserListInfo(Long userId, String name, String profileImageUrl, Integer grade, Integer classNum, Integer number, Boolean isTeacher) { From f22abaa241462d14f9f1d5cd98f4bb83e468e56f Mon Sep 17 00:00:00 2001 From: lyutvs Date: Fri, 11 Feb 2022 13:01:56 +0900 Subject: [PATCH 035/522] =?UTF-8?q?=F0=9F=93=91::=20QueryUserBadgeListResp?= =?UTF-8?q?onse?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../response/QueryUserBadgeListResponse.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/main/java/com/walkhub/walkhub/domain/badge/presentation/dto/response/QueryUserBadgeListResponse.java diff --git a/src/main/java/com/walkhub/walkhub/domain/badge/presentation/dto/response/QueryUserBadgeListResponse.java b/src/main/java/com/walkhub/walkhub/domain/badge/presentation/dto/response/QueryUserBadgeListResponse.java new file mode 100644 index 000000000..6d7a885aa --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/badge/presentation/dto/response/QueryUserBadgeListResponse.java @@ -0,0 +1,24 @@ +package com.walkhub.walkhub.domain.badge.presentation.dto.response; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; + +import java.time.LocalDateTime; +import java.util.List; + +@Getter +@AllArgsConstructor +public class QueryUserBadgeListResponse { + + private final List userBadgeList; + + @Getter + @Builder + public static class DefaultBadgeResponse{ + private final String name; + private final String imageUrl; + private final String condition; + private final LocalDateTime createAt; + } +} From 250424f70462c6a6f06644d36564ca91cda0079f Mon Sep 17 00:00:00 2001 From: lyutvs Date: Fri, 11 Feb 2022 13:02:20 +0900 Subject: [PATCH 036/522] =?UTF-8?q?=F0=9F=93=91::=20QueryUserBadgeListServ?= =?UTF-8?q?ice?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/QueryUserBadgeListService.java | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/main/java/com/walkhub/walkhub/domain/badge/service/QueryUserBadgeListService.java diff --git a/src/main/java/com/walkhub/walkhub/domain/badge/service/QueryUserBadgeListService.java b/src/main/java/com/walkhub/walkhub/domain/badge/service/QueryUserBadgeListService.java new file mode 100644 index 000000000..254e7ffeb --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/badge/service/QueryUserBadgeListService.java @@ -0,0 +1,36 @@ +package com.walkhub.walkhub.domain.badge.service; + +import com.walkhub.walkhub.domain.badge.domain.repository.BadgeRepository; +import com.walkhub.walkhub.domain.badge.presentation.dto.response.QueryUserBadgeListResponse; +import com.walkhub.walkhub.domain.badge.presentation.dto.response.QueryUserBadgeListResponse.DefaultBadgeResponse; +import com.walkhub.walkhub.domain.user.domain.User; +import com.walkhub.walkhub.domain.user.facade.UserFacade; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.stream.Collectors; + +@RequiredArgsConstructor +@Service +public class QueryUserBadgeListService { + + private final BadgeRepository badgeRepository; + private final UserFacade userFacade; + + public QueryUserBadgeListResponse execute(Long badgeId) { + + User user = userFacade.getCurrentUser(); + List badgeList = badgeRepository.findAllById(badgeId) + .stream() + .map(badge -> DefaultBadgeResponse.builder() + .name(badge.getName()) + .imageUrl(badge.getImageUrl()) + .condition(badge.getCondition()) + .createAt(badge.getCreateAt()) + .build()) + .collect(Collectors.toList()); + + return new QueryUserBadgeListResponse(badgeList); + } +} From 221747b24e9bc7c760ffdae04f2c39003d45e869 Mon Sep 17 00:00:00 2001 From: lyutvs Date: Fri, 11 Feb 2022 13:02:32 +0900 Subject: [PATCH 037/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F::=20BadgeController?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/badge/presentation/BadgeController.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/badge/presentation/BadgeController.java b/src/main/java/com/walkhub/walkhub/domain/badge/presentation/BadgeController.java index 1c6eedeb0..8b27b20a6 100644 --- a/src/main/java/com/walkhub/walkhub/domain/badge/presentation/BadgeController.java +++ b/src/main/java/com/walkhub/walkhub/domain/badge/presentation/BadgeController.java @@ -1,5 +1,7 @@ package com.walkhub.walkhub.domain.badge.presentation; +import com.walkhub.walkhub.domain.badge.presentation.dto.response.QueryUserBadgeListResponse; +import com.walkhub.walkhub.domain.badge.service.QueryUserBadgeListService; import com.walkhub.walkhub.domain.badge.service.SetTitleBadgeService; import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; @@ -11,6 +13,7 @@ public class BadgeController { private final SetTitleBadgeService setTitleBadgeService; + private final QueryUserBadgeListService queryUserBadgeListService; @ResponseStatus(HttpStatus.NO_CONTENT) @PutMapping("/{badge-id}") @@ -18,4 +21,9 @@ public void setTitleBadge(@PathVariable("badge-id") Long badgeId) { setTitleBadgeService.execute(badgeId); } + @GetMapping + public QueryUserBadgeListResponse queryUserBadgeList(@PathVariable(name = "badge-id")Long id) { + return queryUserBadgeListService.execute(id); + } + } From fe22b8396196436f54c231dff5f2efadb3f3468a Mon Sep 17 00:00:00 2001 From: lyutvs Date: Fri, 11 Feb 2022 13:02:39 +0900 Subject: [PATCH 038/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F::=20Badge?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../walkhub/domain/badge/domain/Badge.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/badge/domain/Badge.java b/src/main/java/com/walkhub/walkhub/domain/badge/domain/Badge.java index c16331716..1eac93df6 100644 --- a/src/main/java/com/walkhub/walkhub/domain/badge/domain/Badge.java +++ b/src/main/java/com/walkhub/walkhub/domain/badge/domain/Badge.java @@ -13,6 +13,8 @@ import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; +import javax.validation.constraints.NotNull; +import java.time.LocalDateTime; @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) @@ -23,15 +25,25 @@ public class Badge extends BaseTimeEntity { @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; - @Column(length = 20, nullable = false) + @NotNull + @Column(length = 20) private String name; @ColumnDefault(DefaultImage.BADGE_IMAGE) private String imageUrl; + @NotNull + private String condition; + + @NotNull + private LocalDateTime createAt; + @Builder - public Badge(String name, String imageUrl) { + public Badge(String name, String imageUrl, + String condition, LocalDateTime createAt) { this.name = name; this.imageUrl = imageUrl; + this.condition = condition; + this.createAt = createAt; } } From acdef227d190fa8db25cb4bb734e4a02f8dbc2c4 Mon Sep 17 00:00:00 2001 From: lyutvs Date: Fri, 11 Feb 2022 13:02:49 +0900 Subject: [PATCH 039/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F::=20BadgeRepository?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/badge/domain/repository/BadgeRepository.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/BadgeRepository.java b/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/BadgeRepository.java index 073c49c76..d9ad0af8c 100644 --- a/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/BadgeRepository.java +++ b/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/BadgeRepository.java @@ -3,5 +3,8 @@ import com.walkhub.walkhub.domain.badge.domain.Badge; import org.springframework.data.repository.CrudRepository; +import java.util.List; + public interface BadgeRepository extends CrudRepository { + List findAllById(Long badgeId); } From d3e960d062d443b48ef97fe5062bddf26f59236f Mon Sep 17 00:00:00 2001 From: lyutvs Date: Fri, 11 Feb 2022 13:11:11 +0900 Subject: [PATCH 040/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F::=20BaseTImeEntity?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/walkhub/walkhub/domain/badge/domain/Badge.java | 7 +------ .../dto/response/QueryUserBadgeListResponse.java | 2 -- .../domain/badge/service/QueryUserBadgeListService.java | 1 - 3 files changed, 1 insertion(+), 9 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/badge/domain/Badge.java b/src/main/java/com/walkhub/walkhub/domain/badge/domain/Badge.java index 1eac93df6..6eb08d429 100644 --- a/src/main/java/com/walkhub/walkhub/domain/badge/domain/Badge.java +++ b/src/main/java/com/walkhub/walkhub/domain/badge/domain/Badge.java @@ -14,7 +14,6 @@ import javax.persistence.GenerationType; import javax.persistence.Id; import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) @@ -35,15 +34,11 @@ public class Badge extends BaseTimeEntity { @NotNull private String condition; - @NotNull - private LocalDateTime createAt; - @Builder public Badge(String name, String imageUrl, - String condition, LocalDateTime createAt) { + String condition) { this.name = name; this.imageUrl = imageUrl; this.condition = condition; - this.createAt = createAt; } } diff --git a/src/main/java/com/walkhub/walkhub/domain/badge/presentation/dto/response/QueryUserBadgeListResponse.java b/src/main/java/com/walkhub/walkhub/domain/badge/presentation/dto/response/QueryUserBadgeListResponse.java index 6d7a885aa..ecfa50ce7 100644 --- a/src/main/java/com/walkhub/walkhub/domain/badge/presentation/dto/response/QueryUserBadgeListResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/badge/presentation/dto/response/QueryUserBadgeListResponse.java @@ -4,7 +4,6 @@ import lombok.Builder; import lombok.Getter; -import java.time.LocalDateTime; import java.util.List; @Getter @@ -19,6 +18,5 @@ public static class DefaultBadgeResponse{ private final String name; private final String imageUrl; private final String condition; - private final LocalDateTime createAt; } } diff --git a/src/main/java/com/walkhub/walkhub/domain/badge/service/QueryUserBadgeListService.java b/src/main/java/com/walkhub/walkhub/domain/badge/service/QueryUserBadgeListService.java index 254e7ffeb..08aef6493 100644 --- a/src/main/java/com/walkhub/walkhub/domain/badge/service/QueryUserBadgeListService.java +++ b/src/main/java/com/walkhub/walkhub/domain/badge/service/QueryUserBadgeListService.java @@ -27,7 +27,6 @@ public QueryUserBadgeListResponse execute(Long badgeId) { .name(badge.getName()) .imageUrl(badge.getImageUrl()) .condition(badge.getCondition()) - .createAt(badge.getCreateAt()) .build()) .collect(Collectors.toList()); From f30e8c7eafab51aa9fcf2c8b4dc15364e73b61fc Mon Sep 17 00:00:00 2001 From: lyutvs Date: Fri, 11 Feb 2022 13:14:18 +0900 Subject: [PATCH 041/522] =?UTF-8?q?=F0=9F=90=9B::=20=EC=98=A4=EB=A5=98=20?= =?UTF-8?q?=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/walkhub/walkhub/domain/badge/domain/Badge.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/badge/domain/Badge.java b/src/main/java/com/walkhub/walkhub/domain/badge/domain/Badge.java index 6eb08d429..975d60456 100644 --- a/src/main/java/com/walkhub/walkhub/domain/badge/domain/Badge.java +++ b/src/main/java/com/walkhub/walkhub/domain/badge/domain/Badge.java @@ -14,6 +14,7 @@ import javax.persistence.GenerationType; import javax.persistence.Id; import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) @@ -25,7 +26,7 @@ public class Badge extends BaseTimeEntity { private Long id; @NotNull - @Column(length = 20) + @Size(max = 20) private String name; @ColumnDefault(DefaultImage.BADGE_IMAGE) From 21e25feb36169d6398f2e99afe9ab54b2e814b98 Mon Sep 17 00:00:00 2001 From: lyutvs Date: Fri, 11 Feb 2022 13:22:16 +0900 Subject: [PATCH 042/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F::=20findAll=20?= =?UTF-8?q?=EB=A1=9C=20=EB=B0=94=EA=BF=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/badge/domain/repository/BadgeRepository.java | 2 +- .../walkhub/domain/badge/presentation/BadgeController.java | 6 +++--- .../domain/badge/service/QueryUserBadgeListService.java | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/BadgeRepository.java b/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/BadgeRepository.java index d9ad0af8c..cf75ff860 100644 --- a/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/BadgeRepository.java +++ b/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/BadgeRepository.java @@ -6,5 +6,5 @@ import java.util.List; public interface BadgeRepository extends CrudRepository { - List findAllById(Long badgeId); + List findAll(Long badgeId); } diff --git a/src/main/java/com/walkhub/walkhub/domain/badge/presentation/BadgeController.java b/src/main/java/com/walkhub/walkhub/domain/badge/presentation/BadgeController.java index 8b27b20a6..f0d7af352 100644 --- a/src/main/java/com/walkhub/walkhub/domain/badge/presentation/BadgeController.java +++ b/src/main/java/com/walkhub/walkhub/domain/badge/presentation/BadgeController.java @@ -21,9 +21,9 @@ public void setTitleBadge(@PathVariable("badge-id") Long badgeId) { setTitleBadgeService.execute(badgeId); } - @GetMapping - public QueryUserBadgeListResponse queryUserBadgeList(@PathVariable(name = "badge-id")Long id) { - return queryUserBadgeListService.execute(id); + @GetMapping("/{badge-id}") + public QueryUserBadgeListResponse queryUserBadgeList(@PathVariable(name = "badge-id")Long badgeId) { + return queryUserBadgeListService.execute(badgeId); } } diff --git a/src/main/java/com/walkhub/walkhub/domain/badge/service/QueryUserBadgeListService.java b/src/main/java/com/walkhub/walkhub/domain/badge/service/QueryUserBadgeListService.java index 08aef6493..b1778f00c 100644 --- a/src/main/java/com/walkhub/walkhub/domain/badge/service/QueryUserBadgeListService.java +++ b/src/main/java/com/walkhub/walkhub/domain/badge/service/QueryUserBadgeListService.java @@ -21,7 +21,7 @@ public class QueryUserBadgeListService { public QueryUserBadgeListResponse execute(Long badgeId) { User user = userFacade.getCurrentUser(); - List badgeList = badgeRepository.findAllById(badgeId) + List badgeList = badgeRepository.findAll(badgeId) .stream() .map(badge -> DefaultBadgeResponse.builder() .name(badge.getName()) From 924f075bb3769129bcd4e360005c19250e84e799 Mon Sep 17 00:00:00 2001 From: lyutvs Date: Fri, 11 Feb 2022 13:23:21 +0900 Subject: [PATCH 043/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F::=20getCourruntUser?= =?UTF-8?q?=20=EB=BA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../walkhub/domain/badge/service/QueryUserBadgeListService.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/badge/service/QueryUserBadgeListService.java b/src/main/java/com/walkhub/walkhub/domain/badge/service/QueryUserBadgeListService.java index b1778f00c..71073640b 100644 --- a/src/main/java/com/walkhub/walkhub/domain/badge/service/QueryUserBadgeListService.java +++ b/src/main/java/com/walkhub/walkhub/domain/badge/service/QueryUserBadgeListService.java @@ -20,7 +20,6 @@ public class QueryUserBadgeListService { public QueryUserBadgeListResponse execute(Long badgeId) { - User user = userFacade.getCurrentUser(); List badgeList = badgeRepository.findAll(badgeId) .stream() .map(badge -> DefaultBadgeResponse.builder() From 8851b704ae581a4a89e4bd9ea3974a5f6c75a18a Mon Sep 17 00:00:00 2001 From: lyutvs Date: Fri, 11 Feb 2022 14:28:15 +0900 Subject: [PATCH 044/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F::=20codesemll=20?= =?UTF-8?q?=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/walkhub/walkhub/domain/badge/domain/Badge.java | 1 - .../walkhub/domain/badge/service/QueryUserBadgeListService.java | 1 - 2 files changed, 2 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/badge/domain/Badge.java b/src/main/java/com/walkhub/walkhub/domain/badge/domain/Badge.java index 975d60456..ce81cd9c9 100644 --- a/src/main/java/com/walkhub/walkhub/domain/badge/domain/Badge.java +++ b/src/main/java/com/walkhub/walkhub/domain/badge/domain/Badge.java @@ -8,7 +8,6 @@ import lombok.NoArgsConstructor; import org.hibernate.annotations.ColumnDefault; -import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; diff --git a/src/main/java/com/walkhub/walkhub/domain/badge/service/QueryUserBadgeListService.java b/src/main/java/com/walkhub/walkhub/domain/badge/service/QueryUserBadgeListService.java index 71073640b..a8b00ea47 100644 --- a/src/main/java/com/walkhub/walkhub/domain/badge/service/QueryUserBadgeListService.java +++ b/src/main/java/com/walkhub/walkhub/domain/badge/service/QueryUserBadgeListService.java @@ -3,7 +3,6 @@ import com.walkhub.walkhub.domain.badge.domain.repository.BadgeRepository; import com.walkhub.walkhub.domain.badge.presentation.dto.response.QueryUserBadgeListResponse; import com.walkhub.walkhub.domain.badge.presentation.dto.response.QueryUserBadgeListResponse.DefaultBadgeResponse; -import com.walkhub.walkhub.domain.user.domain.User; import com.walkhub.walkhub.domain.user.facade.UserFacade; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; From e83d96c490157307eb19292324e56c38ae20ae9a Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Fri, 11 Feb 2022 14:55:09 +0900 Subject: [PATCH 045/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20=EC=9D=B4?= =?UTF-8?q?=EA=B1=B0=20=EC=99=9C=20=EC=82=AD=EC=A0=9C=ED=96=88=EC=A7=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/user/domain/repository/UserRepositoryCustomImpl.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java index 849bbcd90..01fff6b92 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java @@ -25,6 +25,7 @@ public class UserRepositoryCustomImpl implements UserRepositoryCustom { @Override public List queryUserList(Integer page, String scope, String sort, Integer grade, Integer classNum, User currentUser) { + long size = 4; return queryFactory .select(new QQueryUserListResponse_UserListInfo( user.id.as("userId"), From 19a3442230e2af6c308ea9a7a113c65ffccc61a2 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Fri, 11 Feb 2022 17:52:08 +0900 Subject: [PATCH 046/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20=EB=8B=A4?= =?UTF-8?q?=EC=8B=9C=20=EC=B9=B4=EB=A9=9C=EC=BC=80=EC=9D=B4=EC=8A=A4?= =?UTF-8?q?=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 --- .../java/com/walkhub/walkhub/domain/rank/job/UserRankJob.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/job/UserRankJob.java b/src/main/java/com/walkhub/walkhub/domain/rank/job/UserRankJob.java index c32ab58ac..8dd4a49fa 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/job/UserRankJob.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/job/UserRankJob.java @@ -190,7 +190,7 @@ public ItemProcessor monthlyUserClassRankProcessor(@Valu public JdbcBatchItemWriter userRankWriter(@Value("#{jobParameters[jobKey]}") String jobKey) { JdbcBatchItemWriter writer = new JdbcBatchItemWriterBuilder() .dataSource(dataSource) - .sql("CALL SAVE_USER_RANK(:user_id, :created_at, :date_type, :scope_type, :school_id, :name, :grade, :class_num, :profile_image_url, :ranking, :walk_count)") + .sql("CALL SAVE_USER_RANK(:userId, :createdAt, :dateType, :scopeType, :schoolId, :name, :grade, :classNum, :profileImageUrl, :ranking, :walkCount)") .beanMapped() .build(); From f52a6e4bd1fc24de7ce1e2f9c43106209d1dacc8 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Fri, 11 Feb 2022 18:14:52 +0900 Subject: [PATCH 047/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20=EC=82=AC?= =?UTF-8?q?=EC=9A=A9=ED=95=98=EC=A7=80=20=EC=95=8A=EB=8A=94=20=EC=9D=98?= =?UTF-8?q?=EC=A1=B4=EC=84=B1=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/walkhub/walkhub/domain/rank/job/UserRankJob.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/job/UserRankJob.java b/src/main/java/com/walkhub/walkhub/domain/rank/job/UserRankJob.java index 8dd4a49fa..0da83dc8e 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/job/UserRankJob.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/job/UserRankJob.java @@ -32,7 +32,6 @@ public class UserRankJob { private final JobBuilderFactory jobBuilderFactory; private final StepBuilderFactory stepBuilderFactory; - private final EntityManagerFactory em; private final DataSource dataSource; @Bean From e3f7796f1078edca57bbae4f2e211b5d95e322de Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Fri, 11 Feb 2022 19:48:16 +0900 Subject: [PATCH 048/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20return=20type?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rank/domain/repository/UserRankRepositoryCustom.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustom.java b/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustom.java index 8e0b33315..f8b367857 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustom.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustom.java @@ -1,10 +1,11 @@ package com.walkhub.walkhub.domain.rank.domain.repository; -import com.walkhub.walkhub.domain.rank.domain.UserRankInfo; +import com.walkhub.walkhub.domain.rank.domain.UserRank; +import java.time.LocalDate; import java.util.List; public interface UserRankRepositoryCustom { - UserRankInfo getMyRankByAccountId(String accountId); - List getUserRankListByAgencyCodeAndClassNum(String agencyCode, String classNum, String dateType); + UserRank getMyRankByAccountId(Long accountId, Integer classNum, String dateType, LocalDate date); + List getUserRankListBySchoolId(Long schoolId, Integer classNum, String dateType, LocalDate date); } From 91352d08d557965b03b756fe3755701526a52359 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Fri, 11 Feb 2022 19:48:53 +0900 Subject: [PATCH 049/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20override=20?= =?UTF-8?q?=EB=A9=94=EC=86=8C=EB=93=9C=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UserRankRepositoryCustomImpl.java | 42 ++++++++++++------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustomImpl.java index 4e9de8f12..a4cd696bd 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustomImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustomImpl.java @@ -2,36 +2,46 @@ import com.querydsl.core.types.dsl.BooleanExpression; import com.querydsl.jpa.impl.JPAQueryFactory; -import com.walkhub.walkhub.domain.rank.domain.QUserRankInfo; -import com.walkhub.walkhub.domain.rank.domain.UserRankInfo; -import com.walkhub.walkhub.domain.rank.presentation.dto.response.QUserRankListResponse_UserRankResponse; +import com.walkhub.walkhub.domain.rank.domain.UserRank; import lombok.RequiredArgsConstructor; +import java.time.LocalDate; import java.util.List; -import static com.walkhub.walkhub.domain.rank.domain.QUserRankInfo.*; +import static com.walkhub.walkhub.domain.rank.domain.QUserRank.userRank; @RequiredArgsConstructor -public class UserRankRepositoryCustomImpl implements UserRankRepositoryCustom{ +public class UserRankRepositoryCustomImpl implements UserRankRepositoryCustom { private final JPAQueryFactory queryFactory; @Override - public UserRankInfo getMyRankByAccountId(String accountId) { + public UserRank getMyRankByAccountId(Long userId, Integer classNum, String dateType, LocalDate date) { return queryFactory - .select(new QUserRankListResponse_UserRankResponse( - - )) - .from(userRankInfo) - .where(userRankInfo.accountId.eq(accountId)) + .selectFrom(userRank) + .where( + userRank.userId.eq(userId), + classNumEq(classNum), + userRank.dateType.eq(dateType), + userRank.createdAt.eq(date) + ) .fetchOne(); } @Override - public List getUserRankListByAgencyCodeAndClassNum(String agencyCode, String classNum, String dateType) { - /*return queryFactory - .select(userRankInfo) - .where(userRankInfo.agencyCode.eq(agencyCode))*/ - return null; + public List getUserRankListBySchoolId(Long schoolId, Integer classNum, String dateType, LocalDate date) { + return queryFactory + .selectFrom(userRank) + .where( + userRank.schoolId.eq(schoolId), + classNumEq(classNum), + userRank.dateType.eq(dateType), + userRank.createdAt.eq(date) + ) + .fetch(); + } + + private BooleanExpression classNumEq(Integer classNum) { + return classNum != null ? userRank.scopeType.eq("CLASS").and(userRank.classNum.eq(classNum)) : userRank.scopeType.eq("SCHOOL"); } } From cbd8b28641556d7ac510efadab786a174e2d7198 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Fri, 11 Feb 2022 19:49:11 +0900 Subject: [PATCH 050/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20=ED=83=80?= =?UTF-8?q?=EC=9E=85=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/dto/response/UserRankListResponse.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/presentation/dto/response/UserRankListResponse.java b/src/main/java/com/walkhub/walkhub/domain/rank/presentation/dto/response/UserRankListResponse.java index ab693cbc8..f01cb8789 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/presentation/dto/response/UserRankListResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/presentation/dto/response/UserRankListResponse.java @@ -16,17 +16,17 @@ public class UserRankListResponse { @Getter @Builder public static class UserRankResponse { - private final String accountId; + private final Long userId; private final String name; private final Integer grade; private final Integer classNum; private final Integer ranking; private final String profileImageUrl; - private final Long walkCount; + private final Integer walkCount; @QueryProjection - public UserRankResponse(String accountId, String name, Integer grade, Integer classNum, Integer ranking, String profileImageUrl, Long walkCount) { - this.accountId = accountId; + public UserRankResponse(Long userId, String name, Integer grade, Integer classNum, Integer ranking, String profileImageUrl, Integer walkCount) { + this.userId = userId; this.name = name; this.grade = grade; this.classNum = classNum; From 807f870d2bcc99dd77f478bbfc7b02137c50ae02 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Fri, 11 Feb 2022 19:49:30 +0900 Subject: [PATCH 051/522] =?UTF-8?q?=F0=9F=93=91=20::=20QueryUserRankListSe?= =?UTF-8?q?rvice?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/rank/service/QueryUserRankListService.java | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListService.java diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListService.java b/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListService.java new file mode 100644 index 000000000..4c7a67fb7 --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListService.java @@ -0,0 +1,11 @@ +package com.walkhub.walkhub.domain.rank.service; + +import com.walkhub.walkhub.domain.rank.domain.repository.UserRankRepository; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +@RequiredArgsConstructor +@Service +public class QueryUserRankListService { + private final UserRankRepository userRankRepository; +} From 81842f4144667c73086be2048406f9077951bdee Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Fri, 11 Feb 2022 19:53:17 +0900 Subject: [PATCH 052/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20final=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 --- .../presentation/dto/response/UserRankInfo.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/presentation/dto/response/UserRankInfo.java b/src/main/java/com/walkhub/walkhub/domain/rank/presentation/dto/response/UserRankInfo.java index 6cfecc7e1..8d4a21696 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/presentation/dto/response/UserRankInfo.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/presentation/dto/response/UserRankInfo.java @@ -6,19 +6,19 @@ @Getter @Builder public class UserRankInfo { - private Long userId; + private final Long userId; - private String name; + private final String name; - private Long schoolId; + private final Long schoolId; - private Integer grade; + private final Integer grade; - private Integer classNum; + private final Integer classNum; - private String profileImageUrl; + private final String profileImageUrl; - private Integer walkCount; + private final Integer walkCount; - private Integer ranking; + private final Integer ranking; } From 9d6f8ee79948a7f698a5b6034a088d96fe3a3fe9 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Sat, 12 Feb 2022 02:14:47 +0900 Subject: [PATCH 053/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20queryUserRank?= =?UTF-8?q?ListService?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/QueryUserRankListService.java | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListService.java b/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListService.java index 4c7a67fb7..067b85eec 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListService.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListService.java @@ -1,11 +1,74 @@ package com.walkhub.walkhub.domain.rank.service; +import com.walkhub.walkhub.domain.exercise.cache.ExerciseAnalysisCacheRepository; +import com.walkhub.walkhub.domain.exercise.domain.repository.ExerciseAnalysisRepository; +import com.walkhub.walkhub.domain.rank.domain.UserRank; import com.walkhub.walkhub.domain.rank.domain.repository.UserRankRepository; +import com.walkhub.walkhub.domain.rank.presentation.dto.response.UserRankListResponse; +import com.walkhub.walkhub.domain.user.domain.Section; +import com.walkhub.walkhub.domain.user.domain.User; +import com.walkhub.walkhub.domain.user.facade.UserFacade; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; +import org.springframework.web.client.HttpClientErrorException; + +import java.time.LocalDate; +import java.util.List; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Collectors; @RequiredArgsConstructor @Service public class QueryUserRankListService { private final UserRankRepository userRankRepository; + private final ExerciseAnalysisCacheRepository exerciseAnalysisCacheRepository; + private final UserFacade userFacade; + private final ExerciseAnalysisRepository exerciseAnalysisRepository; + + public UserRankListResponse execute(String scope, String dateType) { + User user = userFacade.getCurrentUser(); + Section section = user.getSection(); + LocalDate date = LocalDate.now(); + if (dateType.equals("DAY")) { + AtomicInteger rankCount = new AtomicInteger(); + return UserRankListResponse.builder() + .myRank(UserRankListResponse.UserRankResponse.builder() + .userId(user.getId()) + .name(user.getName()) + .grade(section.getGrade()) + .classNum(section.getClassNum()) + .ranking(Math.toIntExact(exerciseAnalysisCacheRepository.getUserTodayRank(user.getId()))) + .profileImageUrl(user.getProfileImageUrl()) + .walkCount(exerciseAnalysisRepository.findWalkCountByUserId(user.getId())) + .build() + ) + .rankList(exerciseAnalysisCacheRepository.getUserIdsByRankTop100() + .stream() + .map(userFacade::getUserById) + .map(users -> UserRankListResponse.UserRankResponse.builder() + .userId(users.getId()) + .name(users.getName()) + .grade(users.getSection().getGrade()) + .classNum(users.getSection().getClassNum()) + .ranking(rankCount.incrementAndGet()) + .profileImageUrl(users.getProfileImageUrl()) + .walkCount(exerciseAnalysisRepository.findWalkCountByUserId(users.getId())) + .build() + ).collect(Collectors.toList()) + ).build(); + } else { + if (scope.equals("ALL")) { + return UserRankListResponse.builder() + .myRank(userRankRepository.getMyRankByUserId(user.getId(), null, dateType, date)) + .rankList(userRankRepository.getUserRankListBySchoolId(user.getSchool().getId(), null, dateType, date)) + .build(); + } else if (scope.equals("CLASS")) { + return UserRankListResponse.builder() + .myRank(userRankRepository.getMyRankByUserId(user.getId(), user.getSection().getClassNum(), dateType, date)) + .rankList(userRankRepository.getUserRankListBySchoolId(user.getSchool().getId(), user.getSection().getClassNum(), dateType, date)) + .build(); + } + } + return null; + } } From 24e14a02825e42c4a37e315c4f8eb0f574a47a7d Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Sat, 12 Feb 2022 02:15:07 +0900 Subject: [PATCH 054/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20findWalkCount?= =?UTF-8?q?ByUserId=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exercise/domain/repository/ExerciseAnalysisRepository.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepository.java b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepository.java index 2b3f1a9f0..339f0030c 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepository.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepository.java @@ -9,4 +9,5 @@ public interface ExerciseAnalysisRepository extends CrudRepository { Optional findByUserAndDate(User user, LocalDate date); + Integer findWalkCountByUserId(Long userId); } From adffd3e113708c4756a7df877153041c40afc401 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Sat, 12 Feb 2022 02:16:02 +0900 Subject: [PATCH 055/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20extends=20Use?= =?UTF-8?q?rRankRepositoryCustom?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/rank/domain/repository/UserRankRepository.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepository.java b/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepository.java index fbe5d5a20..78f084295 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepository.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepository.java @@ -5,7 +5,7 @@ import java.util.List; -public interface UserRankRepository extends JpaRepository { +public interface UserRankRepository extends JpaRepository, UserRankRepositoryCustom { List findTop100ByNameContainsAndAgencyCode(String name, String agencyCode); List findTop100ByNameContainsAndAgencyCodeAndClassNumAndGrade(String name, String agencyCode, Integer grade, Integer classNum); } From 81e8f4f9d4dd4552f446e345050f0c04a219b5fa Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Sat, 12 Feb 2022 02:16:18 +0900 Subject: [PATCH 056/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20=EB=A9=94?= =?UTF-8?q?=EC=86=8C=EB=93=9C=20=EB=B0=98=ED=99=98=ED=83=80=EC=9E=85=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rank/domain/repository/UserRankRepositoryCustom.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustom.java b/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustom.java index f8b367857..b3e223387 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustom.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustom.java @@ -1,11 +1,12 @@ package com.walkhub.walkhub.domain.rank.domain.repository; import com.walkhub.walkhub.domain.rank.domain.UserRank; +import com.walkhub.walkhub.domain.rank.presentation.dto.response.UserRankListResponse; import java.time.LocalDate; import java.util.List; public interface UserRankRepositoryCustom { - UserRank getMyRankByAccountId(Long accountId, Integer classNum, String dateType, LocalDate date); - List getUserRankListBySchoolId(Long schoolId, Integer classNum, String dateType, LocalDate date); + UserRankListResponse.UserRankResponse getMyRankByUserId(Long userId, Integer classNum, String dateType, LocalDate date); + List getUserRankListBySchoolId(Long schoolId, Integer classNum, String dateType, LocalDate date); } From d9de5c2282058e26be6bc0b73d1951c6be2a2784 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Sat, 12 Feb 2022 02:16:36 +0900 Subject: [PATCH 057/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20=EB=A9=94?= =?UTF-8?q?=EC=86=8C=EB=93=9C=20=EB=B0=98=ED=99=98=20=ED=83=80=EC=9E=85=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UserRankRepositoryCustomImpl.java | 32 ++++++++++++++++--- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustomImpl.java index a4cd696bd..936fbc33a 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustomImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustomImpl.java @@ -2,7 +2,8 @@ import com.querydsl.core.types.dsl.BooleanExpression; import com.querydsl.jpa.impl.JPAQueryFactory; -import com.walkhub.walkhub.domain.rank.domain.UserRank; +import com.walkhub.walkhub.domain.rank.presentation.dto.response.QUserRankListResponse_UserRankResponse; +import com.walkhub.walkhub.domain.rank.presentation.dto.response.UserRankListResponse; import lombok.RequiredArgsConstructor; import java.time.LocalDate; @@ -14,11 +15,21 @@ public class UserRankRepositoryCustomImpl implements UserRankRepositoryCustom { private final JPAQueryFactory queryFactory; + private static final Long LIMIT = 100L; @Override - public UserRank getMyRankByAccountId(Long userId, Integer classNum, String dateType, LocalDate date) { + public UserRankListResponse.UserRankResponse getMyRankByUserId(Long userId, Integer classNum, String dateType, LocalDate date) { return queryFactory - .selectFrom(userRank) + .select(new QUserRankListResponse_UserRankResponse( + userRank.userId, + userRank.name, + userRank.grade, + userRank.classNum, + userRank.ranking, + userRank.profileImageUrl, + userRank.walkCount + )) + .from(userRank) .where( userRank.userId.eq(userId), classNumEq(classNum), @@ -29,15 +40,26 @@ public UserRank getMyRankByAccountId(Long userId, Integer classNum, String dateT } @Override - public List getUserRankListBySchoolId(Long schoolId, Integer classNum, String dateType, LocalDate date) { + public List getUserRankListBySchoolId(Long schoolId, Integer classNum, String dateType, LocalDate date) { return queryFactory - .selectFrom(userRank) + .select(new QUserRankListResponse_UserRankResponse( + userRank.userId, + userRank.name, + userRank.grade, + userRank.classNum, + userRank.ranking, + userRank.profileImageUrl, + userRank.walkCount + )) + .from(userRank) .where( userRank.schoolId.eq(schoolId), classNumEq(classNum), userRank.dateType.eq(dateType), userRank.createdAt.eq(date) ) + .limit(LIMIT) + .orderBy(userRank.ranking.asc()) .fetch(); } From 685d5d9f8b232f8f39d8ba8aec476cca68b464be Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Sat, 12 Feb 2022 02:17:00 +0900 Subject: [PATCH 058/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20queryUserRank?= =?UTF-8?q?ListByMySchool=20=EB=9D=BC=EC=9A=B0=ED=84=B0=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 --- .../walkhub/domain/rank/presentation/RankController.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/presentation/RankController.java b/src/main/java/com/walkhub/walkhub/domain/rank/presentation/RankController.java index 28b3dcde4..c8b518eef 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/presentation/RankController.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/presentation/RankController.java @@ -1,6 +1,8 @@ package com.walkhub.walkhub.domain.rank.presentation; import com.walkhub.walkhub.domain.rank.presentation.dto.response.UserListResponse; +import com.walkhub.walkhub.domain.rank.presentation.dto.response.UserRankListResponse; +import com.walkhub.walkhub.domain.rank.service.QueryUserRankListService; import com.walkhub.walkhub.domain.rank.service.UserSearchService; import com.walkhub.walkhub.global.enums.UserScope; import lombok.RequiredArgsConstructor; @@ -15,6 +17,7 @@ public class RankController { private final UserSearchService userSearchService; + private final QueryUserRankListService queryUserRankListService; @GetMapping("/users/search") public UserListResponse userSearch(@RequestParam String name, @@ -24,4 +27,9 @@ public UserListResponse userSearch(@RequestParam String name, @RequestParam(required = false) Integer classNum) { return userSearchService.execute(name, userScope, agencyCode, grade, classNum); } + + @GetMapping("/users/my-school") + public UserRankListResponse queryUserRankListByMySchool(@RequestParam String scope, @RequestParam String dateType) { + return queryUserRankListService.execute(scope, dateType); + } } From de2b0b22b213848f931919ace1320f721bf3d577 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Sat, 12 Feb 2022 02:30:36 +0900 Subject: [PATCH 059/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20codesmell=20?= =?UTF-8?q?=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rank/domain/repository/UserRankRepositoryCustom.java | 1 - .../walkhub/domain/rank/service/QueryUserRankListService.java | 3 --- 2 files changed, 4 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustom.java b/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustom.java index b3e223387..3d24f74c2 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustom.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustom.java @@ -1,6 +1,5 @@ package com.walkhub.walkhub.domain.rank.domain.repository; -import com.walkhub.walkhub.domain.rank.domain.UserRank; import com.walkhub.walkhub.domain.rank.presentation.dto.response.UserRankListResponse; import java.time.LocalDate; diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListService.java b/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListService.java index 067b85eec..76a7eec61 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListService.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListService.java @@ -2,7 +2,6 @@ import com.walkhub.walkhub.domain.exercise.cache.ExerciseAnalysisCacheRepository; import com.walkhub.walkhub.domain.exercise.domain.repository.ExerciseAnalysisRepository; -import com.walkhub.walkhub.domain.rank.domain.UserRank; import com.walkhub.walkhub.domain.rank.domain.repository.UserRankRepository; import com.walkhub.walkhub.domain.rank.presentation.dto.response.UserRankListResponse; import com.walkhub.walkhub.domain.user.domain.Section; @@ -10,10 +9,8 @@ import com.walkhub.walkhub.domain.user.facade.UserFacade; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; -import org.springframework.web.client.HttpClientErrorException; import java.time.LocalDate; -import java.util.List; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; From a38ba7c64a8a51280a9267de4969e5c067e43fda Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Sat, 12 Feb 2022 18:57:05 +0900 Subject: [PATCH 060/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20ChallengeStat?= =?UTF-8?q?usRepositoryCustom?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/ChallengeStatusRepositoryCustom.java | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustom.java diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustom.java b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustom.java new file mode 100644 index 000000000..31b6b38dc --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustom.java @@ -0,0 +1,10 @@ +package com.walkhub.walkhub.domain.challenge.domain.repository; + +import com.walkhub.walkhub.domain.challenge.presenstation.dto.response.QueryChallengeParticipantsForStudentResponse; + +import java.util.List; + +public interface ChallengeStatusRepositoryCustom { + Integer getParticipantsListByChallengeId(Long challengeId); + List getRelatedChallengeParticipantsList(Long challengeId); +} From 80407dff5c786586774ce14e27835a253cef3b93 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Sat, 12 Feb 2022 18:57:25 +0900 Subject: [PATCH 061/522] =?UTF-8?q?=F0=9F=93=91=20::=20ChallengeStatusRepo?= =?UTF-8?q?sitoryCustomImpl?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ChallengeStatusRepositoryCustomImpl.java | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java new file mode 100644 index 000000000..c31c7e5a8 --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java @@ -0,0 +1,48 @@ +package com.walkhub.walkhub.domain.challenge.domain.repository; + +import com.querydsl.jpa.impl.JPAQueryFactory; +import com.walkhub.walkhub.domain.challenge.domain.ChallengeStatus; +import com.walkhub.walkhub.domain.challenge.domain.QChallengeStatus; +import com.walkhub.walkhub.domain.challenge.presenstation.dto.response.QQueryChallengeParticipantsForStudentResponse_RelatedChallengeParticipants; +import com.walkhub.walkhub.domain.challenge.presenstation.dto.response.QueryChallengeParticipantsForStudentResponse; +import com.walkhub.walkhub.domain.user.domain.QUser; +import com.walkhub.walkhub.domain.user.domain.User; +import lombok.RequiredArgsConstructor; + +import java.util.List; + +import static com.walkhub.walkhub.domain.challenge.domain.QChallengeStatus.challengeStatus; +import static com.walkhub.walkhub.domain.user.domain.QUser.user; + +@RequiredArgsConstructor +public class ChallengeStatusRepositoryCustomImpl implements ChallengeStatusRepositoryCustom { + private final JPAQueryFactory queryFactory; + + @Override + public Integer getParticipantsListByChallengeId(Long challengeId) { + List participantsList = queryFactory + .select(challengeStatus) + .from(challengeStatus) + .where(challengeStatus.challenge.id.eq(challengeId)) + .fetch(); + return participantsList.size(); + } + + @Override + public List getRelatedChallengeParticipantsList(Long challengeId) { + return queryFactory + .select(new QQueryChallengeParticipantsForStudentResponse_RelatedChallengeParticipants( + user.id.as("userId"), + user.name, + user.profileImageUrl + )) + .from(user) + .join(challengeStatus) + .on(challengeStatus.user.eq(user)) + .where(challengeStatus.challenge.id.eq(challengeId)) + .orderBy() + .limit(3) + .fetch(); + + } +} From 0f4bf7ca09f1bc072c59561b4f304b3db0ced654 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Sat, 12 Feb 2022 18:57:45 +0900 Subject: [PATCH 062/522] =?UTF-8?q?=F0=9F=93=91=20::=20QueryChallengeParti?= =?UTF-8?q?cipantsForStudentResponse=20DTO?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...allengeParticipantsForStudentResponse.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/dto/response/QueryChallengeParticipantsForStudentResponse.java diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/dto/response/QueryChallengeParticipantsForStudentResponse.java b/src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/dto/response/QueryChallengeParticipantsForStudentResponse.java new file mode 100644 index 000000000..713458781 --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/dto/response/QueryChallengeParticipantsForStudentResponse.java @@ -0,0 +1,29 @@ +package com.walkhub.walkhub.domain.challenge.presenstation.dto.response; + +import com.querydsl.core.annotations.QueryProjection; +import lombok.Builder; +import lombok.Getter; + +import java.util.List; + +@Getter +@Builder +public class QueryChallengeParticipantsForStudentResponse { + private final Integer participantCount; + private final List relatedChallengeParticipantList; + + @Getter + @Builder + public static class RelatedChallengeParticipants { + private final Long userId; + private final String name; + private final String profileImageUrl; + + @QueryProjection + public RelatedChallengeParticipants(Long userId, String name, String profileImageUrl) { + this.userId = userId; + this.name = name; + this.profileImageUrl = profileImageUrl; + } + } +} From 7ab4752f0e2353cdaf7aa3717ad83c81b2e2ea02 Mon Sep 17 00:00:00 2001 From: lyutvs Date: Sat, 12 Feb 2022 23:24:40 +0900 Subject: [PATCH 063/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F::=20=EB=AA=85?= =?UTF-8?q?=EC=84=B8=EB=8C=80=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/QueryUserBadgeListService.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/badge/service/QueryUserBadgeListService.java b/src/main/java/com/walkhub/walkhub/domain/badge/service/QueryUserBadgeListService.java index a8b00ea47..b8237914c 100644 --- a/src/main/java/com/walkhub/walkhub/domain/badge/service/QueryUserBadgeListService.java +++ b/src/main/java/com/walkhub/walkhub/domain/badge/service/QueryUserBadgeListService.java @@ -1,8 +1,9 @@ package com.walkhub.walkhub.domain.badge.service; -import com.walkhub.walkhub.domain.badge.domain.repository.BadgeRepository; +import com.walkhub.walkhub.domain.badge.domain.repository.BadgeCollectionRepository; import com.walkhub.walkhub.domain.badge.presentation.dto.response.QueryUserBadgeListResponse; import com.walkhub.walkhub.domain.badge.presentation.dto.response.QueryUserBadgeListResponse.DefaultBadgeResponse; +import com.walkhub.walkhub.domain.user.domain.User; import com.walkhub.walkhub.domain.user.facade.UserFacade; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -14,17 +15,18 @@ @Service public class QueryUserBadgeListService { - private final BadgeRepository badgeRepository; + private final BadgeCollectionRepository badgeCollectionRepository; private final UserFacade userFacade; - public QueryUserBadgeListResponse execute(Long badgeId) { + public QueryUserBadgeListResponse execute(Long userId) { - List badgeList = badgeRepository.findAll(badgeId) + User user = userFacade.getCurrentUser(); + List badgeList = badgeCollectionRepository.findByUserId(userId) .stream() - .map(badge -> DefaultBadgeResponse.builder() - .name(badge.getName()) - .imageUrl(badge.getImageUrl()) - .condition(badge.getCondition()) + .map(badgeCollection -> DefaultBadgeResponse.builder() + .name(badgeCollection.getBadge().getName()) + .imageUrl(badgeCollection.getBadge().getImageUrl()) + .condition(badgeCollection.getBadge().getCondition()) .build()) .collect(Collectors.toList()); From ffde98dfae372ac184994c63b8e4a18f51ae995c Mon Sep 17 00:00:00 2001 From: lyutvs Date: Sat, 12 Feb 2022 23:26:51 +0900 Subject: [PATCH 064/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F::=20findByuserId?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../badge/domain/repository/BadgeCollectionRepository.java | 3 ++- .../domain/badge/domain/repository/BadgeRepository.java | 3 --- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/BadgeCollectionRepository.java b/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/BadgeCollectionRepository.java index c6e317b40..a45af9d04 100644 --- a/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/BadgeCollectionRepository.java +++ b/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/BadgeCollectionRepository.java @@ -5,9 +5,10 @@ import com.walkhub.walkhub.domain.user.domain.User; import org.springframework.data.repository.CrudRepository; +import java.util.List; import java.util.Optional; public interface BadgeCollectionRepository extends CrudRepository { - + List findByUserId(Long userId); Optional findByBadgeIdAndUser(Long badgeId, User user); } diff --git a/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/BadgeRepository.java b/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/BadgeRepository.java index cf75ff860..073c49c76 100644 --- a/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/BadgeRepository.java +++ b/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/BadgeRepository.java @@ -3,8 +3,5 @@ import com.walkhub.walkhub.domain.badge.domain.Badge; import org.springframework.data.repository.CrudRepository; -import java.util.List; - public interface BadgeRepository extends CrudRepository { - List findAll(Long badgeId); } From ba9aae44fe1f069d3a0aa1bbcad5d79eb0293521 Mon Sep 17 00:00:00 2001 From: lyutvs Date: Sat, 12 Feb 2022 23:27:23 +0900 Subject: [PATCH 065/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F::=20("/badge-id")=20?= =?UTF-8?q?->=20("/user-id")?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../walkhub/domain/badge/presentation/BadgeController.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/badge/presentation/BadgeController.java b/src/main/java/com/walkhub/walkhub/domain/badge/presentation/BadgeController.java index f0d7af352..2f482fb10 100644 --- a/src/main/java/com/walkhub/walkhub/domain/badge/presentation/BadgeController.java +++ b/src/main/java/com/walkhub/walkhub/domain/badge/presentation/BadgeController.java @@ -21,9 +21,9 @@ public void setTitleBadge(@PathVariable("badge-id") Long badgeId) { setTitleBadgeService.execute(badgeId); } - @GetMapping("/{badge-id}") - public QueryUserBadgeListResponse queryUserBadgeList(@PathVariable(name = "badge-id")Long badgeId) { - return queryUserBadgeListService.execute(badgeId); + @GetMapping("/{user-id}") + public QueryUserBadgeListResponse queryUserBadgeList(@PathVariable(name = "user-id")Long userId) { + return queryUserBadgeListService.execute(userId); } } From 88fd580d81070aa5e9771b271551c7cd1db74990 Mon Sep 17 00:00:00 2001 From: lyutvs Date: Sat, 12 Feb 2022 23:27:38 +0900 Subject: [PATCH 066/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F::=20isMine?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/dto/response/QueryUserBadgeListResponse.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/badge/presentation/dto/response/QueryUserBadgeListResponse.java b/src/main/java/com/walkhub/walkhub/domain/badge/presentation/dto/response/QueryUserBadgeListResponse.java index ecfa50ce7..ee920a5d8 100644 --- a/src/main/java/com/walkhub/walkhub/domain/badge/presentation/dto/response/QueryUserBadgeListResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/badge/presentation/dto/response/QueryUserBadgeListResponse.java @@ -18,5 +18,6 @@ public static class DefaultBadgeResponse{ private final String name; private final String imageUrl; private final String condition; + private final boolean isMine; } } From 90bab178ef492ea6031d00b896b3f17adfa62cd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Sun, 13 Feb 2022 23:18:27 +0900 Subject: [PATCH 067/522] =?UTF-8?q?=F0=9F=90=9B=20::=20enum=20validation?= =?UTF-8?q?=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/com/walkhub/walkhub/domain/user/domain/User.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/user/domain/User.java b/src/main/java/com/walkhub/walkhub/domain/user/domain/User.java index 7e3abe933..7d3f180f0 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/domain/User.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/domain/User.java @@ -60,7 +60,6 @@ public class User extends BaseTimeEntity { private String profileImageUrl; @NotNull - @Length(max = 6) @Enumerated(EnumType.STRING) private Authority authority; @@ -80,7 +79,6 @@ public class User extends BaseTimeEntity { private HealthInfo healthInfo; @NotNull - @Length(max = 6) @Enumerated(EnumType.STRING) private Sex sex; From c5ba5730b3cbbe860c3b9c7516149fc1201c66eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Sun, 13 Feb 2022 23:21:09 +0900 Subject: [PATCH 068/522] =?UTF-8?q?=F0=9F=90=9B=20::=20enum=20validation?= =?UTF-8?q?=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../user/presentation/dto/request/UpdateUserInfoRequest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/user/presentation/dto/request/UpdateUserInfoRequest.java b/src/main/java/com/walkhub/walkhub/domain/user/presentation/dto/request/UpdateUserInfoRequest.java index 7144c99f0..ce8d37bdf 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/presentation/dto/request/UpdateUserInfoRequest.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/presentation/dto/request/UpdateUserInfoRequest.java @@ -1,6 +1,7 @@ package com.walkhub.walkhub.domain.user.presentation.dto.request; import com.walkhub.walkhub.domain.user.domain.type.Sex; +import javax.validation.constraints.NotNull; import lombok.Getter; import lombok.NoArgsConstructor; @@ -18,8 +19,7 @@ public class UpdateUserInfoRequest { @NotBlank(message = "profile_image_url은 null, 공백, 띄어쓰기를 허용하지 않습니다.") private String profileImageUrl; - @NotBlank(message = "sex는 null, 공백, 띄어쓰기를 허용하지 않습니다.") - @Size(min = 1, max = 1, message = "sex는 1글자 여야 합니다.") + @NotNull(message = "sex는 null, 공백, 띄어쓰기를 허용하지 않습니다.") private Sex sex; } From d4912ccd719217864f2f535db485482a5ed299e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Sun, 13 Feb 2022 23:21:34 +0900 Subject: [PATCH 069/522] =?UTF-8?q?=F0=9F=90=9B=20::=20controller=EC=84=B8?= =?UTF-8?q?=ED=8C=85=20=EC=95=88=EB=8F=BC=EC=9E=88=EB=8D=98=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../walkhub/domain/user/presentation/UserController.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/user/presentation/UserController.java b/src/main/java/com/walkhub/walkhub/domain/user/presentation/UserController.java index d6049e7fc..6e91c0a59 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/presentation/UserController.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/presentation/UserController.java @@ -28,6 +28,7 @@ public class UserController { private final UpdateSchoolInfoService updateSchoolInfoService; private final SearchAccountIdService searchAccountIdService; private final CalorieLevelListService calorieLevelListService; + private final UpdateGoalWalkCountService updateGoalWalkCountService; @ResponseStatus(HttpStatus.CREATED) @PostMapping("/verification-codes") @@ -92,4 +93,10 @@ public CalorieLevelListResponse calorieLevelList() { return calorieLevelListService.execute(); } + @ResponseStatus(HttpStatus.NO_CONTENT) + @PatchMapping("/goal") + public void updateGoalWalkCount(@RequestBody UpdateGoalWalkCountRequest updateGoalWalkCountRequest) { + updateGoalWalkCountService.execute(updateGoalWalkCountRequest); + } + } From 162f87dc5a6c2211896233f863c8bbba75aee13c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Sun, 13 Feb 2022 23:21:50 +0900 Subject: [PATCH 070/522] =?UTF-8?q?=F0=9F=90=9B=20::=20builder=EC=97=90=20?= =?UTF-8?q?=EB=B9=BC=EB=A8=B9=EC=9D=80=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../walkhub/domain/user/service/CalorieLevelListService.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/user/service/CalorieLevelListService.java b/src/main/java/com/walkhub/walkhub/domain/user/service/CalorieLevelListService.java index d70759ab8..0efd3299e 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/service/CalorieLevelListService.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/service/CalorieLevelListService.java @@ -30,6 +30,7 @@ public CalorieLevelListResponse execute() { private CalorieLevelListResponse.CalorieLevelResponse calorieLevelResponse(CalorieLevel calorieLevel) { return CalorieLevelListResponse.CalorieLevelResponse.builder() .levelId(calorieLevel.getId()) + .level(calorieLevel.getLevel()) .foodImageUrl(calorieLevel.getFoodImageUrl()) .foodName(calorieLevel.getFoodName()) .calorie(calorieLevel.getCalorie()) From a523fd0eedecd229b44d4b5d5b7dfe3ef8ddaf55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Sun, 13 Feb 2022 23:22:12 +0900 Subject: [PATCH 071/522] =?UTF-8?q?=F0=9F=90=9B=20::=20@transactional=20?= =?UTF-8?q?=EC=97=86=EB=8D=98=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/user/service/InputHealthInformationService.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/user/service/InputHealthInformationService.java b/src/main/java/com/walkhub/walkhub/domain/user/service/InputHealthInformationService.java index 946d5645d..282b233b3 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/service/InputHealthInformationService.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/service/InputHealthInformationService.java @@ -6,6 +6,7 @@ import com.walkhub.walkhub.domain.user.presentation.dto.request.InputHealthInformationRequest; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; @RequiredArgsConstructor @Service @@ -13,6 +14,7 @@ public class InputHealthInformationService { private final UserFacade userFacade; + @Transactional public void execute(InputHealthInformationRequest request) { User user = userFacade.getCurrentUser(); user.setHealthInfo(new HealthInfo(request.getWeight(), request.getHeight())); From 78e55828ce0395dfc85e521673eee1fef9ae909f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Sun, 13 Feb 2022 23:22:30 +0900 Subject: [PATCH 072/522] =?UTF-8?q?=F0=9F=90=9B=20::=20permission=20settin?= =?UTF-8?q?g=20=EC=98=A4=EB=A5=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/walkhub/walkhub/global/security/SecurityConfig.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java b/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java index 671375d8d..7c21aaddb 100644 --- a/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java +++ b/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java @@ -53,9 +53,11 @@ protected void configure(HttpSecurity http) throws Exception { .antMatchers(HttpMethod.PATCH, "/users").authenticated() .antMatchers(HttpMethod.POST,"/users/classes/{section-id}").authenticated() .antMatchers(HttpMethod.GET, "/users/accounts/{phone-number}").permitAll() - .antMatchers(HttpMethod.PATCH, "/users/healths").authenticated() + .antMatchers(HttpMethod.PATCH, "/users/health").authenticated() .antMatchers(HttpMethod.PATCH, "/users/goal").authenticated() .antMatchers(HttpMethod.PATCH, "/users/school").authenticated() + .antMatchers(HttpMethod.GET, "/users/levels/lists").authenticated() + // badges .antMatchers(HttpMethod.GET, "/badges/{user-id}").authenticated() From 8d73ed7701f9929993efb6144ffb0bbf36b2ba4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Sun, 13 Feb 2022 23:22:49 +0900 Subject: [PATCH 073/522] =?UTF-8?q?=F0=9F=90=9B=20::=20=EB=A1=9C=EA=B7=B8?= =?UTF-8?q?=EB=B3=B4=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/walkhub/walkhub/global/error/ExceptionFilter.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/walkhub/walkhub/global/error/ExceptionFilter.java b/src/main/java/com/walkhub/walkhub/global/error/ExceptionFilter.java index 939ca6510..8cafcad0e 100644 --- a/src/main/java/com/walkhub/walkhub/global/error/ExceptionFilter.java +++ b/src/main/java/com/walkhub/walkhub/global/error/ExceptionFilter.java @@ -23,6 +23,7 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse } catch (WalkhubException e) { sendErrorMessage(response, e.getErrorCode()); } catch (Exception e) { + e.printStackTrace(); sendErrorMessage(response, ErrorCode.INTERNAL_SERVER_ERROR); } } From 054367095793d6cb368eb3b5b48ac7b83ada1570 Mon Sep 17 00:00:00 2001 From: lyutvs Date: Sun, 13 Feb 2022 23:24:00 +0900 Subject: [PATCH 074/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F::=20isMine=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/dto/response/QueryUserBadgeListResponse.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/badge/presentation/dto/response/QueryUserBadgeListResponse.java b/src/main/java/com/walkhub/walkhub/domain/badge/presentation/dto/response/QueryUserBadgeListResponse.java index ee920a5d8..ecfa50ce7 100644 --- a/src/main/java/com/walkhub/walkhub/domain/badge/presentation/dto/response/QueryUserBadgeListResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/badge/presentation/dto/response/QueryUserBadgeListResponse.java @@ -18,6 +18,5 @@ public static class DefaultBadgeResponse{ private final String name; private final String imageUrl; private final String condition; - private final boolean isMine; } } From 12d1b70ea6880d2a32e3ccac1ae0ff749c230d62 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Mon, 14 Feb 2022 00:11:10 +0900 Subject: [PATCH 075/522] =?UTF-8?q?:recycle:=20::=20npe=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95=20&=20error=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../walkhub/domain/teacher/service/DeleteClassService.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/service/DeleteClassService.java b/src/main/java/com/walkhub/walkhub/domain/teacher/service/DeleteClassService.java index 83b49831d..ff967cf23 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/service/DeleteClassService.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/service/DeleteClassService.java @@ -3,6 +3,7 @@ import com.walkhub.walkhub.domain.user.domain.Section; import com.walkhub.walkhub.domain.user.domain.User; import com.walkhub.walkhub.domain.user.domain.repository.SectionRepository; +import com.walkhub.walkhub.domain.user.domain.repository.UserRepository; import com.walkhub.walkhub.domain.user.facade.SectionFacade; import com.walkhub.walkhub.domain.user.facade.UserFacade; import com.walkhub.walkhub.global.enums.Authority; @@ -18,6 +19,7 @@ public class DeleteClassService { private final UserFacade userFacade; private final SectionFacade sectionFacade; private final SectionRepository sectionRepository; + private final UserRepository userRepository; @Transactional public void execute(Long sectionId) { @@ -25,10 +27,11 @@ public void execute(Long sectionId) { User user = userFacade.getCurrentUser(); - if (user.getAuthority() == Authority.TEACHER && !user.getSection().equals(section)) { + if (user.getAuthority() != Authority.TEACHER || !user.getSection().equals(section)) { throw InvalidRoleException.EXCEPTION; } + userRepository.setUserSectionNull(section); sectionRepository.delete(section); } From 75730bea9bf784aace3b57761a0b2e42a56a2dfe Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Mon, 14 Feb 2022 00:11:54 +0900 Subject: [PATCH 076/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20user=20sectio?= =?UTF-8?q?n=5Fid=20null=EB=A1=9C=20=EB=B0=94=EA=BE=B8=EB=8A=94=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/user/domain/repository/UserRepository.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepository.java b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepository.java index 08d01f703..996f3ed42 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepository.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepository.java @@ -3,7 +3,11 @@ import com.walkhub.walkhub.domain.user.domain.Section; import com.walkhub.walkhub.domain.user.domain.User; import com.walkhub.walkhub.global.enums.Authority; +import io.lettuce.core.dynamic.annotation.Param; +import org.springframework.data.jpa.repository.Modifying; +import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.CrudRepository; +import org.springframework.transaction.annotation.Transactional; import java.util.List; import java.util.Optional; @@ -13,4 +17,9 @@ public interface UserRepository extends CrudRepository { Optional findByPhoneNumber(String phoneNumber); List findAllBySectionAndAuthority(Section section, Authority authority); List findAllBySchoolIdAndNameContaining(Long id, String name); + + @Transactional + @Modifying + @Query("update User u set u.section = null where u.section = :section") + void setUserSectionNull(@Param("section") Section section); } From c4b192f3a0eca7bf86aad8e51aaec426c648e3d5 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Mon, 14 Feb 2022 00:12:27 +0900 Subject: [PATCH 077/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20section?= =?UTF-8?q?=EA=B0=80=EC=A0=B8=EC=98=AC=20=EB=95=8C=20null=20=EC=B2=B4?= =?UTF-8?q?=ED=81=AC=20=EB=A1=9C=EC=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../walkhub/domain/user/domain/User.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/user/domain/User.java b/src/main/java/com/walkhub/walkhub/domain/user/domain/User.java index 7d3f180f0..cc5bc842c 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/domain/User.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/domain/User.java @@ -5,14 +5,11 @@ import com.walkhub.walkhub.domain.school.domain.School; import com.walkhub.walkhub.domain.user.domain.type.HealthInfo; import com.walkhub.walkhub.domain.user.domain.type.Sex; +import com.walkhub.walkhub.domain.user.exception.SectionNotFoundException; import com.walkhub.walkhub.domain.user.presentation.dto.request.UpdateUserInfoRequest; import com.walkhub.walkhub.global.entity.BaseTimeEntity; import com.walkhub.walkhub.global.enums.Authority; import com.walkhub.walkhub.infrastructure.image.DefaultImage; -import java.util.List; -import javax.persistence.CascadeType; -import javax.persistence.OneToMany; -import javax.validation.constraints.NotNull; import lombok.AccessLevel; import lombok.Builder; import lombok.Getter; @@ -20,6 +17,7 @@ import lombok.Setter; import org.hibernate.annotations.ColumnDefault; +import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Embedded; import javax.persistence.Entity; @@ -31,9 +29,11 @@ import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; +import javax.persistence.OneToMany; import javax.persistence.OneToOne; +import javax.validation.constraints.NotNull; import java.math.BigDecimal; -import org.hibernate.validator.constraints.Length; +import java.util.List; @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) @@ -103,7 +103,7 @@ public class User extends BaseTimeEntity { @OneToMany(mappedBy = "user", cascade = CascadeType.REMOVE) private List exerciseList; - + @Builder public User(Long id, String accountId, String password, String phoneNumber, String name, Authority authority, Section section, School school, boolean isMeasuring, @@ -162,4 +162,11 @@ public void updatedailyWalkCountGoal(Integer dailyWalkCountGoal) { this.dailyWalkCountGoal = dailyWalkCountGoal; } + public Section getSection() { + if (section == null) { + throw SectionNotFoundException.EXCEPTION; + } + return section; + } + } From 01cf12dc8625714ce946b3c4419506892abec6e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Mon, 14 Feb 2022 00:22:48 +0900 Subject: [PATCH 078/522] =?UTF-8?q?=F0=9F=90=9B=20::=20columndefault=20->?= =?UTF-8?q?=20columndefinition?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/exercise/domain/Exercise.java | 25 ++++++++----------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/Exercise.java b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/Exercise.java index e73843806..27a22cf21 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/Exercise.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/Exercise.java @@ -22,10 +22,12 @@ import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import java.time.LocalDateTime; +import org.hibernate.annotations.DynamicInsert; import org.hibernate.validator.constraints.Length; @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) +@DynamicInsert @Entity public class Exercise extends BaseTimeEntity { @@ -33,43 +35,35 @@ public class Exercise extends BaseTimeEntity { @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; - @ColumnDefault("0") - @Column(nullable = false) + @Column(nullable = false, columnDefinition = "integer default 0") private Integer walkCount; private LocalDateTime endAt; - @ColumnDefault("0") - @Column(nullable = false) + @Column(nullable = false, columnDefinition = "integer default 0") private Integer distance; - @ColumnDefault("0") - @Column(nullable = false) + @Column(nullable = false, columnDefinition = "integer default 0") private Integer calorie; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "user_id", nullable = false) private User user; - @ColumnDefault("6000") - @Column(nullable = false) + @Column(nullable = false, columnDefinition = "integer default 6000") private Integer goal; @NotNull - @Length(max = 8) @Enumerated(EnumType.STRING) private GoalType goalType; - @ColumnDefault("0") - @Column(nullable = false) + @Column(nullable = false, columnDefinition = "boolean default false") private Boolean isExercising; - @ColumnDefault("0") - @Column(nullable = false) + @Column(nullable = false, columnDefinition = "integer default 0") private Long cheeringCount; - @NotNull - @ColumnDefault(DefaultImage.EXERCISE_IMAGE) + @Column(nullable = false, columnDefinition = "varchar(255) default " + DefaultImage.EXERCISE_IMAGE) private String imageUrl; @Builder @@ -77,6 +71,7 @@ public Exercise(User user, Integer goal, GoalType goalType) { this.user = user; this.goalType = goalType; this.goal = goal; + this.isExercising = true; } public void closeExercise(Integer walkCount, Integer distance, Integer calorie) { From 5686db688bae276675bd7ba05aab0bfb4d8798b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Mon, 14 Feb 2022 00:23:14 +0900 Subject: [PATCH 079/522] =?UTF-8?q?=F0=9F=93=91=20::=20AlreadyExercisingEx?= =?UTF-8?q?ception?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exception/AlreadyExercisingException.java | 16 ++++++++++++++++ .../global/error/exception/ErrorCode.java | 1 + 2 files changed, 17 insertions(+) create mode 100644 src/main/java/com/walkhub/walkhub/domain/exercise/exception/AlreadyExercisingException.java diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/exception/AlreadyExercisingException.java b/src/main/java/com/walkhub/walkhub/domain/exercise/exception/AlreadyExercisingException.java new file mode 100644 index 000000000..2e6f8ffc8 --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/exception/AlreadyExercisingException.java @@ -0,0 +1,16 @@ +package com.walkhub.walkhub.domain.exercise.exception; + +import com.walkhub.walkhub.global.error.exception.ErrorCode; +import com.walkhub.walkhub.global.error.exception.WalkhubException; + +public class AlreadyExercisingException extends WalkhubException { + + + public static final WalkhubException EXCEPTION = + new AlreadyExercisingException(); + + private AlreadyExercisingException() { + super(ErrorCode.ALREADY_EXERCISING); + } + +} diff --git a/src/main/java/com/walkhub/walkhub/global/error/exception/ErrorCode.java b/src/main/java/com/walkhub/walkhub/global/error/exception/ErrorCode.java index d37373c64..5fe5af9ec 100644 --- a/src/main/java/com/walkhub/walkhub/global/error/exception/ErrorCode.java +++ b/src/main/java/com/walkhub/walkhub/global/error/exception/ErrorCode.java @@ -47,6 +47,7 @@ public enum ErrorCode { ALREADY_CREATED(409, "SECTION-409-1", "Already Created"), ALREADY_JOINED(409, "USER-409-2", "Already Joined"), ALREADY_PARTICIPATED(409, "CHALLENGE-409-1", "Already Participated"), + ALREADY_EXERCISING(409, "EXERCISE-409-1", "Already Exercising"), REDIS_TRANSACTION_EXCEPTION(500, "REDIS-500-1", "Cannot Read Cache From Redis"), INTERNAL_SERVER_ERROR(500, "SERVER-500-1", "Internal Server Error"); From 5e6eedc87d4816d6147dd844bd34a7f9125de71b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Mon, 14 Feb 2022 00:23:42 +0900 Subject: [PATCH 080/522] =?UTF-8?q?=F0=9F=90=9B=20::=20=EC=9D=B4=EB=AF=B8?= =?UTF-8?q?=EC=B8=A1=EC=A0=95=EC=A4=91=EC=9D=BC=EB=95=8C=20=EC=98=88?= =?UTF-8?q?=EC=99=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exercise/service/CreateExerciseService.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/service/CreateExerciseService.java b/src/main/java/com/walkhub/walkhub/domain/exercise/service/CreateExerciseService.java index 772614974..e8059ed56 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/service/CreateExerciseService.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/service/CreateExerciseService.java @@ -2,8 +2,10 @@ import com.walkhub.walkhub.domain.exercise.domain.Exercise; import com.walkhub.walkhub.domain.exercise.domain.repository.ExerciseRepository; +import com.walkhub.walkhub.domain.exercise.exception.AlreadyExercisingException; import com.walkhub.walkhub.domain.exercise.presentation.dto.request.CreateExerciseRequest; import com.walkhub.walkhub.domain.exercise.presentation.dto.response.CreateExerciseResponse; +import com.walkhub.walkhub.domain.user.domain.User; import com.walkhub.walkhub.domain.user.facade.UserFacade; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -16,9 +18,16 @@ public class CreateExerciseService { private final ExerciseRepository exerciseRepository; public CreateExerciseResponse execute(CreateExerciseRequest request) { + + User user = userFacade.getCurrentUser(); + + if (exerciseRepository.findByIsExercisingTrueAndUser(user).isPresent()) { + throw AlreadyExercisingException.EXCEPTION; + } + Exercise exercise = exerciseRepository.save( Exercise.builder() - .user(userFacade.getCurrentUser()) + .user(user) .goalType(request.getGoalType()) .goal(request.getGoal()) .build() From 2d08f326be2af65ef0c837250ee287faa1a6bd19 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Mon, 14 Feb 2022 00:27:11 +0900 Subject: [PATCH 081/522] =?UTF-8?q?:bookmark=5Ftabs:=20::=20detailsClass?= =?UTF-8?q?=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 --- .../teacher/presentation/TeacherController.java | 14 +++++++------- ...ntCodeService.java => DetailsClassService.java} | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) rename src/main/java/com/walkhub/walkhub/domain/teacher/service/{QueryStudentCodeService.java => DetailsClassService.java} (98%) diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/TeacherController.java b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/TeacherController.java index 3e4d89e8f..99847495f 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/TeacherController.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/TeacherController.java @@ -8,11 +8,10 @@ import com.walkhub.walkhub.domain.teacher.service.ConfirmTeacherCodeService; import com.walkhub.walkhub.domain.teacher.service.CreateClassService; import com.walkhub.walkhub.domain.teacher.service.DeleteClassService; -import com.walkhub.walkhub.domain.teacher.service.QueryStudentCodeService; +import com.walkhub.walkhub.domain.teacher.service.DetailsClassService; import com.walkhub.walkhub.domain.teacher.service.QueryUserDetailsService; import com.walkhub.walkhub.domain.teacher.service.RefreshClassCodeService; import com.walkhub.walkhub.domain.teacher.service.VerificationCodeService; -import java.time.LocalDate; import lombok.RequiredArgsConstructor; import org.springframework.format.annotation.DateTimeFormat; import org.springframework.http.HttpStatus; @@ -28,6 +27,7 @@ import org.springframework.web.bind.annotation.RestController; import javax.validation.Valid; +import java.time.LocalDate; @RequiredArgsConstructor @RequestMapping("/teachers") @@ -38,7 +38,7 @@ public class TeacherController { private final VerificationCodeService verificationCodeService; private final DeleteClassService deleteClassService; private final RefreshClassCodeService refreshClassCodeService; - private final QueryStudentCodeService queryStudentCodeService; + private final DetailsClassService detailsClassService; private final QueryUserDetailsService queryUserDetailsService; private final ConfirmTeacherCodeService confirmTeacherCodeService; @@ -66,14 +66,14 @@ public CodeResponse refreshClassCode() { } @GetMapping("/classes") - public DetailsClassResponse queryStudentCode() { - return queryStudentCodeService.execute(); + public DetailsClassResponse detailsClass() { + return detailsClassService.execute(); } @GetMapping("/users/{user-id}") public QueryUserDetailsResponse queryUserDetails(@PathVariable Long userId, - @RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate startAt, - @RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate endAt) { + @RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate startAt, + @RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate endAt) { return queryUserDetailsService.execute(userId, startAt, endAt); } diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/service/QueryStudentCodeService.java b/src/main/java/com/walkhub/walkhub/domain/teacher/service/DetailsClassService.java similarity index 98% rename from src/main/java/com/walkhub/walkhub/domain/teacher/service/QueryStudentCodeService.java rename to src/main/java/com/walkhub/walkhub/domain/teacher/service/DetailsClassService.java index 5b939ee82..4381e854f 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/service/QueryStudentCodeService.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/service/DetailsClassService.java @@ -19,7 +19,7 @@ @RequiredArgsConstructor @Service -public class QueryStudentCodeService { +public class DetailsClassService { private final UserFacade userFacade; private final SectionFacade sectionFacade; From fbdedb418531e8a3e1bbec85f0698550ceb3b0a2 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Mon, 14 Feb 2022 00:30:12 +0900 Subject: [PATCH 082/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20hasAnyAuthori?= =?UTF-8?q?ty=20->=20hasAuthority?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/walkhub/walkhub/global/security/SecurityConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java b/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java index 7c21aaddb..08f4b9e56 100644 --- a/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java +++ b/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java @@ -112,7 +112,7 @@ protected void configure(HttpSecurity http) throws Exception { .antMatchers(HttpMethod.PATCH, "/teachers/verification-codes").hasAuthority("USER") .antMatchers(HttpMethod.POST, "/teachers/classes").hasAnyAuthority("TEACHER", "ROOT") .antMatchers(HttpMethod.DELETE, "/teachers/classes/{section-id}").hasAnyAuthority("TEACHER", "ROOT") - .antMatchers(HttpMethod.GET, "/teachers/classes").hasAnyAuthority("TEACHER") + .antMatchers(HttpMethod.GET, "/teachers/classes").hasAuthority("TEACHER") .antMatchers(HttpMethod.GET,"/teachers/{user-id}").hasAnyAuthority("TEACHER") .antMatchers(HttpMethod.GET,"/teachers/users").hasAnyAuthority("TEACHER","ROOT") .antMatchers(HttpMethod.GET,"/teachers/students/verification-codes").hasAnyAuthority("TEACHER") From d3dfcaff87c82938419e7c4b292af3eda44f6e58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Mon, 14 Feb 2022 00:30:18 +0900 Subject: [PATCH 083/522] =?UTF-8?q?=F0=9F=90=9B=20::=20is=20exercising=20?= =?UTF-8?q?=EC=97=AC=EB=B6=80=20false=EB=A1=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/walkhub/walkhub/domain/exercise/domain/Exercise.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/Exercise.java b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/Exercise.java index 27a22cf21..867d2d65f 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/Exercise.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/Exercise.java @@ -79,6 +79,7 @@ public void closeExercise(Integer walkCount, Integer distance, Integer calorie) this.distance = distance; this.calorie = calorie; this.endAt = LocalDateTime.now(); + this.isExercising = false; } public void addCheeringCount() { From 0c09dca75679a9bc4385729ec843ce089108cb82 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Mon, 14 Feb 2022 00:35:35 +0900 Subject: [PATCH 084/522] =?UTF-8?q?:recycle:=20::=20@PathVariable("user-id?= =?UTF-8?q?")=20Long=20userId=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../walkhub/domain/teacher/presentation/TeacherController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/TeacherController.java b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/TeacherController.java index 99847495f..b91873d81 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/TeacherController.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/TeacherController.java @@ -71,7 +71,7 @@ public DetailsClassResponse detailsClass() { } @GetMapping("/users/{user-id}") - public QueryUserDetailsResponse queryUserDetails(@PathVariable Long userId, + public QueryUserDetailsResponse queryUserDetails(@PathVariable("user-id") Long userId, @RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate startAt, @RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate endAt) { return queryUserDetailsService.execute(userId, startAt, endAt); From 15a768e5bd094d3f149d472377d8bbd05f2a28d5 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Mon, 14 Feb 2022 00:40:20 +0900 Subject: [PATCH 085/522] =?UTF-8?q?:coffin:=20::=20=EB=B6=88=ED=95=84?= =?UTF-8?q?=EC=9A=94=ED=95=9C=20api=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/TeacherController.java | 7 ------ .../service/RefreshClassCodeService.java | 25 ------------------- 2 files changed, 32 deletions(-) delete mode 100644 src/main/java/com/walkhub/walkhub/domain/teacher/service/RefreshClassCodeService.java diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/TeacherController.java b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/TeacherController.java index b91873d81..4899bc52c 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/TeacherController.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/TeacherController.java @@ -10,7 +10,6 @@ import com.walkhub.walkhub.domain.teacher.service.DeleteClassService; import com.walkhub.walkhub.domain.teacher.service.DetailsClassService; import com.walkhub.walkhub.domain.teacher.service.QueryUserDetailsService; -import com.walkhub.walkhub.domain.teacher.service.RefreshClassCodeService; import com.walkhub.walkhub.domain.teacher.service.VerificationCodeService; import lombok.RequiredArgsConstructor; import org.springframework.format.annotation.DateTimeFormat; @@ -37,7 +36,6 @@ public class TeacherController { private final CreateClassService createClassService; private final VerificationCodeService verificationCodeService; private final DeleteClassService deleteClassService; - private final RefreshClassCodeService refreshClassCodeService; private final DetailsClassService detailsClassService; private final QueryUserDetailsService queryUserDetailsService; private final ConfirmTeacherCodeService confirmTeacherCodeService; @@ -60,11 +58,6 @@ public void deleteClass(@PathVariable(name = "section-id") Long sectionId) { deleteClassService.execute(sectionId); } - @PatchMapping("/classes/verification-codes") - public CodeResponse refreshClassCode() { - return refreshClassCodeService.execute(); - } - @GetMapping("/classes") public DetailsClassResponse detailsClass() { return detailsClassService.execute(); diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/service/RefreshClassCodeService.java b/src/main/java/com/walkhub/walkhub/domain/teacher/service/RefreshClassCodeService.java deleted file mode 100644 index 692b53b74..000000000 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/service/RefreshClassCodeService.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.walkhub.walkhub.domain.teacher.service; - -import com.walkhub.walkhub.domain.teacher.presentation.dto.response.CodeResponse; -import com.walkhub.walkhub.domain.user.facade.UserFacade; -import com.walkhub.walkhub.global.utils.code.RandomCodeUtil; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -@RequiredArgsConstructor -@Service -public class RefreshClassCodeService { - - private final UserFacade userFacade; - - @Transactional - public CodeResponse execute() { - - String classCode = RandomCodeUtil.make(7); - - userFacade.getCurrentUser().getSection().setClassCode(classCode); - - return new CodeResponse(classCode); - } -} From ba1a1f8dfa579d8c86a7065fe1460ae5c374836a Mon Sep 17 00:00:00 2001 From: lyutvs Date: Mon, 14 Feb 2022 00:41:43 +0900 Subject: [PATCH 086/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F::=20codesmell=20?= =?UTF-8?q?=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/badge/service/QueryUserBadgeListService.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/badge/service/QueryUserBadgeListService.java b/src/main/java/com/walkhub/walkhub/domain/badge/service/QueryUserBadgeListService.java index b8237914c..3001c706b 100644 --- a/src/main/java/com/walkhub/walkhub/domain/badge/service/QueryUserBadgeListService.java +++ b/src/main/java/com/walkhub/walkhub/domain/badge/service/QueryUserBadgeListService.java @@ -3,8 +3,6 @@ import com.walkhub.walkhub.domain.badge.domain.repository.BadgeCollectionRepository; import com.walkhub.walkhub.domain.badge.presentation.dto.response.QueryUserBadgeListResponse; import com.walkhub.walkhub.domain.badge.presentation.dto.response.QueryUserBadgeListResponse.DefaultBadgeResponse; -import com.walkhub.walkhub.domain.user.domain.User; -import com.walkhub.walkhub.domain.user.facade.UserFacade; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -16,11 +14,9 @@ public class QueryUserBadgeListService { private final BadgeCollectionRepository badgeCollectionRepository; - private final UserFacade userFacade; public QueryUserBadgeListResponse execute(Long userId) { - User user = userFacade.getCurrentUser(); List badgeList = badgeCollectionRepository.findByUserId(userId) .stream() .map(badgeCollection -> DefaultBadgeResponse.builder() From 25cf584a3c7cefdf11d43cd969699f1a39f5a34c Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Mon, 14 Feb 2022 01:25:20 +0900 Subject: [PATCH 087/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20url=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 --- .../com/walkhub/walkhub/global/security/SecurityConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java b/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java index 08f4b9e56..eb5b9c687 100644 --- a/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java +++ b/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java @@ -113,7 +113,7 @@ protected void configure(HttpSecurity http) throws Exception { .antMatchers(HttpMethod.POST, "/teachers/classes").hasAnyAuthority("TEACHER", "ROOT") .antMatchers(HttpMethod.DELETE, "/teachers/classes/{section-id}").hasAnyAuthority("TEACHER", "ROOT") .antMatchers(HttpMethod.GET, "/teachers/classes").hasAuthority("TEACHER") - .antMatchers(HttpMethod.GET,"/teachers/{user-id}").hasAnyAuthority("TEACHER") + .antMatchers(HttpMethod.GET,"/teachers/users/{user-id}").hasAnyAuthority("TEACHER") .antMatchers(HttpMethod.GET,"/teachers/users").hasAnyAuthority("TEACHER","ROOT") .antMatchers(HttpMethod.GET,"/teachers/students/verification-codes").hasAnyAuthority("TEACHER") .antMatchers(HttpMethod.PATCH, "/teachers/classes/verification-codes").hasAuthority("TEACHER") From 6bbbf4544b91387e2eb2ba8b399c0dfb306c52a4 Mon Sep 17 00:00:00 2001 From: lyutvs Date: Mon, 14 Feb 2022 01:39:18 +0900 Subject: [PATCH 088/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F::=20BadgeController?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/badge/presentation/BadgeController.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/badge/presentation/BadgeController.java b/src/main/java/com/walkhub/walkhub/domain/badge/presentation/BadgeController.java index ee5611b2b..2cf489ade 100644 --- a/src/main/java/com/walkhub/walkhub/domain/badge/presentation/BadgeController.java +++ b/src/main/java/com/walkhub/walkhub/domain/badge/presentation/BadgeController.java @@ -1,7 +1,9 @@ package com.walkhub.walkhub.domain.badge.presentation; import com.walkhub.walkhub.domain.badge.presentation.dto.response.ClaimBadgeResponse; +import com.walkhub.walkhub.domain.badge.presentation.dto.response.MyBadgeListResponse; import com.walkhub.walkhub.domain.badge.service.ClaimBadgeService; +import com.walkhub.walkhub.domain.badge.service.MyBadgeListService; import com.walkhub.walkhub.domain.badge.service.SetTitleBadgeService; import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; @@ -19,6 +21,7 @@ public class BadgeController { private final SetTitleBadgeService setTitleBadgeService; private final ClaimBadgeService claimBadgeService; + private final MyBadgeListService myBadgeListService; @ResponseStatus(HttpStatus.NO_CONTENT) @PutMapping("/{badge-id}") @@ -31,4 +34,9 @@ public ClaimBadgeResponse claimBadge() { return claimBadgeService.execute(); } + @GetMapping + public MyBadgeListResponse myBadgeList() { + return myBadgeListService.execute(); + } + } From 4a2eba9e075f410504b8e9be9007fe121c6b65f8 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Mon, 14 Feb 2022 01:56:52 +0900 Subject: [PATCH 089/522] =?UTF-8?q?:coffin:=20::=20school-id=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/school/presentation/SchoolController.java | 7 +++---- .../domain/school/service/SchoolLogoSettingService.java | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/school/presentation/SchoolController.java b/src/main/java/com/walkhub/walkhub/domain/school/presentation/SchoolController.java index f2cf4a3ec..59639dec7 100644 --- a/src/main/java/com/walkhub/walkhub/domain/school/presentation/SchoolController.java +++ b/src/main/java/com/walkhub/walkhub/domain/school/presentation/SchoolController.java @@ -26,10 +26,9 @@ public class SchoolController { private final SearchSchoolService searchSchoolService; @ResponseStatus(HttpStatus.NO_CONTENT) - @PatchMapping("/logos/{school-id}") - public void schoolLogoSetting(@PathVariable(name = "school-id") Long schoolId, - @RequestBody @Valid SchoolLogoRequest request) { - schoolLogoSettingService.execute(schoolId, request); + @PatchMapping("/logos") + public void schoolLogoSetting(@RequestBody @Valid SchoolLogoRequest request) { + schoolLogoSettingService.execute(request); } @GetMapping("/search") diff --git a/src/main/java/com/walkhub/walkhub/domain/school/service/SchoolLogoSettingService.java b/src/main/java/com/walkhub/walkhub/domain/school/service/SchoolLogoSettingService.java index 81aa00a67..1cf9eb3cf 100644 --- a/src/main/java/com/walkhub/walkhub/domain/school/service/SchoolLogoSettingService.java +++ b/src/main/java/com/walkhub/walkhub/domain/school/service/SchoolLogoSettingService.java @@ -19,10 +19,10 @@ public class SchoolLogoSettingService { private final SchoolRepository schoolRepository; @Transactional - public void execute(Long schoolId, SchoolLogoRequest request) { + public void execute(SchoolLogoRequest request) { User user = userFacade.getCurrentUser(); - School school = schoolRepository.findById(schoolId) + School school = schoolRepository.findById(user.getSchool().getId()) .orElseThrow(() -> SchoolNotFoundException.EXCEPTION); if (!user.getSchool().equals(school)) { From 64ea51a8fe7ef304e6399b7f35439a38caf55d02 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Mon, 14 Feb 2022 01:58:11 +0900 Subject: [PATCH 090/522] =?UTF-8?q?:recycle:=20::=20=EC=BD=94=EB=93=9C=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 --- .../school/service/SchoolLogoSettingService.java | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/school/service/SchoolLogoSettingService.java b/src/main/java/com/walkhub/walkhub/domain/school/service/SchoolLogoSettingService.java index 1cf9eb3cf..b6ba86d6d 100644 --- a/src/main/java/com/walkhub/walkhub/domain/school/service/SchoolLogoSettingService.java +++ b/src/main/java/com/walkhub/walkhub/domain/school/service/SchoolLogoSettingService.java @@ -1,11 +1,7 @@ package com.walkhub.walkhub.domain.school.service; -import com.walkhub.walkhub.domain.school.domain.School; -import com.walkhub.walkhub.domain.school.domain.repository.SchoolRepository; -import com.walkhub.walkhub.domain.school.exception.AgencyCodeNotMatchException; import com.walkhub.walkhub.domain.school.presentation.dto.request.SchoolLogoRequest; import com.walkhub.walkhub.domain.user.domain.User; -import com.walkhub.walkhub.domain.user.exception.SchoolNotFoundException; import com.walkhub.walkhub.domain.user.facade.UserFacade; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -16,19 +12,11 @@ public class SchoolLogoSettingService { private final UserFacade userFacade; - private final SchoolRepository schoolRepository; @Transactional public void execute(SchoolLogoRequest request) { User user = userFacade.getCurrentUser(); - School school = schoolRepository.findById(user.getSchool().getId()) - .orElseThrow(() -> SchoolNotFoundException.EXCEPTION); - - if (!user.getSchool().equals(school)) { - throw AgencyCodeNotMatchException.EXCEPTION; - } - - school.setLogoImage(request.getImageUrl()); + user.getSchool().setLogoImage(request.getImageUrl()); } } From 74519ca98c0d95a5429999b0de51d1015fed3727 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Mon, 14 Feb 2022 02:02:05 +0900 Subject: [PATCH 091/522] =?UTF-8?q?=F0=9F=90=9B=20::=20idClass=20=EC=98=A4?= =?UTF-8?q?=EB=A5=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../walkhub/domain/exercise/domain/LocationId.java | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/LocationId.java b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/LocationId.java index 06b711e43..f4ae791d4 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/LocationId.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/LocationId.java @@ -5,10 +5,6 @@ import lombok.Getter; import lombok.NoArgsConstructor; -import javax.persistence.Column; -import javax.persistence.FetchType; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; import java.io.Serializable; @Getter @@ -16,11 +12,8 @@ @EqualsAndHashCode public class LocationId implements Serializable { - @Column(nullable = false) private Integer sequence; - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "exercise_id", nullable = false) - private Exercise exercise; + private Long exercise; } From ba23f4aabbf9818ad24f4aa61ecd734c8f1ce7cd Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Mon, 14 Feb 2022 02:08:30 +0900 Subject: [PATCH 092/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20=ED=95=99?= =?UTF-8?q?=EA=B3=A0=20=EB=8C=80=ED=91=9C=20=EB=A1=9C=EA=B3=A0=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95=20url=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/walkhub/walkhub/global/security/SecurityConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java b/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java index eb5b9c687..439c9c9ff 100644 --- a/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java +++ b/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java @@ -104,7 +104,7 @@ protected void configure(HttpSecurity http) throws Exception { .antMatchers(HttpMethod.POST, "/images").permitAll() // schools - .antMatchers(HttpMethod.PATCH, "/schools/logos/{school-id}").hasAuthority("ROOT") + .antMatchers(HttpMethod.PATCH, "/schools/logos").hasAuthority("ROOT") .antMatchers(HttpMethod.GET, "/schools/search").authenticated() // teachers From 00cc669491a1a52618822561fb0bc50ca4e92858 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Mon, 14 Feb 2022 02:22:30 +0900 Subject: [PATCH 093/522] =?UTF-8?q?=F0=9F=90=9B=20::=20enum=20validation?= =?UTF-8?q?=20error?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/walkhub/walkhub/domain/notice/domain/Notice.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/notice/domain/Notice.java b/src/main/java/com/walkhub/walkhub/domain/notice/domain/Notice.java index df17d10ef..d1cdb1cc0 100644 --- a/src/main/java/com/walkhub/walkhub/domain/notice/domain/Notice.java +++ b/src/main/java/com/walkhub/walkhub/domain/notice/domain/Notice.java @@ -37,7 +37,6 @@ public class Notice extends BaseTimeEntity { private String content; @NotNull - @Length(max = 7) @Enumerated(EnumType.STRING) private Scope scope; From aae9d18e1d0dbe948b7767e6aa739e33237b23da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Mon, 14 Feb 2022 02:22:53 +0900 Subject: [PATCH 094/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20createNotice?= =?UTF-8?q?=20scope=20=EC=A1=B0=EA=B1=B4=EB=AC=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../walkhub/domain/notice/service/CreateNoticeService.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/notice/service/CreateNoticeService.java b/src/main/java/com/walkhub/walkhub/domain/notice/service/CreateNoticeService.java index 28565a90a..16af789e8 100644 --- a/src/main/java/com/walkhub/walkhub/domain/notice/service/CreateNoticeService.java +++ b/src/main/java/com/walkhub/walkhub/domain/notice/service/CreateNoticeService.java @@ -24,9 +24,8 @@ public class CreateNoticeService { public void execute(CreateNoticeRequest request) { User user = userFacade.getCurrentUser(); - if (Scope.SCHOOL.equals(request.getScope()) && user.getSection() == null) { - throw SectionNotFoundException.EXCEPTION; - } else if (!Authority.ROOT.equals(user.getAuthority())) { + if (request.getScope().equals(Scope.SCHOOL) && !user.getAuthority().equals(Authority.ROOT) || + request.getScope().equals(Scope.ALL) && !user.getAuthority().equals(Authority.SU)) { throw InvalidRoleException.EXCEPTION; } From 9ea958d91d58e5db79826d55202d8ecbd24226ac Mon Sep 17 00:00:00 2001 From: lyutvs Date: Mon, 14 Feb 2022 02:27:15 +0900 Subject: [PATCH 095/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F::=20=ED=8C=A8?= =?UTF-8?q?=ED=82=A4=EC=A7=80=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 --- .../repository/CustomBadgeRepository.java | 5 ++-- .../repository/CustomBadgeRepositoryImpl.java | 25 ++++++++++++++++--- ...{ClaimBadgeVO.java => DefaultBadgeVO.java} | 4 +-- .../badge/service/ClaimBadgeService.java | 13 +++++----- 4 files changed, 33 insertions(+), 14 deletions(-) rename src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/vo/{ClaimBadgeVO.java => DefaultBadgeVO.java} (78%) diff --git a/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/CustomBadgeRepository.java b/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/CustomBadgeRepository.java index b7a53862a..252953f50 100644 --- a/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/CustomBadgeRepository.java +++ b/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/CustomBadgeRepository.java @@ -1,9 +1,10 @@ package com.walkhub.walkhub.domain.badge.domain.repository; -import com.walkhub.walkhub.domain.badge.domain.repository.vo.ClaimBadgeVO; +import com.walkhub.walkhub.domain.badge.domain.repository.vo.DefaultBadgeVO; import java.util.List; public interface CustomBadgeRepository { - List findAllByBadgeCollectionsNotIn(Long userId); + List findAllByBadgeCollectionsNotIn(Long userId); + List findAllByBadgeCollections(Long userId); } diff --git a/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/CustomBadgeRepositoryImpl.java b/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/CustomBadgeRepositoryImpl.java index 43bce1bc4..9212f76f4 100644 --- a/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/CustomBadgeRepositoryImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/CustomBadgeRepositoryImpl.java @@ -1,8 +1,8 @@ package com.walkhub.walkhub.domain.badge.domain.repository; import com.querydsl.jpa.impl.JPAQueryFactory; -import com.walkhub.walkhub.domain.badge.domain.repository.vo.ClaimBadgeVO; -import com.walkhub.walkhub.domain.badge.domain.repository.vo.QClaimBadgeVO; +import com.walkhub.walkhub.domain.badge.domain.repository.vo.DefaultBadgeVO; +import com.walkhub.walkhub.domain.badge.domain.repository.vo.QDefaultBadgeVO; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Repository; @@ -19,9 +19,9 @@ public class CustomBadgeRepositoryImpl implements CustomBadgeRepository { private final JPAQueryFactory query; @Override - public List findAllByBadgeCollectionsNotIn(Long userId) { + public List findAllByBadgeCollectionsNotIn(Long userId) { return query - .select(new QClaimBadgeVO( + .select(new QDefaultBadgeVO( badge.id, badge.name, badge.imageUrl @@ -35,4 +35,21 @@ public List findAllByBadgeCollectionsNotIn(Long userId) { .fetch(); } + @Override + public List findAllByBadgeCollections(Long userId) { + return query + .select(new QDefaultBadgeVO( + badge.id, + badge.name, + badge.imageUrl + )) + .from(badge) + .leftJoin(badgeCollection) + .on(badgeCollection.badge.eq(badge)) + .leftJoin(user) + .on(badgeCollection.user.eq(user)) + .where(user.isNull().or(user.id.eq(userId))) + .fetch(); + } + } diff --git a/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/vo/ClaimBadgeVO.java b/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/vo/DefaultBadgeVO.java similarity index 78% rename from src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/vo/ClaimBadgeVO.java rename to src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/vo/DefaultBadgeVO.java index 61a2a78e2..4e75cb68e 100644 --- a/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/vo/ClaimBadgeVO.java +++ b/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/vo/DefaultBadgeVO.java @@ -4,13 +4,13 @@ import lombok.Getter; @Getter -public class ClaimBadgeVO { +public class DefaultBadgeVO { private final Long badgeId; private final String name; private final String imageUrl; @QueryProjection - public ClaimBadgeVO(Long badgeId, String name, String imageUrl) { + public DefaultBadgeVO(Long badgeId, String name, String imageUrl) { this.badgeId = badgeId; this.name = name; this.imageUrl = imageUrl; diff --git a/src/main/java/com/walkhub/walkhub/domain/badge/service/ClaimBadgeService.java b/src/main/java/com/walkhub/walkhub/domain/badge/service/ClaimBadgeService.java index 44e7bc8fc..c514bb5bd 100644 --- a/src/main/java/com/walkhub/walkhub/domain/badge/service/ClaimBadgeService.java +++ b/src/main/java/com/walkhub/walkhub/domain/badge/service/ClaimBadgeService.java @@ -1,8 +1,9 @@ package com.walkhub.walkhub.domain.badge.service; import com.walkhub.walkhub.domain.badge.domain.repository.BadgeRepository; -import com.walkhub.walkhub.domain.badge.domain.repository.vo.ClaimBadgeVO; +import com.walkhub.walkhub.domain.badge.domain.repository.vo.DefaultBadgeVO; import com.walkhub.walkhub.domain.badge.presentation.dto.response.ClaimBadgeResponse; +import com.walkhub.walkhub.domain.badge.presentation.dto.response.ClaimBadgeResponse.BadgeResponse; import com.walkhub.walkhub.domain.user.domain.User; import com.walkhub.walkhub.domain.user.facade.UserFacade; import lombok.RequiredArgsConstructor; @@ -20,10 +21,10 @@ public class ClaimBadgeService { public ClaimBadgeResponse execute() { User user = userFacade.getCurrentUser(); - List badgeResponses = new ArrayList<>(); - List claimBadgeList = badgeRepository.findAllByBadgeCollectionsNotIn(user.getId()); + List badgeResponses = new ArrayList<>(); + List claimBadgeList = badgeRepository.findAllByBadgeCollectionsNotIn(user.getId()); - for (ClaimBadgeVO vo : claimBadgeList) { + for (DefaultBadgeVO vo : claimBadgeList) { // todo 뱃지가 추가되면 그때마다 if 처리를 하겠습니다. badgeResponses.add(buildBadgeResponse(vo)); } @@ -31,8 +32,8 @@ public ClaimBadgeResponse execute() { return new ClaimBadgeResponse(badgeResponses); } - private ClaimBadgeResponse.BadgeResponse buildBadgeResponse(ClaimBadgeVO vo) { - return ClaimBadgeResponse.BadgeResponse.builder() + private BadgeResponse buildBadgeResponse(DefaultBadgeVO vo) { + return BadgeResponse.builder() .badgeId(vo.getBadgeId()) .name(vo.getName()) .imageUrl(vo.getImageUrl()) From d40a1f74a8b3265d7995a9de7c45f12daf0bcd0c Mon Sep 17 00:00:00 2001 From: lyutvs Date: Mon, 14 Feb 2022 03:30:53 +0900 Subject: [PATCH 096/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F::=20@Builder=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 --- .../domain/badge/domain/repository/vo/DefaultBadgeVO.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/vo/DefaultBadgeVO.java b/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/vo/DefaultBadgeVO.java index 4e75cb68e..9e13a48aa 100644 --- a/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/vo/DefaultBadgeVO.java +++ b/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/vo/DefaultBadgeVO.java @@ -1,6 +1,7 @@ package com.walkhub.walkhub.domain.badge.domain.repository.vo; import com.querydsl.core.annotations.QueryProjection; +import lombok.Builder; import lombok.Getter; @Getter @@ -10,6 +11,7 @@ public class DefaultBadgeVO { private final String imageUrl; @QueryProjection + @Builder public DefaultBadgeVO(Long badgeId, String name, String imageUrl) { this.badgeId = badgeId; this.name = name; From 2e252946b2539f637c3363ff7a08905946aa5b88 Mon Sep 17 00:00:00 2001 From: lyutvs Date: Mon, 14 Feb 2022 03:31:07 +0900 Subject: [PATCH 097/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F::=20BadgeController?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/badge/presentation/BadgeController.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/badge/presentation/BadgeController.java b/src/main/java/com/walkhub/walkhub/domain/badge/presentation/BadgeController.java index 2cf489ade..758183a13 100644 --- a/src/main/java/com/walkhub/walkhub/domain/badge/presentation/BadgeController.java +++ b/src/main/java/com/walkhub/walkhub/domain/badge/presentation/BadgeController.java @@ -1,9 +1,9 @@ package com.walkhub.walkhub.domain.badge.presentation; import com.walkhub.walkhub.domain.badge.presentation.dto.response.ClaimBadgeResponse; -import com.walkhub.walkhub.domain.badge.presentation.dto.response.MyBadgeListResponse; +import com.walkhub.walkhub.domain.badge.presentation.dto.response.QueryMyBadgeListResponse; import com.walkhub.walkhub.domain.badge.service.ClaimBadgeService; -import com.walkhub.walkhub.domain.badge.service.MyBadgeListService; +import com.walkhub.walkhub.domain.badge.service.QueryMyBadgeListService; import com.walkhub.walkhub.domain.badge.service.SetTitleBadgeService; import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; @@ -21,7 +21,7 @@ public class BadgeController { private final SetTitleBadgeService setTitleBadgeService; private final ClaimBadgeService claimBadgeService; - private final MyBadgeListService myBadgeListService; + private final QueryMyBadgeListService myBadgeListService; @ResponseStatus(HttpStatus.NO_CONTENT) @PutMapping("/{badge-id}") @@ -35,7 +35,7 @@ public ClaimBadgeResponse claimBadge() { } @GetMapping - public MyBadgeListResponse myBadgeList() { + public QueryMyBadgeListResponse myBadgeList() { return myBadgeListService.execute(); } From f7320877240b1e7a8791004ccd54b266b27f8c9d Mon Sep 17 00:00:00 2001 From: lyutvs Date: Mon, 14 Feb 2022 03:32:42 +0900 Subject: [PATCH 098/522] =?UTF-8?q?=F0=9F=93=91::=20QueryMyBadgeListServic?= =?UTF-8?q?e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/QueryMyBadgeListService.java | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/main/java/com/walkhub/walkhub/domain/badge/service/QueryMyBadgeListService.java diff --git a/src/main/java/com/walkhub/walkhub/domain/badge/service/QueryMyBadgeListService.java b/src/main/java/com/walkhub/walkhub/domain/badge/service/QueryMyBadgeListService.java new file mode 100644 index 000000000..6e95c5a40 --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/badge/service/QueryMyBadgeListService.java @@ -0,0 +1,40 @@ +package com.walkhub.walkhub.domain.badge.service; + +import com.walkhub.walkhub.domain.badge.domain.repository.BadgeRepository; +import com.walkhub.walkhub.domain.badge.domain.repository.vo.DefaultBadgeVO; +import com.walkhub.walkhub.domain.badge.presentation.dto.response.QueryMyBadgeListResponse; +import com.walkhub.walkhub.domain.badge.presentation.dto.response.QueryMyBadgeListResponse.BadgeListResponse; +import com.walkhub.walkhub.domain.user.domain.User; +import com.walkhub.walkhub.domain.user.facade.UserFacade; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +@RequiredArgsConstructor +@Service +public class QueryMyBadgeListService { + + private final BadgeRepository badgeRepository; + private final UserFacade userFacade; + + @Transactional(readOnly = true) + public QueryMyBadgeListResponse execute() { + User user = userFacade.getCurrentUser(); + List badgeListResponseList = new ArrayList<>(); + List badgeVOList = badgeRepository.findAllByBadgeCollections(user.getId()) + .stream() + .map(defaultBadgeVO -> DefaultBadgeVO.builder() + .badgeId(defaultBadgeVO.getBadgeId()) + .name(defaultBadgeVO.getName()) + .imageUrl(defaultBadgeVO.getImageUrl()) + .build() + ) + .collect(Collectors.toList()); + + return new QueryMyBadgeListResponse(badgeListResponseList); + } +} From 0c4f3a232aa9a01c8a59d5106a592492c91fc27f Mon Sep 17 00:00:00 2001 From: lyutvs Date: Mon, 14 Feb 2022 03:32:57 +0900 Subject: [PATCH 099/522] =?UTF-8?q?=F0=9F=93=91::=20QueryMyBadgeListRespon?= =?UTF-8?q?se?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../response/QueryMyBadgeListResponse.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/main/java/com/walkhub/walkhub/domain/badge/presentation/dto/response/QueryMyBadgeListResponse.java diff --git a/src/main/java/com/walkhub/walkhub/domain/badge/presentation/dto/response/QueryMyBadgeListResponse.java b/src/main/java/com/walkhub/walkhub/domain/badge/presentation/dto/response/QueryMyBadgeListResponse.java new file mode 100644 index 000000000..fcb6de18a --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/badge/presentation/dto/response/QueryMyBadgeListResponse.java @@ -0,0 +1,24 @@ +package com.walkhub.walkhub.domain.badge.presentation.dto.response; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; + +import java.util.List; + +@Getter +@AllArgsConstructor +public class QueryMyBadgeListResponse { + + private final List badgeLists; + + @Getter + @Builder + public static class BadgeListResponse { + private final Long id; + private final String name; + private final String imageUrl; + private final boolean isMine; + } + +} From d32d90eb9691ca647cedcd20f4e83b7115786dff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Mon, 14 Feb 2022 03:46:47 +0900 Subject: [PATCH 100/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20column=20defa?= =?UTF-8?q?ult=20=EB=AC=B8=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/walkhub/walkhub/domain/user/domain/User.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/user/domain/User.java b/src/main/java/com/walkhub/walkhub/domain/user/domain/User.java index cc5bc842c..1b817bf58 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/domain/User.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/domain/User.java @@ -97,18 +97,17 @@ public class User extends BaseTimeEntity { @JoinColumn(name = "max_level_id") private CalorieLevel maxLevel; - @NotNull @ColumnDefault("10000") + @Column(nullable = false) private Integer dailyWalkCountGoal; @OneToMany(mappedBy = "user", cascade = CascadeType.REMOVE) private List exerciseList; @Builder - public User(Long id, String accountId, String password, String phoneNumber, String name, + public User(String accountId, String password, String phoneNumber, String name, Authority authority, Section section, School school, boolean isMeasuring, - Integer weight, BigDecimal height, Sex sex, Badge badge, String deviceToken, Integer dailyWalkCountGoal) { - this.id = id; + Integer weight, BigDecimal height, Sex sex) { this.accountId = accountId; this.password = password; this.phoneNumber = phoneNumber; @@ -118,10 +117,8 @@ public User(Long id, String accountId, String password, String phoneNumber, Stri this.school = school; this.isMeasuring = isMeasuring; this.healthInfo = new HealthInfo(weight, height); + this.dailyWalkCountGoal = 10000; this.sex = sex; - this.badge = badge; - this.deviceToken = deviceToken; - this.dailyWalkCountGoal = dailyWalkCountGoal; } public void setDeviceToken(String deviceToken) { From acba9870367782bc4ac2191099cc183de266c3d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Mon, 14 Feb 2022 03:47:12 +0900 Subject: [PATCH 101/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20UserSignUpSer?= =?UTF-8?q?vice?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../walkhub/domain/user/service/UserSignUpService.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/user/service/UserSignUpService.java b/src/main/java/com/walkhub/walkhub/domain/user/service/UserSignUpService.java index 257757265..8eeae5f8d 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/service/UserSignUpService.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/service/UserSignUpService.java @@ -62,9 +62,10 @@ public UserTokenResponse execute(UserSignUpRequest request) { String refreshToken = jwtTokenProvider.generateRefreshToken(request.getAccountId()); return UserTokenResponse.builder() - .accessToken(accessToken) - .expiredAt(LocalDateTime.now().plusSeconds(jwtProperties.getAccessExp())) - .refreshToken(refreshToken) - .build(); + .accessToken(accessToken) + .expiredAt(LocalDateTime.now().plusSeconds(jwtProperties.getAccessExp())) + .refreshToken(refreshToken) + .authority(Authority.USER) + .build(); } } From 19c78299370c9817655c5a62f7b0f04fa466e128 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Mon, 14 Feb 2022 03:53:07 +0900 Subject: [PATCH 102/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20=EC=9A=B4?= =?UTF-8?q?=EB=8F=99=20=EC=8B=9C=EA=B0=84=20=EB=B0=9B=EA=B8=B0=20&=20?= =?UTF-8?q?=EC=A0=80=EC=9E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exercise/domain/ExerciseAnalysis.java | 17 ++++++++++++++--- .../request/SaveExerciseAnalysisRequest.java | 4 ++++ .../SaveOrUpdateExerciseAnalysisService.java | 1 + 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/ExerciseAnalysis.java b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/ExerciseAnalysis.java index 1e7483270..735f8539d 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/ExerciseAnalysis.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/ExerciseAnalysis.java @@ -7,7 +7,14 @@ import lombok.Getter; import lombok.NoArgsConstructor; -import javax.persistence.*; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; import java.time.LocalDate; @Getter @@ -31,17 +38,21 @@ public class ExerciseAnalysis { @Column(nullable = false) private LocalDate date; + @Column(nullable = false) + private Double exerciseTime; + @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "user_id", nullable = false) private User user; @Builder - public ExerciseAnalysis(Integer calorie, Integer walkCount, - Integer distance, LocalDate date, User user) { + public ExerciseAnalysis(Integer calorie, Integer walkCount, Integer distance, + LocalDate date, Double exerciseTime, User user) { this.calorie = calorie; this.walkCount = walkCount; this.distance = distance; this.date = date; + this.exerciseTime = exerciseTime; this.user = user; } diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/request/SaveExerciseAnalysisRequest.java b/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/request/SaveExerciseAnalysisRequest.java index b9d2677a5..2f214a3c7 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/request/SaveExerciseAnalysisRequest.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/request/SaveExerciseAnalysisRequest.java @@ -26,4 +26,8 @@ public class SaveExerciseAnalysisRequest { @NotNull(message = "calorie는 Null을 허용하지 않습니다.") private Integer calorie; + @PositiveOrZero(message = "calorie는 음수를 허용하지 않습니다.") + @NotNull(message = "exercise_time은 Null을 허용하지 않습니다") + private Double exerciseTime; + } diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/service/SaveOrUpdateExerciseAnalysisService.java b/src/main/java/com/walkhub/walkhub/domain/exercise/service/SaveOrUpdateExerciseAnalysisService.java index cde119a2d..7419816e0 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/service/SaveOrUpdateExerciseAnalysisService.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/service/SaveOrUpdateExerciseAnalysisService.java @@ -40,6 +40,7 @@ private ExerciseAnalysis buildExerciseAnalysis(SaveExerciseAnalysisRequest reque .distance(request.getDistance()) .walkCount(request.getWalkCount()) .calorie(request.getCalorie()) + .exerciseTime(request.getExerciseTime()) .user(user) .build(); } From c5d7633707d0a861a60413d6f66e53bc11b2fc65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Mon, 14 Feb 2022 03:57:48 +0900 Subject: [PATCH 103/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20refreshToken?= =?UTF-8?q?=20=EC=A0=80=EC=9E=A5=20=EB=A1=9C=EC=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../user/service/UserSignUpService.java | 29 ++++++++++--------- .../global/security/jwt/JwtTokenProvider.java | 14 +++++++-- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/user/service/UserSignUpService.java b/src/main/java/com/walkhub/walkhub/domain/user/service/UserSignUpService.java index 8eeae5f8d..00fd86ee2 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/service/UserSignUpService.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/service/UserSignUpService.java @@ -1,5 +1,6 @@ package com.walkhub.walkhub.domain.user.service; +import com.walkhub.walkhub.domain.auth.domain.repository.RefreshTokenRepository; import com.walkhub.walkhub.domain.auth.presentation.dto.response.UserTokenResponse; import com.walkhub.walkhub.domain.school.domain.School; import com.walkhub.walkhub.domain.school.domain.repository.SchoolRepository; @@ -45,18 +46,20 @@ public UserTokenResponse execute(UserSignUpRequest request) { School school = schoolRepository.findById(request.getSchoolId()) .orElseThrow(() -> SchoolNotFoundException.EXCEPTION); - userRepository.save(User.builder() - .accountId(request.getAccountId()) - .password(passwordEncoder.encode(request.getPassword())) - .phoneNumber(request.getPhoneNumber()) - .authority(Authority.USER) - .name(request.getName()) - .school(school) - .height(request.getHeight()) - .weight(request.getWeight()) - .sex(request.getSex()) - .isMeasuring(false) - .build()); + User user = User.builder() + .accountId(request.getAccountId()) + .password(passwordEncoder.encode(request.getPassword())) + .phoneNumber(request.getPhoneNumber()) + .authority(Authority.USER) + .name(request.getName()) + .school(school) + .height(request.getHeight()) + .weight(request.getWeight()) + .sex(request.getSex()) + .isMeasuring(false) + .build(); + + userRepository.save(user); String accessToken = jwtTokenProvider.generateAccessToken(request.getAccountId()); String refreshToken = jwtTokenProvider.generateRefreshToken(request.getAccountId()); @@ -65,7 +68,7 @@ public UserTokenResponse execute(UserSignUpRequest request) { .accessToken(accessToken) .expiredAt(LocalDateTime.now().plusSeconds(jwtProperties.getAccessExp())) .refreshToken(refreshToken) - .authority(Authority.USER) + .authority(user.getAuthority()) .build(); } } diff --git a/src/main/java/com/walkhub/walkhub/global/security/jwt/JwtTokenProvider.java b/src/main/java/com/walkhub/walkhub/global/security/jwt/JwtTokenProvider.java index 3662b066e..fbaa4bfb8 100644 --- a/src/main/java/com/walkhub/walkhub/global/security/jwt/JwtTokenProvider.java +++ b/src/main/java/com/walkhub/walkhub/global/security/jwt/JwtTokenProvider.java @@ -1,5 +1,7 @@ package com.walkhub.walkhub.global.security.jwt; +import com.walkhub.walkhub.domain.auth.domain.RefreshToken; +import com.walkhub.walkhub.domain.auth.domain.repository.RefreshTokenRepository; import com.walkhub.walkhub.global.exception.ExpiredJwtException; import com.walkhub.walkhub.global.exception.InvalidJwtException; import com.walkhub.walkhub.global.security.auth.AuthDetailsService; @@ -21,13 +23,21 @@ public class JwtTokenProvider { private final JwtProperties jwtProperties; private final AuthDetailsService authDetailsService; + private final RefreshTokenRepository refreshTokenRepository; public String generateAccessToken(String id) { return generateToken(id, "access", jwtProperties.getAccessExp()); } public String generateRefreshToken(String id) { - return generateToken(id, "refresh", jwtProperties.getRefreshExp()); + String refreshToken = generateToken(id, "refresh", jwtProperties.getRefreshExp()); + refreshTokenRepository.save(RefreshToken.builder() + .accountId(id) + .token(refreshToken) + .timeToLive(jwtProperties.getRefreshExp()) + .build()); + + return refreshToken; } private String generateToken(String id, String type, Long exp) { @@ -36,7 +46,7 @@ private String generateToken(String id, String type, Long exp) { .setSubject(id) .claim("type", type) .setIssuedAt(new Date()) - .setExpiration(new Date(System.currentTimeMillis() + exp)) + .setExpiration(new Date(System.currentTimeMillis() + exp * 1000)) .compact(); } From 63412513be2e6b0ca34eeef0733acfb6793702dd Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Mon, 14 Feb 2022 03:59:18 +0900 Subject: [PATCH 104/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20calorie=20typ?= =?UTF-8?q?e=EC=9D=84=20INTGER=20->=20DOUBLE=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../walkhub/domain/exercise/domain/Exercise.java | 10 ++++------ .../dto/request/FinishExerciseRequest.java | 4 +++- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/Exercise.java b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/Exercise.java index 867d2d65f..75eb65f00 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/Exercise.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/Exercise.java @@ -4,12 +4,11 @@ import com.walkhub.walkhub.domain.user.domain.User; import com.walkhub.walkhub.global.entity.BaseTimeEntity; import com.walkhub.walkhub.infrastructure.image.DefaultImage; -import javax.validation.constraints.NotNull; import lombok.AccessLevel; import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; -import org.hibernate.annotations.ColumnDefault; +import org.hibernate.annotations.DynamicInsert; import javax.persistence.Column; import javax.persistence.Entity; @@ -21,9 +20,8 @@ import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; +import javax.validation.constraints.NotNull; import java.time.LocalDateTime; -import org.hibernate.annotations.DynamicInsert; -import org.hibernate.validator.constraints.Length; @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) @@ -44,7 +42,7 @@ public class Exercise extends BaseTimeEntity { private Integer distance; @Column(nullable = false, columnDefinition = "integer default 0") - private Integer calorie; + private Double calorie; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "user_id", nullable = false) @@ -74,7 +72,7 @@ public Exercise(User user, Integer goal, GoalType goalType) { this.isExercising = true; } - public void closeExercise(Integer walkCount, Integer distance, Integer calorie) { + public void closeExercise(Integer walkCount, Integer distance, Double calorie) { this.walkCount = walkCount; this.distance = distance; this.calorie = calorie; diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/request/FinishExerciseRequest.java b/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/request/FinishExerciseRequest.java index 26ae35312..0ea97332a 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/request/FinishExerciseRequest.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/request/FinishExerciseRequest.java @@ -5,6 +5,7 @@ import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; +import javax.validation.constraints.PositiveOrZero; import java.util.List; @Getter @@ -17,8 +18,9 @@ public class FinishExerciseRequest { @NotNull(message = "distance는 null, 공백을 허용하지 않습니다.") private Integer distance; + @PositiveOrZero(message = "calorie는 음수일 수 없습니다.") @NotNull(message = "calorie는 null, 공백을 허용하지 않습니다.") - private Integer calorie; + private Double calorie; @NotEmpty(message = "image_url은 공백을 허용하지 않습니다.") private List imageUrl; From 3d22d4432e27241384e3cb0b90a8b9dac45f7da5 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Mon, 14 Feb 2022 04:01:43 +0900 Subject: [PATCH 105/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20Integer=20->?= =?UTF-8?q?=20Double=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/user/domain/CalorieLevel.java | 64 +++++++++---------- .../response/CalorieLevelListResponse.java | 2 +- 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/user/domain/CalorieLevel.java b/src/main/java/com/walkhub/walkhub/domain/user/domain/CalorieLevel.java index 6e2f0931b..779da1798 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/domain/CalorieLevel.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/domain/CalorieLevel.java @@ -1,54 +1,54 @@ package com.walkhub.walkhub.domain.user.domain; +import lombok.AccessLevel; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import org.hibernate.validator.constraints.Length; + import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.validation.constraints.NotNull; -import lombok.AccessLevel; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; -import org.hibernate.validator.constraints.Length; @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) @Entity public class CalorieLevel { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; - @NotNull - @Length(max = 10) - private String foodName; + @NotNull + @Length(max = 10) + private String foodName; - @NotNull - private Integer size; + @NotNull + private Integer size; - @NotNull - private String message; + @NotNull + private String message; - @NotNull - private String foodImageUrl; + @NotNull + private String foodImageUrl; - @NotNull - @Column(columnDefinition = "TINYINT") - private Integer level; + @NotNull + @Column(columnDefinition = "TINYINT") + private Integer level; - @NotNull - private Integer calorie; + @NotNull + private Double calorie; - @Builder - public CalorieLevel(String foodName, Integer size, String message, String foodImageUrl, Integer level, - Integer calorie) { - this.foodName = foodName; - this.size = size; - this.message = message; - this.foodImageUrl = foodImageUrl; - this.level = level; - this.calorie = calorie; - } + @Builder + public CalorieLevel(String foodName, Integer size, String message, String foodImageUrl, Integer level, Double calorie) { + this.foodName = foodName; + this.size = size; + this.message = message; + this.foodImageUrl = foodImageUrl; + this.level = level; + this.calorie = calorie; + } } diff --git a/src/main/java/com/walkhub/walkhub/domain/user/presentation/dto/response/CalorieLevelListResponse.java b/src/main/java/com/walkhub/walkhub/domain/user/presentation/dto/response/CalorieLevelListResponse.java index b97865551..2fcd74bf0 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/presentation/dto/response/CalorieLevelListResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/presentation/dto/response/CalorieLevelListResponse.java @@ -18,7 +18,7 @@ public static class CalorieLevelResponse { private final Long levelId; private final String foodImageUrl; private final String foodName; - private final Integer calorie; + private final Double calorie; private final Integer size; private final Integer level; private final String message; From cb6cec687e6c9a636737d0086f0a2dc41ee7e110 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Mon, 14 Feb 2022 04:26:36 +0900 Subject: [PATCH 106/522] =?UTF-8?q?=F0=9F=90=9B=20::=20enum=20validation?= =?UTF-8?q?=20error?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/walkhub/walkhub/domain/challenge/domain/Challenge.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/Challenge.java b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/Challenge.java index 9381d58a0..6cb768d44 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/Challenge.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/Challenge.java @@ -57,17 +57,14 @@ public class Challenge { private String award; @NotNull - @Length(max = 6) @Enumerated(EnumType.STRING) private UserScope userScope; @NotNull - @Length(max = 3) @Enumerated(EnumType.STRING) private GoalScope goalScope; @NotNull - @Length(max = 8) @Enumerated(EnumType.STRING) private GoalType goalType; From b0b249f4ab4aae29fc5c20b53796a07d1cdd7abc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Mon, 14 Feb 2022 04:26:49 +0900 Subject: [PATCH 107/522] =?UTF-8?q?=F0=9F=90=9B=20::=20user=20builder=20?= =?UTF-8?q?=EC=98=A4=EB=A5=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../walkhub/domain/challenge/service/CreateChallengeService.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/service/CreateChallengeService.java b/src/main/java/com/walkhub/walkhub/domain/challenge/service/CreateChallengeService.java index 98216cb79..48f7ef5d6 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/service/CreateChallengeService.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/service/CreateChallengeService.java @@ -24,6 +24,7 @@ public void execute(CreateChallengeRequest request) { UserScope userScope = user.getAuthority() == Authority.SU ? UserScope.ALL : request.getUserScope(); challengeRepository.save(Challenge.builder() + .user(user) .name(request.getName()) .content(request.getContent()) .imageUrl(request.getImageUrl()) From 873a50ec6b74c25a3fbd26969f3951a70f346f7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Mon, 14 Feb 2022 05:36:05 +0900 Subject: [PATCH 108/522] =?UTF-8?q?=F0=9F=93=91=20::=20DateType=20enum=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 --- .../walkhub/walkhub/domain/rank/domain/type/DateType.java | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 src/main/java/com/walkhub/walkhub/domain/rank/domain/type/DateType.java diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/domain/type/DateType.java b/src/main/java/com/walkhub/walkhub/domain/rank/domain/type/DateType.java new file mode 100644 index 000000000..9de490b40 --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/rank/domain/type/DateType.java @@ -0,0 +1,6 @@ +package com.walkhub.walkhub.domain.rank.domain.type; + +public enum DateType { + WEEK, + MONTH +} From 3af4f00e9f0ea3b26f1d73ef3890aaf6661e2d35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Mon, 14 Feb 2022 05:36:22 +0900 Subject: [PATCH 109/522] =?UTF-8?q?=F0=9F=93=91=20::=20SchoolRankResponse?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/response/SchoolRankResponse.java | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/main/java/com/walkhub/walkhub/domain/rank/presentation/dto/response/SchoolRankResponse.java diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/presentation/dto/response/SchoolRankResponse.java b/src/main/java/com/walkhub/walkhub/domain/rank/presentation/dto/response/SchoolRankResponse.java new file mode 100644 index 000000000..44beea5ef --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/rank/presentation/dto/response/SchoolRankResponse.java @@ -0,0 +1,36 @@ +package com.walkhub.walkhub.domain.rank.presentation.dto.response; + +import java.util.List; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public class SchoolRankResponse { + + private final MySchoolResponse mySchoolRank; + private final List schoolList; + + @Getter + @Builder + public static class MySchoolResponse { + private final Long schoolId; + private final String name; + private final String logoImageUrl; + private final Integer walkCount; + private final Integer grade; + private final Integer classNum; + } + + @Getter + @Builder + public static class SchoolResponse { + private final Long schoolId; + private final String name; + private final Integer rank; + private final Long studentCount; + private final String logoImageUrl; + private final Integer walkCount; + } +} From 2e985dccb14704feeff683f2fcc63739e1687339 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Mon, 14 Feb 2022 05:36:37 +0900 Subject: [PATCH 110/522] =?UTF-8?q?=F0=9F=93=91=20::=20QuerySchoolRankServ?= =?UTF-8?q?ice?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rank/service/QuerySchoolRankService.java | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 src/main/java/com/walkhub/walkhub/domain/rank/service/QuerySchoolRankService.java diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/service/QuerySchoolRankService.java b/src/main/java/com/walkhub/walkhub/domain/rank/service/QuerySchoolRankService.java new file mode 100644 index 000000000..d37dae98c --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/rank/service/QuerySchoolRankService.java @@ -0,0 +1,61 @@ +package com.walkhub.walkhub.domain.rank.service; + +import com.walkhub.walkhub.domain.rank.domain.SchoolRank; +import com.walkhub.walkhub.domain.rank.domain.repository.SchoolRankRepository; +import com.walkhub.walkhub.domain.rank.domain.type.DateType; +import com.walkhub.walkhub.domain.rank.presentation.dto.response.SchoolRankResponse; +import com.walkhub.walkhub.domain.rank.presentation.dto.response.SchoolRankResponse.MySchoolResponse; +import com.walkhub.walkhub.domain.rank.presentation.dto.response.SchoolRankResponse.SchoolResponse; +import com.walkhub.walkhub.domain.user.domain.User; +import com.walkhub.walkhub.domain.user.facade.UserFacade; +import java.time.LocalDate; +import java.util.List; +import java.util.stream.Collectors; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +@RequiredArgsConstructor +@Service +public class QuerySchoolRankService { + + private final SchoolRankRepository schoolRankRepository; + private final UserFacade userFacade; + + public SchoolRankResponse execute(DateType dateType) { + LocalDate localDate = LocalDate.now(); + switch (dateType) { + case WEEK: localDate = localDate.minusWeeks(1); + break; + case MONTH: localDate = localDate.minusMonths(1); + break; + } + + User user = userFacade.getCurrentUser(); + SchoolRank schoolRank = schoolRankRepository. + findBySchoolIdAndDateTypeAndCreatedAtBetween(user.getSchool().getId(), dateType.toString(), localDate, LocalDate.now()); + + MySchoolResponse mySchoolResponse = MySchoolResponse.builder() + .schoolId(schoolRank.getSchoolId()) + .name(schoolRank.getName()) + .logoImageUrl(schoolRank.getLogoImageUrl()) + .walkCount(schoolRank.getWalkCount()) + .grade(user.getSection().getGrade()) + .classNum(user.getSection().getClassNum()) + .build(); + + List schoolResponseList = schoolRankRepository + .findAllByDateTypeAndCreatedAtBetween(dateType.toString(), localDate, LocalDate.now()) + .stream() + .map(schoolRank -> SchoolResponse.builder() + .schoolId(schoolRank.getSchoolId()) + .name(schoolRank.getName()) + .rank(schoolRank.getRanking()) + .studentCount(schoolRank.getUserCount()) + .logoImageUrl(schoolRank.getLogoImageUrl()) + .walkCount(schoolRank.getWalkCount()) + .build()) + .collect(Collectors.toList()); + + return new SchoolRankResponse(mySchoolResponse, schoolResponseList); + } +} From 0946d9c46b98ae32227e3620296c312efc9dc67f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Mon, 14 Feb 2022 05:36:50 +0900 Subject: [PATCH 111/522] =?UTF-8?q?=E2=9A=A1=20::=20SchoolRankRepository?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/rank/domain/repository/SchoolRankRepository.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/SchoolRankRepository.java b/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/SchoolRankRepository.java index e7e00f334..e256e7a03 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/SchoolRankRepository.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/SchoolRankRepository.java @@ -2,7 +2,12 @@ import com.walkhub.walkhub.domain.rank.domain.SchoolRank; import com.walkhub.walkhub.domain.rank.domain.SchoolRankId; +import java.time.LocalDate; +import java.util.List; import org.springframework.data.repository.CrudRepository; public interface SchoolRankRepository extends CrudRepository { + SchoolRank findBySchoolIdAndDateTypeAndCreatedAtBetween(Long schoolId, + String dateType, LocalDate createdAt, LocalDate createdAt2); + List findAllByDateTypeAndCreatedAtBetween(String dateType, LocalDate createdAt, LocalDate createdAt2); } From d38e0f24ca23d673c7e45fd5842577370e2d8af9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Mon, 14 Feb 2022 05:36:59 +0900 Subject: [PATCH 112/522] =?UTF-8?q?=E2=9A=A1=20::=20RankController?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../walkhub/domain/rank/presentation/RankController.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/presentation/RankController.java b/src/main/java/com/walkhub/walkhub/domain/rank/presentation/RankController.java index 3a970fdb0..03d4a9402 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/presentation/RankController.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/presentation/RankController.java @@ -1,6 +1,8 @@ package com.walkhub.walkhub.domain.rank.presentation; +import com.walkhub.walkhub.domain.rank.presentation.dto.response.SchoolRankResponse; import com.walkhub.walkhub.domain.rank.presentation.dto.response.UserListResponse; +import com.walkhub.walkhub.domain.rank.service.QuerySchoolRankService; import com.walkhub.walkhub.domain.rank.service.UserSearchService; import com.walkhub.walkhub.global.enums.DateType; import lombok.RequiredArgsConstructor; @@ -16,6 +18,7 @@ public class RankController { private final UserSearchService userSearchService; + private final QuerySchoolRankService querySchoolRankService; @GetMapping("/users/search/{school-id}") public UserListResponse userSearch(@PathVariable("school-id") Long schoolId, @@ -23,4 +26,9 @@ public UserListResponse userSearch(@PathVariable("school-id") Long schoolId, @RequestParam DateType dateType) { return userSearchService.execute(schoolId, name, dateType); } + + @GetMapping("/schools") + public SchoolRankResponse querySchoolRank(@RequestParam com.walkhub.walkhub.domain.rank.domain.type.DateType dateType) { + return querySchoolRankService.execute(dateType); + } } From 1027c4529f014e8e735c97c7b4779d95ec2cb5af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Mon, 14 Feb 2022 08:36:44 +0900 Subject: [PATCH 113/522] =?UTF-8?q?=F0=9F=90=9B=20::=20=EC=9D=B4=EB=A6=84?= =?UTF-8?q?=20=EC=A4=91=EB=B3=B5=20=EB=B2=84=EA=B7=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rank/service/QuerySchoolRankService.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/service/QuerySchoolRankService.java b/src/main/java/com/walkhub/walkhub/domain/rank/service/QuerySchoolRankService.java index d37dae98c..385067abc 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/service/QuerySchoolRankService.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/service/QuerySchoolRankService.java @@ -46,13 +46,13 @@ public SchoolRankResponse execute(DateType dateType) { List schoolResponseList = schoolRankRepository .findAllByDateTypeAndCreatedAtBetween(dateType.toString(), localDate, LocalDate.now()) .stream() - .map(schoolRank -> SchoolResponse.builder() - .schoolId(schoolRank.getSchoolId()) - .name(schoolRank.getName()) - .rank(schoolRank.getRanking()) - .studentCount(schoolRank.getUserCount()) - .logoImageUrl(schoolRank.getLogoImageUrl()) - .walkCount(schoolRank.getWalkCount()) + .map(schoolRank2 -> SchoolResponse.builder() + .schoolId(schoolRank2.getSchoolId()) + .name(schoolRank2.getName()) + .rank(schoolRank2.getRanking()) + .studentCount(schoolRank2.getUserCount()) + .logoImageUrl(schoolRank2.getLogoImageUrl()) + .walkCount(schoolRank2.getWalkCount()) .build()) .collect(Collectors.toList()); From 77e9f46790799746d5e594953a24feaf509f2b58 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Mon, 14 Feb 2022 08:42:29 +0900 Subject: [PATCH 114/522] =?UTF-8?q?:recycle:=20::=20=EC=A4=84=EB=B0=94?= =?UTF-8?q?=EA=BF=88=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exception/AlreadyExercisingException.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/exception/AlreadyExercisingException.java b/src/main/java/com/walkhub/walkhub/domain/exercise/exception/AlreadyExercisingException.java index 2e6f8ffc8..c8e0276aa 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/exception/AlreadyExercisingException.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/exception/AlreadyExercisingException.java @@ -5,12 +5,11 @@ public class AlreadyExercisingException extends WalkhubException { + public static final WalkhubException EXCEPTION = + new AlreadyExercisingException(); - public static final WalkhubException EXCEPTION = - new AlreadyExercisingException(); - - private AlreadyExercisingException() { - super(ErrorCode.ALREADY_EXERCISING); - } + private AlreadyExercisingException() { + super(ErrorCode.ALREADY_EXERCISING); + } } From a5b40f3979eff0fef93315768a68652964e779ef Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Mon, 14 Feb 2022 08:43:29 +0900 Subject: [PATCH 115/522] =?UTF-8?q?:recycle:=20::=20message=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 --- .../presentation/dto/request/SaveExerciseAnalysisRequest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/request/SaveExerciseAnalysisRequest.java b/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/request/SaveExerciseAnalysisRequest.java index 2f214a3c7..83f89ebe9 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/request/SaveExerciseAnalysisRequest.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/request/SaveExerciseAnalysisRequest.java @@ -26,7 +26,7 @@ public class SaveExerciseAnalysisRequest { @NotNull(message = "calorie는 Null을 허용하지 않습니다.") private Integer calorie; - @PositiveOrZero(message = "calorie는 음수를 허용하지 않습니다.") + @PositiveOrZero(message = "exercise_time은 음수를 허용하지 않습니다.") @NotNull(message = "exercise_time은 Null을 허용하지 않습니다") private Double exerciseTime; From 3e5f4e6584b6acf975cf49c6dc0c68f74fedbbb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Mon, 14 Feb 2022 08:45:50 +0900 Subject: [PATCH 116/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/rank/domain/repository/SchoolRankRepository.java | 2 +- .../walkhub/domain/rank/service/QuerySchoolRankService.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/SchoolRankRepository.java b/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/SchoolRankRepository.java index e256e7a03..4fd463d2c 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/SchoolRankRepository.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/SchoolRankRepository.java @@ -9,5 +9,5 @@ public interface SchoolRankRepository extends CrudRepository { SchoolRank findBySchoolIdAndDateTypeAndCreatedAtBetween(Long schoolId, String dateType, LocalDate createdAt, LocalDate createdAt2); - List findAllByDateTypeAndCreatedAtBetween(String dateType, LocalDate createdAt, LocalDate createdAt2); + List findAllByDateTypeAndCreatedAtBetweenOrderByRankingDesc(String dateType, LocalDate createdAt, LocalDate createdAt2); } diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/service/QuerySchoolRankService.java b/src/main/java/com/walkhub/walkhub/domain/rank/service/QuerySchoolRankService.java index 385067abc..ee6f57293 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/service/QuerySchoolRankService.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/service/QuerySchoolRankService.java @@ -44,7 +44,7 @@ public SchoolRankResponse execute(DateType dateType) { .build(); List schoolResponseList = schoolRankRepository - .findAllByDateTypeAndCreatedAtBetween(dateType.toString(), localDate, LocalDate.now()) + .findAllByDateTypeAndCreatedAtBetweenOrderByRankingDesc(dateType.toString(), localDate, LocalDate.now()) .stream() .map(schoolRank2 -> SchoolResponse.builder() .schoolId(schoolRank2.getSchoolId()) From bd9dd81f4bdf766ebe1212a4e57f50e07e28ab47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Mon, 14 Feb 2022 08:50:26 +0900 Subject: [PATCH 117/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20DateType=20->?= =?UTF-8?q?=20SchoolDateType?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/type/{DateType.java => SchoolDateType.java} | 2 +- .../domain/rank/presentation/RankController.java | 5 +++-- .../domain/rank/service/QuerySchoolRankService.java | 10 +++++----- 3 files changed, 9 insertions(+), 8 deletions(-) rename src/main/java/com/walkhub/walkhub/domain/rank/domain/type/{DateType.java => SchoolDateType.java} (70%) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/domain/type/DateType.java b/src/main/java/com/walkhub/walkhub/domain/rank/domain/type/SchoolDateType.java similarity index 70% rename from src/main/java/com/walkhub/walkhub/domain/rank/domain/type/DateType.java rename to src/main/java/com/walkhub/walkhub/domain/rank/domain/type/SchoolDateType.java index 9de490b40..031b95a2b 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/domain/type/DateType.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/domain/type/SchoolDateType.java @@ -1,6 +1,6 @@ package com.walkhub.walkhub.domain.rank.domain.type; -public enum DateType { +public enum SchoolDateType { WEEK, MONTH } diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/presentation/RankController.java b/src/main/java/com/walkhub/walkhub/domain/rank/presentation/RankController.java index 03d4a9402..40aa183af 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/presentation/RankController.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/presentation/RankController.java @@ -1,5 +1,6 @@ package com.walkhub.walkhub.domain.rank.presentation; +import com.walkhub.walkhub.domain.rank.domain.type.SchoolDateType; import com.walkhub.walkhub.domain.rank.presentation.dto.response.SchoolRankResponse; import com.walkhub.walkhub.domain.rank.presentation.dto.response.UserListResponse; import com.walkhub.walkhub.domain.rank.service.QuerySchoolRankService; @@ -28,7 +29,7 @@ public UserListResponse userSearch(@PathVariable("school-id") Long schoolId, } @GetMapping("/schools") - public SchoolRankResponse querySchoolRank(@RequestParam com.walkhub.walkhub.domain.rank.domain.type.DateType dateType) { - return querySchoolRankService.execute(dateType); + public SchoolRankResponse querySchoolRank(@RequestParam SchoolDateType schoolDateType) { + return querySchoolRankService.execute(schoolDateType); } } diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/service/QuerySchoolRankService.java b/src/main/java/com/walkhub/walkhub/domain/rank/service/QuerySchoolRankService.java index ee6f57293..de314f077 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/service/QuerySchoolRankService.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/service/QuerySchoolRankService.java @@ -2,7 +2,7 @@ import com.walkhub.walkhub.domain.rank.domain.SchoolRank; import com.walkhub.walkhub.domain.rank.domain.repository.SchoolRankRepository; -import com.walkhub.walkhub.domain.rank.domain.type.DateType; +import com.walkhub.walkhub.domain.rank.domain.type.SchoolDateType; import com.walkhub.walkhub.domain.rank.presentation.dto.response.SchoolRankResponse; import com.walkhub.walkhub.domain.rank.presentation.dto.response.SchoolRankResponse.MySchoolResponse; import com.walkhub.walkhub.domain.rank.presentation.dto.response.SchoolRankResponse.SchoolResponse; @@ -21,9 +21,9 @@ public class QuerySchoolRankService { private final SchoolRankRepository schoolRankRepository; private final UserFacade userFacade; - public SchoolRankResponse execute(DateType dateType) { + public SchoolRankResponse execute(SchoolDateType schoolDateType) { LocalDate localDate = LocalDate.now(); - switch (dateType) { + switch (schoolDateType) { case WEEK: localDate = localDate.minusWeeks(1); break; case MONTH: localDate = localDate.minusMonths(1); @@ -32,7 +32,7 @@ public SchoolRankResponse execute(DateType dateType) { User user = userFacade.getCurrentUser(); SchoolRank schoolRank = schoolRankRepository. - findBySchoolIdAndDateTypeAndCreatedAtBetween(user.getSchool().getId(), dateType.toString(), localDate, LocalDate.now()); + findBySchoolIdAndDateTypeAndCreatedAtBetween(user.getSchool().getId(), schoolDateType.toString(), localDate, LocalDate.now()); MySchoolResponse mySchoolResponse = MySchoolResponse.builder() .schoolId(schoolRank.getSchoolId()) @@ -44,7 +44,7 @@ public SchoolRankResponse execute(DateType dateType) { .build(); List schoolResponseList = schoolRankRepository - .findAllByDateTypeAndCreatedAtBetweenOrderByRankingDesc(dateType.toString(), localDate, LocalDate.now()) + .findAllByDateTypeAndCreatedAtBetweenOrderByRankingDesc(schoolDateType.toString(), localDate, LocalDate.now()) .stream() .map(schoolRank2 -> SchoolResponse.builder() .schoolId(schoolRank2.getSchoolId()) From 1d44ff0d7dafda6e7c4a8884e6b169273f8300cd Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Mon, 14 Feb 2022 08:51:12 +0900 Subject: [PATCH 118/522] =?UTF-8?q?:recycle:=20::=20length=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 --- .../walkhub/domain/challenge/domain/Challenge.java | 14 ++++++++------ .../walkhub/domain/notice/domain/Notice.java | 1 + .../walkhub/domain/user/domain/CalorieLevel.java | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/Challenge.java b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/Challenge.java index 6cb768d44..2d9ac7d71 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/Challenge.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/Challenge.java @@ -6,18 +6,13 @@ import com.walkhub.walkhub.domain.user.domain.User; import com.walkhub.walkhub.global.enums.UserScope; import com.walkhub.walkhub.infrastructure.image.DefaultImage; -import java.time.LocalDateTime; -import java.util.List; -import javax.persistence.CascadeType; -import javax.persistence.OneToMany; -import javax.validation.constraints.NotNull; import lombok.AccessLevel; import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; import org.hibernate.annotations.ColumnDefault; -import org.hibernate.validator.constraints.Length; +import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.EnumType; @@ -28,6 +23,10 @@ import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; +import javax.persistence.OneToMany; +import javax.validation.constraints.NotNull; +import java.time.LocalDateTime; +import java.util.List; @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) @@ -58,14 +57,17 @@ public class Challenge { @NotNull @Enumerated(EnumType.STRING) + @Column(length = 6) private UserScope userScope; @NotNull @Enumerated(EnumType.STRING) + @Column(length = 3) private GoalScope goalScope; @NotNull @Enumerated(EnumType.STRING) + @Column(length = 8) private GoalType goalType; @NotNull diff --git a/src/main/java/com/walkhub/walkhub/domain/notice/domain/Notice.java b/src/main/java/com/walkhub/walkhub/domain/notice/domain/Notice.java index d1cdb1cc0..d39e7cd3c 100644 --- a/src/main/java/com/walkhub/walkhub/domain/notice/domain/Notice.java +++ b/src/main/java/com/walkhub/walkhub/domain/notice/domain/Notice.java @@ -38,6 +38,7 @@ public class Notice extends BaseTimeEntity { @NotNull @Enumerated(EnumType.STRING) + @Column(length = 6) private Scope scope; @ManyToOne(fetch = FetchType.LAZY) diff --git a/src/main/java/com/walkhub/walkhub/domain/user/domain/CalorieLevel.java b/src/main/java/com/walkhub/walkhub/domain/user/domain/CalorieLevel.java index 779da1798..e96e3c2f7 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/domain/CalorieLevel.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/domain/CalorieLevel.java @@ -23,7 +23,7 @@ public class CalorieLevel { private Long id; @NotNull - @Length(max = 10) + @Column(length = 10) private String foodName; @NotNull From 6faf278be324b600296ae5c2dc1cc96dc067cc23 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Mon, 14 Feb 2022 08:55:22 +0900 Subject: [PATCH 119/522] =?UTF-8?q?:recycle:=20::=20Code=20Smells=20?= =?UTF-8?q?=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../walkhub/domain/notice/domain/Notice.java | 3 +- .../notice/service/CreateNoticeService.java | 3 +- .../school/presentation/SchoolController.java | 1 - .../domain/user/domain/CalorieLevel.java | 1 - .../user/service/UserSignUpService.java | 33 +++++++++---------- 5 files changed, 18 insertions(+), 23 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/notice/domain/Notice.java b/src/main/java/com/walkhub/walkhub/domain/notice/domain/Notice.java index d39e7cd3c..9228a9ad2 100644 --- a/src/main/java/com/walkhub/walkhub/domain/notice/domain/Notice.java +++ b/src/main/java/com/walkhub/walkhub/domain/notice/domain/Notice.java @@ -3,7 +3,6 @@ import com.walkhub.walkhub.domain.notice.domain.type.Scope; import com.walkhub.walkhub.domain.user.domain.User; import com.walkhub.walkhub.global.entity.BaseTimeEntity; -import javax.validation.constraints.NotNull; import lombok.AccessLevel; import lombok.Builder; import lombok.Getter; @@ -19,7 +18,7 @@ import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; -import org.hibernate.validator.constraints.Length; +import javax.validation.constraints.NotNull; @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) diff --git a/src/main/java/com/walkhub/walkhub/domain/notice/service/CreateNoticeService.java b/src/main/java/com/walkhub/walkhub/domain/notice/service/CreateNoticeService.java index 16af789e8..fbc1f978a 100644 --- a/src/main/java/com/walkhub/walkhub/domain/notice/service/CreateNoticeService.java +++ b/src/main/java/com/walkhub/walkhub/domain/notice/service/CreateNoticeService.java @@ -5,7 +5,6 @@ import com.walkhub.walkhub.domain.notice.domain.type.Scope; import com.walkhub.walkhub.domain.notice.presentation.dto.request.CreateNoticeRequest; import com.walkhub.walkhub.domain.user.domain.User; -import com.walkhub.walkhub.domain.user.exception.SectionNotFoundException; import com.walkhub.walkhub.domain.user.facade.UserFacade; import com.walkhub.walkhub.global.enums.Authority; import com.walkhub.walkhub.global.exception.InvalidRoleException; @@ -25,7 +24,7 @@ public void execute(CreateNoticeRequest request) { User user = userFacade.getCurrentUser(); if (request.getScope().equals(Scope.SCHOOL) && !user.getAuthority().equals(Authority.ROOT) || - request.getScope().equals(Scope.ALL) && !user.getAuthority().equals(Authority.SU)) { + request.getScope().equals(Scope.ALL) && !user.getAuthority().equals(Authority.SU)) { throw InvalidRoleException.EXCEPTION; } diff --git a/src/main/java/com/walkhub/walkhub/domain/school/presentation/SchoolController.java b/src/main/java/com/walkhub/walkhub/domain/school/presentation/SchoolController.java index 59639dec7..6197eefa6 100644 --- a/src/main/java/com/walkhub/walkhub/domain/school/presentation/SchoolController.java +++ b/src/main/java/com/walkhub/walkhub/domain/school/presentation/SchoolController.java @@ -8,7 +8,6 @@ import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PatchMapping; -import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; diff --git a/src/main/java/com/walkhub/walkhub/domain/user/domain/CalorieLevel.java b/src/main/java/com/walkhub/walkhub/domain/user/domain/CalorieLevel.java index e96e3c2f7..b098d0a9c 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/domain/CalorieLevel.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/domain/CalorieLevel.java @@ -4,7 +4,6 @@ import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; -import org.hibernate.validator.constraints.Length; import javax.persistence.Column; import javax.persistence.Entity; diff --git a/src/main/java/com/walkhub/walkhub/domain/user/service/UserSignUpService.java b/src/main/java/com/walkhub/walkhub/domain/user/service/UserSignUpService.java index 00fd86ee2..c52d15633 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/service/UserSignUpService.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/service/UserSignUpService.java @@ -1,6 +1,5 @@ package com.walkhub.walkhub.domain.user.service; -import com.walkhub.walkhub.domain.auth.domain.repository.RefreshTokenRepository; import com.walkhub.walkhub.domain.auth.presentation.dto.response.UserTokenResponse; import com.walkhub.walkhub.domain.school.domain.School; import com.walkhub.walkhub.domain.school.domain.repository.SchoolRepository; @@ -47,17 +46,17 @@ public UserTokenResponse execute(UserSignUpRequest request) { .orElseThrow(() -> SchoolNotFoundException.EXCEPTION); User user = User.builder() - .accountId(request.getAccountId()) - .password(passwordEncoder.encode(request.getPassword())) - .phoneNumber(request.getPhoneNumber()) - .authority(Authority.USER) - .name(request.getName()) - .school(school) - .height(request.getHeight()) - .weight(request.getWeight()) - .sex(request.getSex()) - .isMeasuring(false) - .build(); + .accountId(request.getAccountId()) + .password(passwordEncoder.encode(request.getPassword())) + .phoneNumber(request.getPhoneNumber()) + .authority(Authority.USER) + .name(request.getName()) + .school(school) + .height(request.getHeight()) + .weight(request.getWeight()) + .sex(request.getSex()) + .isMeasuring(false) + .build(); userRepository.save(user); @@ -65,10 +64,10 @@ public UserTokenResponse execute(UserSignUpRequest request) { String refreshToken = jwtTokenProvider.generateRefreshToken(request.getAccountId()); return UserTokenResponse.builder() - .accessToken(accessToken) - .expiredAt(LocalDateTime.now().plusSeconds(jwtProperties.getAccessExp())) - .refreshToken(refreshToken) - .authority(user.getAuthority()) - .build(); + .accessToken(accessToken) + .expiredAt(LocalDateTime.now().plusSeconds(jwtProperties.getAccessExp())) + .refreshToken(refreshToken) + .authority(user.getAuthority()) + .build(); } } From ac01eafe3ac3f43ddc4466e38b9011ade39aa8ab Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Mon, 14 Feb 2022 08:57:09 +0900 Subject: [PATCH 120/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20name=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/com/walkhub/walkhub/domain/user/domain/User.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/user/domain/User.java b/src/main/java/com/walkhub/walkhub/domain/user/domain/User.java index 1b817bf58..6a8e2048f 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/domain/User.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/domain/User.java @@ -155,7 +155,7 @@ public void setAuthorityTeacher() { this.authority = Authority.TEACHER; } - public void updatedailyWalkCountGoal(Integer dailyWalkCountGoal) { + public void updateDailyWalkCountGoal(Integer dailyWalkCountGoal) { this.dailyWalkCountGoal = dailyWalkCountGoal; } From 87d5c5100abf63f3f134248c16641828fef2a341 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Mon, 14 Feb 2022 09:01:41 +0900 Subject: [PATCH 121/522] =?UTF-8?q?:recycle:=20::=20name=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 --- .../walkhub/domain/user/service/UpdateGoalWalkCountService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/user/service/UpdateGoalWalkCountService.java b/src/main/java/com/walkhub/walkhub/domain/user/service/UpdateGoalWalkCountService.java index f17e0abfe..be701453a 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/service/UpdateGoalWalkCountService.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/service/UpdateGoalWalkCountService.java @@ -17,6 +17,6 @@ public class UpdateGoalWalkCountService { public void execute(UpdateGoalWalkCountRequest request) { User user = userFacade.getCurrentUser(); - user.updatedailyWalkCountGoal(request.getDailyWalkCountGoal()); + user.updateDailyWalkCountGoal(request.getDailyWalkCountGoal()); } } From c47efd1123038241f47f122e1831426e9888c692 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Mon, 14 Feb 2022 10:12:36 +0900 Subject: [PATCH 122/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20rank=20to=20r?= =?UTF-8?q?anking?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rank/presentation/dto/response/SchoolRankResponse.java | 2 +- .../walkhub/domain/rank/service/QuerySchoolRankService.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/presentation/dto/response/SchoolRankResponse.java b/src/main/java/com/walkhub/walkhub/domain/rank/presentation/dto/response/SchoolRankResponse.java index 44beea5ef..e80646808 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/presentation/dto/response/SchoolRankResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/presentation/dto/response/SchoolRankResponse.java @@ -28,7 +28,7 @@ public static class MySchoolResponse { public static class SchoolResponse { private final Long schoolId; private final String name; - private final Integer rank; + private final Integer ranking; private final Long studentCount; private final String logoImageUrl; private final Integer walkCount; diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/service/QuerySchoolRankService.java b/src/main/java/com/walkhub/walkhub/domain/rank/service/QuerySchoolRankService.java index de314f077..f46648816 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/service/QuerySchoolRankService.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/service/QuerySchoolRankService.java @@ -49,7 +49,7 @@ public SchoolRankResponse execute(SchoolDateType schoolDateType) { .map(schoolRank2 -> SchoolResponse.builder() .schoolId(schoolRank2.getSchoolId()) .name(schoolRank2.getName()) - .rank(schoolRank2.getRanking()) + .ranking(schoolRank2.getRanking()) .studentCount(schoolRank2.getUserCount()) .logoImageUrl(schoolRank2.getLogoImageUrl()) .walkCount(schoolRank2.getWalkCount()) From cce55be60a10de86b3a78dcfd3496a344bdb274e Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Mon, 14 Feb 2022 10:13:52 +0900 Subject: [PATCH 123/522] :recycle: :: rank -> ranking --- .../rank/presentation/dto/response/UserListResponse.java | 2 +- .../walkhub/domain/rank/service/UserSearchService.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/presentation/dto/response/UserListResponse.java b/src/main/java/com/walkhub/walkhub/domain/rank/presentation/dto/response/UserListResponse.java index d762c7569..50b86e185 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/presentation/dto/response/UserListResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/presentation/dto/response/UserListResponse.java @@ -17,7 +17,7 @@ public class UserListResponse { public static class UserSearchResponse { private final Long userId; private final String name; - private final Integer rank; + private final Integer ranking; private final Integer grade; private final Integer classNum; private final String profileImageUrl; diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/service/UserSearchService.java b/src/main/java/com/walkhub/walkhub/domain/rank/service/UserSearchService.java index 4cde0729b..720be3a7c 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/service/UserSearchService.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/service/UserSearchService.java @@ -48,7 +48,7 @@ private UserListResponse.UserSearchResponse buildDayUserSearchResponse(User user return UserListResponse.UserSearchResponse.builder() .userId(user.getId()) .name(user.getName()) - .rank(exerciseAnalysisDto.getRanking()) + .ranking(exerciseAnalysisDto.getRanking()) .grade(user.getSection().getGrade()) .classNum(user.getSection().getClassNum()) .profileImageUrl(user.getProfileImageUrl()) @@ -60,7 +60,7 @@ private UserListResponse.UserSearchResponse buildWeekOrMonthUserSearchResponse(U return UserListResponse.UserSearchResponse.builder() .userId(userRank.getUserId()) .name(userRank.getName()) - .rank(userRank.getRanking()) + .ranking(userRank.getRanking()) .grade(userRank.getGrade()) .classNum(userRank.getClassNum()) .profileImageUrl(userRank.getProfileImageUrl()) From 1057f9ae2d83ff19278f9e39b67c0e6286459a9f Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Mon, 14 Feb 2022 10:59:27 +0900 Subject: [PATCH 124/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20ChallengeStat?= =?UTF-8?q?usRepositoryCustom=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../challenge/domain/repository/ChallengeStatusRepository.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepository.java b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepository.java index 98a1dd12b..4e5de6959 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepository.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepository.java @@ -9,7 +9,7 @@ import java.util.Optional; -public interface ChallengeStatusRepository extends CrudRepository { +public interface ChallengeStatusRepository extends CrudRepository, ChallengeStatusRepositoryCustom { Optional findByChallengeAndUser(Challenge challenge, User user); List findAllByUser(User user); } From 30b7d44bd957e3fed2341c864bbc19120ffda5f5 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Mon, 14 Feb 2022 10:59:46 +0900 Subject: [PATCH 125/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20=EB=B0=98?= =?UTF-8?q?=ED=99=98=ED=83=80=EC=9E=85=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/repository/ChallengeStatusRepositoryCustom.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustom.java b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustom.java index 31b6b38dc..63af43fa8 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustom.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustom.java @@ -1,10 +1,12 @@ package com.walkhub.walkhub.domain.challenge.domain.repository; +import com.walkhub.walkhub.domain.challenge.domain.repository.vo.RelatedChallengeParticipantsVO; import com.walkhub.walkhub.domain.challenge.presenstation.dto.response.QueryChallengeParticipantsForStudentResponse; +import com.walkhub.walkhub.domain.school.domain.School; import java.util.List; public interface ChallengeStatusRepositoryCustom { Integer getParticipantsListByChallengeId(Long challengeId); - List getRelatedChallengeParticipantsList(Long challengeId); + List getRelatedChallengeParticipantsList(Long challengeId, School school, Integer grade, Integer classNum); } From 8193e8e5cbf4ad3fb8f46081f07507042c6a5dd3 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Mon, 14 Feb 2022 11:00:09 +0900 Subject: [PATCH 126/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20orderby=20?= =?UTF-8?q?=EC=A1=B0=EA=B1=B4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ChallengeStatusRepositoryCustomImpl.java | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java index c31c7e5a8..dc5ca5f4b 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java @@ -2,16 +2,15 @@ import com.querydsl.jpa.impl.JPAQueryFactory; import com.walkhub.walkhub.domain.challenge.domain.ChallengeStatus; -import com.walkhub.walkhub.domain.challenge.domain.QChallengeStatus; -import com.walkhub.walkhub.domain.challenge.presenstation.dto.response.QQueryChallengeParticipantsForStudentResponse_RelatedChallengeParticipants; -import com.walkhub.walkhub.domain.challenge.presenstation.dto.response.QueryChallengeParticipantsForStudentResponse; -import com.walkhub.walkhub.domain.user.domain.QUser; -import com.walkhub.walkhub.domain.user.domain.User; +import com.walkhub.walkhub.domain.challenge.domain.repository.vo.QRelatedChallengeParticipantsVO; +import com.walkhub.walkhub.domain.challenge.domain.repository.vo.RelatedChallengeParticipantsVO; +import com.walkhub.walkhub.domain.school.domain.School; import lombok.RequiredArgsConstructor; import java.util.List; import static com.walkhub.walkhub.domain.challenge.domain.QChallengeStatus.challengeStatus; +import static com.walkhub.walkhub.domain.user.domain.QSection.section; import static com.walkhub.walkhub.domain.user.domain.QUser.user; @RequiredArgsConstructor @@ -29,9 +28,9 @@ public Integer getParticipantsListByChallengeId(Long challengeId) { } @Override - public List getRelatedChallengeParticipantsList(Long challengeId) { + public List getRelatedChallengeParticipantsList(Long challengeId, School school, Integer grade, Integer classNum) { return queryFactory - .select(new QQueryChallengeParticipantsForStudentResponse_RelatedChallengeParticipants( + .select(new QRelatedChallengeParticipantsVO( user.id.as("userId"), user.name, user.profileImageUrl @@ -39,10 +38,18 @@ public List Date: Mon, 14 Feb 2022 11:00:27 +0900 Subject: [PATCH 127/522] =?UTF-8?q?=F0=9F=93=91=20::=20RelatedChallengePar?= =?UTF-8?q?ticipantsVO?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vo/RelatedChallengeParticipantsVO.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/vo/RelatedChallengeParticipantsVO.java diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/vo/RelatedChallengeParticipantsVO.java b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/vo/RelatedChallengeParticipantsVO.java new file mode 100644 index 000000000..9bbf9c9b1 --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/vo/RelatedChallengeParticipantsVO.java @@ -0,0 +1,18 @@ +package com.walkhub.walkhub.domain.challenge.domain.repository.vo; + +import com.querydsl.core.annotations.QueryProjection; +import lombok.Getter; + +@Getter +public class RelatedChallengeParticipantsVO { + private final Long userId; + private final String name; + private final String profileImageUrl; + + @QueryProjection + public RelatedChallengeParticipantsVO(Long userId, String name, String profileImageUrl) { + this.userId = userId; + this.name = name; + this.profileImageUrl = profileImageUrl; + } +} From 59023def4362b9e9fb776dd5c968c48422397ba4 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Mon, 14 Feb 2022 11:00:43 +0900 Subject: [PATCH 128/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20=EB=9D=BC?= =?UTF-8?q?=EC=9A=B0=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 --- .../presenstation/ChallengeController.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/ChallengeController.java b/src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/ChallengeController.java index dada5c0f9..4b8107914 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/ChallengeController.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/ChallengeController.java @@ -4,13 +4,8 @@ import com.walkhub.walkhub.domain.challenge.presenstation.dto.request.UpdateChallengeRequest; import com.walkhub.walkhub.domain.challenge.presenstation.dto.response.QueryChallengeDetailsResponse; import com.walkhub.walkhub.domain.challenge.presenstation.dto.response.QueryChallengeListResponse; -import com.walkhub.walkhub.domain.challenge.service.CreateChallengeService; -import com.walkhub.walkhub.domain.challenge.service.ParticipateChallengeService; -import com.walkhub.walkhub.domain.challenge.service.QueryChallengeDetailsService; -import com.walkhub.walkhub.domain.challenge.service.QueryChallengeListService; -import com.walkhub.walkhub.domain.challenge.service.QueryParticipatedChallengeListService; -import com.walkhub.walkhub.domain.challenge.service.RemoveChallengeService; -import com.walkhub.walkhub.domain.challenge.service.UpdateChallengeService; +import com.walkhub.walkhub.domain.challenge.presenstation.dto.response.QueryChallengeParticipantsForStudentResponse; +import com.walkhub.walkhub.domain.challenge.service.*; import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.DeleteMapping; @@ -37,6 +32,7 @@ public class ChallengeController { private final QueryChallengeDetailsService queryChallengeDetailsService; private final ParticipateChallengeService participateChallengeService; private final QueryParticipatedChallengeListService queryParticipatedChallengeListService; + private final QueryChallengeParticipantsForStudentService queryChallengeParticipantsForStudentService; @ResponseStatus(HttpStatus.NO_CONTENT) @DeleteMapping("/{challenge-id}") @@ -78,4 +74,8 @@ public QueryChallengeListResponse queryParticipatedChallengeList() { return queryParticipatedChallengeListService.execute(); } + @GetMapping("/{challenge-id}/participants/students") + public QueryChallengeParticipantsForStudentResponse queryChallengeParticipantsForStudent(@PathVariable("challenge-id") Long challengeId) { + return queryChallengeParticipantsForStudentService.execute(challengeId); + } } From 896870118f4ad23d425d5da2980179ca9547a878 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Mon, 14 Feb 2022 11:00:59 +0900 Subject: [PATCH 129/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20QueryProjecti?= =?UTF-8?q?on=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../QueryChallengeParticipantsForStudentResponse.java | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/dto/response/QueryChallengeParticipantsForStudentResponse.java b/src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/dto/response/QueryChallengeParticipantsForStudentResponse.java index 713458781..658e8afc5 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/dto/response/QueryChallengeParticipantsForStudentResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/dto/response/QueryChallengeParticipantsForStudentResponse.java @@ -1,6 +1,5 @@ package com.walkhub.walkhub.domain.challenge.presenstation.dto.response; -import com.querydsl.core.annotations.QueryProjection; import lombok.Builder; import lombok.Getter; @@ -18,12 +17,5 @@ public static class RelatedChallengeParticipants { private final Long userId; private final String name; private final String profileImageUrl; - - @QueryProjection - public RelatedChallengeParticipants(Long userId, String name, String profileImageUrl) { - this.userId = userId; - this.name = name; - this.profileImageUrl = profileImageUrl; - } } } From 01f291c3cfe82b6ab084ab8df3a37046fc0898e4 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Mon, 14 Feb 2022 11:01:23 +0900 Subject: [PATCH 130/522] =?UTF-8?q?=F0=9F=93=91=20::=20QueryChallengeParti?= =?UTF-8?q?cipantsForStudentService?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...hallengeParticipantsForStudentService.java | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/main/java/com/walkhub/walkhub/domain/challenge/service/QueryChallengeParticipantsForStudentService.java diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/service/QueryChallengeParticipantsForStudentService.java b/src/main/java/com/walkhub/walkhub/domain/challenge/service/QueryChallengeParticipantsForStudentService.java new file mode 100644 index 000000000..f326e25f1 --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/service/QueryChallengeParticipantsForStudentService.java @@ -0,0 +1,36 @@ +package com.walkhub.walkhub.domain.challenge.service; + +import com.walkhub.walkhub.domain.challenge.domain.repository.ChallengeStatusRepository; +import com.walkhub.walkhub.domain.challenge.presenstation.dto.response.QueryChallengeParticipantsForStudentResponse; +import com.walkhub.walkhub.domain.school.domain.School; +import com.walkhub.walkhub.domain.user.domain.Section; +import com.walkhub.walkhub.domain.user.domain.User; +import com.walkhub.walkhub.domain.user.facade.UserFacade; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +import java.util.stream.Collectors; + +@RequiredArgsConstructor +@Service +public class QueryChallengeParticipantsForStudentService { + private final ChallengeStatusRepository challengeStatusRepository; + private final UserFacade userFacade; + + public QueryChallengeParticipantsForStudentResponse execute(Long challengeId) { + User user = userFacade.getCurrentUser(); + School school = user.getSchool(); + Section section = user.getSection(); + + return QueryChallengeParticipantsForStudentResponse.builder() + .participantCount(challengeStatusRepository.getParticipantsListByChallengeId(challengeId)) + .relatedChallengeParticipantList(challengeStatusRepository.getRelatedChallengeParticipantsList(challengeId, school, section.getGrade(), section.getClassNum()) + .stream().map(participants -> QueryChallengeParticipantsForStudentResponse.RelatedChallengeParticipants.builder() + .userId(participants.getUserId()) + .name(participants.getName()) + .profileImageUrl(participants.getProfileImageUrl()) + .build() + ).collect(Collectors.toList()) + ).build(); + } +} From b475be79e9d0de538f344ec63bbb5ec1a2c6073d Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Mon, 14 Feb 2022 13:45:16 +0900 Subject: [PATCH 131/522] =?UTF-8?q?=F0=9F=93=91=20::=20AuthorityScope=20EN?= =?UTF-8?q?UM?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../walkhub/domain/teacher/type/AuthorityScope.java | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 src/main/java/com/walkhub/walkhub/domain/teacher/type/AuthorityScope.java diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/type/AuthorityScope.java b/src/main/java/com/walkhub/walkhub/domain/teacher/type/AuthorityScope.java new file mode 100644 index 000000000..10101dee0 --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/type/AuthorityScope.java @@ -0,0 +1,7 @@ +package com.walkhub.walkhub.domain.teacher.type; + +public enum AuthorityScope { + ALL, + STUDENT, + TEACHER +} From f28068c3903262fc49b1f5a9ee4e158200838489 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Mon, 14 Feb 2022 13:45:27 +0900 Subject: [PATCH 132/522] =?UTF-8?q?=F0=9F=93=91=20::=20SortStandard=20ENUM?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../walkhub/walkhub/domain/teacher/type/SortStandard.java | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 src/main/java/com/walkhub/walkhub/domain/teacher/type/SortStandard.java diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/type/SortStandard.java b/src/main/java/com/walkhub/walkhub/domain/teacher/type/SortStandard.java new file mode 100644 index 000000000..7a344733b --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/type/SortStandard.java @@ -0,0 +1,8 @@ +package com.walkhub.walkhub.domain.teacher.type; + +public enum SortStandard { + NAME, + GCN, + WALK_COUNT, + DISTANCE +} From 4a9d435022cb00178278e53bd7aef29eaa126a24 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Mon, 14 Feb 2022 13:45:42 +0900 Subject: [PATCH 133/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20=ED=8C=8C?= =?UTF-8?q?=EB=9D=BC=EB=AF=B8=ED=84=B0=20ENUM=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../teacher/service/QueryUserListService.java | 4 +++- .../repository/UserRepositoryCustom.java | 4 +++- .../repository/UserRepositoryCustomImpl.java | 22 ++++++++++--------- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/service/QueryUserListService.java b/src/main/java/com/walkhub/walkhub/domain/teacher/service/QueryUserListService.java index d4c15d2a3..c33ce1723 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/service/QueryUserListService.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/service/QueryUserListService.java @@ -1,6 +1,8 @@ package com.walkhub.walkhub.domain.teacher.service; import com.walkhub.walkhub.domain.teacher.presentation.dto.response.QueryUserListResponse; +import com.walkhub.walkhub.domain.teacher.type.AuthorityScope; +import com.walkhub.walkhub.domain.teacher.type.SortStandard; import com.walkhub.walkhub.domain.user.domain.repository.UserRepository; import com.walkhub.walkhub.domain.user.facade.UserFacade; import lombok.RequiredArgsConstructor; @@ -12,7 +14,7 @@ public class QueryUserListService { private final UserRepository userRepository; private final UserFacade userFacade; - public QueryUserListResponse execute(Integer page, String scope, String sort, Integer grade, Integer classNum) { + public QueryUserListResponse execute(Integer page, AuthorityScope scope, SortStandard sort, Integer grade, Integer classNum) { return QueryUserListResponse.builder() .userList(userRepository.queryUserList(page, scope, sort, grade, classNum, userFacade.getCurrentUser())) .build(); diff --git a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustom.java b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustom.java index 401bddddf..9b20576df 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustom.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustom.java @@ -1,10 +1,12 @@ package com.walkhub.walkhub.domain.user.domain.repository; import com.walkhub.walkhub.domain.teacher.presentation.dto.response.QueryUserListResponse; +import com.walkhub.walkhub.domain.teacher.type.AuthorityScope; +import com.walkhub.walkhub.domain.teacher.type.SortStandard; import com.walkhub.walkhub.domain.user.domain.User; import java.util.List; public interface UserRepositoryCustom { - List queryUserList(Integer page, String scope, String sort, Integer grade, Integer classNum, User currentUser); + List queryUserList(Integer page, AuthorityScope scope, SortStandard sort, Integer grade, Integer classNum, User currentUser); } diff --git a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java index 01fff6b92..0bc0f790a 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java @@ -6,6 +6,8 @@ import com.querydsl.jpa.impl.JPAQueryFactory; import com.walkhub.walkhub.domain.teacher.presentation.dto.response.QQueryUserListResponse_UserListInfo; import com.walkhub.walkhub.domain.teacher.presentation.dto.response.QueryUserListResponse; +import com.walkhub.walkhub.domain.teacher.type.AuthorityScope; +import com.walkhub.walkhub.domain.teacher.type.SortStandard; import com.walkhub.walkhub.domain.user.domain.User; import com.walkhub.walkhub.domain.user.facade.SectionFacade; import com.walkhub.walkhub.global.enums.Authority; @@ -24,7 +26,7 @@ public class UserRepositoryCustomImpl implements UserRepositoryCustom { private final SectionFacade sectionFacade; @Override - public List queryUserList(Integer page, String scope, String sort, Integer grade, Integer classNum, User currentUser) { + public List queryUserList(Integer page, AuthorityScope scope, SortStandard sort, Integer grade, Integer classNum, User currentUser) { long size = 4; return queryFactory .select(new QQueryUserListResponse_UserListInfo( @@ -62,38 +64,38 @@ private BooleanBuilder classNumEq(Integer classNum) { return querydslUtil.nullSafeBuilder(() -> user.section.classNum.eq(classNum)); } - private BooleanExpression buildFilteringCondition(String scope) { + private BooleanExpression buildFilteringCondition(AuthorityScope scope) { switch (scope) { - case "ALL": + case ALL: return user.authority.eq(Authority.TEACHER).or(user.authority.eq(Authority.USER)); - case "STUDENT": + case STUDENT: return user.authority.eq(Authority.USER); - case "TEACHER": + case TEACHER: return user.authority.eq(Authority.TEACHER); default: return null; } } - private OrderSpecifier[] buildSortCondition(String sort) { + private OrderSpecifier[] buildSortCondition(SortStandard sort) { switch (sort) { - case "NAME": + case NAME: return new OrderSpecifier[]{ user.name.asc(), user.authority.asc() }; - case "GCN": + case GCN: return new OrderSpecifier[]{ user.section.grade.asc(), user.section.classNum.asc(), user.number.asc(), user.authority.asc() }; - case "WALK_COUNT": + case WALK_COUNT: return new OrderSpecifier[]{ exerciseAnalysis.walkCount.desc(), user.authority.asc() }; - case "DISTANCE": + case DISTANCE: return new OrderSpecifier[]{ exerciseAnalysis.distance.desc(), user.authority.asc() From 3063babdb938b049ff988cc7f3def39f31fa7f70 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Mon, 14 Feb 2022 13:48:44 +0900 Subject: [PATCH 134/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20=ED=8C=8C?= =?UTF-8?q?=EB=9D=BC=EB=AF=B8=ED=84=B0=20ENUM=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/teacher/presentation/TeacherController.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/TeacherController.java b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/TeacherController.java index cd5113896..76cf62861 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/TeacherController.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/TeacherController.java @@ -4,6 +4,8 @@ import com.walkhub.walkhub.domain.teacher.presentation.dto.response.CodeResponse; import com.walkhub.walkhub.domain.teacher.presentation.dto.response.QueryUserListResponse; import com.walkhub.walkhub.domain.teacher.service.*; +import com.walkhub.walkhub.domain.teacher.type.AuthorityScope; +import com.walkhub.walkhub.domain.teacher.type.SortStandard; import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.*; @@ -62,8 +64,8 @@ public CodeResponse refreshClassCode() { @GetMapping("/users") public QueryUserListResponse queryUserList(@RequestParam Integer page, - @RequestParam String scope, - @RequestParam String sort, + @RequestParam AuthorityScope scope, + @RequestParam SortStandard sort, @RequestParam(required = false) Integer grade, @RequestParam(required = false) Integer classNum) { return queryUserListService.execute(page, scope, sort, grade, classNum); From 43887ae38c7e275e84d088d9f7a559f9267b020a Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Mon, 14 Feb 2022 13:54:27 +0900 Subject: [PATCH 135/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20vo=EB=A1=9C?= =?UTF-8?q?=20=ED=83=80=EC=9E=85=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../teacher/service/QueryUserListService.java | 15 ++++++++++++++- .../domain/repository/UserRepositoryCustom.java | 3 ++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/service/QueryUserListService.java b/src/main/java/com/walkhub/walkhub/domain/teacher/service/QueryUserListService.java index c33ce1723..ddd653d36 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/service/QueryUserListService.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/service/QueryUserListService.java @@ -8,6 +8,8 @@ import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; +import java.util.stream.Collectors; + @RequiredArgsConstructor @Service public class QueryUserListService { @@ -16,7 +18,18 @@ public class QueryUserListService { public QueryUserListResponse execute(Integer page, AuthorityScope scope, SortStandard sort, Integer grade, Integer classNum) { return QueryUserListResponse.builder() - .userList(userRepository.queryUserList(page, scope, sort, grade, classNum, userFacade.getCurrentUser())) + .userList(userRepository.queryUserList(page, scope, sort, grade, classNum, userFacade.getCurrentUser()) + .stream().map(users -> QueryUserListResponse.UserListInfo.builder() + .userId(users.getUserId()) + .name(users.getName()) + .profileImageUrl(users.getProfileImageUrl()) + .grade(users.getGrade()) + .classNum(users.getClassNum()) + .number(users.getNumber()) + .isTeacher(users.getIsTeacher()) + .build() + ).collect(Collectors.toList()) + ) .build(); } } diff --git a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustom.java b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustom.java index 9b20576df..b04e7c978 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustom.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustom.java @@ -3,10 +3,11 @@ import com.walkhub.walkhub.domain.teacher.presentation.dto.response.QueryUserListResponse; import com.walkhub.walkhub.domain.teacher.type.AuthorityScope; import com.walkhub.walkhub.domain.teacher.type.SortStandard; +import com.walkhub.walkhub.domain.teacher.vo.UserListInfoVO; import com.walkhub.walkhub.domain.user.domain.User; import java.util.List; public interface UserRepositoryCustom { - List queryUserList(Integer page, AuthorityScope scope, SortStandard sort, Integer grade, Integer classNum, User currentUser); + List queryUserList(Integer page, AuthorityScope scope, SortStandard sort, Integer grade, Integer classNum, User currentUser); } From 30f875c872d133b89a5970371a81bc4f6b34f9f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Mon, 14 Feb 2022 14:02:23 +0900 Subject: [PATCH 136/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20param=20?= =?UTF-8?q?=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 --- .../walkhub/domain/rank/presentation/RankController.java | 4 ++-- .../domain/rank/service/QuerySchoolRankService.java | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/presentation/RankController.java b/src/main/java/com/walkhub/walkhub/domain/rank/presentation/RankController.java index 40aa183af..1e8de87d0 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/presentation/RankController.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/presentation/RankController.java @@ -29,7 +29,7 @@ public UserListResponse userSearch(@PathVariable("school-id") Long schoolId, } @GetMapping("/schools") - public SchoolRankResponse querySchoolRank(@RequestParam SchoolDateType schoolDateType) { - return querySchoolRankService.execute(schoolDateType); + public SchoolRankResponse querySchoolRank(@RequestParam SchoolDateType dateType) { + return querySchoolRankService.execute(dateType); } } diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/service/QuerySchoolRankService.java b/src/main/java/com/walkhub/walkhub/domain/rank/service/QuerySchoolRankService.java index f46648816..0c69241f3 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/service/QuerySchoolRankService.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/service/QuerySchoolRankService.java @@ -21,9 +21,9 @@ public class QuerySchoolRankService { private final SchoolRankRepository schoolRankRepository; private final UserFacade userFacade; - public SchoolRankResponse execute(SchoolDateType schoolDateType) { + public SchoolRankResponse execute(SchoolDateType dateType) { LocalDate localDate = LocalDate.now(); - switch (schoolDateType) { + switch (dateType) { case WEEK: localDate = localDate.minusWeeks(1); break; case MONTH: localDate = localDate.minusMonths(1); @@ -32,7 +32,7 @@ public SchoolRankResponse execute(SchoolDateType schoolDateType) { User user = userFacade.getCurrentUser(); SchoolRank schoolRank = schoolRankRepository. - findBySchoolIdAndDateTypeAndCreatedAtBetween(user.getSchool().getId(), schoolDateType.toString(), localDate, LocalDate.now()); + findBySchoolIdAndDateTypeAndCreatedAtBetween(user.getSchool().getId(), dateType.toString(), localDate, LocalDate.now()); MySchoolResponse mySchoolResponse = MySchoolResponse.builder() .schoolId(schoolRank.getSchoolId()) @@ -44,7 +44,7 @@ public SchoolRankResponse execute(SchoolDateType schoolDateType) { .build(); List schoolResponseList = schoolRankRepository - .findAllByDateTypeAndCreatedAtBetweenOrderByRankingDesc(schoolDateType.toString(), localDate, LocalDate.now()) + .findAllByDateTypeAndCreatedAtBetweenOrderByRankingDesc(dateType.toString(), localDate, LocalDate.now()) .stream() .map(schoolRank2 -> SchoolResponse.builder() .schoolId(schoolRank2.getSchoolId()) From f3620e7dfc462319eca8da56b868e1637b534b9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Mon, 14 Feb 2022 14:06:03 +0900 Subject: [PATCH 137/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20=EB=B6=88?= =?UTF-8?q?=ED=95=84=EC=9A=94=ED=95=9C=20=EC=BB=AC=EB=9F=BC=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rank/presentation/dto/response/SchoolRankResponse.java | 1 - .../walkhub/domain/rank/service/QuerySchoolRankService.java | 1 - 2 files changed, 2 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/presentation/dto/response/SchoolRankResponse.java b/src/main/java/com/walkhub/walkhub/domain/rank/presentation/dto/response/SchoolRankResponse.java index e80646808..e9e11def1 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/presentation/dto/response/SchoolRankResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/presentation/dto/response/SchoolRankResponse.java @@ -18,7 +18,6 @@ public static class MySchoolResponse { private final Long schoolId; private final String name; private final String logoImageUrl; - private final Integer walkCount; private final Integer grade; private final Integer classNum; } diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/service/QuerySchoolRankService.java b/src/main/java/com/walkhub/walkhub/domain/rank/service/QuerySchoolRankService.java index 0c69241f3..01edd94ed 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/service/QuerySchoolRankService.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/service/QuerySchoolRankService.java @@ -38,7 +38,6 @@ public SchoolRankResponse execute(SchoolDateType dateType) { .schoolId(schoolRank.getSchoolId()) .name(schoolRank.getName()) .logoImageUrl(schoolRank.getLogoImageUrl()) - .walkCount(schoolRank.getWalkCount()) .grade(user.getSection().getGrade()) .classNum(user.getSection().getClassNum()) .build(); From 7bfd6b69baa761d3bb701006a64e3fe80c05212b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Mon, 14 Feb 2022 14:08:18 +0900 Subject: [PATCH 138/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=202=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rank/service/QuerySchoolRankService.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/service/QuerySchoolRankService.java b/src/main/java/com/walkhub/walkhub/domain/rank/service/QuerySchoolRankService.java index 01edd94ed..69c2143ad 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/service/QuerySchoolRankService.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/service/QuerySchoolRankService.java @@ -31,13 +31,13 @@ public SchoolRankResponse execute(SchoolDateType dateType) { } User user = userFacade.getCurrentUser(); - SchoolRank schoolRank = schoolRankRepository. + SchoolRank mySchoolRank = schoolRankRepository. findBySchoolIdAndDateTypeAndCreatedAtBetween(user.getSchool().getId(), dateType.toString(), localDate, LocalDate.now()); MySchoolResponse mySchoolResponse = MySchoolResponse.builder() - .schoolId(schoolRank.getSchoolId()) - .name(schoolRank.getName()) - .logoImageUrl(schoolRank.getLogoImageUrl()) + .schoolId(mySchoolRank.getSchoolId()) + .name(mySchoolRank.getName()) + .logoImageUrl(mySchoolRank.getLogoImageUrl()) .grade(user.getSection().getGrade()) .classNum(user.getSection().getClassNum()) .build(); @@ -45,13 +45,13 @@ public SchoolRankResponse execute(SchoolDateType dateType) { List schoolResponseList = schoolRankRepository .findAllByDateTypeAndCreatedAtBetweenOrderByRankingDesc(dateType.toString(), localDate, LocalDate.now()) .stream() - .map(schoolRank2 -> SchoolResponse.builder() - .schoolId(schoolRank2.getSchoolId()) - .name(schoolRank2.getName()) - .ranking(schoolRank2.getRanking()) - .studentCount(schoolRank2.getUserCount()) - .logoImageUrl(schoolRank2.getLogoImageUrl()) - .walkCount(schoolRank2.getWalkCount()) + .map(schoolRank -> SchoolResponse.builder() + .schoolId(schoolRank.getSchoolId()) + .name(schoolRank.getName()) + .ranking(schoolRank.getRanking()) + .studentCount(schoolRank.getUserCount()) + .logoImageUrl(schoolRank.getLogoImageUrl()) + .walkCount(schoolRank.getWalkCount()) .build()) .collect(Collectors.toList()); From de825565cc86bf151dde508fd4d7a55d781b9f70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Mon, 14 Feb 2022 14:14:44 +0900 Subject: [PATCH 139/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20code=20smell?= =?UTF-8?q?=ED=95=B4=EA=B2=B0=20&=20read=20only?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/repository/SchoolRankRepository.java | 2 +- .../domain/rank/service/QuerySchoolRankService.java | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/SchoolRankRepository.java b/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/SchoolRankRepository.java index 4fd463d2c..1c413fdf7 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/SchoolRankRepository.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/SchoolRankRepository.java @@ -9,5 +9,5 @@ public interface SchoolRankRepository extends CrudRepository { SchoolRank findBySchoolIdAndDateTypeAndCreatedAtBetween(Long schoolId, String dateType, LocalDate createdAt, LocalDate createdAt2); - List findAllByDateTypeAndCreatedAtBetweenOrderByRankingDesc(String dateType, LocalDate createdAt, LocalDate createdAt2); + List findAllByDateTypeAndCreatedAtBetweenOrderByRankingAsc(String dateType, LocalDate createdAt, LocalDate createdAt2); } diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/service/QuerySchoolRankService.java b/src/main/java/com/walkhub/walkhub/domain/rank/service/QuerySchoolRankService.java index 69c2143ad..f13b2a42c 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/service/QuerySchoolRankService.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/service/QuerySchoolRankService.java @@ -13,6 +13,7 @@ import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; @RequiredArgsConstructor @Service @@ -21,13 +22,13 @@ public class QuerySchoolRankService { private final SchoolRankRepository schoolRankRepository; private final UserFacade userFacade; + @Transactional(readOnly = true) public SchoolRankResponse execute(SchoolDateType dateType) { LocalDate localDate = LocalDate.now(); - switch (dateType) { - case WEEK: localDate = localDate.minusWeeks(1); - break; - case MONTH: localDate = localDate.minusMonths(1); - break; + if (dateType.equals(SchoolDateType.MONTH)) { + localDate = localDate.minusMonths(1); + } else { + localDate = localDate.minusWeeks(1); } User user = userFacade.getCurrentUser(); @@ -43,7 +44,7 @@ public SchoolRankResponse execute(SchoolDateType dateType) { .build(); List schoolResponseList = schoolRankRepository - .findAllByDateTypeAndCreatedAtBetweenOrderByRankingDesc(dateType.toString(), localDate, LocalDate.now()) + .findAllByDateTypeAndCreatedAtBetweenOrderByRankingAsc(dateType.toString(), localDate, LocalDate.now()) .stream() .map(schoolRank -> SchoolResponse.builder() .schoolId(schoolRank.getSchoolId()) From 889b4cdf7f949ec22a26b0178bc17ce344db2b21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Mon, 14 Feb 2022 14:22:54 +0900 Subject: [PATCH 140/522] =?UTF-8?q?=F0=9F=90=9B=20::=20security=20hotspot?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/walkhub/walkhub/global/error/ExceptionFilter.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/global/error/ExceptionFilter.java b/src/main/java/com/walkhub/walkhub/global/error/ExceptionFilter.java index 8cafcad0e..a89661f34 100644 --- a/src/main/java/com/walkhub/walkhub/global/error/ExceptionFilter.java +++ b/src/main/java/com/walkhub/walkhub/global/error/ExceptionFilter.java @@ -4,6 +4,7 @@ import com.walkhub.walkhub.global.error.exception.ErrorCode; import com.walkhub.walkhub.global.error.exception.WalkhubException; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.web.filter.OncePerRequestFilter; import javax.servlet.FilterChain; @@ -11,6 +12,7 @@ import javax.servlet.http.HttpServletResponse; import java.io.IOException; +@Slf4j @RequiredArgsConstructor public class ExceptionFilter extends OncePerRequestFilter { @@ -23,7 +25,7 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse } catch (WalkhubException e) { sendErrorMessage(response, e.getErrorCode()); } catch (Exception e) { - e.printStackTrace(); + logger.error(e); sendErrorMessage(response, ErrorCode.INTERNAL_SERVER_ERROR); } } From 295da6d9ed6cef1fbc4812f927fc4f457005d881 Mon Sep 17 00:00:00 2001 From: lyutvs Date: Mon, 14 Feb 2022 15:43:48 +0900 Subject: [PATCH 141/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F::=20ExerciseControll?= =?UTF-8?q?er?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/exercise/presentation/ExerciseController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/ExerciseController.java b/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/ExerciseController.java index b65b26a9f..06705a873 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/ExerciseController.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/ExerciseController.java @@ -58,7 +58,7 @@ public void saveOrUpdateTodayExercise(@RequestBody @Valid SaveExerciseAnalysisRe } @GetMapping("/analysis") - public QueryExerciseAnalysisResponse setQueryExerciseAnalysis() { + public QueryExerciseAnalysisResponse QueryExerciseAnalysis() { return queryExerciseAnalysisService.execute(); } From d91c272b69c7a5c76e102c8cd12f1bbfe4176b47 Mon Sep 17 00:00:00 2001 From: lyutvs Date: Mon, 14 Feb 2022 15:44:24 +0900 Subject: [PATCH 142/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F::=20calorie=20?= =?UTF-8?q?=ED=83=80=EC=9E=85=20Duble=20=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 --- .../com/walkhub/walkhub/domain/exercise/domain/Exercise.java | 4 ++-- .../walkhub/domain/exercise/domain/ExerciseAnalysis.java | 4 ++-- .../presentation/dto/request/FinishExerciseRequest.java | 2 +- .../presentation/dto/request/SaveExerciseAnalysisRequest.java | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/Exercise.java b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/Exercise.java index e73843806..a24eef8d0 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/Exercise.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/Exercise.java @@ -45,7 +45,7 @@ public class Exercise extends BaseTimeEntity { @ColumnDefault("0") @Column(nullable = false) - private Integer calorie; + private Double calorie; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "user_id", nullable = false) @@ -79,7 +79,7 @@ public Exercise(User user, Integer goal, GoalType goalType) { this.goal = goal; } - public void closeExercise(Integer walkCount, Integer distance, Integer calorie) { + public void closeExercise(Integer walkCount, Integer distance, Double calorie) { this.walkCount = walkCount; this.distance = distance; this.calorie = calorie; diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/ExerciseAnalysis.java b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/ExerciseAnalysis.java index 850524c24..62fc7193c 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/ExerciseAnalysis.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/ExerciseAnalysis.java @@ -21,7 +21,7 @@ public class ExerciseAnalysis { private Long id; @NotNull - private Integer calorie; + private Double calorie; @NotNull private Integer walkCount; @@ -38,7 +38,7 @@ public class ExerciseAnalysis { @Builder - public ExerciseAnalysis(Integer calorie, Integer walkCount, + public ExerciseAnalysis(Double calorie, Integer walkCount, Integer distance, LocalDate date, User user) { this.calorie = calorie; this.walkCount = walkCount; diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/request/FinishExerciseRequest.java b/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/request/FinishExerciseRequest.java index 26ae35312..32f7b440f 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/request/FinishExerciseRequest.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/request/FinishExerciseRequest.java @@ -18,7 +18,7 @@ public class FinishExerciseRequest { private Integer distance; @NotNull(message = "calorie는 null, 공백을 허용하지 않습니다.") - private Integer calorie; + private Double calorie; @NotEmpty(message = "image_url은 공백을 허용하지 않습니다.") private List imageUrl; diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/request/SaveExerciseAnalysisRequest.java b/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/request/SaveExerciseAnalysisRequest.java index b9d2677a5..5f5a8661f 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/request/SaveExerciseAnalysisRequest.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/request/SaveExerciseAnalysisRequest.java @@ -24,6 +24,6 @@ public class SaveExerciseAnalysisRequest { @PositiveOrZero(message = "calorie는 음수를 허용하지 않습니다.") @NotNull(message = "calorie는 Null을 허용하지 않습니다.") - private Integer calorie; + private Double calorie; } From 58e7201f8151545a6a7b77996738ba4ed174458e Mon Sep 17 00:00:00 2001 From: lyutvs Date: Mon, 14 Feb 2022 15:44:34 +0900 Subject: [PATCH 143/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F::=20Response=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../QueryExerciseAnalysisResponse.java | 29 ++++--------------- 1 file changed, 6 insertions(+), 23 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/response/QueryExerciseAnalysisResponse.java b/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/response/QueryExerciseAnalysisResponse.java index 21cbcc59f..469a2c3be 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/response/QueryExerciseAnalysisResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/response/QueryExerciseAnalysisResponse.java @@ -1,33 +1,16 @@ package com.walkhub.walkhub.domain.exercise.presentation.dto.response; - -import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; -import java.time.LocalDateTime; import java.util.List; @Getter -@AllArgsConstructor +@Builder public class QueryExerciseAnalysisResponse { - - private final List exerciseAnalysisList; - - @Getter - @Builder - public static class ExerciseAnalysisResponse { - private final List walkCountList; - private final Integer dailyWalkCountGoal; - private final Integer walkCount; - private final Integer calorie; - private final Integer distance; - private final LocalDateTime walkTime; - } - - @Getter - @Builder - public static class WalkCountListResponse { - private final Integer walkCount; - } + private final List walkCountList; + private final Integer dailyWalkCountGoal; + private final Integer walkCount; + private final Double calorie; + private final Integer distance; } From 9b51bea1f21cf3ad2574d3dbf619dcae6598c2e6 Mon Sep 17 00:00:00 2001 From: lyutvs Date: Mon, 14 Feb 2022 16:12:51 +0900 Subject: [PATCH 144/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F::=20findAllByUserAnd?= =?UTF-8?q?DateBetween?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exercise/domain/repository/ExerciseAnalysisRepository.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepository.java b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepository.java index 4c61e8dde..ad8419e7b 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepository.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepository.java @@ -11,4 +11,5 @@ public interface ExerciseAnalysisRepository extends CrudRepository { Optional findByUserAndDate(User user, LocalDate date); List findByUser(User user); + List findAllByUserAndDateBetween(User user, LocalDate startAt, LocalDate endAt); } From dd75d56975d3bb71a57eb22168098cd8b56e7e80 Mon Sep 17 00:00:00 2001 From: lyutvs Date: Mon, 14 Feb 2022 16:13:07 +0900 Subject: [PATCH 145/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F::=20QueryExerciseAna?= =?UTF-8?q?lysisService?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/QueryExerciseAnalysisService.java | 34 +++++++++++-------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/service/QueryExerciseAnalysisService.java b/src/main/java/com/walkhub/walkhub/domain/exercise/service/QueryExerciseAnalysisService.java index b5a4321a3..a00ae23d9 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/service/QueryExerciseAnalysisService.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/service/QueryExerciseAnalysisService.java @@ -1,15 +1,16 @@ package com.walkhub.walkhub.domain.exercise.service; +import com.walkhub.walkhub.domain.exercise.domain.ExerciseAnalysis; import com.walkhub.walkhub.domain.exercise.domain.repository.ExerciseAnalysisRepository; import com.walkhub.walkhub.domain.exercise.presentation.dto.response.QueryExerciseAnalysisResponse; -import com.walkhub.walkhub.domain.exercise.presentation.dto.response.QueryExerciseAnalysisResponse.ExerciseAnalysisResponse; -import com.walkhub.walkhub.domain.user.domain.CalorieLevel; import com.walkhub.walkhub.domain.user.domain.User; import com.walkhub.walkhub.domain.user.facade.UserFacade; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.time.LocalDate; +import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; @@ -22,18 +23,23 @@ public class QueryExerciseAnalysisService { @Transactional(readOnly = true) public QueryExerciseAnalysisResponse execute() { + User user = userFacade.getCurrentUser(); - List queryExerciseAnalysisResponseList = - exerciseAnalysisRepository.findByUser(user) - .stream() - .map(exerciseAnalysis -> ExerciseAnalysisResponse.builder() - .dailyWalkCountGoal(user.getDailyWalkCountGoal()) - .walkCount(exerciseAnalysis.getWalkCount()) - .calorie(exerciseAnalysis.getCalorie()) - .distance(exerciseAnalysis.getDistance()) - .build()) - .collect(Collectors.toList()); - - return new QueryExerciseAnalysisResponse(queryExerciseAnalysisResponseList); + LocalDate startAt = LocalDate.now().minusDays(28); + + ExerciseAnalysis exerciseAnalysis = exerciseAnalysisRepository.findByUserAndDate(user, LocalDate.now()) + .orElse(ExerciseAnalysis.builder().build()); + + List walkCountList = exerciseAnalysisRepository.findAllByUserAndDateBetween(user, startAt, LocalDate.now()) + .stream().map(ExerciseAnalysis::getWalkCount) + .collect(Collectors.toList()); + + return QueryExerciseAnalysisResponse.builder() + .walkCount(exerciseAnalysis.getWalkCount()) + .walkCountList(walkCountList) + .calorie(exerciseAnalysis.getCalorie()) + .dailyWalkCountGoal(user.getDailyWalkCountGoal()) + .distance(exerciseAnalysis.getDistance()) + .build(); } } \ No newline at end of file From 97f95b924541febef821179d48b4d6f15a718c3a Mon Sep 17 00:00:00 2001 From: lyutvs Date: Mon, 14 Feb 2022 16:14:01 +0900 Subject: [PATCH 146/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F::=20findAllByUserId?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../badge/domain/repository/BadgeCollectionRepository.java | 2 +- .../domain/badge/service/QueryUserBadgeListService.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/BadgeCollectionRepository.java b/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/BadgeCollectionRepository.java index a45af9d04..6b312b25f 100644 --- a/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/BadgeCollectionRepository.java +++ b/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/BadgeCollectionRepository.java @@ -9,6 +9,6 @@ import java.util.Optional; public interface BadgeCollectionRepository extends CrudRepository { - List findByUserId(Long userId); + List findAllByUserId(Long userId); Optional findByBadgeIdAndUser(Long badgeId, User user); } diff --git a/src/main/java/com/walkhub/walkhub/domain/badge/service/QueryUserBadgeListService.java b/src/main/java/com/walkhub/walkhub/domain/badge/service/QueryUserBadgeListService.java index 3001c706b..2e9f95b1b 100644 --- a/src/main/java/com/walkhub/walkhub/domain/badge/service/QueryUserBadgeListService.java +++ b/src/main/java/com/walkhub/walkhub/domain/badge/service/QueryUserBadgeListService.java @@ -17,13 +17,13 @@ public class QueryUserBadgeListService { public QueryUserBadgeListResponse execute(Long userId) { - List badgeList = badgeCollectionRepository.findByUserId(userId) + List badgeList = badgeCollectionRepository.findAllByUserId(userId) .stream() .map(badgeCollection -> DefaultBadgeResponse.builder() .name(badgeCollection.getBadge().getName()) .imageUrl(badgeCollection.getBadge().getImageUrl()) .condition(badgeCollection.getBadge().getCondition()) - .build()) + .buil .collect(Collectors.toList()); return new QueryUserBadgeListResponse(badgeList); From 6ad2bfad03f71f0b1f6749c42e17e3d266adfc9e Mon Sep 17 00:00:00 2001 From: lyutvs Date: Mon, 14 Feb 2022 16:14:19 +0900 Subject: [PATCH 147/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F::=20.build?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../walkhub/domain/badge/service/QueryUserBadgeListService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/badge/service/QueryUserBadgeListService.java b/src/main/java/com/walkhub/walkhub/domain/badge/service/QueryUserBadgeListService.java index 2e9f95b1b..dcb9a4763 100644 --- a/src/main/java/com/walkhub/walkhub/domain/badge/service/QueryUserBadgeListService.java +++ b/src/main/java/com/walkhub/walkhub/domain/badge/service/QueryUserBadgeListService.java @@ -23,7 +23,7 @@ public QueryUserBadgeListResponse execute(Long userId) { .name(badgeCollection.getBadge().getName()) .imageUrl(badgeCollection.getBadge().getImageUrl()) .condition(badgeCollection.getBadge().getCondition()) - .buil + .build .collect(Collectors.toList()); return new QueryUserBadgeListResponse(badgeList); From b94f744eef2af87323b76dc0d1ee4385812c5dda Mon Sep 17 00:00:00 2001 From: lyutvs Date: Mon, 14 Feb 2022 16:21:07 +0900 Subject: [PATCH 148/522] =?UTF-8?q?=F0=9F=90=9B::=20=EC=8A=A4=EC=BD=94?= =?UTF-8?q?=ED=94=84=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../walkhub/domain/badge/service/QueryUserBadgeListService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/badge/service/QueryUserBadgeListService.java b/src/main/java/com/walkhub/walkhub/domain/badge/service/QueryUserBadgeListService.java index dcb9a4763..7538c0907 100644 --- a/src/main/java/com/walkhub/walkhub/domain/badge/service/QueryUserBadgeListService.java +++ b/src/main/java/com/walkhub/walkhub/domain/badge/service/QueryUserBadgeListService.java @@ -23,7 +23,7 @@ public QueryUserBadgeListResponse execute(Long userId) { .name(badgeCollection.getBadge().getName()) .imageUrl(badgeCollection.getBadge().getImageUrl()) .condition(badgeCollection.getBadge().getCondition()) - .build + .build()) .collect(Collectors.toList()); return new QueryUserBadgeListResponse(badgeList); From 8244077d9532f4a65632765cab921352439b4d1e Mon Sep 17 00:00:00 2001 From: lyutvs Date: Mon, 14 Feb 2022 17:44:34 +0900 Subject: [PATCH 149/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F::=20=EA=B0=80?= =?UTF-8?q?=EB=8F=85=EC=84=B1=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/exercise/service/QueryExerciseAnalysisService.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/service/QueryExerciseAnalysisService.java b/src/main/java/com/walkhub/walkhub/domain/exercise/service/QueryExerciseAnalysisService.java index a00ae23d9..d41130bb2 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/service/QueryExerciseAnalysisService.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/service/QueryExerciseAnalysisService.java @@ -31,7 +31,8 @@ public QueryExerciseAnalysisResponse execute() { .orElse(ExerciseAnalysis.builder().build()); List walkCountList = exerciseAnalysisRepository.findAllByUserAndDateBetween(user, startAt, LocalDate.now()) - .stream().map(ExerciseAnalysis::getWalkCount) + .stream() + .map(ExerciseAnalysis::getWalkCount) .collect(Collectors.toList()); return QueryExerciseAnalysisResponse.builder() From 6f89172de2342957696214c17c1343a03f3710f4 Mon Sep 17 00:00:00 2001 From: lyutvs Date: Mon, 14 Feb 2022 17:46:09 +0900 Subject: [PATCH 150/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F::=20import=20?= =?UTF-8?q?=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/walkhub/walkhub/domain/badge/domain/Badge.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/badge/domain/Badge.java b/src/main/java/com/walkhub/walkhub/domain/badge/domain/Badge.java index c59015930..80b314de1 100644 --- a/src/main/java/com/walkhub/walkhub/domain/badge/domain/Badge.java +++ b/src/main/java/com/walkhub/walkhub/domain/badge/domain/Badge.java @@ -9,7 +9,6 @@ import org.hibernate.annotations.ColumnDefault; import javax.persistence.CascadeType; -import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; From 8b5d6f8f8ebecfc79d4d0de884cd75430dc1b964 Mon Sep 17 00:00:00 2001 From: lyutvs Date: Mon, 14 Feb 2022 18:02:35 +0900 Subject: [PATCH 151/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F::=20QueryMyBadgeList?= =?UTF-8?q?Response?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/dto/response/QueryMyBadgeListResponse.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/badge/presentation/dto/response/QueryMyBadgeListResponse.java b/src/main/java/com/walkhub/walkhub/domain/badge/presentation/dto/response/QueryMyBadgeListResponse.java index fcb6de18a..e3a1cabba 100644 --- a/src/main/java/com/walkhub/walkhub/domain/badge/presentation/dto/response/QueryMyBadgeListResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/badge/presentation/dto/response/QueryMyBadgeListResponse.java @@ -1,5 +1,6 @@ package com.walkhub.walkhub.domain.badge.presentation.dto.response; +import com.walkhub.walkhub.domain.badge.domain.repository.vo.DefaultBadgeVO; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; @@ -10,7 +11,7 @@ @AllArgsConstructor public class QueryMyBadgeListResponse { - private final List badgeLists; + private final List badgeLists; @Getter @Builder @@ -20,5 +21,4 @@ public static class BadgeListResponse { private final String imageUrl; private final boolean isMine; } - } From 71f754acc13734476813f2a371cafce23ee82414 Mon Sep 17 00:00:00 2001 From: lyutvs Date: Mon, 14 Feb 2022 18:02:46 +0900 Subject: [PATCH 152/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F::=20QueryMyBadgeList?= =?UTF-8?q?Service?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../badge/service/QueryMyBadgeListService.java | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/badge/service/QueryMyBadgeListService.java b/src/main/java/com/walkhub/walkhub/domain/badge/service/QueryMyBadgeListService.java index 6e95c5a40..2c497e550 100644 --- a/src/main/java/com/walkhub/walkhub/domain/badge/service/QueryMyBadgeListService.java +++ b/src/main/java/com/walkhub/walkhub/domain/badge/service/QueryMyBadgeListService.java @@ -3,16 +3,13 @@ import com.walkhub.walkhub.domain.badge.domain.repository.BadgeRepository; import com.walkhub.walkhub.domain.badge.domain.repository.vo.DefaultBadgeVO; import com.walkhub.walkhub.domain.badge.presentation.dto.response.QueryMyBadgeListResponse; -import com.walkhub.walkhub.domain.badge.presentation.dto.response.QueryMyBadgeListResponse.BadgeListResponse; import com.walkhub.walkhub.domain.user.domain.User; import com.walkhub.walkhub.domain.user.facade.UserFacade; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.util.ArrayList; import java.util.List; -import java.util.stream.Collectors; @RequiredArgsConstructor @Service @@ -24,17 +21,7 @@ public class QueryMyBadgeListService { @Transactional(readOnly = true) public QueryMyBadgeListResponse execute() { User user = userFacade.getCurrentUser(); - List badgeListResponseList = new ArrayList<>(); - List badgeVOList = badgeRepository.findAllByBadgeCollections(user.getId()) - .stream() - .map(defaultBadgeVO -> DefaultBadgeVO.builder() - .badgeId(defaultBadgeVO.getBadgeId()) - .name(defaultBadgeVO.getName()) - .imageUrl(defaultBadgeVO.getImageUrl()) - .build() - ) - .collect(Collectors.toList()); - - return new QueryMyBadgeListResponse(badgeListResponseList); + List badgeVOList = badgeRepository.findAllByBadgeCollections(user.getId()); + return new QueryMyBadgeListResponse(badgeVOList); } } From bacda827999f115d04461db95d6ef3fb78426382 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B2=94=EC=A7=84?= Date: Mon, 14 Feb 2022 23:09:50 +0900 Subject: [PATCH 153/522] =?UTF-8?q?=E2=9A=B0=20::=20successCount?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/challenge/domain/ChallengeStatus.java | 15 +++++++-------- .../service/ParticipateChallengeService.java | 1 - 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/ChallengeStatus.java b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/ChallengeStatus.java index 8e0a84642..45b42a2aa 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/ChallengeStatus.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/ChallengeStatus.java @@ -5,9 +5,13 @@ import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; -import org.hibernate.annotations.ColumnDefault; -import javax.persistence.*; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.Id; +import javax.persistence.IdClass; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) @@ -25,15 +29,10 @@ public class ChallengeStatus { @JoinColumn(name = "user_id") private User user; - @ColumnDefault("1") - @Column(nullable = false) - private Long successCount; - @Builder - public ChallengeStatus(Challenge challenge, User user, Long successCount) { + public ChallengeStatus(Challenge challenge, User user) { this.challenge = challenge; this.user = user; - this.successCount = successCount; } } diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/service/ParticipateChallengeService.java b/src/main/java/com/walkhub/walkhub/domain/challenge/service/ParticipateChallengeService.java index 779d56aa6..b184178b0 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/service/ParticipateChallengeService.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/service/ParticipateChallengeService.java @@ -36,7 +36,6 @@ public void execute(Long challengeId) { ChallengeStatus challengeStatus = ChallengeStatus.builder() .challenge(challenge) .user(user) - .successCount(0L) .build(); challengeStatusRepository.save(challengeStatus); From ad4d306a8f48eb48b2d50d500f40311b637506e2 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Mon, 14 Feb 2022 23:14:31 +0900 Subject: [PATCH 154/522] =?UTF-8?q?=F0=9F=93=91=20::=20UserListInfoVO?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/teacher/vo/UserListInfoVO.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/main/java/com/walkhub/walkhub/domain/teacher/vo/UserListInfoVO.java diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/vo/UserListInfoVO.java b/src/main/java/com/walkhub/walkhub/domain/teacher/vo/UserListInfoVO.java new file mode 100644 index 000000000..e1bd0a6e3 --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/vo/UserListInfoVO.java @@ -0,0 +1,26 @@ +package com.walkhub.walkhub.domain.teacher.vo; + +import com.querydsl.core.annotations.QueryProjection; +import lombok.Getter; + +@Getter +public class UserListInfoVO { + private final Long userId; + private final String name; + private final String profileImageUrl; + private final Integer grade; + private final Integer classNum; + private final Integer number; + private final Boolean isTeacher; + + @QueryProjection + public UserListInfoVO(Long userId, String name, String profileImageUrl, Integer grade, Integer classNum, Integer number, Boolean isTeacher) { + this.userId = userId; + this.name = name; + this.profileImageUrl = profileImageUrl; + this.grade = grade; + this.classNum = classNum; + this.number = number; + this.isTeacher = isTeacher; + } +} From a629fe37256648e179c1a5db7e9c46169d3188be Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Mon, 14 Feb 2022 23:15:06 +0900 Subject: [PATCH 155/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20VO=EB=A1=9C?= =?UTF-8?q?=20=ED=83=80=EC=9E=85=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../user/domain/repository/UserRepositoryCustomImpl.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java index 0bc0f790a..613959729 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java @@ -4,10 +4,11 @@ import com.querydsl.core.types.OrderSpecifier; import com.querydsl.core.types.dsl.BooleanExpression; import com.querydsl.jpa.impl.JPAQueryFactory; -import com.walkhub.walkhub.domain.teacher.presentation.dto.response.QQueryUserListResponse_UserListInfo; import com.walkhub.walkhub.domain.teacher.presentation.dto.response.QueryUserListResponse; import com.walkhub.walkhub.domain.teacher.type.AuthorityScope; import com.walkhub.walkhub.domain.teacher.type.SortStandard; +import com.walkhub.walkhub.domain.teacher.vo.QUserListInfoVO; +import com.walkhub.walkhub.domain.teacher.vo.UserListInfoVO; import com.walkhub.walkhub.domain.user.domain.User; import com.walkhub.walkhub.domain.user.facade.SectionFacade; import com.walkhub.walkhub.global.enums.Authority; @@ -26,10 +27,10 @@ public class UserRepositoryCustomImpl implements UserRepositoryCustom { private final SectionFacade sectionFacade; @Override - public List queryUserList(Integer page, AuthorityScope scope, SortStandard sort, Integer grade, Integer classNum, User currentUser) { + public List queryUserList(Integer page, AuthorityScope scope, SortStandard sort, Integer grade, Integer classNum, User currentUser) { long size = 4; return queryFactory - .select(new QQueryUserListResponse_UserListInfo( + .select(new QUserListInfoVO( user.id.as("userId"), user.name, user.profileImageUrl, @@ -49,6 +50,7 @@ public List queryUserList(Integer page, Auth .offset((long)page * size) .limit(size) .orderBy(buildSortCondition(sort)) + .groupBy(user.id) .fetch(); } From 6910c920b22c91ba5d4ce29804f733e9f2752db4 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Mon, 14 Feb 2022 23:15:35 +0900 Subject: [PATCH 156/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20=EB=9D=84?= =?UTF-8?q?=EC=96=B4=EC=93=B0=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/walkhub/walkhub/global/security/SecurityConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java b/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java index 40bf2df7a..183fd6746 100644 --- a/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java +++ b/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java @@ -111,7 +111,7 @@ protected void configure(HttpSecurity http) throws Exception { .antMatchers(HttpMethod.DELETE, "/teachers/classes/{section-id}").hasAnyAuthority("TEACHER", "ROOT") .antMatchers(HttpMethod.GET, "/teachers/classes").hasAnyAuthority("TEACHER") .antMatchers(HttpMethod.GET,"/teachers/{user-id}").hasAnyAuthority("TEACHER") - .antMatchers(HttpMethod.GET,"/teachers/users").hasAnyAuthority("TEACHER","ROOT") + .antMatchers(HttpMethod.GET,"/teachers/users").hasAnyAuthority("TEACHER", "ROOT") .antMatchers(HttpMethod.GET,"/teachers/students/verification-codes").hasAnyAuthority("TEACHER") .antMatchers(HttpMethod.PATCH, "/teachers/classes/verification-codes").hasAuthority("TEACHER") From 6cc92eec757b66214b1e4f93bdab66b1cdce5b31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B2=94=EC=A7=84?= Date: Mon, 14 Feb 2022 23:16:26 +0900 Subject: [PATCH 157/522] =?UTF-8?q?=E2=9A=A1=20::=20=EC=9C=A0=EC=A0=80=20?= =?UTF-8?q?=EC=A0=95=EB=B3=B4=EC=99=80=20=EC=84=B1=EA=B3=B5=ED=95=9C=20?= =?UTF-8?q?=EB=82=A0=EC=A7=9C=20=EC=A1=B0=ED=9A=8C=20=EB=B0=A9=EC=8B=9D=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CustomChallengeRepositoryImpl.java | 46 ++++++++++--------- .../vo/ChallengeParticipantsVO.java | 9 ++-- 2 files changed, 27 insertions(+), 28 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/CustomChallengeRepositoryImpl.java b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/CustomChallengeRepositoryImpl.java index 6e278b290..619dd26a9 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/CustomChallengeRepositoryImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/CustomChallengeRepositoryImpl.java @@ -1,8 +1,7 @@ package com.walkhub.walkhub.domain.challenge.domain.repository; -import com.querydsl.core.group.GroupBy; import com.querydsl.core.types.dsl.BooleanExpression; -import com.querydsl.jpa.JPAExpressions; +import com.querydsl.core.types.dsl.Expressions; import com.querydsl.jpa.impl.JPAQueryFactory; import com.walkhub.walkhub.domain.challenge.domain.Challenge; import com.walkhub.walkhub.domain.challenge.domain.repository.vo.ChallengeParticipantsVO; @@ -14,7 +13,7 @@ import java.util.List; -import static com.querydsl.core.group.GroupBy.groupBy; +import static com.querydsl.jpa.JPAExpressions.select; import static com.walkhub.walkhub.domain.challenge.domain.QChallengeStatus.challengeStatus; import static com.walkhub.walkhub.domain.exercise.domain.QExerciseAnalysis.exerciseAnalysis; import static com.walkhub.walkhub.domain.school.domain.QSchool.school; @@ -29,7 +28,17 @@ public class CustomChallengeRepositoryImpl implements CustomChallengeRepository @Override public List queryChallengeParticipantsList(Challenge challenge, SuccessScope successScope) { return jpaQueryFactory - .selectFrom(user) + .select(new QChallengeParticipantsVO( + user.id.as("userId"), + user.section.grade, + user.section.classNum, + user.number, + user.name, + user.profileImageUrl, + school.name, + exerciseAnalysis.date + )) + .from(user) .join(user.school, school) .leftJoin(user.section, section) .join(user.exerciseAnalyses, exerciseAnalysis) @@ -37,33 +46,26 @@ public List queryChallengeParticipantsList(Challenge ch .join(challengeStatus.challenge) .on(challengeStatus.challenge.eq(challenge)) .where( - successScopeFilter(challenge, successScope), goalTypeFilter(challenge), + successScopeFilter(challenge, successScope), exerciseAnalysis.date.between(challenge.getStartAt(), challenge.getEndAt()) ) + .groupBy(user.id, exerciseAnalysis.date) .orderBy(user.name.asc(), user.id.asc()) - .transform(groupBy(user.name, user.id) - .list(new QChallengeParticipantsVO( - user.id.as("userId"), - user.section.grade, - user.section.classNum, - user.number, - user.name, - user.profileImageUrl, - user.school.name.as("schoolName"), - challengeStatus.successCount.goe(challenge.getSuccessStandard()).as("isSuccess"), - GroupBy.list(exerciseAnalysis.date)) - ) - ); + .fetch(); } private BooleanExpression successScopeFilter(Challenge challenge, SuccessScope successScope) { switch (successScope) { case TRUE: { - return challengeStatus.successCount.goe(challenge.getSuccessStandard()); + return Expressions.asNumber(select(exerciseAnalysis.count()) + .from(exerciseAnalysis) + .where(exerciseAnalysis.user.eq(user))).goe(challenge.getSuccessStandard()); } case FALSE: { - return challengeStatus.successCount.lt(challenge.getSuccessStandard()); + return Expressions.asNumber(select(exerciseAnalysis.count()) + .from(exerciseAnalysis) + .where(exerciseAnalysis.user.eq(user))).lt(challenge.getSuccessStandard()); } default: { return null; @@ -84,7 +86,7 @@ private BooleanExpression isChallengeSuccessByWalkCount(Challenge challenge) { return exerciseAnalysis.walkCount.goe(challenge.getGoal()); } - return JPAExpressions.select(exerciseAnalysis.walkCount.sum()) + return select(exerciseAnalysis.walkCount.sum()) .from(exerciseAnalysis) .where(exerciseAnalysis.date.between(challenge.getStartAt(), challenge.getEndAt())) .goe(challenge.getGoal()); @@ -95,7 +97,7 @@ private BooleanExpression isChallengeSuccessByDistance(Challenge challenge) { return exerciseAnalysis.distance.goe(challenge.getGoal()); } - return JPAExpressions.select(exerciseAnalysis.distance.sum()) + return select(exerciseAnalysis.distance.sum()) .from(exerciseAnalysis) .where(exerciseAnalysis.date.between(challenge.getStartAt(), challenge.getEndAt())) .goe(challenge.getGoal()); diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/vo/ChallengeParticipantsVO.java b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/vo/ChallengeParticipantsVO.java index c3b381ec5..7929d272a 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/vo/ChallengeParticipantsVO.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/vo/ChallengeParticipantsVO.java @@ -4,7 +4,6 @@ import lombok.Getter; import java.time.LocalDate; -import java.util.List; @Getter public class ChallengeParticipantsVO { @@ -15,12 +14,11 @@ public class ChallengeParticipantsVO { private final String name; private final String profileImageUrl; private final String schoolName; - private final Boolean isSuccess; - private final List exerciseAnalysesDates; + private final LocalDate exerciseAnalysesDate; @QueryProjection public ChallengeParticipantsVO(Long userId, Integer grade, Integer classNum, Integer number, - String name, String profileImageUrl, String schoolName, Boolean isSuccess, List exerciseAnalysesDates) { + String name, String profileImageUrl, String schoolName, LocalDate exerciseAnalysesDate) { this.userId = userId; this.grade = grade; this.classNum = classNum; @@ -28,7 +26,6 @@ public ChallengeParticipantsVO(Long userId, Integer grade, Integer classNum, Int this.name = name; this.profileImageUrl = profileImageUrl; this.schoolName = schoolName; - this.isSuccess = isSuccess; - this.exerciseAnalysesDates = exerciseAnalysesDates; + this.exerciseAnalysesDate = exerciseAnalysesDate; } } From 67a225c12eb945244e9e0bec56d4900f8a1a7527 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Mon, 14 Feb 2022 23:41:08 +0900 Subject: [PATCH 158/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20=EC=9D=8C..?= =?UTF-8?q?=20=EC=96=B4=EC=A8=8C=EB=93=A0=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/walkhub/walkhub/global/security/SecurityConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java b/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java index 94dd63018..e302b9989 100644 --- a/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java +++ b/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java @@ -108,11 +108,11 @@ protected void configure(HttpSecurity http) throws Exception { // teachers .antMatchers(HttpMethod.POST, "/teachers/verification-codes").hasAuthority("ROOT") .antMatchers(HttpMethod.PATCH, "/teachers/verification-codes").hasAuthority("USER") + .antMatchers(HttpMethod.GET,"/teachers/users").hasAnyAuthority("TEACHER", "ROOT") .antMatchers(HttpMethod.POST, "/teachers/classes").hasAnyAuthority("TEACHER", "ROOT") .antMatchers(HttpMethod.DELETE, "/teachers/classes/{section-id}").hasAnyAuthority("TEACHER", "ROOT") .antMatchers(HttpMethod.GET, "/teachers/classes").hasAnyAuthority("TEACHER") .antMatchers(HttpMethod.GET,"/teachers/{user-id}").hasAnyAuthority("TEACHER") - .antMatchers(HttpMethod.GET,"/teachers/users").hasAnyAuthority("TEACHER", "ROOT") .antMatchers(HttpMethod.GET,"/teachers/students/verification-codes").hasAnyAuthority("TEACHER") .antMatchers(HttpMethod.PATCH, "/teachers/classes/verification-codes").hasAuthority("TEACHER") From 65d9b43ce43c4d63a2539b9a4c160f8a4cda8dff Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Mon, 14 Feb 2022 23:43:31 +0900 Subject: [PATCH 159/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20=EC=A1=B0?= =?UTF-8?q?=EC=9D=B8=EB=AC=B8=20=EA=B9=94=EC=8C=88=ED=95=98=EA=B2=8C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../user/domain/repository/UserRepositoryCustomImpl.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java index 613959729..3260f8fd4 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java @@ -40,8 +40,7 @@ public List queryUserList(Integer page, AuthorityScope scope, So user.authority.eq(Authority.TEACHER).as("isTeacher") )) .from(user) - .leftJoin(exerciseAnalysis) - .on(exerciseAnalysis.user.eq(user)) + .leftJoin(user.exerciseAnalyses, exerciseAnalysis) .where( user.school.eq(currentUser.getSchool()), buildFilteringCondition(scope), From 6a2a0851b893dd42305be489f8d3a040c18ef490 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B2=94=EC=A7=84?= Date: Mon, 14 Feb 2022 23:44:37 +0900 Subject: [PATCH 160/522] =?UTF-8?q?=E2=9A=A1=20::=20=EC=A1=B0=ED=9A=8C=20?= =?UTF-8?q?=EB=B0=A9=EC=8B=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...hallengeParticipantsForTeacherService.java | 49 ++++++++++++++----- 1 file changed, 36 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/service/QueryChallengeParticipantsForTeacherService.java b/src/main/java/com/walkhub/walkhub/domain/challenge/service/QueryChallengeParticipantsForTeacherService.java index 7470e56a0..e1c72b6a5 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/service/QueryChallengeParticipantsForTeacherService.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/service/QueryChallengeParticipantsForTeacherService.java @@ -2,14 +2,18 @@ import com.walkhub.walkhub.domain.challenge.domain.Challenge; import com.walkhub.walkhub.domain.challenge.domain.repository.ChallengeStatusRepository; +import com.walkhub.walkhub.domain.challenge.domain.repository.vo.ChallengeParticipantsVO; import com.walkhub.walkhub.domain.challenge.domain.type.SuccessScope; import com.walkhub.walkhub.domain.challenge.facade.ChallengeFacade; import com.walkhub.walkhub.domain.challenge.presenstation.dto.response.QueryChallengeParticipantsForTeacherResponse; +import com.walkhub.walkhub.domain.user.exception.UserNotFoundException; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.time.LocalDate; import java.util.List; +import java.util.Map; import java.util.stream.Collectors; @RequiredArgsConstructor @@ -30,20 +34,39 @@ public QueryChallengeParticipantsForTeacherResponse execute(Long challengeId, Su private List queryChallengeParticipantsForTeacherResponseBuilder( Challenge challenge, SuccessScope successScope ) { - return challengeStatusRepository.queryChallengeParticipantsList(challenge, successScope) - .stream() - .map(vo -> QueryChallengeParticipantsForTeacherResponse.ChallengeParticipants.builder() - .userId(vo.getUserId()) - .grade(vo.getGrade()) - .classNum(vo.getClassNum()) - .number(vo.getNumber()) - .name(vo.getName()) - .profileImageUrl(vo.getProfileImageUrl()) - .schoolName(vo.getSchoolName()) - .successDate(vo.getExerciseAnalysesDates()) - .isSuccess(vo.getIsSuccess()) - .build()) + Map> participants = + challengeStatusRepository.queryChallengeParticipantsList(challenge, successScope).stream() + .collect(Collectors.groupingBy(ChallengeParticipantsVO::getUserId)); + + return participants.values().stream() + .map(vo -> buildChallengeParticipantsResponse(vo, challenge)) .collect(Collectors.toList()); } + private QueryChallengeParticipantsForTeacherResponse.ChallengeParticipants buildChallengeParticipantsResponse( + List challengeParticipantsVOs, + Challenge challenge + ) { + List successDates = challengeParticipantsVOs.stream() + .map(ChallengeParticipantsVO::getExerciseAnalysesDate) + .sorted().collect(Collectors.toList()); + + ChallengeParticipantsVO participantsVO = challengeParticipantsVOs.stream().findFirst() + .orElseThrow(() -> UserNotFoundException.EXCEPTION); + + Integer successCount = successDates.size(); + + return QueryChallengeParticipantsForTeacherResponse.ChallengeParticipants.builder() + .userId(participantsVO.getUserId()) + .grade(participantsVO.getGrade()) + .classNum(participantsVO.getClassNum()) + .number(participantsVO.getNumber()) + .name(participantsVO.getName()) + .profileImageUrl(participantsVO.getProfileImageUrl()) + .schoolName(participantsVO.getSchoolName()) + .successDate(successDates) + .isSuccess(challenge.getSuccessStandard() <= successCount) + .build(); + } + } From c98b0e000e474afeb809b8affeaddc3416ca2227 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Mon, 14 Feb 2022 23:46:52 +0900 Subject: [PATCH 161/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20codesmell=20?= =?UTF-8?q?=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../walkhub/domain/teacher/presentation/TeacherController.java | 3 --- .../domain/user/domain/repository/UserRepositoryCustom.java | 1 - .../user/domain/repository/UserRepositoryCustomImpl.java | 1 - 3 files changed, 5 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/TeacherController.java b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/TeacherController.java index 8bbc853ea..0e415586e 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/TeacherController.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/TeacherController.java @@ -9,7 +9,6 @@ import com.walkhub.walkhub.domain.teacher.type.SortStandard; import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; -import org.springframework.web.bind.annotation.*; import com.walkhub.walkhub.domain.teacher.presentation.dto.response.DetailsClassResponse; import com.walkhub.walkhub.domain.teacher.presentation.dto.response.QueryUserDetailsResponse; import com.walkhub.walkhub.domain.teacher.service.ConfirmTeacherCodeService; @@ -20,9 +19,7 @@ import com.walkhub.walkhub.domain.teacher.service.RefreshClassCodeService; import com.walkhub.walkhub.domain.teacher.service.VerificationCodeService; import java.time.LocalDate; -import lombok.RequiredArgsConstructor; import org.springframework.format.annotation.DateTimeFormat; -import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PatchMapping; diff --git a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustom.java b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustom.java index b04e7c978..5928ce3bb 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustom.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustom.java @@ -1,6 +1,5 @@ package com.walkhub.walkhub.domain.user.domain.repository; -import com.walkhub.walkhub.domain.teacher.presentation.dto.response.QueryUserListResponse; import com.walkhub.walkhub.domain.teacher.type.AuthorityScope; import com.walkhub.walkhub.domain.teacher.type.SortStandard; import com.walkhub.walkhub.domain.teacher.vo.UserListInfoVO; diff --git a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java index 3260f8fd4..a3d0a86b8 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java @@ -4,7 +4,6 @@ import com.querydsl.core.types.OrderSpecifier; import com.querydsl.core.types.dsl.BooleanExpression; import com.querydsl.jpa.impl.JPAQueryFactory; -import com.walkhub.walkhub.domain.teacher.presentation.dto.response.QueryUserListResponse; import com.walkhub.walkhub.domain.teacher.type.AuthorityScope; import com.walkhub.walkhub.domain.teacher.type.SortStandard; import com.walkhub.walkhub.domain.teacher.vo.QUserListInfoVO; From 9be125d8133994375387dd83e6a78279f37f8e46 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Tue, 15 Feb 2022 00:13:10 +0900 Subject: [PATCH 162/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20BooleanExpres?= =?UTF-8?q?sion=EC=9C=BC=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 --- .../repository/UserRepositoryCustomImpl.java | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java index a3d0a86b8..a63cd30c1 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java @@ -43,7 +43,8 @@ public List queryUserList(Integer page, AuthorityScope scope, So .where( user.school.eq(currentUser.getSchool()), buildFilteringCondition(scope), - gradeAndClassNumEq(grade, classNum) + gradeEq(grade), + classNumEq(classNum) ) .offset((long)page * size) .limit(size) @@ -52,16 +53,12 @@ public List queryUserList(Integer page, AuthorityScope scope, So .fetch(); } - private BooleanBuilder gradeAndClassNumEq(Integer grade, Integer classNum) { - return gradeEq(grade).and(classNumEq(classNum)); + private BooleanExpression gradeEq(Integer grade) { + return grade != null ? user.section.grade.eq(grade) : null; } - private BooleanBuilder gradeEq(Integer grade) { - return querydslUtil.nullSafeBuilder(() -> user.section.grade.eq(grade)); - } - - private BooleanBuilder classNumEq(Integer classNum) { - return querydslUtil.nullSafeBuilder(() -> user.section.classNum.eq(classNum)); + private BooleanExpression classNumEq(Integer classNum) { + return classNum != null ? user.section.classNum.eq(classNum) : null; } private BooleanExpression buildFilteringCondition(AuthorityScope scope) { From 5e9370417203a16c2c98f00748dd28585c766763 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Tue, 15 Feb 2022 00:14:44 +0900 Subject: [PATCH 163/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20querydslUtil?= =?UTF-8?q?=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/UserRepositoryCustomImpl.java | 5 ----- .../walkhub/global/querydsl/QuerydslUtil.java | 18 ------------------ 2 files changed, 23 deletions(-) delete mode 100644 src/main/java/com/walkhub/walkhub/global/querydsl/QuerydslUtil.java diff --git a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java index a63cd30c1..1c0cb5678 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java @@ -1,6 +1,5 @@ package com.walkhub.walkhub.domain.user.domain.repository; -import com.querydsl.core.BooleanBuilder; import com.querydsl.core.types.OrderSpecifier; import com.querydsl.core.types.dsl.BooleanExpression; import com.querydsl.jpa.impl.JPAQueryFactory; @@ -9,9 +8,7 @@ import com.walkhub.walkhub.domain.teacher.vo.QUserListInfoVO; import com.walkhub.walkhub.domain.teacher.vo.UserListInfoVO; import com.walkhub.walkhub.domain.user.domain.User; -import com.walkhub.walkhub.domain.user.facade.SectionFacade; import com.walkhub.walkhub.global.enums.Authority; -import com.walkhub.walkhub.global.querydsl.QuerydslUtil; import lombok.RequiredArgsConstructor; import java.util.List; @@ -22,8 +19,6 @@ @RequiredArgsConstructor public class UserRepositoryCustomImpl implements UserRepositoryCustom { private final JPAQueryFactory queryFactory; - private final QuerydslUtil querydslUtil; - private final SectionFacade sectionFacade; @Override public List queryUserList(Integer page, AuthorityScope scope, SortStandard sort, Integer grade, Integer classNum, User currentUser) { diff --git a/src/main/java/com/walkhub/walkhub/global/querydsl/QuerydslUtil.java b/src/main/java/com/walkhub/walkhub/global/querydsl/QuerydslUtil.java deleted file mode 100644 index 209476891..000000000 --- a/src/main/java/com/walkhub/walkhub/global/querydsl/QuerydslUtil.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.walkhub.walkhub.global.querydsl; - -import com.querydsl.core.BooleanBuilder; -import com.querydsl.core.types.dsl.BooleanExpression; -import org.springframework.stereotype.Component; - -import java.util.function.Supplier; - -@Component -public class QuerydslUtil { - public BooleanBuilder nullSafeBuilder(Supplier f) { - try { - return new BooleanBuilder(f.get()); - } catch (IllegalArgumentException e) { - return new BooleanBuilder(); - } - } -} From dfd73b6e6ff2afb02b4f9db0b42e42f21d8fce01 Mon Sep 17 00:00:00 2001 From: lyutvs Date: Tue, 15 Feb 2022 00:21:41 +0900 Subject: [PATCH 164/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F::=20=EB=B6=88?= =?UTF-8?q?=ED=95=84=EC=9A=94=ED=95=9C=20=EC=9E=84=ED=8F=AC=ED=8A=B8=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exercise/domain/repository/ExerciseAnalysisRepository.java | 1 - .../domain/exercise/presentation/ExerciseController.java | 2 +- .../domain/exercise/service/QueryExerciseAnalysisService.java | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepository.java b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepository.java index cceea1c49..5b04a76e0 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepository.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepository.java @@ -2,7 +2,6 @@ import com.walkhub.walkhub.domain.exercise.domain.ExerciseAnalysis; import com.walkhub.walkhub.domain.user.domain.User; -import java.util.List; import org.springframework.data.repository.CrudRepository; import java.time.LocalDate; diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/ExerciseController.java b/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/ExerciseController.java index 06705a873..4d78a2062 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/ExerciseController.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/ExerciseController.java @@ -58,7 +58,7 @@ public void saveOrUpdateTodayExercise(@RequestBody @Valid SaveExerciseAnalysisRe } @GetMapping("/analysis") - public QueryExerciseAnalysisResponse QueryExerciseAnalysis() { + public QueryExerciseAnalysisResponse queryExerciseAnalysis() { return queryExerciseAnalysisService.execute(); } diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/service/QueryExerciseAnalysisService.java b/src/main/java/com/walkhub/walkhub/domain/exercise/service/QueryExerciseAnalysisService.java index d41130bb2..01181be2d 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/service/QueryExerciseAnalysisService.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/service/QueryExerciseAnalysisService.java @@ -10,7 +10,6 @@ import org.springframework.transaction.annotation.Transactional; import java.time.LocalDate; -import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; From 772728023b87daad55441251306267fecebb5848 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Tue, 15 Feb 2022 00:25:10 +0900 Subject: [PATCH 165/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20=EC=BF=BC?= =?UTF-8?q?=EB=A6=AC=EB=A9=94=EC=86=8C=EB=93=9C=EB=AA=85=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD,=20=ED=8C=8C=EB=9D=BC=EB=AF=B8=ED=84=B0=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 --- .../domain/repository/ExerciseAnalysisRepository.java | 2 +- .../walkhub/domain/rank/service/QueryUserRankListService.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepository.java b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepository.java index 339f0030c..cd1356eb6 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepository.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepository.java @@ -9,5 +9,5 @@ public interface ExerciseAnalysisRepository extends CrudRepository { Optional findByUserAndDate(User user, LocalDate date); - Integer findWalkCountByUserId(Long userId); + Integer findByUserIdAndDate(Long userId, LocalDate date); } diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListService.java b/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListService.java index 76a7eec61..a527b8836 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListService.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListService.java @@ -36,7 +36,7 @@ public UserRankListResponse execute(String scope, String dateType) { .classNum(section.getClassNum()) .ranking(Math.toIntExact(exerciseAnalysisCacheRepository.getUserTodayRank(user.getId()))) .profileImageUrl(user.getProfileImageUrl()) - .walkCount(exerciseAnalysisRepository.findWalkCountByUserId(user.getId())) + .walkCount(exerciseAnalysisRepository.findByUserIdAndDate(user.getId(), LocalDate.now())) .build() ) .rankList(exerciseAnalysisCacheRepository.getUserIdsByRankTop100() @@ -49,7 +49,7 @@ public UserRankListResponse execute(String scope, String dateType) { .classNum(users.getSection().getClassNum()) .ranking(rankCount.incrementAndGet()) .profileImageUrl(users.getProfileImageUrl()) - .walkCount(exerciseAnalysisRepository.findWalkCountByUserId(users.getId())) + .walkCount(exerciseAnalysisRepository.findByUserIdAndDate(users.getId(), LocalDate.now())) .build() ).collect(Collectors.toList()) ).build(); From 4f3df7083aaca4bac97221d7fc63acc1822b87ac Mon Sep 17 00:00:00 2001 From: lyutvs Date: Tue, 15 Feb 2022 00:28:29 +0900 Subject: [PATCH 166/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F::=20@Transactioanl(r?= =?UTF-8?q?eadOnly=3Dtrue)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../walkhub/domain/badge/service/QueryUserBadgeListService.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/badge/service/QueryUserBadgeListService.java b/src/main/java/com/walkhub/walkhub/domain/badge/service/QueryUserBadgeListService.java index 7538c0907..35ad3b24c 100644 --- a/src/main/java/com/walkhub/walkhub/domain/badge/service/QueryUserBadgeListService.java +++ b/src/main/java/com/walkhub/walkhub/domain/badge/service/QueryUserBadgeListService.java @@ -5,6 +5,7 @@ import com.walkhub.walkhub.domain.badge.presentation.dto.response.QueryUserBadgeListResponse.DefaultBadgeResponse; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.util.List; import java.util.stream.Collectors; @@ -15,6 +16,7 @@ public class QueryUserBadgeListService { private final BadgeCollectionRepository badgeCollectionRepository; + @Transactional(readOnly = true) public QueryUserBadgeListResponse execute(Long userId) { List badgeList = badgeCollectionRepository.findAllByUserId(userId) From 29bdccaa3272bcc4ede0b231c77ae02e8bf297ab Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Tue, 15 Feb 2022 00:55:05 +0900 Subject: [PATCH 167/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20VO=EB=A1=9C?= =?UTF-8?q?=20=ED=83=80=EC=9E=85=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rank/domain/repository/UserRankRepositoryCustom.java | 6 +++--- .../domain/repository/UserRankRepositoryCustomImpl.java | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustom.java b/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustom.java index 3d24f74c2..8fdd3dfa2 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustom.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustom.java @@ -1,11 +1,11 @@ package com.walkhub.walkhub.domain.rank.domain.repository; -import com.walkhub.walkhub.domain.rank.presentation.dto.response.UserRankListResponse; +import com.walkhub.walkhub.domain.rank.domain.repository.vo.UserRankVO; import java.time.LocalDate; import java.util.List; public interface UserRankRepositoryCustom { - UserRankListResponse.UserRankResponse getMyRankByUserId(Long userId, Integer classNum, String dateType, LocalDate date); - List getUserRankListBySchoolId(Long schoolId, Integer classNum, String dateType, LocalDate date); + UserRankVO getMyRankByUserId(Long userId, Integer classNum, String dateType, LocalDate date); + List getUserRankListBySchoolId(Long schoolId, Integer classNum, String dateType, LocalDate date); } diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustomImpl.java index 936fbc33a..5f08ad2a8 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustomImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustomImpl.java @@ -2,6 +2,7 @@ import com.querydsl.core.types.dsl.BooleanExpression; import com.querydsl.jpa.impl.JPAQueryFactory; +import com.walkhub.walkhub.domain.rank.domain.repository.vo.UserRankVO; import com.walkhub.walkhub.domain.rank.presentation.dto.response.QUserRankListResponse_UserRankResponse; import com.walkhub.walkhub.domain.rank.presentation.dto.response.UserRankListResponse; import lombok.RequiredArgsConstructor; @@ -18,7 +19,7 @@ public class UserRankRepositoryCustomImpl implements UserRankRepositoryCustom { private static final Long LIMIT = 100L; @Override - public UserRankListResponse.UserRankResponse getMyRankByUserId(Long userId, Integer classNum, String dateType, LocalDate date) { + public UserRankVO getMyRankByUserId(Long userId, Integer classNum, String dateType, LocalDate date) { return queryFactory .select(new QUserRankListResponse_UserRankResponse( userRank.userId, @@ -40,7 +41,7 @@ public UserRankListResponse.UserRankResponse getMyRankByUserId(Long userId, Inte } @Override - public List getUserRankListBySchoolId(Long schoolId, Integer classNum, String dateType, LocalDate date) { + public List getUserRankListBySchoolId(Long schoolId, Integer classNum, String dateType, LocalDate date) { return queryFactory .select(new QUserRankListResponse_UserRankResponse( userRank.userId, From f3df30a8f00ef9c5bd7b142c72d102063b581a91 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Tue, 15 Feb 2022 00:55:18 +0900 Subject: [PATCH 168/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20UserRankVO?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rank/domain/repository/vo/UserRankVO.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/vo/UserRankVO.java diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/vo/UserRankVO.java b/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/vo/UserRankVO.java new file mode 100644 index 000000000..28edcf7ef --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/vo/UserRankVO.java @@ -0,0 +1,26 @@ +package com.walkhub.walkhub.domain.rank.domain.repository.vo; + +import com.querydsl.core.annotations.QueryProjection; +import lombok.Getter; + +@Getter +public class UserRankVO { + private final Long userId; + private final String name; + private final Integer grade; + private final Integer classNum; + private final Integer ranking; + private final String profileImageUrl; + private final Integer walkCount; + + @QueryProjection + public UserRankVO(Long userId, String name, Integer grade, Integer classNum, Integer ranking, String profileImageUrl, Integer walkCount) { + this.userId = userId; + this.name = name; + this.grade = grade; + this.classNum = classNum; + this.ranking = ranking; + this.profileImageUrl = profileImageUrl; + this.walkCount = walkCount; + } +} From 7b6642543d7eb0359ce75bb8a1dc6070f4e3ee48 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Tue, 15 Feb 2022 00:55:33 +0900 Subject: [PATCH 169/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20QueryProjecti?= =?UTF-8?q?on=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/response/UserRankListResponse.java | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/presentation/dto/response/UserRankListResponse.java b/src/main/java/com/walkhub/walkhub/domain/rank/presentation/dto/response/UserRankListResponse.java index f01cb8789..81067c8d3 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/presentation/dto/response/UserRankListResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/presentation/dto/response/UserRankListResponse.java @@ -1,6 +1,5 @@ package com.walkhub.walkhub.domain.rank.presentation.dto.response; -import com.querydsl.core.annotations.QueryProjection; import lombok.Builder; import lombok.Getter; @@ -23,16 +22,5 @@ public static class UserRankResponse { private final Integer ranking; private final String profileImageUrl; private final Integer walkCount; - - @QueryProjection - public UserRankResponse(Long userId, String name, Integer grade, Integer classNum, Integer ranking, String profileImageUrl, Integer walkCount) { - this.userId = userId; - this.name = name; - this.grade = grade; - this.classNum = classNum; - this.ranking = ranking; - this.profileImageUrl = profileImageUrl; - this.walkCount = walkCount; - } } } From f37b9d0fb106e87987f148dc90f5407f22080670 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Tue, 15 Feb 2022 00:55:45 +0900 Subject: [PATCH 170/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20=EB=8B=A4=20e?= =?UTF-8?q?lse=20if=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 --- .../service/QueryUserRankListService.java | 64 +++++++++++++++---- 1 file changed, 52 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListService.java b/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListService.java index a527b8836..356849151 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListService.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListService.java @@ -3,6 +3,7 @@ import com.walkhub.walkhub.domain.exercise.cache.ExerciseAnalysisCacheRepository; import com.walkhub.walkhub.domain.exercise.domain.repository.ExerciseAnalysisRepository; import com.walkhub.walkhub.domain.rank.domain.repository.UserRankRepository; +import com.walkhub.walkhub.domain.rank.domain.repository.vo.UserRankVO; import com.walkhub.walkhub.domain.rank.presentation.dto.response.UserRankListResponse; import com.walkhub.walkhub.domain.user.domain.Section; import com.walkhub.walkhub.domain.user.domain.User; @@ -53,18 +54,57 @@ public UserRankListResponse execute(String scope, String dateType) { .build() ).collect(Collectors.toList()) ).build(); - } else { - if (scope.equals("ALL")) { - return UserRankListResponse.builder() - .myRank(userRankRepository.getMyRankByUserId(user.getId(), null, dateType, date)) - .rankList(userRankRepository.getUserRankListBySchoolId(user.getSchool().getId(), null, dateType, date)) - .build(); - } else if (scope.equals("CLASS")) { - return UserRankListResponse.builder() - .myRank(userRankRepository.getMyRankByUserId(user.getId(), user.getSection().getClassNum(), dateType, date)) - .rankList(userRankRepository.getUserRankListBySchoolId(user.getSchool().getId(), user.getSection().getClassNum(), dateType, date)) - .build(); - } + } else if (scope.equals("ALL")) { + UserRankVO userRankVO = userRankRepository.getMyRankByUserId(user.getId(), null, dateType, date); + return UserRankListResponse.builder() + .myRank(UserRankListResponse.UserRankResponse.builder() + .userId(userRankVO.getUserId()) + .name(userRankVO.getName()) + .grade(userRankVO.getGrade()) + .classNum(userRankVO.getClassNum()) + .ranking(userRankVO.getRanking()) + .profileImageUrl(userRankVO.getProfileImageUrl()) + .walkCount(userRankVO.getWalkCount()) + .build() + ) + .rankList(userRankRepository.getUserRankListBySchoolId(user.getSchool().getId(), null, dateType, date) + .stream().map(vo -> UserRankListResponse.UserRankResponse.builder() + .userId(vo.getUserId()) + .name(vo.getName()) + .grade(vo.getGrade()) + .classNum(vo.getClassNum()) + .ranking(vo.getRanking()) + .profileImageUrl(vo.getProfileImageUrl()) + .walkCount(vo.getWalkCount()) + .build() + ).collect(Collectors.toList()) + ) + .build(); + } else if (scope.equals("CLASS")) { + UserRankVO userRankVO = userRankRepository.getMyRankByUserId(user.getId(), user.getSection().getClassNum(), dateType, date); + return UserRankListResponse.builder() + .myRank(UserRankListResponse.UserRankResponse.builder() + .userId(userRankVO.getUserId()) + .name(userRankVO.getName()) + .grade(userRankVO.getGrade()) + .classNum(userRankVO.getClassNum()) + .ranking(userRankVO.getRanking()) + .profileImageUrl(userRankVO.getProfileImageUrl()) + .walkCount(userRankVO.getWalkCount()) + .build()) + .rankList(userRankRepository.getUserRankListBySchoolId(user.getSchool().getId(), user.getSection().getClassNum(), dateType, date) + .stream().map(vo -> UserRankListResponse.UserRankResponse.builder() + .userId(vo.getUserId()) + .name(vo.getName()) + .grade(vo.getGrade()) + .classNum(vo.getClassNum()) + .ranking(vo.getRanking()) + .profileImageUrl(vo.getProfileImageUrl()) + .walkCount(vo.getWalkCount()) + .build() + ).collect(Collectors.toList()) + ) + .build(); } return null; } From bf5d5e410cad8017231be57219cb003e60babf51 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Tue, 15 Feb 2022 00:57:12 +0900 Subject: [PATCH 171/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20QueryProjecti?= =?UTF-8?q?on=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/response/QueryUserListResponse.java | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/QueryUserListResponse.java b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/QueryUserListResponse.java index 5c2aa6eb3..84eb32e93 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/QueryUserListResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/QueryUserListResponse.java @@ -1,6 +1,5 @@ package com.walkhub.walkhub.domain.teacher.presentation.dto.response; -import com.querydsl.core.annotations.QueryProjection; import lombok.Builder; import lombok.Getter; @@ -22,16 +21,5 @@ public static class UserListInfo { private final Integer classNum; private final Integer number; private final Boolean isTeacher; - - @QueryProjection - public UserListInfo(Long userId, String name, String profileImageUrl, Integer grade, Integer classNum, Integer number, Boolean isTeacher) { - this.userId = userId; - this.name = name; - this.profileImageUrl = profileImageUrl; - this.grade = grade; - this.classNum = classNum; - this.number = number; - this.isTeacher = isTeacher; - } } } From 402122dcdf22c4b8fa1921ba5910f8dd8d727bbd Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Tue, 15 Feb 2022 00:59:39 +0900 Subject: [PATCH 172/522] =?UTF-8?q?Revert=20"=E2=99=BB=EF=B8=8F=20::=20Que?= =?UTF-8?q?ryProjection=20=EC=82=AD=EC=A0=9C"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit bf5d5e410cad8017231be57219cb003e60babf51. --- .../dto/response/QueryUserListResponse.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/QueryUserListResponse.java b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/QueryUserListResponse.java index 84eb32e93..5c2aa6eb3 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/QueryUserListResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/QueryUserListResponse.java @@ -1,5 +1,6 @@ package com.walkhub.walkhub.domain.teacher.presentation.dto.response; +import com.querydsl.core.annotations.QueryProjection; import lombok.Builder; import lombok.Getter; @@ -21,5 +22,16 @@ public static class UserListInfo { private final Integer classNum; private final Integer number; private final Boolean isTeacher; + + @QueryProjection + public UserListInfo(Long userId, String name, String profileImageUrl, Integer grade, Integer classNum, Integer number, Boolean isTeacher) { + this.userId = userId; + this.name = name; + this.profileImageUrl = profileImageUrl; + this.grade = grade; + this.classNum = classNum; + this.number = number; + this.isTeacher = isTeacher; + } } } From 38b954d9f8a496c2ccceb52bc0b74f7d86286697 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Tue, 15 Feb 2022 01:05:58 +0900 Subject: [PATCH 173/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20QueryProjecti?= =?UTF-8?q?on=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/response/QueryUserListResponse.java | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/QueryUserListResponse.java b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/QueryUserListResponse.java index 5c2aa6eb3..84eb32e93 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/QueryUserListResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/QueryUserListResponse.java @@ -1,6 +1,5 @@ package com.walkhub.walkhub.domain.teacher.presentation.dto.response; -import com.querydsl.core.annotations.QueryProjection; import lombok.Builder; import lombok.Getter; @@ -22,16 +21,5 @@ public static class UserListInfo { private final Integer classNum; private final Integer number; private final Boolean isTeacher; - - @QueryProjection - public UserListInfo(Long userId, String name, String profileImageUrl, Integer grade, Integer classNum, Integer number, Boolean isTeacher) { - this.userId = userId; - this.name = name; - this.profileImageUrl = profileImageUrl; - this.grade = grade; - this.classNum = classNum; - this.number = number; - this.isTeacher = isTeacher; - } } } From a290e69766efed7616794176c51712460ae04c5a Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Tue, 15 Feb 2022 01:29:29 +0900 Subject: [PATCH 174/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20createDate=20?= =?UTF-8?q?=EC=BB=AC=EB=9F=BC=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/walkhub/walkhub/domain/rank/domain/SchoolRankInfo.java | 2 -- .../com/walkhub/walkhub/domain/rank/domain/UserRankInfo.java | 3 --- 2 files changed, 5 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/domain/SchoolRankInfo.java b/src/main/java/com/walkhub/walkhub/domain/rank/domain/SchoolRankInfo.java index d04c50650..578f5ea17 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/domain/SchoolRankInfo.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/domain/SchoolRankInfo.java @@ -20,6 +20,4 @@ public class SchoolRankInfo { private Integer ranking; private String logoImageUrl; private Integer walkCount; - private LocalDateTime createDate; - } diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/domain/UserRankInfo.java b/src/main/java/com/walkhub/walkhub/domain/rank/domain/UserRankInfo.java index 2a86d0c76..c9c8c9a99 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/domain/UserRankInfo.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/domain/UserRankInfo.java @@ -33,7 +33,4 @@ public class UserRankInfo { private Integer ranking; private String agencyCode; - - private LocalDateTime createDate; - } From 9a3d4ccb61f0eb8360351a0fc3aa9af2c21450f5 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Tue, 15 Feb 2022 01:31:38 +0900 Subject: [PATCH 175/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20VO=EB=A1=9C?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/repository/UserRankRepositoryCustomImpl.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustomImpl.java index 5f08ad2a8..d907ec42f 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustomImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustomImpl.java @@ -2,9 +2,8 @@ import com.querydsl.core.types.dsl.BooleanExpression; import com.querydsl.jpa.impl.JPAQueryFactory; +import com.walkhub.walkhub.domain.rank.domain.repository.vo.QUserRankVO; import com.walkhub.walkhub.domain.rank.domain.repository.vo.UserRankVO; -import com.walkhub.walkhub.domain.rank.presentation.dto.response.QUserRankListResponse_UserRankResponse; -import com.walkhub.walkhub.domain.rank.presentation.dto.response.UserRankListResponse; import lombok.RequiredArgsConstructor; import java.time.LocalDate; @@ -21,7 +20,7 @@ public class UserRankRepositoryCustomImpl implements UserRankRepositoryCustom { @Override public UserRankVO getMyRankByUserId(Long userId, Integer classNum, String dateType, LocalDate date) { return queryFactory - .select(new QUserRankListResponse_UserRankResponse( + .select(new QUserRankVO( userRank.userId, userRank.name, userRank.grade, @@ -43,7 +42,7 @@ public UserRankVO getMyRankByUserId(Long userId, Integer classNum, String dateTy @Override public List getUserRankListBySchoolId(Long schoolId, Integer classNum, String dateType, LocalDate date) { return queryFactory - .select(new QUserRankListResponse_UserRankResponse( + .select(new QUserRankVO( userRank.userId, userRank.name, userRank.grade, From 664dc46174cdb8c13cb460d035089a82d6e7a8b3 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Tue, 15 Feb 2022 01:59:14 +0900 Subject: [PATCH 176/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20=ED=8C=8C?= =?UTF-8?q?=EB=9D=BC=EB=AF=B8=ED=84=B0=20=ED=83=80=EC=9E=85=20ENUM?= =?UTF-8?q?=EC=9C=BC=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 --- .../domain/repository/UserRankRepositoryCustom.java | 5 +++-- .../domain/rank/presentation/RankController.java | 3 ++- .../domain/rank/service/QueryUserRankListService.java | 10 ++++++---- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustom.java b/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustom.java index 8fdd3dfa2..b382c2f2d 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustom.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustom.java @@ -1,11 +1,12 @@ package com.walkhub.walkhub.domain.rank.domain.repository; import com.walkhub.walkhub.domain.rank.domain.repository.vo.UserRankVO; +import com.walkhub.walkhub.global.enums.DateType; import java.time.LocalDate; import java.util.List; public interface UserRankRepositoryCustom { - UserRankVO getMyRankByUserId(Long userId, Integer classNum, String dateType, LocalDate date); - List getUserRankListBySchoolId(Long schoolId, Integer classNum, String dateType, LocalDate date); + UserRankVO getMyRankByUserId(Long userId, Integer classNum, DateType dateType, LocalDate date); + List getUserRankListBySchoolId(Long schoolId, Integer classNum, DateType dateType, LocalDate date); } diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/presentation/RankController.java b/src/main/java/com/walkhub/walkhub/domain/rank/presentation/RankController.java index 7d82e530f..cb1694708 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/presentation/RankController.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/presentation/RankController.java @@ -1,6 +1,7 @@ package com.walkhub.walkhub.domain.rank.presentation; import com.walkhub.walkhub.domain.rank.domain.type.SchoolDateType; +import com.walkhub.walkhub.domain.rank.domain.type.UserRankScope; import com.walkhub.walkhub.domain.rank.presentation.dto.response.SchoolRankResponse; import com.walkhub.walkhub.domain.rank.presentation.dto.response.UserListResponse; import com.walkhub.walkhub.domain.rank.presentation.dto.response.UserRankListResponse; @@ -37,7 +38,7 @@ public SchoolRankResponse querySchoolRank(@RequestParam SchoolDateType dateType) } @GetMapping("/users/my-school") - public UserRankListResponse queryUserRankListByMySchool(@RequestParam String scope, @RequestParam String dateType) { + public UserRankListResponse queryUserRankListByMySchool(@RequestParam UserRankScope scope, @RequestParam DateType dateType) { return queryUserRankListService.execute(scope, dateType); } } diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListService.java b/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListService.java index d54fa80be..c4a4ce196 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListService.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListService.java @@ -4,10 +4,12 @@ import com.walkhub.walkhub.domain.exercise.domain.repository.ExerciseAnalysisRepository; import com.walkhub.walkhub.domain.rank.domain.repository.UserRankRepository; import com.walkhub.walkhub.domain.rank.domain.repository.vo.UserRankVO; +import com.walkhub.walkhub.domain.rank.domain.type.UserRankScope; import com.walkhub.walkhub.domain.rank.presentation.dto.response.UserRankListResponse; import com.walkhub.walkhub.domain.user.domain.Section; import com.walkhub.walkhub.domain.user.domain.User; import com.walkhub.walkhub.domain.user.facade.UserFacade; +import com.walkhub.walkhub.global.enums.DateType; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -23,11 +25,11 @@ public class QueryUserRankListService { private final UserFacade userFacade; private final ExerciseAnalysisRepository exerciseAnalysisRepository; - public UserRankListResponse execute(String scope, String dateType) { + public UserRankListResponse execute(UserRankScope scope, DateType dateType) { User user = userFacade.getCurrentUser(); Section section = user.getSection(); LocalDate date = LocalDate.now(); - if (dateType.equals("DAY")) { + if (dateType.equals(DateType.DAY)) { AtomicInteger rankCount = new AtomicInteger(); return UserRankListResponse.builder() .myRank(UserRankListResponse.UserRankResponse.builder() @@ -54,7 +56,7 @@ public UserRankListResponse execute(String scope, String dateType) { .build() ).collect(Collectors.toList()) ).build(); - } else if (scope.equals("ALL")) { + } else if (scope.equals(UserRankScope.ALL)) { UserRankVO userRankVO = userRankRepository.getMyRankByUserId(user.getId(), null, dateType, date); return UserRankListResponse.builder() .myRank(UserRankListResponse.UserRankResponse.builder() @@ -80,7 +82,7 @@ public UserRankListResponse execute(String scope, String dateType) { ).collect(Collectors.toList()) ) .build(); - } else if (scope.equals("CLASS")) { + } else if (scope.equals(UserRankScope.CLASS)) { UserRankVO userRankVO = userRankRepository.getMyRankByUserId(user.getId(), user.getSection().getClassNum(), dateType, date); return UserRankListResponse.builder() .myRank(UserRankListResponse.UserRankResponse.builder() From 2a5ec1fffe9ebc17fd80912fc900d5b148771c16 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Tue, 15 Feb 2022 01:59:31 +0900 Subject: [PATCH 177/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20UserRankRepos?= =?UTF-8?q?itoryCustom=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/rank/domain/repository/UserRankRepository.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepository.java b/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepository.java index ba96d8f2f..ce9162d7c 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepository.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepository.java @@ -5,6 +5,6 @@ import java.util.List; -public interface UserRankRepository extends JpaRepository { +public interface UserRankRepository extends JpaRepository, UserRankRepositoryCustom { List findAllBySchoolIdAndNameContainingAndDateType(Long schoolId, String name, String dateType); } From 4b4ac9feeaadba7aa42ccd9ad22d8fc9e071bf84 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Tue, 15 Feb 2022 01:59:51 +0900 Subject: [PATCH 178/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20=EB=8B=A4=20B?= =?UTF-8?q?ooleanExpression=EC=9C=BC=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 --- .../UserRankRepositoryCustomImpl.java | 38 ++++++++++++++----- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustomImpl.java index 8b20b1b03..b498fd0cc 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustomImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustomImpl.java @@ -4,6 +4,7 @@ import com.querydsl.jpa.impl.JPAQueryFactory; import com.walkhub.walkhub.domain.rank.domain.repository.vo.QUserRankVO; import com.walkhub.walkhub.domain.rank.domain.repository.vo.UserRankVO; +import com.walkhub.walkhub.global.enums.DateType; import lombok.RequiredArgsConstructor; import java.time.LocalDate; @@ -18,7 +19,7 @@ public class UserRankRepositoryCustomImpl implements UserRankRepositoryCustom { private static final Long LIMIT = 100L; @Override - public UserRankVO getMyRankByUserId(Long userId, Integer classNum, String dateType, LocalDate date) { + public UserRankVO getMyRankByUserId(Long userId, Integer classNum, DateType dateType, LocalDate date) { return queryFactory .select(new QUserRankVO( userRank.userId, @@ -31,16 +32,16 @@ public UserRankVO getMyRankByUserId(Long userId, Integer classNum, String dateTy )) .from(userRank) .where( - userRank.userId.eq(userId), + userIdEq(userId), classNumEq(classNum), - userRank.dateType.eq(dateType), - userRank.createdAt.eq(date) + dateTypeEq(dateType), + createdAtEq(date) ) .fetchOne(); } @Override - public List getUserRankListBySchoolId(Long schoolId, Integer classNum, String dateType, LocalDate date) { + public List getUserRankListBySchoolId(Long schoolId, Integer classNum, DateType dateType, LocalDate date) { return queryFactory .select(new QUserRankVO( userRank.userId, @@ -53,23 +54,40 @@ public List getUserRankListBySchoolId(Long schoolId, Integer classNu )) .from(userRank) .where( - userRank.schoolId.eq(schoolId), + schoolIdEq(schoolId), classNumEq(classNum), - userRank.dateType.eq(dateType), - userRank.createdAt.eq(date) + dateTypeEq(dateType), + createdAtEq(date) ) .limit(LIMIT) .orderBy(userRank.ranking.asc()) .fetch(); } + private BooleanExpression userIdEq(Long userId) { + return userId != null ? userRank.userId.eq(userId) : null; + } + private BooleanExpression schoolIdEq(Long schoolId) { return schoolId != null ? userRank.schoolId.eq(schoolId) : null; } - private BooleanExpression - private BooleanExpression classNumEq(Integer classNum) { return classNum != null ? userRank.scopeType.eq("CLASS").and(userRank.classNum.eq(classNum)) : userRank.scopeType.eq("SCHOOL"); } + + private BooleanExpression dateTypeEq(DateType dateType) { + switch (dateType) { + case WEEK: + return userRank.dateType.eq("WEEK"); + case MONTH: + return userRank.dateType.eq("MONTH"); + default: + return null; + } + } + + private BooleanExpression createdAtEq(LocalDate date) { + return date != null ? userRank.createdAt.eq(date) : null; + } } From 77ae40d5ac3b0f81b703ee35d9ba9e5a1cc902b5 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Tue, 15 Feb 2022 02:00:04 +0900 Subject: [PATCH 179/522] =?UTF-8?q?=F0=9F=93=91=20::=20UserRankScope=20ENU?= =?UTF-8?q?M?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../walkhub/domain/rank/domain/type/UserRankScope.java | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 src/main/java/com/walkhub/walkhub/domain/rank/domain/type/UserRankScope.java diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/domain/type/UserRankScope.java b/src/main/java/com/walkhub/walkhub/domain/rank/domain/type/UserRankScope.java new file mode 100644 index 000000000..5e4878172 --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/rank/domain/type/UserRankScope.java @@ -0,0 +1,6 @@ +package com.walkhub.walkhub.domain.rank.domain.type; + +public enum UserRankScope { + ALL, + CLASS +} From e208497d09606b966f2d806126a6311779c96dc4 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Tue, 15 Feb 2022 09:16:33 +0900 Subject: [PATCH 180/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20=EB=8B=A4?= =?UTF-8?q?=EB=A5=B8=20enum=EB=93=A4=EA=B3=BC=20=ED=98=95=EC=8B=9D=20?= =?UTF-8?q?=ED=86=B5=EC=9D=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/walkhub/walkhub/global/enums/UserScope.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/global/enums/UserScope.java b/src/main/java/com/walkhub/walkhub/global/enums/UserScope.java index 26a12fbbd..62a9fa5b3 100644 --- a/src/main/java/com/walkhub/walkhub/global/enums/UserScope.java +++ b/src/main/java/com/walkhub/walkhub/global/enums/UserScope.java @@ -1,5 +1,8 @@ package com.walkhub.walkhub.global.enums; public enum UserScope { - CLASS, GRADE, SCHOOL, ALL + CLASS, + GRADE, + SCHOOL, + ALL } From 17b9dfeb91e6125f2bab386b69778befae831043 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Tue, 15 Feb 2022 09:35:24 +0900 Subject: [PATCH 181/522] =?UTF-8?q?:bug:=20::=20=ED=9A=8C=EC=9B=90?= =?UTF-8?q?=EA=B0=80=EC=9E=85=20=EC=8B=9C=ED=95=99=EA=B5=90=20=EA=B2=80?= =?UTF-8?q?=EC=83=89=20api=20authenticated=20->=20permitAll=EB=A1=9C=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 --- .../walkhub/global/security/SecurityConfig.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java b/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java index 439c9c9ff..630975d8f 100644 --- a/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java +++ b/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java @@ -51,7 +51,7 @@ protected void configure(HttpSecurity http) throws Exception { .antMatchers(HttpMethod.GET, "/users/{user-id}").authenticated() .antMatchers(HttpMethod.GET, "/users").authenticated() .antMatchers(HttpMethod.PATCH, "/users").authenticated() - .antMatchers(HttpMethod.POST,"/users/classes/{section-id}").authenticated() + .antMatchers(HttpMethod.POST, "/users/classes/{section-id}").authenticated() .antMatchers(HttpMethod.GET, "/users/accounts/{phone-number}").permitAll() .antMatchers(HttpMethod.PATCH, "/users/health").authenticated() .antMatchers(HttpMethod.PATCH, "/users/goal").authenticated() @@ -105,7 +105,7 @@ protected void configure(HttpSecurity http) throws Exception { // schools .antMatchers(HttpMethod.PATCH, "/schools/logos").hasAuthority("ROOT") - .antMatchers(HttpMethod.GET, "/schools/search").authenticated() + .antMatchers(HttpMethod.GET, "/schools/search").permitAll() // teachers .antMatchers(HttpMethod.POST, "/teachers/verification-codes").hasAuthority("ROOT") @@ -113,16 +113,16 @@ protected void configure(HttpSecurity http) throws Exception { .antMatchers(HttpMethod.POST, "/teachers/classes").hasAnyAuthority("TEACHER", "ROOT") .antMatchers(HttpMethod.DELETE, "/teachers/classes/{section-id}").hasAnyAuthority("TEACHER", "ROOT") .antMatchers(HttpMethod.GET, "/teachers/classes").hasAuthority("TEACHER") - .antMatchers(HttpMethod.GET,"/teachers/users/{user-id}").hasAnyAuthority("TEACHER") - .antMatchers(HttpMethod.GET,"/teachers/users").hasAnyAuthority("TEACHER","ROOT") - .antMatchers(HttpMethod.GET,"/teachers/students/verification-codes").hasAnyAuthority("TEACHER") - .antMatchers(HttpMethod.PATCH, "/teachers/classes/verification-codes").hasAuthority("TEACHER") + .antMatchers(HttpMethod.GET, "/teachers/users/{user-id}").hasAnyAuthority("TEACHER") + .antMatchers(HttpMethod.GET, "/teachers/users").hasAnyAuthority("TEACHER", "ROOT") + .antMatchers(HttpMethod.GET, "/teachers/students/verification-codes").hasAnyAuthority("TEACHER") + .antMatchers(HttpMethod.PATCH, "/teachers/classes/verification-codes").hasAuthority("TEACHER") // su - .antMatchers(HttpMethod.GET,"/su").hasAnyAuthority("SU") + .antMatchers(HttpMethod.GET, "/su").hasAnyAuthority("SU") //excel - .antMatchers(HttpMethod.GET,"/excel").hasAnyAuthority("TEACHER", "ROOT") + .antMatchers(HttpMethod.GET, "/excel").hasAnyAuthority("TEACHER", "ROOT") // socket.io .antMatchers(HttpMethod.GET, "/socket.io").authenticated() From d2be21c7e1d54b16c58bca387695d86909dc2e79 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Tue, 15 Feb 2022 10:31:01 +0900 Subject: [PATCH 182/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20section-id=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 --- .../domain/teacher/presentation/TeacherController.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/TeacherController.java b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/TeacherController.java index 3e4d89e8f..7b6deeda8 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/TeacherController.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/TeacherController.java @@ -65,9 +65,9 @@ public CodeResponse refreshClassCode() { return refreshClassCodeService.execute(); } - @GetMapping("/classes") - public DetailsClassResponse queryStudentCode() { - return queryStudentCodeService.execute(); + @GetMapping("/classes/{section-id}") + public DetailsClassResponse queryStudentCode(@PathVariable("section-id") Long sectionId) { + return queryStudentCodeService.execute(sectionId); } @GetMapping("/users/{user-id}") From 8e4d7bf439a2179f5f37aaea7dbd97d65625d607 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Tue, 15 Feb 2022 10:31:22 +0900 Subject: [PATCH 183/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20teacher=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 --- .../dto/response/DetailsClassResponse.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/DetailsClassResponse.java b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/DetailsClassResponse.java index c0a6bd6e1..1f445cf4e 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/DetailsClassResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/DetailsClassResponse.java @@ -1,6 +1,5 @@ package com.walkhub.walkhub.domain.teacher.presentation.dto.response; -import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; @@ -8,19 +7,27 @@ @Getter -@AllArgsConstructor +@Builder public class DetailsClassResponse { + private final TeacherResponse teacher; private final String classCode; private final List userList; + @Getter + @Builder + public static class TeacherResponse { + private final Long userId; + private final String name; + private final String profileImageUrl; + } @Getter @Builder public static class UserListResponse { - private Long userId; - private String name; - private String profileImageUrl; - private Integer walkCount; + private final Long userId; + private final String name; + private final String profileImageUrl; + private final Integer walkCount; } } From 9be173f1d839982d1cea0a1b79ab5d2c7e6295fb Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Tue, 15 Feb 2022 10:31:38 +0900 Subject: [PATCH 184/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20=EB=85=B8?= =?UTF-8?q?=EC=85=98=EC=97=90=20=EB=94=B0=EB=9D=BC=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/QueryStudentCodeService.java | 38 +++++++++++++------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/service/QueryStudentCodeService.java b/src/main/java/com/walkhub/walkhub/domain/teacher/service/QueryStudentCodeService.java index 5b939ee82..12ebd90d5 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/service/QueryStudentCodeService.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/service/QueryStudentCodeService.java @@ -3,11 +3,12 @@ import com.walkhub.walkhub.domain.exercise.domain.ExerciseAnalysis; import com.walkhub.walkhub.domain.exercise.domain.repository.ExerciseAnalysisRepository; import com.walkhub.walkhub.domain.teacher.presentation.dto.response.DetailsClassResponse; +import com.walkhub.walkhub.domain.teacher.presentation.dto.response.DetailsClassResponse.TeacherResponse; +import com.walkhub.walkhub.domain.teacher.presentation.dto.response.DetailsClassResponse.UserListResponse; import com.walkhub.walkhub.domain.user.domain.Section; import com.walkhub.walkhub.domain.user.domain.User; -import com.walkhub.walkhub.domain.user.domain.repository.UserRepository; +import com.walkhub.walkhub.domain.user.exception.UserNotFoundException; import com.walkhub.walkhub.domain.user.facade.SectionFacade; -import com.walkhub.walkhub.domain.user.facade.UserFacade; import com.walkhub.walkhub.global.enums.Authority; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -21,30 +22,43 @@ @Service public class QueryStudentCodeService { - private final UserFacade userFacade; private final SectionFacade sectionFacade; - private final UserRepository userRepository; private final ExerciseAnalysisRepository exerciseAnalysisRepository; @Transactional(readOnly = true) - public DetailsClassResponse execute() { - User teacher = userFacade.getCurrentUser(); - Section section = sectionFacade.getSectionById(teacher.getSection().getId()); + public DetailsClassResponse execute(Long sectionId) { + Section section = sectionFacade.getSectionById(sectionId); - List result = - userRepository.findAllBySectionAndAuthority(section, Authority.STUDENT) + List result = + section.getUsers() .stream() + .filter(user -> user.getAuthority() == Authority.STUDENT) .map(this::buildUserListResponse) .collect(Collectors.toList()); - return new DetailsClassResponse(section.getClassCode(), result); + User teacher = section.getUsers().stream() + .filter(user -> user.getAuthority() == Authority.TEACHER) + .findFirst() + .orElseThrow(() -> UserNotFoundException.EXCEPTION); + + TeacherResponse teacherResponse = TeacherResponse.builder() + .userId(teacher.getId()) + .name(teacher.getName()) + .profileImageUrl(teacher.getProfileImageUrl()) + .build(); + + return DetailsClassResponse.builder() + .teacher(teacherResponse) + .classCode(section.getClassCode()) + .userList(result) + .build(); } - private DetailsClassResponse.UserListResponse buildUserListResponse(User user) { + private UserListResponse buildUserListResponse(User user) { Integer walkCount = exerciseAnalysisRepository.findByUserAndDate(user, LocalDate.now()) .map(ExerciseAnalysis::getWalkCount) .orElse(0); - return DetailsClassResponse.UserListResponse.builder() + return UserListResponse.builder() .userId(user.getId()) .name(user.getName()) .profileImageUrl(user.getProfileImageUrl()) From f036ce74d135f2aabede39229efaa137542bdf34 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Tue, 15 Feb 2022 10:31:54 +0900 Subject: [PATCH 185/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20User=EB=9E=91?= =?UTF-8?q?=20=EA=B4=80=EA=B3=84=20=EB=A7=A4=ED=95=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/walkhub/walkhub/domain/user/domain/Section.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/user/domain/Section.java b/src/main/java/com/walkhub/walkhub/domain/user/domain/Section.java index 6d7448220..02c337dde 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/domain/Section.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/domain/Section.java @@ -15,7 +15,9 @@ import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; +import javax.persistence.OneToMany; import javax.persistence.Table; +import java.util.List; @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) @@ -40,6 +42,9 @@ public class Section extends BaseTimeEntity { @JoinColumn(name = "school_id") private School school; + @OneToMany(mappedBy = "section") + private List users; + @Builder public Section(Integer grade, Integer classNum, School school, String classCode) { this.grade = grade; From 42e16b026bf8897f08a455c7f433da1ee08412a8 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Tue, 15 Feb 2022 10:32:52 +0900 Subject: [PATCH 186/522] =?UTF-8?q?:coffin:=20::=20findAllBySectionAndAuth?= =?UTF-8?q?ority=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../walkhub/domain/user/domain/repository/UserRepository.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepository.java b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepository.java index 08d01f703..3d274b370 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepository.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepository.java @@ -1,8 +1,6 @@ package com.walkhub.walkhub.domain.user.domain.repository; -import com.walkhub.walkhub.domain.user.domain.Section; import com.walkhub.walkhub.domain.user.domain.User; -import com.walkhub.walkhub.global.enums.Authority; import org.springframework.data.repository.CrudRepository; import java.util.List; @@ -11,6 +9,5 @@ public interface UserRepository extends CrudRepository { Optional findByAccountId(String accountId); Optional findByPhoneNumber(String phoneNumber); - List findAllBySectionAndAuthority(Section section, Authority authority); List findAllBySchoolIdAndNameContaining(Long id, String name); } From b5e08267f211c0c41066d35040ee33997974d6e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B2=94=EC=A7=84?= Date: Tue, 15 Feb 2022 10:45:17 +0900 Subject: [PATCH 187/522] =?UTF-8?q?=E2=9A=A1=20::=20=EC=9B=90=EB=9E=98?= =?UTF-8?q?=EB=8C=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 --- ...hallengeParticipantsForTeacherService.java | 50 ++++++------------- 1 file changed, 14 insertions(+), 36 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/service/QueryChallengeParticipantsForTeacherService.java b/src/main/java/com/walkhub/walkhub/domain/challenge/service/QueryChallengeParticipantsForTeacherService.java index e1c72b6a5..7dceaa3b3 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/service/QueryChallengeParticipantsForTeacherService.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/service/QueryChallengeParticipantsForTeacherService.java @@ -2,18 +2,14 @@ import com.walkhub.walkhub.domain.challenge.domain.Challenge; import com.walkhub.walkhub.domain.challenge.domain.repository.ChallengeStatusRepository; -import com.walkhub.walkhub.domain.challenge.domain.repository.vo.ChallengeParticipantsVO; import com.walkhub.walkhub.domain.challenge.domain.type.SuccessScope; import com.walkhub.walkhub.domain.challenge.facade.ChallengeFacade; import com.walkhub.walkhub.domain.challenge.presenstation.dto.response.QueryChallengeParticipantsForTeacherResponse; -import com.walkhub.walkhub.domain.user.exception.UserNotFoundException; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.time.LocalDate; import java.util.List; -import java.util.Map; import java.util.stream.Collectors; @RequiredArgsConstructor @@ -34,39 +30,21 @@ public QueryChallengeParticipantsForTeacherResponse execute(Long challengeId, Su private List queryChallengeParticipantsForTeacherResponseBuilder( Challenge challenge, SuccessScope successScope ) { - Map> participants = - challengeStatusRepository.queryChallengeParticipantsList(challenge, successScope).stream() - .collect(Collectors.groupingBy(ChallengeParticipantsVO::getUserId)); - - return participants.values().stream() - .map(vo -> buildChallengeParticipantsResponse(vo, challenge)) + return challengeStatusRepository.queryChallengeParticipantsList(challenge, successScope) + .stream() + .map(vo -> QueryChallengeParticipantsForTeacherResponse.ChallengeParticipants.builder() + .userId(vo.getUserId()) + .grade(vo.getGrade()) + .classNum(vo.getClassNum()) + .number(vo.getNumber()) + .name(vo.getName()) + .profileImageUrl(vo.getProfileImageUrl()) + .schoolName(vo.getSchoolName()) + .successDate(vo.getExerciseAnalysesDates()) + .isSuccess(vo.getIsSuccess()) + .build() + ) .collect(Collectors.toList()); } - private QueryChallengeParticipantsForTeacherResponse.ChallengeParticipants buildChallengeParticipantsResponse( - List challengeParticipantsVOs, - Challenge challenge - ) { - List successDates = challengeParticipantsVOs.stream() - .map(ChallengeParticipantsVO::getExerciseAnalysesDate) - .sorted().collect(Collectors.toList()); - - ChallengeParticipantsVO participantsVO = challengeParticipantsVOs.stream().findFirst() - .orElseThrow(() -> UserNotFoundException.EXCEPTION); - - Integer successCount = successDates.size(); - - return QueryChallengeParticipantsForTeacherResponse.ChallengeParticipants.builder() - .userId(participantsVO.getUserId()) - .grade(participantsVO.getGrade()) - .classNum(participantsVO.getClassNum()) - .number(participantsVO.getNumber()) - .name(participantsVO.getName()) - .profileImageUrl(participantsVO.getProfileImageUrl()) - .schoolName(participantsVO.getSchoolName()) - .successDate(successDates) - .isSuccess(challenge.getSuccessStandard() <= successCount) - .build(); - } - } From d12dd5d24b3a6fbcf08cf0daf1b67e50ebf54f57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B2=94=EC=A7=84?= Date: Tue, 15 Feb 2022 10:45:37 +0900 Subject: [PATCH 188/522] =?UTF-8?q?=E2=9A=A1=20::=20=EC=97=AC=EB=9F=AC=20?= =?UTF-8?q?=EC=A1=B0=EA=B1=B4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CustomChallengeRepositoryImpl.java | 69 +++++++++++++------ .../vo/ChallengeParticipantsVO.java | 10 ++- 2 files changed, 55 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/CustomChallengeRepositoryImpl.java b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/CustomChallengeRepositoryImpl.java index 619dd26a9..0d13ba3f9 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/CustomChallengeRepositoryImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/CustomChallengeRepositoryImpl.java @@ -1,7 +1,9 @@ package com.walkhub.walkhub.domain.challenge.domain.repository; +import com.querydsl.core.group.GroupBy; import com.querydsl.core.types.dsl.BooleanExpression; import com.querydsl.core.types.dsl.Expressions; +import com.querydsl.jpa.JPAExpressions; import com.querydsl.jpa.impl.JPAQueryFactory; import com.walkhub.walkhub.domain.challenge.domain.Challenge; import com.walkhub.walkhub.domain.challenge.domain.repository.vo.ChallengeParticipantsVO; @@ -13,6 +15,7 @@ import java.util.List; +import static com.querydsl.core.group.GroupBy.groupBy; import static com.querydsl.jpa.JPAExpressions.select; import static com.walkhub.walkhub.domain.challenge.domain.QChallengeStatus.challengeStatus; import static com.walkhub.walkhub.domain.exercise.domain.QExerciseAnalysis.exerciseAnalysis; @@ -28,17 +31,7 @@ public class CustomChallengeRepositoryImpl implements CustomChallengeRepository @Override public List queryChallengeParticipantsList(Challenge challenge, SuccessScope successScope) { return jpaQueryFactory - .select(new QChallengeParticipantsVO( - user.id.as("userId"), - user.section.grade, - user.section.classNum, - user.number, - user.name, - user.profileImageUrl, - school.name, - exerciseAnalysis.date - )) - .from(user) + .selectFrom(user) .join(user.school, school) .leftJoin(user.section, section) .join(user.exerciseAnalyses, exerciseAnalysis) @@ -46,13 +39,31 @@ public List queryChallengeParticipantsList(Challenge ch .join(challengeStatus.challenge) .on(challengeStatus.challenge.eq(challenge)) .where( - goalTypeFilter(challenge), successScopeFilter(challenge, successScope), + goalTypeFilter(challenge), exerciseAnalysis.date.between(challenge.getStartAt(), challenge.getEndAt()) ) - .groupBy(user.id, exerciseAnalysis.date) - .orderBy(user.name.asc(), user.id.asc()) - .fetch(); + .orderBy(user.name.asc(), user.id.asc(), exerciseAnalysis.date.asc()) + .transform(groupBy(user.name, user.id) + .list(new QChallengeParticipantsVO( + user.id.as("userId"), + user.section.grade, + user.section.classNum, + user.number, + user.name, + user.profileImageUrl, + user.school.name.as("schoolName"), + Expressions.asNumber(select(exerciseAnalysis.count()) + .from(exerciseAnalysis) + .where( + goalTypeFilter(challenge), + exerciseAnalysis.user.eq(user), + exerciseAnalysis.date.between(challenge.getStartAt(), challenge.getEndAt()) + )) + .goe(challenge.getSuccessStandard()).as("isSuccess"), + GroupBy.list(exerciseAnalysis.date)) + ) + ); } private BooleanExpression successScopeFilter(Challenge challenge, SuccessScope successScope) { @@ -60,12 +71,22 @@ private BooleanExpression successScopeFilter(Challenge challenge, SuccessScope s case TRUE: { return Expressions.asNumber(select(exerciseAnalysis.count()) .from(exerciseAnalysis) - .where(exerciseAnalysis.user.eq(user))).goe(challenge.getSuccessStandard()); + .where( + goalTypeFilter(challenge), + exerciseAnalysis.user.eq(user), + exerciseAnalysis.date.between(challenge.getStartAt(), challenge.getEndAt()) + )) + .goe(challenge.getSuccessStandard()); } case FALSE: { return Expressions.asNumber(select(exerciseAnalysis.count()) .from(exerciseAnalysis) - .where(exerciseAnalysis.user.eq(user))).lt(challenge.getSuccessStandard()); + .where( + goalTypeFilter(challenge), + exerciseAnalysis.user.eq(user), + exerciseAnalysis.date.between(challenge.getStartAt(), challenge.getEndAt()) + )) + .lt(challenge.getSuccessStandard()); } default: { return null; @@ -86,9 +107,12 @@ private BooleanExpression isChallengeSuccessByWalkCount(Challenge challenge) { return exerciseAnalysis.walkCount.goe(challenge.getGoal()); } - return select(exerciseAnalysis.walkCount.sum()) + return JPAExpressions.select(exerciseAnalysis.walkCount.sum()) .from(exerciseAnalysis) - .where(exerciseAnalysis.date.between(challenge.getStartAt(), challenge.getEndAt())) + .where( + exerciseAnalysis.date.between(challenge.getStartAt(), challenge.getEndAt()), + exerciseAnalysis.user.eq(user) + ) .goe(challenge.getGoal()); } @@ -97,9 +121,12 @@ private BooleanExpression isChallengeSuccessByDistance(Challenge challenge) { return exerciseAnalysis.distance.goe(challenge.getGoal()); } - return select(exerciseAnalysis.distance.sum()) + return JPAExpressions.select(exerciseAnalysis.distance.sum()) .from(exerciseAnalysis) - .where(exerciseAnalysis.date.between(challenge.getStartAt(), challenge.getEndAt())) + .where( + exerciseAnalysis.date.between(challenge.getStartAt(), challenge.getEndAt()), + exerciseAnalysis.user.eq(user) + ) .goe(challenge.getGoal()); } diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/vo/ChallengeParticipantsVO.java b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/vo/ChallengeParticipantsVO.java index 7929d272a..740e5b752 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/vo/ChallengeParticipantsVO.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/vo/ChallengeParticipantsVO.java @@ -4,6 +4,7 @@ import lombok.Getter; import java.time.LocalDate; +import java.util.List; @Getter public class ChallengeParticipantsVO { @@ -14,11 +15,13 @@ public class ChallengeParticipantsVO { private final String name; private final String profileImageUrl; private final String schoolName; - private final LocalDate exerciseAnalysesDate; + private final List exerciseAnalysesDates; + private final Boolean isSuccess; @QueryProjection public ChallengeParticipantsVO(Long userId, Integer grade, Integer classNum, Integer number, - String name, String profileImageUrl, String schoolName, LocalDate exerciseAnalysesDate) { + String name, String profileImageUrl, String schoolName, + Boolean isSuccess, List exerciseAnalysesDates) { this.userId = userId; this.grade = grade; this.classNum = classNum; @@ -26,6 +29,7 @@ public ChallengeParticipantsVO(Long userId, Integer grade, Integer classNum, Int this.name = name; this.profileImageUrl = profileImageUrl; this.schoolName = schoolName; - this.exerciseAnalysesDate = exerciseAnalysesDate; + this.exerciseAnalysesDates = exerciseAnalysesDates; + this.isSuccess = isSuccess; } } From fa9783faadc0ac50980f5a73b7937524666a8803 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B2=94=EC=A7=84?= Date: Tue, 15 Feb 2022 11:44:29 +0900 Subject: [PATCH 189/522] =?UTF-8?q?=E2=99=BB=20::=20=EB=A9=94=EC=86=8C?= =?UTF-8?q?=EB=93=9C=20=EC=A0=95=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CustomChallengeRepositoryImpl.java | 36 +++++++++++++------ 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/CustomChallengeRepositoryImpl.java b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/CustomChallengeRepositoryImpl.java index 0d13ba3f9..946e8989b 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/CustomChallengeRepositoryImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/CustomChallengeRepositoryImpl.java @@ -3,6 +3,7 @@ import com.querydsl.core.group.GroupBy; import com.querydsl.core.types.dsl.BooleanExpression; import com.querydsl.core.types.dsl.Expressions; +import com.querydsl.core.types.dsl.NumberPath; import com.querydsl.jpa.JPAExpressions; import com.querydsl.jpa.impl.JPAQueryFactory; import com.walkhub.walkhub.domain.challenge.domain.Challenge; @@ -104,26 +105,41 @@ private BooleanExpression goalTypeFilter(Challenge challenge) { private BooleanExpression isChallengeSuccessByWalkCount(Challenge challenge) { if (challenge.getGoalScope() == GoalScope.DAY) { - return exerciseAnalysis.walkCount.goe(challenge.getGoal()); + return isChallengeSuccessInDayScope(challenge); } - return JPAExpressions.select(exerciseAnalysis.walkCount.sum()) - .from(exerciseAnalysis) - .where( - exerciseAnalysis.date.between(challenge.getStartAt(), challenge.getEndAt()), - exerciseAnalysis.user.eq(user) - ) - .goe(challenge.getGoal()); + return isChallengeSuccessInAllScope(challenge); } private BooleanExpression isChallengeSuccessByDistance(Challenge challenge) { if (challenge.getGoalScope() == GoalScope.DAY) { - return exerciseAnalysis.distance.goe(challenge.getGoal()); + return isChallengeSuccessInDayScope(challenge); + } + + return isChallengeSuccessInAllScope(challenge); + } + + private BooleanExpression isChallengeSuccessInDayScope(Challenge challenge) { + NumberPath exerciseAmount = exerciseAnalysis.distance; + + if (challenge.getGoalType() == GoalType.WALK) { + exerciseAmount = exerciseAnalysis.walkCount; + } + + return exerciseAmount.goe(challenge.getGoal()); + } + + private BooleanExpression isChallengeSuccessInAllScope(Challenge challenge) { + NumberPath exerciseAmount = exerciseAnalysis.distance; + + if (challenge.getGoalType() == GoalType.WALK) { + exerciseAmount = exerciseAnalysis.walkCount; } - return JPAExpressions.select(exerciseAnalysis.distance.sum()) + return JPAExpressions.select(exerciseAmount.sum()) .from(exerciseAnalysis) .where( + // 시작일과 참여일 비교 필요 exerciseAnalysis.date.between(challenge.getStartAt(), challenge.getEndAt()), exerciseAnalysis.user.eq(user) ) From b106684733d0cf8b2065f4f2d22d0166dd8bf0e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B2=94=EC=A7=84?= Date: Tue, 15 Feb 2022 11:54:31 +0900 Subject: [PATCH 190/522] =?UTF-8?q?=E2=9A=A1=20::=20challenge=20status?= =?UTF-8?q?=EC=97=90=20=EC=B0=B8=EC=97=AC=ED=95=9C=20=EB=82=A0=EC=A7=9C=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 --- .../walkhub/domain/challenge/domain/ChallengeStatus.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/ChallengeStatus.java b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/ChallengeStatus.java index 45b42a2aa..33defb85d 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/ChallengeStatus.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/ChallengeStatus.java @@ -1,6 +1,7 @@ package com.walkhub.walkhub.domain.challenge.domain; import com.walkhub.walkhub.domain.user.domain.User; +import com.walkhub.walkhub.global.entity.BaseTimeEntity; import lombok.AccessLevel; import lombok.Builder; import lombok.Getter; @@ -17,7 +18,7 @@ @NoArgsConstructor(access = AccessLevel.PROTECTED) @IdClass(ChallengeStatusId.class) @Entity -public class ChallengeStatus { +public class ChallengeStatus extends BaseTimeEntity { @Id @ManyToOne(fetch = FetchType.LAZY) From eb541def141877eacf1979c0f27ce5e18092a39d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Tue, 15 Feb 2022 13:54:53 +0900 Subject: [PATCH 191/522] =?UTF-8?q?=F0=9F=93=91=20::=20ExcelController?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../excel/presentation/ExcelController.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/main/java/com/walkhub/walkhub/domain/excel/presentation/ExcelController.java diff --git a/src/main/java/com/walkhub/walkhub/domain/excel/presentation/ExcelController.java b/src/main/java/com/walkhub/walkhub/domain/excel/presentation/ExcelController.java new file mode 100644 index 000000000..7ce7edca0 --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/excel/presentation/ExcelController.java @@ -0,0 +1,29 @@ +package com.walkhub.walkhub.domain.excel.presentation; + +import com.walkhub.walkhub.domain.excel.service.PrintExcelService; +import com.walkhub.walkhub.global.enums.Authority; +import java.io.IOException; +import java.time.LocalDate; +import javax.servlet.http.HttpServletResponse; +import lombok.RequiredArgsConstructor; +import org.springframework.format.annotation.DateTimeFormat; +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; + +@RequiredArgsConstructor +@RequestMapping("/excel") +@RestController +public class ExcelController { + + private final PrintExcelService printExcelService; + + @GetMapping + public void getExcel(@RequestParam("startAt") @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate startAt, + @RequestParam("endAt") @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate endAt, @RequestParam("authority") Authority authority, + @RequestParam(value = "grade", required = false) Integer grade, @RequestParam(value = "classNum", required = false) Integer classNum, + HttpServletResponse response) throws IOException { + printExcelService.execute(startAt, endAt, authority, grade, classNum, response); + } +} From ed16c06491c5947263db3375c4826135e6283166 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Tue, 15 Feb 2022 13:55:07 +0900 Subject: [PATCH 192/522] =?UTF-8?q?=F0=9F=93=91=20::=20PrintExcelService?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../excel/service/PrintExcelService.java | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/main/java/com/walkhub/walkhub/domain/excel/service/PrintExcelService.java diff --git a/src/main/java/com/walkhub/walkhub/domain/excel/service/PrintExcelService.java b/src/main/java/com/walkhub/walkhub/domain/excel/service/PrintExcelService.java new file mode 100644 index 000000000..4d944bcb9 --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/excel/service/PrintExcelService.java @@ -0,0 +1,33 @@ +package com.walkhub.walkhub.domain.excel.service; + +import com.lannstark.excel.ExcelFile; +import com.lannstark.excel.onesheet.OneSheetExcelFile; +import com.walkhub.walkhub.domain.exercise.domain.repository.ExerciseAnalysisRepository; +import com.walkhub.walkhub.domain.exercise.domain.repository.vo.PrintExcelVo; +import com.walkhub.walkhub.domain.user.facade.UserFacade; +import com.walkhub.walkhub.global.enums.Authority; +import java.io.IOException; +import java.time.LocalDate; +import java.util.List; +import javax.servlet.http.HttpServletResponse; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +@RequiredArgsConstructor +@Service +public class PrintExcelService { + + private final ExerciseAnalysisRepository exerciseAnalysisRepository; + private final UserFacade userFacade; + + public void execute(LocalDate startAt, LocalDate endAt, Authority authority, Integer grade, Integer classNum, HttpServletResponse response) + throws IOException { + Long schoolId = userFacade.getCurrentUser().getSchool().getId(); + List printExcelVoList = exerciseAnalysisRepository.getPrintExcelVoList(startAt, endAt, authority, grade, classNum, schoolId); + + response.setContentType("application/vnd.ms-excel"); + + ExcelFile excelFile = new OneSheetExcelFile<>(printExcelVoList, PrintExcelVo.class); + excelFile.write(response.getOutputStream()); + } +} From 0d35c4de19dbdd07fd4078b32f0ddf5b197def29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Tue, 15 Feb 2022 13:55:36 +0900 Subject: [PATCH 193/522] =?UTF-8?q?=F0=9F=93=91=20::=20PrintExcelVo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/repository/vo/PrintExcelVo.java | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/vo/PrintExcelVo.java diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/vo/PrintExcelVo.java b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/vo/PrintExcelVo.java new file mode 100644 index 000000000..2d16f7095 --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/vo/PrintExcelVo.java @@ -0,0 +1,40 @@ +package com.walkhub.walkhub.domain.exercise.domain.repository.vo; + +import com.lannstark.ExcelColumn; +import com.querydsl.core.annotations.QueryProjection; +import lombok.Getter; + +@Getter +public class PrintExcelVo { + + @ExcelColumn(headerName = "name") + private final String name; + @ExcelColumn(headerName = "grade") + private final Integer grade; + @ExcelColumn(headerName = "classNum") + private final Integer classNum; + @ExcelColumn(headerName = "number") + private final Integer number; + @ExcelColumn(headerName = "allWalkCount") + private final Integer allWalkCount; + @ExcelColumn(headerName = "averageWalkCount") + private final Integer averageWalkCount; + @ExcelColumn(headerName = "allDistance") + private final Integer allDistance; + @ExcelColumn(headerName = "averageDistance") + private final Integer averageDistance; + + @QueryProjection + public PrintExcelVo(String name, Integer grade, Integer classNum, Integer number, + Integer allWalkCount, Integer averageWalkCount, Integer allDistance, + Integer averageDistance) { + this.name = name; + this.grade = grade; + this.classNum = classNum; + this.number = number; + this.allWalkCount = allWalkCount; + this.averageWalkCount = averageWalkCount; + this.allDistance = allDistance; + this.averageDistance = averageDistance; + } +} From 6571d409f361ada31920563d13854aaaf896d285 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Tue, 15 Feb 2022 13:55:55 +0900 Subject: [PATCH 194/522] =?UTF-8?q?=F0=9F=93=91=20::=20ExerciseAnalysisRep?= =?UTF-8?q?ositoryCustom?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/repository/ExerciseAnalysisRepository.java | 2 +- .../repository/ExerciseAnalysisRepositoryCustom.java | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepositoryCustom.java diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepository.java b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepository.java index b657ba8c4..aa2b93c4c 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepository.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepository.java @@ -8,7 +8,7 @@ import java.time.LocalDate; import java.util.Optional; -public interface ExerciseAnalysisRepository extends CrudRepository { +public interface ExerciseAnalysisRepository extends CrudRepository, ExerciseAnalysisRepositoryCustom { Optional findByUserAndDate(User user, LocalDate date); List findAllByDateBetweenAndUser(LocalDate startAt, LocalDate endAt, User user); } diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepositoryCustom.java b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepositoryCustom.java new file mode 100644 index 000000000..637bd32f8 --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepositoryCustom.java @@ -0,0 +1,10 @@ +package com.walkhub.walkhub.domain.exercise.domain.repository; + +import com.walkhub.walkhub.domain.exercise.domain.repository.vo.PrintExcelVo; +import com.walkhub.walkhub.global.enums.Authority; +import java.time.LocalDate; +import java.util.List; + +public interface ExerciseAnalysisRepositoryCustom { + List getPrintExcelVoList(LocalDate startAt, LocalDate endAt, Authority authority, Integer grade, Integer classNum, Long SchoolId); +} From 6f7dfb118dda92116676b041211df705112b9b31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Tue, 15 Feb 2022 13:56:19 +0900 Subject: [PATCH 195/522] =?UTF-8?q?=F0=9F=93=91=20::=20ExerciseAnalysisRep?= =?UTF-8?q?ositoryCustomImpl?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ExerciseAnalysisRepositoryCustomImpl.java | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepositoryCustomImpl.java diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepositoryCustomImpl.java new file mode 100644 index 000000000..43737c7db --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepositoryCustomImpl.java @@ -0,0 +1,59 @@ +package com.walkhub.walkhub.domain.exercise.domain.repository; + +import static com.walkhub.walkhub.domain.exercise.domain.QExerciseAnalysis.exerciseAnalysis; +import static com.walkhub.walkhub.domain.user.domain.QUser.user; +import static com.walkhub.walkhub.domain.school.domain.QSchool.school; +import static com.walkhub.walkhub.domain.user.domain.QSection.section; + +import com.querydsl.core.BooleanBuilder; +import com.querydsl.jpa.impl.JPAQueryFactory; +import com.walkhub.walkhub.domain.exercise.domain.repository.vo.PrintExcelVo; +import com.walkhub.walkhub.domain.exercise.domain.repository.vo.QPrintExcelVo; +import com.walkhub.walkhub.global.enums.Authority; +import java.time.LocalDate; +import java.util.List; +import lombok.RequiredArgsConstructor; + +@RequiredArgsConstructor +public class ExerciseAnalysisRepositoryCustomImpl implements ExerciseAnalysisRepositoryCustom { + private final JPAQueryFactory queryFactory; + + @Override + public List getPrintExcelVoList(LocalDate startAt, LocalDate endAt, Authority authority, Integer grade, Integer classNum, Long schoolId) { + + BooleanBuilder builder = new BooleanBuilder(); + + if (authority.equals(Authority.STUDENT)) { + if (grade != null) { + builder.and(section.grade.eq(grade)); + } + if (classNum != null) { + builder.and(section.classNum.eq(classNum)); + } + } + + return queryFactory + .select(new QPrintExcelVo( + user.name, + section.grade, + section.classNum, + user.number, + exerciseAnalysis.walkCount.sum(), + exerciseAnalysis.walkCount.avg().intValue(), + exerciseAnalysis.distance.sum(), + exerciseAnalysis.distance.avg().intValue() + )) + .from(exerciseAnalysis) + .join(exerciseAnalysis.user, user) + .join(user.school, school) + .join(user.section, section) + .where( + school.id.eq(schoolId), + user.authority.eq(authority), + exerciseAnalysis.date.between(localDate, localDate2), + builder + ) + .groupBy(user) + .fetch(); + } +} From 1de6ab734538c5a6d761fef5236165d1001d0ad7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Tue, 15 Feb 2022 13:56:41 +0900 Subject: [PATCH 196/522] =?UTF-8?q?=E2=9A=A1=20::=20=EC=97=91=EC=85=80?= =?UTF-8?q?=EA=B4=80=EB=A0=A8=20dependency=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/build.gradle b/build.gradle index 10711dc26..923b7b6ed 100644 --- a/build.gradle +++ b/build.gradle @@ -52,6 +52,10 @@ dependencies { implementation 'org.hibernate:hibernate-jcache:5.6.5.Final' implementation 'org.ehcache:ehcache:3.9.2' + implementation group: 'org.apache.poi', name: 'poi', version: '5.0.0' + implementation group: 'org.apache.poi', name: 'poi-ooxml', version: '5.0.0' + + implementation('com.github.lannstark:excel-download:0.1.1') } test { @@ -69,3 +73,9 @@ sonarqube { property "sonar.host.url", "https://sonarcloud.io" } } + +allprojects { + repositories { + maven { url 'https://jitpack.io' } + } +} From 6f3777eed0fe0809989ccf19c7603c53b128e59b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Tue, 15 Feb 2022 13:56:52 +0900 Subject: [PATCH 197/522] =?UTF-8?q?=E2=9A=A1=20::=20permission=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 --- .../com/walkhub/walkhub/global/security/SecurityConfig.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java b/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java index 4f2b27678..509b55a28 100644 --- a/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java +++ b/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java @@ -126,6 +126,8 @@ protected void configure(HttpSecurity http) throws Exception { // socket.io .antMatchers(HttpMethod.GET, "/socket.io").authenticated() + // excel + .antMatchers(HttpMethod.GET, "/excel").hasAnyAuthority("TEACHER", "ROOT") .anyRequest().denyAll() .and() From 6a6b9c098476e376c2e56873c086655ab6e8f113 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Tue, 15 Feb 2022 14:04:39 +0900 Subject: [PATCH 198/522] =?UTF-8?q?=F0=9F=90=9B=20::=20=ED=8C=8C=EB=9D=BC?= =?UTF-8?q?=EB=AF=B8=ED=84=B0=20=EB=AA=85=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/repository/ExerciseAnalysisRepositoryCustomImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepositoryCustomImpl.java index 43737c7db..144757ee2 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepositoryCustomImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepositoryCustomImpl.java @@ -50,7 +50,7 @@ public List getPrintExcelVoList(LocalDate startAt, LocalDate endAt .where( school.id.eq(schoolId), user.authority.eq(authority), - exerciseAnalysis.date.between(localDate, localDate2), + exerciseAnalysis.date.between(startAt, endAt), builder ) .groupBy(user) From 5ae53e4e111e02a0c1ca8a782c80bc441c7e6780 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Tue, 15 Feb 2022 14:04:54 +0900 Subject: [PATCH 199/522] =?UTF-8?q?=E2=9A=A1=20::=20contentType=20xls=20->?= =?UTF-8?q?=20xlsx?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../walkhub/walkhub/domain/excel/service/PrintExcelService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/excel/service/PrintExcelService.java b/src/main/java/com/walkhub/walkhub/domain/excel/service/PrintExcelService.java index 4d944bcb9..99f81c078 100644 --- a/src/main/java/com/walkhub/walkhub/domain/excel/service/PrintExcelService.java +++ b/src/main/java/com/walkhub/walkhub/domain/excel/service/PrintExcelService.java @@ -25,7 +25,7 @@ public void execute(LocalDate startAt, LocalDate endAt, Authority authority, Int Long schoolId = userFacade.getCurrentUser().getSchool().getId(); List printExcelVoList = exerciseAnalysisRepository.getPrintExcelVoList(startAt, endAt, authority, grade, classNum, schoolId); - response.setContentType("application/vnd.ms-excel"); + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); ExcelFile excelFile = new OneSheetExcelFile<>(printExcelVoList, PrintExcelVo.class); excelFile.write(response.getOutputStream()); From 5bcc09a2cc1856c43eea986f46ab1ebb21340131 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B2=94=EC=A7=84?= Date: Tue, 15 Feb 2022 14:09:38 +0900 Subject: [PATCH 200/522] =?UTF-8?q?=E2=9A=A1=20::=20createdAt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../walkhub/domain/challenge/domain/ChallengeStatus.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/ChallengeStatus.java b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/ChallengeStatus.java index 33defb85d..ae349ee14 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/ChallengeStatus.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/ChallengeStatus.java @@ -1,7 +1,6 @@ package com.walkhub.walkhub.domain.challenge.domain; import com.walkhub.walkhub.domain.user.domain.User; -import com.walkhub.walkhub.global.entity.BaseTimeEntity; import lombok.AccessLevel; import lombok.Builder; import lombok.Getter; @@ -13,12 +12,14 @@ import javax.persistence.IdClass; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; +import javax.validation.constraints.NotNull; +import java.time.LocalDate; @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) @IdClass(ChallengeStatusId.class) @Entity -public class ChallengeStatus extends BaseTimeEntity { +public class ChallengeStatus { @Id @ManyToOne(fetch = FetchType.LAZY) @@ -30,6 +31,9 @@ public class ChallengeStatus extends BaseTimeEntity { @JoinColumn(name = "user_id") private User user; + @NotNull + private final LocalDate createdAt = LocalDate.now(); + @Builder public ChallengeStatus(Challenge challenge, User user) { this.challenge = challenge; From 178777d56e60aa88b24f344aa8f5e507c47b7855 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B2=94=EC=A7=84?= Date: Tue, 15 Feb 2022 14:10:06 +0900 Subject: [PATCH 201/522] =?UTF-8?q?=E2=9A=A1=20::=20=EC=B0=B8=EC=97=AC?= =?UTF-8?q?=EC=9D=BC=EA=B3=BC=20=EC=8B=9C=EC=9E=91=EC=9D=BC=20=EB=B9=84?= =?UTF-8?q?=EA=B5=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CustomChallengeRepositoryImpl.java | 48 ++++++++----------- 1 file changed, 20 insertions(+), 28 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/CustomChallengeRepositoryImpl.java b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/CustomChallengeRepositoryImpl.java index 946e8989b..d6accbe51 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/CustomChallengeRepositoryImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/CustomChallengeRepositoryImpl.java @@ -41,8 +41,9 @@ public List queryChallengeParticipantsList(Challenge ch .on(challengeStatus.challenge.eq(challenge)) .where( successScopeFilter(challenge, successScope), - goalTypeFilter(challenge), - exerciseAnalysis.date.between(challenge.getStartAt(), challenge.getEndAt()) + isChallengeSuccessFilter(challenge),exerciseAnalysis.date.goe(challenge.getStartAt()), + exerciseAnalysis.date.goe(challengeStatus.createdAt), + exerciseAnalysis.date.loe(challenge.getEndAt()) ) .orderBy(user.name.asc(), user.id.asc(), exerciseAnalysis.date.asc()) .transform(groupBy(user.name, user.id) @@ -57,9 +58,11 @@ public List queryChallengeParticipantsList(Challenge ch Expressions.asNumber(select(exerciseAnalysis.count()) .from(exerciseAnalysis) .where( - goalTypeFilter(challenge), + isChallengeSuccessFilter(challenge), exerciseAnalysis.user.eq(user), - exerciseAnalysis.date.between(challenge.getStartAt(), challenge.getEndAt()) + exerciseAnalysis.date.goe(challenge.getStartAt()), + exerciseAnalysis.date.goe(challengeStatus.createdAt), + exerciseAnalysis.date.loe(challenge.getEndAt()) )) .goe(challenge.getSuccessStandard()).as("isSuccess"), GroupBy.list(exerciseAnalysis.date)) @@ -73,9 +76,11 @@ private BooleanExpression successScopeFilter(Challenge challenge, SuccessScope s return Expressions.asNumber(select(exerciseAnalysis.count()) .from(exerciseAnalysis) .where( - goalTypeFilter(challenge), + isChallengeSuccessFilter(challenge), exerciseAnalysis.user.eq(user), - exerciseAnalysis.date.between(challenge.getStartAt(), challenge.getEndAt()) + exerciseAnalysis.date.goe(challenge.getStartAt()), + exerciseAnalysis.date.goe(challengeStatus.createdAt), + exerciseAnalysis.date.loe(challenge.getEndAt()) )) .goe(challenge.getSuccessStandard()); } @@ -83,9 +88,11 @@ private BooleanExpression successScopeFilter(Challenge challenge, SuccessScope s return Expressions.asNumber(select(exerciseAnalysis.count()) .from(exerciseAnalysis) .where( - goalTypeFilter(challenge), + isChallengeSuccessFilter(challenge), exerciseAnalysis.user.eq(user), - exerciseAnalysis.date.between(challenge.getStartAt(), challenge.getEndAt()) + exerciseAnalysis.date.goe(challenge.getStartAt()), + exerciseAnalysis.date.goe(challengeStatus.createdAt), + exerciseAnalysis.date.loe(challenge.getEndAt()) )) .lt(challenge.getSuccessStandard()); } @@ -95,23 +102,7 @@ private BooleanExpression successScopeFilter(Challenge challenge, SuccessScope s } } - private BooleanExpression goalTypeFilter(Challenge challenge) { - if (challenge.getGoalType() == GoalType.WALK) { - return isChallengeSuccessByWalkCount(challenge); - } - - return isChallengeSuccessByDistance(challenge); - } - - private BooleanExpression isChallengeSuccessByWalkCount(Challenge challenge) { - if (challenge.getGoalScope() == GoalScope.DAY) { - return isChallengeSuccessInDayScope(challenge); - } - - return isChallengeSuccessInAllScope(challenge); - } - - private BooleanExpression isChallengeSuccessByDistance(Challenge challenge) { + private BooleanExpression isChallengeSuccessFilter(Challenge challenge) { if (challenge.getGoalScope() == GoalScope.DAY) { return isChallengeSuccessInDayScope(challenge); } @@ -139,9 +130,10 @@ private BooleanExpression isChallengeSuccessInAllScope(Challenge challenge) { return JPAExpressions.select(exerciseAmount.sum()) .from(exerciseAnalysis) .where( - // 시작일과 참여일 비교 필요 - exerciseAnalysis.date.between(challenge.getStartAt(), challenge.getEndAt()), - exerciseAnalysis.user.eq(user) + exerciseAnalysis.user.eq(user), + exerciseAnalysis.date.goe(challenge.getStartAt()), + exerciseAnalysis.date.goe(challengeStatus.createdAt), + exerciseAnalysis.date.loe(challenge.getEndAt()) ) .goe(challenge.getGoal()); } From 5e667cbe93bca8b6de396370af0873fba5097fd3 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Tue, 15 Feb 2022 14:15:34 +0900 Subject: [PATCH 202/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20=EA=B3=B5?= =?UTF-8?q?=ED=86=B5=EB=A1=9C=EC=A7=81=20=EB=A9=94=EC=86=8C=EB=93=9C?= =?UTF-8?q?=EB=A1=9C=20=EB=BA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/QueryUserRankListService.java | 157 +++++++++--------- 1 file changed, 75 insertions(+), 82 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListService.java b/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListService.java index c4a4ce196..67e7dc549 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListService.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListService.java @@ -1,12 +1,11 @@ package com.walkhub.walkhub.domain.rank.service; import com.walkhub.walkhub.domain.exercise.cache.ExerciseAnalysisCacheRepository; -import com.walkhub.walkhub.domain.exercise.domain.repository.ExerciseAnalysisRepository; +import com.walkhub.walkhub.domain.exercise.cache.ExerciseAnalysisDto; import com.walkhub.walkhub.domain.rank.domain.repository.UserRankRepository; import com.walkhub.walkhub.domain.rank.domain.repository.vo.UserRankVO; import com.walkhub.walkhub.domain.rank.domain.type.UserRankScope; import com.walkhub.walkhub.domain.rank.presentation.dto.response.UserRankListResponse; -import com.walkhub.walkhub.domain.user.domain.Section; import com.walkhub.walkhub.domain.user.domain.User; import com.walkhub.walkhub.domain.user.facade.UserFacade; import com.walkhub.walkhub.global.enums.DateType; @@ -14,8 +13,8 @@ import org.springframework.stereotype.Service; import java.time.LocalDate; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.stream.Collectors; +import java.util.ArrayList; +import java.util.List; @RequiredArgsConstructor @Service @@ -23,91 +22,85 @@ public class QueryUserRankListService { private final UserRankRepository userRankRepository; private final ExerciseAnalysisCacheRepository exerciseAnalysisCacheRepository; private final UserFacade userFacade; - private final ExerciseAnalysisRepository exerciseAnalysisRepository; public UserRankListResponse execute(UserRankScope scope, DateType dateType) { User user = userFacade.getCurrentUser(); - Section section = user.getSection(); LocalDate date = LocalDate.now(); + UserRankListResponse.UserRankResponse myRank = null; + List userRankList = new ArrayList<>(); if (dateType.equals(DateType.DAY)) { - AtomicInteger rankCount = new AtomicInteger(); - return UserRankListResponse.builder() - .myRank(UserRankListResponse.UserRankResponse.builder() - .userId(user.getId()) - .name(user.getName()) - .grade(section.getGrade()) - .classNum(section.getClassNum()) - .ranking(Math.toIntExact(exerciseAnalysisCacheRepository.getUserTodayRank(user.getId()).getRanking())) - .profileImageUrl(user.getProfileImageUrl()) - .walkCount(exerciseAnalysisRepository.findByUserIdAndDate(user.getId(), LocalDate.now())) - .build() - ) - .rankList(exerciseAnalysisCacheRepository.getUserIdsByRankTop100() - .stream() - .map(userIds -> userFacade.getUserById(userIds.getUserId())) - .map(users -> UserRankListResponse.UserRankResponse.builder() - .userId(users.getId()) - .name(users.getName()) - .grade(users.getSection().getGrade()) - .classNum(users.getSection().getClassNum()) - .ranking(rankCount.incrementAndGet()) - .profileImageUrl(users.getProfileImageUrl()) - .walkCount(exerciseAnalysisRepository.findByUserIdAndDate(users.getId(), LocalDate.now())) - .build() - ).collect(Collectors.toList()) - ).build(); + myRank = buildDayMyRankResponse(user); + List usersDayRank = exerciseAnalysisCacheRepository.getUserIdsByRankTop100(); + for (ExerciseAnalysisDto users : usersDayRank) { + userRankList.add(buildDayUsersRankResponse(users)); + } } else if (scope.equals(UserRankScope.ALL)) { - UserRankVO userRankVO = userRankRepository.getMyRankByUserId(user.getId(), null, dateType, date); - return UserRankListResponse.builder() - .myRank(UserRankListResponse.UserRankResponse.builder() - .userId(userRankVO.getUserId()) - .name(userRankVO.getName()) - .grade(userRankVO.getGrade()) - .classNum(userRankVO.getClassNum()) - .ranking(userRankVO.getRanking()) - .profileImageUrl(userRankVO.getProfileImageUrl()) - .walkCount(userRankVO.getWalkCount()) - .build() - ) - .rankList(userRankRepository.getUserRankListBySchoolId(user.getSchool().getId(), null, dateType, date) - .stream().map(vo -> UserRankListResponse.UserRankResponse.builder() - .userId(vo.getUserId()) - .name(vo.getName()) - .grade(vo.getGrade()) - .classNum(vo.getClassNum()) - .ranking(vo.getRanking()) - .profileImageUrl(vo.getProfileImageUrl()) - .walkCount(vo.getWalkCount()) - .build() - ).collect(Collectors.toList()) - ) - .build(); + myRank = buildWeekOrMonthMyRankResponse(user.getId(), null, dateType, date); + List usersWeekOrMonthRank = userRankRepository.getUserRankListBySchoolId(user.getSchool().getId(), null, dateType, date); + for (UserRankVO users : usersWeekOrMonthRank) { + userRankList.add(buildWeekOrMonthUsersRankResponse(users)); + } } else if (scope.equals(UserRankScope.CLASS)) { - UserRankVO userRankVO = userRankRepository.getMyRankByUserId(user.getId(), user.getSection().getClassNum(), dateType, date); - return UserRankListResponse.builder() - .myRank(UserRankListResponse.UserRankResponse.builder() - .userId(userRankVO.getUserId()) - .name(userRankVO.getName()) - .grade(userRankVO.getGrade()) - .classNum(userRankVO.getClassNum()) - .ranking(userRankVO.getRanking()) - .profileImageUrl(userRankVO.getProfileImageUrl()) - .walkCount(userRankVO.getWalkCount()) - .build()) - .rankList(userRankRepository.getUserRankListBySchoolId(user.getSchool().getId(), user.getSection().getClassNum(), dateType, date) - .stream().map(vo -> UserRankListResponse.UserRankResponse.builder() - .userId(vo.getUserId()) - .name(vo.getName()) - .grade(vo.getGrade()) - .classNum(vo.getClassNum()) - .ranking(vo.getRanking()) - .profileImageUrl(vo.getProfileImageUrl()) - .walkCount(vo.getWalkCount()) - .build() - ).collect(Collectors.toList()) - ) - .build(); + myRank = buildWeekOrMonthMyRankResponse(user.getId(), user.getSection().getClassNum(), dateType, date); + List usersWeekOrMonthRank = userRankRepository.getUserRankListBySchoolId(user.getSchool().getId(), user.getSection().getClassNum(), dateType, date); + for (UserRankVO users : usersWeekOrMonthRank) { + userRankList.add(buildWeekOrMonthUsersRankResponse(users)); + } } - return null; + return UserRankListResponse.builder() + .myRank(myRank) + .rankList(userRankList) + .build(); + } + + private UserRankListResponse.UserRankResponse buildDayMyRankResponse(User user) { + ExerciseAnalysisDto exerciseAnalysisDto = exerciseAnalysisCacheRepository.getUserTodayRank(user.getId()); + return UserRankListResponse.UserRankResponse.builder() + .userId(user.getId()) + .name(user.getName()) + .grade(user.getSection().getGrade()) + .classNum(user.getSection().getClassNum()) + .ranking(exerciseAnalysisDto.getRanking()) + .profileImageUrl(user.getProfileImageUrl()) + .walkCount(exerciseAnalysisDto.getWalkCount()) + .build(); + } + + private UserRankListResponse.UserRankResponse buildDayUsersRankResponse(ExerciseAnalysisDto dayRank) { + User user = userFacade.getUserById(dayRank.getUserId()); + return UserRankListResponse.UserRankResponse.builder() + .userId(user.getId()) + .name(user.getName()) + .grade(user.getSection().getGrade()) + .classNum(user.getSection().getClassNum()) + .ranking(dayRank.getRanking()) + .profileImageUrl(user.getProfileImageUrl()) + .walkCount(dayRank.getWalkCount()) + .build(); + } + + private UserRankListResponse.UserRankResponse buildWeekOrMonthMyRankResponse(Long userId, Integer classNum, DateType dateType, LocalDate date) { + UserRankVO userRank = userRankRepository.getMyRankByUserId(userId, classNum, dateType, date); + return UserRankListResponse.UserRankResponse.builder() + .userId(userRank.getUserId()) + .name(userRank.getName()) + .grade(userRank.getGrade()) + .classNum(userRank.getClassNum()) + .ranking(userRank.getRanking()) + .profileImageUrl(userRank.getProfileImageUrl()) + .walkCount(userRank.getWalkCount()) + .build(); + } + + private UserRankListResponse.UserRankResponse buildWeekOrMonthUsersRankResponse(UserRankVO userRank) { + return UserRankListResponse.UserRankResponse.builder() + .userId(userRank.getUserId()) + .name(userRank.getName()) + .grade(userRank.getGrade()) + .classNum(userRank.getClassNum()) + .ranking(userRank.getRanking()) + .profileImageUrl(userRank.getProfileImageUrl()) + .walkCount(userRank.getWalkCount()) + .build(); } } From 95e83f01c1af5a234459392b09a2778f7e379860 Mon Sep 17 00:00:00 2001 From: lyutvs Date: Tue, 15 Feb 2022 14:18:09 +0900 Subject: [PATCH 203/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F::=20=EA=B0=80?= =?UTF-8?q?=EB=8F=85=EC=84=B1=20=EC=98=AC=EB=A6=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../walkhub/domain/badge/presentation/BadgeController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/badge/presentation/BadgeController.java b/src/main/java/com/walkhub/walkhub/domain/badge/presentation/BadgeController.java index 63a0b2de7..45f6ea5ea 100644 --- a/src/main/java/com/walkhub/walkhub/domain/badge/presentation/BadgeController.java +++ b/src/main/java/com/walkhub/walkhub/domain/badge/presentation/BadgeController.java @@ -30,7 +30,7 @@ public void setTitleBadge(@PathVariable("badge-id") Long badgeId) { } @GetMapping("/{user-id}") - public QueryUserBadgeListResponse queryUserBadgeList(@PathVariable(name = "user-id")Long userId) { + public QueryUserBadgeListResponse queryUserBadgeList(@PathVariable(name = "user-id") Long userId) { return queryUserBadgeListService.execute(userId); } From dae0007af912c818067ce6342d96a9a517ea616a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Tue, 15 Feb 2022 14:22:25 +0900 Subject: [PATCH 204/522] =?UTF-8?q?=E2=9A=A1=20::=20=EC=A4=84=EB=B0=94?= =?UTF-8?q?=EA=BF=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/exercise/domain/repository/vo/PrintExcelVo.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/vo/PrintExcelVo.java b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/vo/PrintExcelVo.java index 2d16f7095..41833a0b0 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/vo/PrintExcelVo.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/vo/PrintExcelVo.java @@ -9,18 +9,25 @@ public class PrintExcelVo { @ExcelColumn(headerName = "name") private final String name; + @ExcelColumn(headerName = "grade") private final Integer grade; + @ExcelColumn(headerName = "classNum") private final Integer classNum; + @ExcelColumn(headerName = "number") private final Integer number; + @ExcelColumn(headerName = "allWalkCount") private final Integer allWalkCount; + @ExcelColumn(headerName = "averageWalkCount") private final Integer averageWalkCount; + @ExcelColumn(headerName = "allDistance") private final Integer allDistance; + @ExcelColumn(headerName = "averageDistance") private final Integer averageDistance; From c4150545e4719dd16a5290b91fe227049ced880e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Tue, 15 Feb 2022 14:26:31 +0900 Subject: [PATCH 205/522] =?UTF-8?q?=E2=9A=A1=20::=20readOnly?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../walkhub/walkhub/domain/excel/service/PrintExcelService.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/excel/service/PrintExcelService.java b/src/main/java/com/walkhub/walkhub/domain/excel/service/PrintExcelService.java index 99f81c078..eba9dfbea 100644 --- a/src/main/java/com/walkhub/walkhub/domain/excel/service/PrintExcelService.java +++ b/src/main/java/com/walkhub/walkhub/domain/excel/service/PrintExcelService.java @@ -12,6 +12,7 @@ import javax.servlet.http.HttpServletResponse; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; @RequiredArgsConstructor @Service @@ -20,6 +21,7 @@ public class PrintExcelService { private final ExerciseAnalysisRepository exerciseAnalysisRepository; private final UserFacade userFacade; + @Transactional(readOnly = true) public void execute(LocalDate startAt, LocalDate endAt, Authority authority, Integer grade, Integer classNum, HttpServletResponse response) throws IOException { Long schoolId = userFacade.getCurrentUser().getSchool().getId(); From 20327b8d00ee83bdc52c1931e91254eef750bc8e Mon Sep 17 00:00:00 2001 From: lyutvs Date: Tue, 15 Feb 2022 14:53:05 +0900 Subject: [PATCH 206/522] =?UTF-8?q?=F0=9F=93=91::=20MyBadgeVo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../badge/domain/repository/vo/MyBadgeVo.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/vo/MyBadgeVo.java diff --git a/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/vo/MyBadgeVo.java b/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/vo/MyBadgeVo.java new file mode 100644 index 000000000..c5b74b2a8 --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/vo/MyBadgeVo.java @@ -0,0 +1,23 @@ +package com.walkhub.walkhub.domain.badge.domain.repository.vo; + +import com.querydsl.core.annotations.QueryProjection; +import lombok.Getter; + +@Getter +public class MyBadgeVo { + + private final Long badgeId; + private final String name; + private final String imageUrl; + private final boolean isMine; + + @QueryProjection + public MyBadgeVo(Long badgeId, String name, + String imageUrl, boolean isMine) { + this.badgeId = badgeId; + this.name = name; + this.imageUrl = imageUrl; + this.isMine = isMine; + } + +} From 135e50ec1ce27ed005719fd34dba828e0c7ba118 Mon Sep 17 00:00:00 2001 From: lyutvs Date: Tue, 15 Feb 2022 14:53:19 +0900 Subject: [PATCH 207/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F::=20MyBadgeVO=20?= =?UTF-8?q?=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 --- .../domain/badge/domain/repository/CustomBadgeRepository.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/CustomBadgeRepository.java b/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/CustomBadgeRepository.java index 252953f50..f138ae926 100644 --- a/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/CustomBadgeRepository.java +++ b/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/CustomBadgeRepository.java @@ -1,10 +1,11 @@ package com.walkhub.walkhub.domain.badge.domain.repository; import com.walkhub.walkhub.domain.badge.domain.repository.vo.DefaultBadgeVO; +import com.walkhub.walkhub.domain.badge.domain.repository.vo.MyBadgeVo; import java.util.List; public interface CustomBadgeRepository { List findAllByBadgeCollectionsNotIn(Long userId); - List findAllByBadgeCollections(Long userId); + List findAllByBadgeCollections(Long userId); } From 958efec86138b06a9b87affb78208ec7363691e5 Mon Sep 17 00:00:00 2001 From: lyutvs Date: Tue, 15 Feb 2022 14:54:01 +0900 Subject: [PATCH 208/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F::=20isMine=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20=EB=B0=8F=20=EB=B3=91=ED=95=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/CustomBadgeRepositoryImpl.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/CustomBadgeRepositoryImpl.java b/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/CustomBadgeRepositoryImpl.java index 9212f76f4..567348ced 100644 --- a/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/CustomBadgeRepositoryImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/CustomBadgeRepositoryImpl.java @@ -2,7 +2,9 @@ import com.querydsl.jpa.impl.JPAQueryFactory; import com.walkhub.walkhub.domain.badge.domain.repository.vo.DefaultBadgeVO; +import com.walkhub.walkhub.domain.badge.domain.repository.vo.MyBadgeVo; import com.walkhub.walkhub.domain.badge.domain.repository.vo.QDefaultBadgeVO; +import com.walkhub.walkhub.domain.badge.domain.repository.vo.QMyBadgeVo; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Repository; @@ -36,18 +38,17 @@ public List findAllByBadgeCollectionsNotIn(Long userId) { } @Override - public List findAllByBadgeCollections(Long userId) { + public List findAllByBadgeCollections(Long userId) { return query - .select(new QDefaultBadgeVO( + .select(new QMyBadgeVo( badge.id, badge.name, - badge.imageUrl + badge.imageUrl, + user.id.eq(userId) )) .from(badge) - .leftJoin(badgeCollection) - .on(badgeCollection.badge.eq(badge)) - .leftJoin(user) - .on(badgeCollection.user.eq(user)) + .leftJoin(badgeCollection.badge, badge) + .leftJoin(badgeCollection.user, user) .where(user.isNull().or(user.id.eq(userId))) .fetch(); } From 9e8d3e26bcb80cdefbbf5b7f9cb0612782e0ea63 Mon Sep 17 00:00:00 2001 From: lyutvs Date: Tue, 15 Feb 2022 14:54:13 +0900 Subject: [PATCH 209/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F::=20=EC=95=88=20?= =?UTF-8?q?=EC=93=B0=EB=8A=94=20=EC=BD=94=EB=93=9C=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/badge/domain/repository/vo/DefaultBadgeVO.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/vo/DefaultBadgeVO.java b/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/vo/DefaultBadgeVO.java index 9e13a48aa..4e75cb68e 100644 --- a/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/vo/DefaultBadgeVO.java +++ b/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/vo/DefaultBadgeVO.java @@ -1,7 +1,6 @@ package com.walkhub.walkhub.domain.badge.domain.repository.vo; import com.querydsl.core.annotations.QueryProjection; -import lombok.Builder; import lombok.Getter; @Getter @@ -11,7 +10,6 @@ public class DefaultBadgeVO { private final String imageUrl; @QueryProjection - @Builder public DefaultBadgeVO(Long badgeId, String name, String imageUrl) { this.badgeId = badgeId; this.name = name; From 2fce9ef97db96913071a0fd2163cfb858897a0d9 Mon Sep 17 00:00:00 2001 From: lyutvs Date: Tue, 15 Feb 2022 14:54:33 +0900 Subject: [PATCH 210/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F::=20MyBadgeVo=20?= =?UTF-8?q?=EB=A5=BC=20List=20=EB=A1=9C=20=EB=B0=9B=EC=95=84=EC=98=A4?= =?UTF-8?q?=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/response/QueryMyBadgeListResponse.java | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/badge/presentation/dto/response/QueryMyBadgeListResponse.java b/src/main/java/com/walkhub/walkhub/domain/badge/presentation/dto/response/QueryMyBadgeListResponse.java index e3a1cabba..911e93901 100644 --- a/src/main/java/com/walkhub/walkhub/domain/badge/presentation/dto/response/QueryMyBadgeListResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/badge/presentation/dto/response/QueryMyBadgeListResponse.java @@ -1,8 +1,7 @@ package com.walkhub.walkhub.domain.badge.presentation.dto.response; -import com.walkhub.walkhub.domain.badge.domain.repository.vo.DefaultBadgeVO; +import com.walkhub.walkhub.domain.badge.domain.repository.vo.MyBadgeVo; import lombok.AllArgsConstructor; -import lombok.Builder; import lombok.Getter; import java.util.List; @@ -10,15 +9,5 @@ @Getter @AllArgsConstructor public class QueryMyBadgeListResponse { - - private final List badgeLists; - - @Getter - @Builder - public static class BadgeListResponse { - private final Long id; - private final String name; - private final String imageUrl; - private final boolean isMine; - } + private final List badgeLists; } From a2f57dd1a360ed10b6d0915ccf782303c398b5bd Mon Sep 17 00:00:00 2001 From: lyutvs Date: Tue, 15 Feb 2022 14:54:52 +0900 Subject: [PATCH 211/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F::=20MyBadgeVo=20?= =?UTF-8?q?=EB=A1=9C=20=EA=B0=9D=EC=B2=B4=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../walkhub/domain/badge/service/QueryMyBadgeListService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/badge/service/QueryMyBadgeListService.java b/src/main/java/com/walkhub/walkhub/domain/badge/service/QueryMyBadgeListService.java index 2c497e550..72023e8e7 100644 --- a/src/main/java/com/walkhub/walkhub/domain/badge/service/QueryMyBadgeListService.java +++ b/src/main/java/com/walkhub/walkhub/domain/badge/service/QueryMyBadgeListService.java @@ -1,7 +1,7 @@ package com.walkhub.walkhub.domain.badge.service; import com.walkhub.walkhub.domain.badge.domain.repository.BadgeRepository; -import com.walkhub.walkhub.domain.badge.domain.repository.vo.DefaultBadgeVO; +import com.walkhub.walkhub.domain.badge.domain.repository.vo.MyBadgeVo; import com.walkhub.walkhub.domain.badge.presentation.dto.response.QueryMyBadgeListResponse; import com.walkhub.walkhub.domain.user.domain.User; import com.walkhub.walkhub.domain.user.facade.UserFacade; @@ -21,7 +21,7 @@ public class QueryMyBadgeListService { @Transactional(readOnly = true) public QueryMyBadgeListResponse execute() { User user = userFacade.getCurrentUser(); - List badgeVOList = badgeRepository.findAllByBadgeCollections(user.getId()); + List badgeVOList = badgeRepository.findAllByBadgeCollections(user.getId()); return new QueryMyBadgeListResponse(badgeVOList); } } From 493eb1fc3e4933938027080c5c95b833433d03e4 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Tue, 15 Feb 2022 15:01:08 +0900 Subject: [PATCH 212/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20=ED=95=84?= =?UTF-8?q?=EC=9A=94=EC=97=86=EB=8A=94=20=EB=A9=94=EC=86=8C=EB=93=9C=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exercise/domain/repository/ExerciseAnalysisRepository.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepository.java b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepository.java index dc6333ae5..b657ba8c4 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepository.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepository.java @@ -10,6 +10,5 @@ public interface ExerciseAnalysisRepository extends CrudRepository { Optional findByUserAndDate(User user, LocalDate date); - Integer findByUserIdAndDate(Long userId, LocalDate date); List findAllByDateBetweenAndUser(LocalDate startAt, LocalDate endAt, User user); } From 3c433c633f19676d87719b529fe667dbcb687655 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Tue, 15 Feb 2022 15:01:45 +0900 Subject: [PATCH 213/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20=EB=9E=8C?= =?UTF-8?q?=EB=8B=A4=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 --- .../service/QueryUserRankListService.java | 53 ++++++++++--------- 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListService.java b/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListService.java index 67e7dc549..b91c5eb4a 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListService.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListService.java @@ -15,6 +15,7 @@ import java.time.LocalDate; import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; @RequiredArgsConstructor @Service @@ -37,15 +38,11 @@ public UserRankListResponse execute(UserRankScope scope, DateType dateType) { } else if (scope.equals(UserRankScope.ALL)) { myRank = buildWeekOrMonthMyRankResponse(user.getId(), null, dateType, date); List usersWeekOrMonthRank = userRankRepository.getUserRankListBySchoolId(user.getSchool().getId(), null, dateType, date); - for (UserRankVO users : usersWeekOrMonthRank) { - userRankList.add(buildWeekOrMonthUsersRankResponse(users)); - } + userRankList = buildWeekOrMonthUsersRankResponse(usersWeekOrMonthRank); } else if (scope.equals(UserRankScope.CLASS)) { myRank = buildWeekOrMonthMyRankResponse(user.getId(), user.getSection().getClassNum(), dateType, date); List usersWeekOrMonthRank = userRankRepository.getUserRankListBySchoolId(user.getSchool().getId(), user.getSection().getClassNum(), dateType, date); - for (UserRankVO users : usersWeekOrMonthRank) { - userRankList.add(buildWeekOrMonthUsersRankResponse(users)); - } + userRankList = buildWeekOrMonthUsersRankResponse(usersWeekOrMonthRank); } return UserRankListResponse.builder() .myRank(myRank) @@ -55,6 +52,9 @@ public UserRankListResponse execute(UserRankScope scope, DateType dateType) { private UserRankListResponse.UserRankResponse buildDayMyRankResponse(User user) { ExerciseAnalysisDto exerciseAnalysisDto = exerciseAnalysisCacheRepository.getUserTodayRank(user.getId()); + if (exerciseAnalysisDto == null) { + return null; + } return UserRankListResponse.UserRankResponse.builder() .userId(user.getId()) .name(user.getName()) @@ -80,27 +80,32 @@ private UserRankListResponse.UserRankResponse buildDayUsersRankResponse(Exercise } private UserRankListResponse.UserRankResponse buildWeekOrMonthMyRankResponse(Long userId, Integer classNum, DateType dateType, LocalDate date) { - UserRankVO userRank = userRankRepository.getMyRankByUserId(userId, classNum, dateType, date); + UserRankVO myRank = userRankRepository.getMyRankByUserId(userId, classNum, dateType, date); + if (myRank == null) { + return null; + } return UserRankListResponse.UserRankResponse.builder() - .userId(userRank.getUserId()) - .name(userRank.getName()) - .grade(userRank.getGrade()) - .classNum(userRank.getClassNum()) - .ranking(userRank.getRanking()) - .profileImageUrl(userRank.getProfileImageUrl()) - .walkCount(userRank.getWalkCount()) + .userId(myRank.getUserId()) + .name(myRank.getName()) + .grade(myRank.getGrade()) + .classNum(myRank.getClassNum()) + .ranking(myRank.getRanking()) + .profileImageUrl(myRank.getProfileImageUrl()) + .walkCount(myRank.getWalkCount()) .build(); } - private UserRankListResponse.UserRankResponse buildWeekOrMonthUsersRankResponse(UserRankVO userRank) { - return UserRankListResponse.UserRankResponse.builder() - .userId(userRank.getUserId()) - .name(userRank.getName()) - .grade(userRank.getGrade()) - .classNum(userRank.getClassNum()) - .ranking(userRank.getRanking()) - .profileImageUrl(userRank.getProfileImageUrl()) - .walkCount(userRank.getWalkCount()) - .build(); + private List buildWeekOrMonthUsersRankResponse(List userRanks) { + return userRanks.stream() + .map(userRank -> UserRankListResponse.UserRankResponse.builder() + .userId(userRank.getUserId()) + .name(userRank.getName()) + .grade(userRank.getGrade()) + .classNum(userRank.getClassNum()) + .ranking(userRank.getRanking()) + .profileImageUrl(userRank.getProfileImageUrl()) + .walkCount(userRank.getWalkCount()) + .build() + ).collect(Collectors.toList()); } } From 7a30cee40bde6120c50e98262d474454922878e4 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Tue, 15 Feb 2022 15:21:51 +0900 Subject: [PATCH 214/522] :bookmark_tabs: :: ClassListService --- .../teacher/service/ClassListService.java | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 src/main/java/com/walkhub/walkhub/domain/teacher/service/ClassListService.java diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/service/ClassListService.java b/src/main/java/com/walkhub/walkhub/domain/teacher/service/ClassListService.java new file mode 100644 index 000000000..f10f73209 --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/service/ClassListService.java @@ -0,0 +1,54 @@ +package com.walkhub.walkhub.domain.teacher.service; + +import com.walkhub.walkhub.domain.school.domain.School; +import com.walkhub.walkhub.domain.teacher.presentation.dto.response.ClassListResponse; +import com.walkhub.walkhub.domain.teacher.presentation.dto.response.ClassListResponse.ClassResponse; +import com.walkhub.walkhub.domain.teacher.presentation.dto.response.ClassListResponse.SectionResponse; +import com.walkhub.walkhub.domain.teacher.presentation.dto.response.ClassListResponse.TeacherResponse; +import com.walkhub.walkhub.domain.user.domain.User; +import com.walkhub.walkhub.domain.user.domain.repository.UserRepository; +import com.walkhub.walkhub.domain.user.facade.UserFacade; +import com.walkhub.walkhub.global.enums.Authority; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.stream.Collectors; + +@RequiredArgsConstructor +@Service +public class ClassListService { + + private final UserFacade userFacade; + private final UserRepository userRepository; + + public ClassListResponse execute() { + User teacher = userFacade.getCurrentUser(); + School school = teacher.getSchool(); + + List classList = school.getSections() + .stream() + .map(section -> { + User user = userRepository.findBySectionAndAuthority(section, Authority.TEACHER); + Integer userCount = userRepository.findAllBySectionAndAuthority(section, Authority.USER).size(); + return ClassResponse.builder() + .section(SectionResponse.builder() + .sectionId(section.getId()) + .grade(section.getGrade()) + .classNum(section.getClassNum()) + .build()) + .teacher(TeacherResponse.builder() + .userId(user.getId()) + .name(user.getName()) + .profileImageUrl(user.getProfileImageUrl()) + .build()) + .userCount(userCount) + .build(); + }).collect(Collectors.toList()); + + return new ClassListResponse(classList); + } +} + + + From f5935c89a06468a7f350a1e70de57747b9989b70 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Tue, 15 Feb 2022 15:22:07 +0900 Subject: [PATCH 215/522] :bookmark_tabs: :: ClassListResponse --- .../dto/response/ClassListResponse.java | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/ClassListResponse.java diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/ClassListResponse.java b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/ClassListResponse.java new file mode 100644 index 000000000..9efcfca57 --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/ClassListResponse.java @@ -0,0 +1,39 @@ +package com.walkhub.walkhub.domain.teacher.presentation.dto.response; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; + +import java.util.List; + +@Getter +@AllArgsConstructor +public class ClassListResponse { + + private final List classList; + + @Getter + @Builder + public static class ClassResponse { + private final SectionResponse section; + private final TeacherResponse teacher; + private final Integer userCount; + } + + @Getter + @Builder + public static class SectionResponse { + private final Long sectionId; + private final Integer grade; + private final Integer classNum; + } + + @Getter + @Builder + public static class TeacherResponse { + private final Long userId; + private final String name; + private final String profileImageUrl; + } + +} From 998fec10bc45de5b2ff0c81922082e36b23481a4 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Tue, 15 Feb 2022 15:22:23 +0900 Subject: [PATCH 216/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20section=20?= =?UTF-8?q?=EA=B4=80=EA=B3=84=20=EB=A7=A4=ED=95=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/walkhub/walkhub/domain/school/domain/School.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/school/domain/School.java b/src/main/java/com/walkhub/walkhub/domain/school/domain/School.java index e2b23ff0e..32e3b8550 100644 --- a/src/main/java/com/walkhub/walkhub/domain/school/domain/School.java +++ b/src/main/java/com/walkhub/walkhub/domain/school/domain/School.java @@ -1,5 +1,6 @@ package com.walkhub.walkhub.domain.school.domain; +import com.walkhub.walkhub.domain.user.domain.Section; import com.walkhub.walkhub.global.entity.BaseTimeEntity; import com.walkhub.walkhub.infrastructure.image.DefaultImage; import lombok.AccessLevel; @@ -13,6 +14,8 @@ import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; +import javax.persistence.OneToMany; +import java.util.List; @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) @@ -36,6 +39,9 @@ public class School extends BaseTimeEntity { @Column(columnDefinition = "char(7)") private String authCode; + @OneToMany(mappedBy = "school") + private List
sections; + @Builder public School(String name, String logoImageUrl) { this.name = name; From bd3c3c7e60de11b998a43d14e91b116cf3c20259 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Tue, 15 Feb 2022 15:24:17 +0900 Subject: [PATCH 217/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20class=20List?= =?UTF-8?q?=20api=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/teacher/presentation/TeacherController.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/TeacherController.java b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/TeacherController.java index 3e4d89e8f..a5d7a9566 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/TeacherController.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/TeacherController.java @@ -2,9 +2,11 @@ import com.walkhub.walkhub.domain.teacher.presentation.dto.request.CreateClassRequest; import com.walkhub.walkhub.domain.teacher.presentation.dto.request.TeacherCodeRequest; +import com.walkhub.walkhub.domain.teacher.presentation.dto.response.ClassListResponse; import com.walkhub.walkhub.domain.teacher.presentation.dto.response.CodeResponse; import com.walkhub.walkhub.domain.teacher.presentation.dto.response.DetailsClassResponse; import com.walkhub.walkhub.domain.teacher.presentation.dto.response.QueryUserDetailsResponse; +import com.walkhub.walkhub.domain.teacher.service.ClassListService; import com.walkhub.walkhub.domain.teacher.service.ConfirmTeacherCodeService; import com.walkhub.walkhub.domain.teacher.service.CreateClassService; import com.walkhub.walkhub.domain.teacher.service.DeleteClassService; @@ -12,7 +14,6 @@ import com.walkhub.walkhub.domain.teacher.service.QueryUserDetailsService; import com.walkhub.walkhub.domain.teacher.service.RefreshClassCodeService; import com.walkhub.walkhub.domain.teacher.service.VerificationCodeService; -import java.time.LocalDate; import lombok.RequiredArgsConstructor; import org.springframework.format.annotation.DateTimeFormat; import org.springframework.http.HttpStatus; @@ -28,6 +29,7 @@ import org.springframework.web.bind.annotation.RestController; import javax.validation.Valid; +import java.time.LocalDate; @RequiredArgsConstructor @RequestMapping("/teachers") @@ -41,6 +43,7 @@ public class TeacherController { private final QueryStudentCodeService queryStudentCodeService; private final QueryUserDetailsService queryUserDetailsService; private final ConfirmTeacherCodeService confirmTeacherCodeService; + private final ClassListService classListService; @ResponseStatus(HttpStatus.CREATED) @PostMapping("/classes") @@ -83,4 +86,9 @@ public void confirmTeacherCode(@RequestBody TeacherCodeRequest teacherCodeReques confirmTeacherCodeService.execute(teacherCodeRequest); } + @GetMapping("lists") + public ClassListResponse classList() { + return classListService.execute(); + } + } From d326592de56ddca77831d8a5fbfa3665c9812383 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Tue, 15 Feb 2022 15:24:44 +0900 Subject: [PATCH 218/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20findBySection?= =?UTF-8?q?AndAuthority=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../walkhub/domain/user/domain/repository/UserRepository.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepository.java b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepository.java index 08d01f703..7d5eb8281 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepository.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepository.java @@ -11,6 +11,7 @@ public interface UserRepository extends CrudRepository { Optional findByAccountId(String accountId); Optional findByPhoneNumber(String phoneNumber); + User findBySectionAndAuthority(Section section, Authority authority); List findAllBySectionAndAuthority(Section section, Authority authority); List findAllBySchoolIdAndNameContaining(Long id, String name); } From d442ed22861b28c3271d6c51130fdb0de5b586c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B2=94=EC=A7=84?= Date: Tue, 15 Feb 2022 15:24:52 +0900 Subject: [PATCH 219/522] =?UTF-8?q?=E2=9A=A1=20::=20=ED=8E=98=EC=9D=B4?= =?UTF-8?q?=EC=A7=95=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/repository/CustomChallengeRepository.java | 2 +- .../domain/repository/CustomChallengeRepositoryImpl.java | 5 ++++- .../challenge/presenstation/ChallengeController.java | 5 +++-- .../QueryChallengeParticipantsForTeacherService.java | 8 ++++---- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/CustomChallengeRepository.java b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/CustomChallengeRepository.java index 6dd4d1f7e..5aebdef95 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/CustomChallengeRepository.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/CustomChallengeRepository.java @@ -7,5 +7,5 @@ import java.util.List; public interface CustomChallengeRepository { - List queryChallengeParticipantsList(Challenge challenge, SuccessScope successScope); + List queryChallengeParticipantsList(Challenge challenge, SuccessScope successScope, Long page); } diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/CustomChallengeRepositoryImpl.java b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/CustomChallengeRepositoryImpl.java index d6accbe51..dbc94d2ae 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/CustomChallengeRepositoryImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/CustomChallengeRepositoryImpl.java @@ -30,7 +30,8 @@ public class CustomChallengeRepositoryImpl implements CustomChallengeRepository private final JPAQueryFactory jpaQueryFactory; @Override - public List queryChallengeParticipantsList(Challenge challenge, SuccessScope successScope) { + public List queryChallengeParticipantsList(Challenge challenge, SuccessScope successScope, Long page) { + final long size = 20L; return jpaQueryFactory .selectFrom(user) .join(user.school, school) @@ -45,6 +46,8 @@ public List queryChallengeParticipantsList(Challenge ch exerciseAnalysis.date.goe(challengeStatus.createdAt), exerciseAnalysis.date.loe(challenge.getEndAt()) ) + .offset(page * size) + .limit(size) .orderBy(user.name.asc(), user.id.asc(), exerciseAnalysis.date.asc()) .transform(groupBy(user.name, user.id) .list(new QChallengeParticipantsVO( diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/ChallengeController.java b/src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/ChallengeController.java index 0445be77f..f50963dfd 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/ChallengeController.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/ChallengeController.java @@ -85,8 +85,9 @@ public QueryChallengeListResponse queryParticipatedChallengeList() { @GetMapping("/{challenge-id}/participants/teachers") public QueryChallengeParticipantsForTeacherResponse queryChallengeParticipantsForTeacher(@PathVariable("challenge-id") Long challengeId, - @RequestParam SuccessScope successScope) { - return queryChallengeParticipantsForTeacherService.execute(challengeId, successScope); + @RequestParam SuccessScope successScope, + @RequestParam Long page) { + return queryChallengeParticipantsForTeacherService.execute(challengeId, successScope, page); } } diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/service/QueryChallengeParticipantsForTeacherService.java b/src/main/java/com/walkhub/walkhub/domain/challenge/service/QueryChallengeParticipantsForTeacherService.java index 7dceaa3b3..a913a7059 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/service/QueryChallengeParticipantsForTeacherService.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/service/QueryChallengeParticipantsForTeacherService.java @@ -19,18 +19,18 @@ public class QueryChallengeParticipantsForTeacherService { private final ChallengeStatusRepository challengeStatusRepository; @Transactional(readOnly = true) - public QueryChallengeParticipantsForTeacherResponse execute(Long challengeId, SuccessScope successScope) { + public QueryChallengeParticipantsForTeacherResponse execute(Long challengeId, SuccessScope successScope, Long page) { Challenge challenge = challengeFacade.getChallengeById(challengeId); return new QueryChallengeParticipantsForTeacherResponse( - queryChallengeParticipantsForTeacherResponseBuilder(challenge, successScope) + queryChallengeParticipantsForTeacherResponseBuilder(challenge, successScope, page) ); } private List queryChallengeParticipantsForTeacherResponseBuilder( - Challenge challenge, SuccessScope successScope + Challenge challenge, SuccessScope successScope, Long page ) { - return challengeStatusRepository.queryChallengeParticipantsList(challenge, successScope) + return challengeStatusRepository.queryChallengeParticipantsList(challenge, successScope, page) .stream() .map(vo -> QueryChallengeParticipantsForTeacherResponse.ChallengeParticipants.builder() .userId(vo.getUserId()) From 185907ab7f3699b0bef308cdc0ac684801d66ab2 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Tue, 15 Feb 2022 15:28:51 +0900 Subject: [PATCH 220/522] =?UTF-8?q?:coffin:=20::=20STUDENT=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/walkhub/walkhub/global/enums/Authority.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/global/enums/Authority.java b/src/main/java/com/walkhub/walkhub/global/enums/Authority.java index 712313986..bd82e9595 100644 --- a/src/main/java/com/walkhub/walkhub/global/enums/Authority.java +++ b/src/main/java/com/walkhub/walkhub/global/enums/Authority.java @@ -2,7 +2,6 @@ public enum Authority { USER, - STUDENT, TEACHER, ROOT, SU From 2ceb6eeeb854b176776eb118509d3c33a59a85ff Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Tue, 15 Feb 2022 15:29:03 +0900 Subject: [PATCH 221/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20STUDENT=20->?= =?UTF-8?q?=20USER?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../walkhub/domain/teacher/service/QueryStudentCodeService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/service/QueryStudentCodeService.java b/src/main/java/com/walkhub/walkhub/domain/teacher/service/QueryStudentCodeService.java index 12ebd90d5..8d9667586 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/service/QueryStudentCodeService.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/service/QueryStudentCodeService.java @@ -32,7 +32,7 @@ public DetailsClassResponse execute(Long sectionId) { List result = section.getUsers() .stream() - .filter(user -> user.getAuthority() == Authority.STUDENT) + .filter(user -> user.getAuthority() == Authority.USER) .map(this::buildUserListResponse) .collect(Collectors.toList()); From 8897f4ec3318e5045f40692eaf8e94724824c8ce Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Tue, 15 Feb 2022 15:49:34 +0900 Subject: [PATCH 222/522] =?UTF-8?q?:recycle:=20::=20=EB=B3=80=EC=88=98?= =?UTF-8?q?=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 --- .../domain/teacher/service/QueryStudentCodeService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/service/QueryStudentCodeService.java b/src/main/java/com/walkhub/walkhub/domain/teacher/service/QueryStudentCodeService.java index 8d9667586..73702aa07 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/service/QueryStudentCodeService.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/service/QueryStudentCodeService.java @@ -29,7 +29,7 @@ public class QueryStudentCodeService { public DetailsClassResponse execute(Long sectionId) { Section section = sectionFacade.getSectionById(sectionId); - List result = + List userListResponses = section.getUsers() .stream() .filter(user -> user.getAuthority() == Authority.USER) @@ -50,7 +50,7 @@ public DetailsClassResponse execute(Long sectionId) { return DetailsClassResponse.builder() .teacher(teacherResponse) .classCode(section.getClassCode()) - .userList(result) + .userList(userListResponses) .build(); } From 5935ade931de456d7125f180f74fc991c9c52ed1 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Tue, 15 Feb 2022 16:05:04 +0900 Subject: [PATCH 223/522] =?UTF-8?q?:recycle:=20::=20Response=20=EC=88=9C?= =?UTF-8?q?=EC=84=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../teacher/presentation/dto/response/DetailsClassResponse.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/DetailsClassResponse.java b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/DetailsClassResponse.java index 1f445cf4e..b00a1e43c 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/DetailsClassResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/DetailsClassResponse.java @@ -10,8 +10,8 @@ @Builder public class DetailsClassResponse { - private final TeacherResponse teacher; private final String classCode; + private final TeacherResponse teacher; private final List userList; @Getter From 97bb1b5b55ec884e14175e0e1edcf0b175a106d8 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Tue, 15 Feb 2022 16:05:33 +0900 Subject: [PATCH 224/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20=EC=88=9C?= =?UTF-8?q?=EC=84=9C=20=EB=B3=80=EA=B2=BD=20&=20=EB=A1=9C=EC=A7=81=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 --- .../teacher/service/QueryStudentCodeService.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/service/QueryStudentCodeService.java b/src/main/java/com/walkhub/walkhub/domain/teacher/service/QueryStudentCodeService.java index 73702aa07..41e3f4532 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/service/QueryStudentCodeService.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/service/QueryStudentCodeService.java @@ -29,13 +29,6 @@ public class QueryStudentCodeService { public DetailsClassResponse execute(Long sectionId) { Section section = sectionFacade.getSectionById(sectionId); - List userListResponses = - section.getUsers() - .stream() - .filter(user -> user.getAuthority() == Authority.USER) - .map(this::buildUserListResponse) - .collect(Collectors.toList()); - User teacher = section.getUsers().stream() .filter(user -> user.getAuthority() == Authority.TEACHER) .findFirst() @@ -47,9 +40,15 @@ public DetailsClassResponse execute(Long sectionId) { .profileImageUrl(teacher.getProfileImageUrl()) .build(); + List userListResponses = section.getUsers() + .stream() + .filter(user -> user.getAuthority() == Authority.USER) + .map(this::buildUserListResponse) + .collect(Collectors.toList()); + return DetailsClassResponse.builder() - .teacher(teacherResponse) .classCode(section.getClassCode()) + .teacher(teacherResponse) .userList(userListResponses) .build(); } From d6edbf42ea721283dbb982c75b4ce90efa717fe9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Tue, 15 Feb 2022 16:16:38 +0900 Subject: [PATCH 225/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20excel=20?= =?UTF-8?q?=EC=B6=9C=EB=A0=A5=EC=A0=9C=EA=B1=B0=20response=EB=A1=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 하 --- build.gradle | 11 ---------- .../excel/service/PrintExcelService.java | 18 +++++---------- .../domain/repository/vo/PrintExcelVo.java | 22 ++++--------------- 3 files changed, 9 insertions(+), 42 deletions(-) diff --git a/build.gradle b/build.gradle index 923b7b6ed..768fc76b3 100644 --- a/build.gradle +++ b/build.gradle @@ -51,11 +51,6 @@ dependencies { implementation 'org.hibernate:hibernate-ehcache:5.4.30.Final' implementation 'org.hibernate:hibernate-jcache:5.6.5.Final' implementation 'org.ehcache:ehcache:3.9.2' - - implementation group: 'org.apache.poi', name: 'poi', version: '5.0.0' - implementation group: 'org.apache.poi', name: 'poi-ooxml', version: '5.0.0' - - implementation('com.github.lannstark:excel-download:0.1.1') } test { @@ -73,9 +68,3 @@ sonarqube { property "sonar.host.url", "https://sonarcloud.io" } } - -allprojects { - repositories { - maven { url 'https://jitpack.io' } - } -} diff --git a/src/main/java/com/walkhub/walkhub/domain/excel/service/PrintExcelService.java b/src/main/java/com/walkhub/walkhub/domain/excel/service/PrintExcelService.java index eba9dfbea..50ccdb43e 100644 --- a/src/main/java/com/walkhub/walkhub/domain/excel/service/PrintExcelService.java +++ b/src/main/java/com/walkhub/walkhub/domain/excel/service/PrintExcelService.java @@ -1,15 +1,11 @@ package com.walkhub.walkhub.domain.excel.service; -import com.lannstark.excel.ExcelFile; -import com.lannstark.excel.onesheet.OneSheetExcelFile; +import com.walkhub.walkhub.domain.excel.presentation.dto.request.PrintExcelRequest; +import com.walkhub.walkhub.domain.excel.presentation.dto.response.PrintExcelResponse; import com.walkhub.walkhub.domain.exercise.domain.repository.ExerciseAnalysisRepository; import com.walkhub.walkhub.domain.exercise.domain.repository.vo.PrintExcelVo; import com.walkhub.walkhub.domain.user.facade.UserFacade; -import com.walkhub.walkhub.global.enums.Authority; -import java.io.IOException; -import java.time.LocalDate; import java.util.List; -import javax.servlet.http.HttpServletResponse; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -22,14 +18,10 @@ public class PrintExcelService { private final UserFacade userFacade; @Transactional(readOnly = true) - public void execute(LocalDate startAt, LocalDate endAt, Authority authority, Integer grade, Integer classNum, HttpServletResponse response) - throws IOException { + public PrintExcelResponse execute(PrintExcelRequest printExcelRequest) { Long schoolId = userFacade.getCurrentUser().getSchool().getId(); - List printExcelVoList = exerciseAnalysisRepository.getPrintExcelVoList(startAt, endAt, authority, grade, classNum, schoolId); + List printExcelVoList = exerciseAnalysisRepository.getPrintExcelVoList(printExcelRequest, schoolId); - response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); - - ExcelFile excelFile = new OneSheetExcelFile<>(printExcelVoList, PrintExcelVo.class); - excelFile.write(response.getOutputStream()); + return new PrintExcelResponse(printExcelVoList); } } diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/vo/PrintExcelVo.java b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/vo/PrintExcelVo.java index 41833a0b0..4ce5a1720 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/vo/PrintExcelVo.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/vo/PrintExcelVo.java @@ -1,40 +1,25 @@ package com.walkhub.walkhub.domain.exercise.domain.repository.vo; -import com.lannstark.ExcelColumn; import com.querydsl.core.annotations.QueryProjection; +import com.walkhub.walkhub.global.enums.Authority; import lombok.Getter; @Getter public class PrintExcelVo { - @ExcelColumn(headerName = "name") private final String name; - - @ExcelColumn(headerName = "grade") private final Integer grade; - - @ExcelColumn(headerName = "classNum") private final Integer classNum; - - @ExcelColumn(headerName = "number") private final Integer number; - - @ExcelColumn(headerName = "allWalkCount") private final Integer allWalkCount; - - @ExcelColumn(headerName = "averageWalkCount") private final Integer averageWalkCount; - - @ExcelColumn(headerName = "allDistance") private final Integer allDistance; - - @ExcelColumn(headerName = "averageDistance") private final Integer averageDistance; + private final Authority authority; @QueryProjection public PrintExcelVo(String name, Integer grade, Integer classNum, Integer number, - Integer allWalkCount, Integer averageWalkCount, Integer allDistance, - Integer averageDistance) { + Integer allWalkCount, Integer averageWalkCount, Integer allDistance, Integer averageDistance, Authority authority) { this.name = name; this.grade = grade; this.classNum = classNum; @@ -43,5 +28,6 @@ public PrintExcelVo(String name, Integer grade, Integer classNum, Integer number this.averageWalkCount = averageWalkCount; this.allDistance = allDistance; this.averageDistance = averageDistance; + this.authority = authority; } } From 22846fbd7ab07b2e111ea7d3aa876c77c26d02f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Tue, 15 Feb 2022 16:17:05 +0900 Subject: [PATCH 226/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20request=20res?= =?UTF-8?q?ponse=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../excel/presentation/ExcelController.java | 15 ++++--------- .../dto/request/PrintExcelRequest.java | 22 +++++++++++++++++++ .../dto/response/PrintExcelResponse.java | 13 +++++++++++ .../ExerciseAnalysisRepositoryCustom.java | 5 ++--- 4 files changed, 41 insertions(+), 14 deletions(-) create mode 100644 src/main/java/com/walkhub/walkhub/domain/excel/presentation/dto/request/PrintExcelRequest.java create mode 100644 src/main/java/com/walkhub/walkhub/domain/excel/presentation/dto/response/PrintExcelResponse.java diff --git a/src/main/java/com/walkhub/walkhub/domain/excel/presentation/ExcelController.java b/src/main/java/com/walkhub/walkhub/domain/excel/presentation/ExcelController.java index 7ce7edca0..5edb104e6 100644 --- a/src/main/java/com/walkhub/walkhub/domain/excel/presentation/ExcelController.java +++ b/src/main/java/com/walkhub/walkhub/domain/excel/presentation/ExcelController.java @@ -1,15 +1,11 @@ package com.walkhub.walkhub.domain.excel.presentation; +import com.walkhub.walkhub.domain.excel.presentation.dto.request.PrintExcelRequest; +import com.walkhub.walkhub.domain.excel.presentation.dto.response.PrintExcelResponse; import com.walkhub.walkhub.domain.excel.service.PrintExcelService; -import com.walkhub.walkhub.global.enums.Authority; -import java.io.IOException; -import java.time.LocalDate; -import javax.servlet.http.HttpServletResponse; import lombok.RequiredArgsConstructor; -import org.springframework.format.annotation.DateTimeFormat; 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; @RequiredArgsConstructor @@ -20,10 +16,7 @@ public class ExcelController { private final PrintExcelService printExcelService; @GetMapping - public void getExcel(@RequestParam("startAt") @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate startAt, - @RequestParam("endAt") @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate endAt, @RequestParam("authority") Authority authority, - @RequestParam(value = "grade", required = false) Integer grade, @RequestParam(value = "classNum", required = false) Integer classNum, - HttpServletResponse response) throws IOException { - printExcelService.execute(startAt, endAt, authority, grade, classNum, response); + public PrintExcelResponse getExcel(PrintExcelRequest printExcelRequest) { + return printExcelService.execute(printExcelRequest); } } diff --git a/src/main/java/com/walkhub/walkhub/domain/excel/presentation/dto/request/PrintExcelRequest.java b/src/main/java/com/walkhub/walkhub/domain/excel/presentation/dto/request/PrintExcelRequest.java new file mode 100644 index 000000000..9ecc98ef8 --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/excel/presentation/dto/request/PrintExcelRequest.java @@ -0,0 +1,22 @@ +package com.walkhub.walkhub.domain.excel.presentation.dto.request; + +import com.walkhub.walkhub.global.enums.Authority; +import java.time.LocalDate; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +@Data +public class PrintExcelRequest { + + @DateTimeFormat(pattern = "yyyy-MM-dd") + private LocalDate startAt; + + @DateTimeFormat(pattern = "yyyy-MM-dd") + private LocalDate endAt; + + private Authority authority; + + private Integer grade; + + private Integer classNum; +} diff --git a/src/main/java/com/walkhub/walkhub/domain/excel/presentation/dto/response/PrintExcelResponse.java b/src/main/java/com/walkhub/walkhub/domain/excel/presentation/dto/response/PrintExcelResponse.java new file mode 100644 index 000000000..8b5db0833 --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/excel/presentation/dto/response/PrintExcelResponse.java @@ -0,0 +1,13 @@ +package com.walkhub.walkhub.domain.excel.presentation.dto.response; + +import com.walkhub.walkhub.domain.exercise.domain.repository.vo.PrintExcelVo; +import java.util.List; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public class PrintExcelResponse { + + private final List userList; +} diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepositoryCustom.java b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepositoryCustom.java index 637bd32f8..24612c44c 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepositoryCustom.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepositoryCustom.java @@ -1,10 +1,9 @@ package com.walkhub.walkhub.domain.exercise.domain.repository; +import com.walkhub.walkhub.domain.excel.presentation.dto.request.PrintExcelRequest; import com.walkhub.walkhub.domain.exercise.domain.repository.vo.PrintExcelVo; -import com.walkhub.walkhub.global.enums.Authority; -import java.time.LocalDate; import java.util.List; public interface ExerciseAnalysisRepositoryCustom { - List getPrintExcelVoList(LocalDate startAt, LocalDate endAt, Authority authority, Integer grade, Integer classNum, Long SchoolId); + List getPrintExcelVoList(PrintExcelRequest printExcelRequest, Long schoolId); } From 5fffdd3728f6d7d4f7320b6807487b18f17a0ede Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Tue, 15 Feb 2022 16:17:17 +0900 Subject: [PATCH 227/522] =?UTF-8?q?:recycle:=20::=20@Transactional(readOnl?= =?UTF-8?q?y=20=3D=20true)=20&=20=EC=88=9C=EC=84=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../teacher/presentation/dto/response/ClassListResponse.java | 2 +- .../walkhub/domain/teacher/service/ClassListService.java | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/ClassListResponse.java b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/ClassListResponse.java index 9efcfca57..be2bf70a9 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/ClassListResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/ClassListResponse.java @@ -15,9 +15,9 @@ public class ClassListResponse { @Getter @Builder public static class ClassResponse { + private final Integer userCount; private final SectionResponse section; private final TeacherResponse teacher; - private final Integer userCount; } @Getter diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/service/ClassListService.java b/src/main/java/com/walkhub/walkhub/domain/teacher/service/ClassListService.java index f10f73209..edefc69a3 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/service/ClassListService.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/service/ClassListService.java @@ -11,6 +11,7 @@ import com.walkhub.walkhub.global.enums.Authority; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.util.List; import java.util.stream.Collectors; @@ -22,6 +23,7 @@ public class ClassListService { private final UserFacade userFacade; private final UserRepository userRepository; + @Transactional(readOnly = true) public ClassListResponse execute() { User teacher = userFacade.getCurrentUser(); School school = teacher.getSchool(); @@ -32,6 +34,7 @@ public ClassListResponse execute() { User user = userRepository.findBySectionAndAuthority(section, Authority.TEACHER); Integer userCount = userRepository.findAllBySectionAndAuthority(section, Authority.USER).size(); return ClassResponse.builder() + .userCount(userCount) .section(SectionResponse.builder() .sectionId(section.getId()) .grade(section.getGrade()) @@ -42,7 +45,6 @@ public ClassListResponse execute() { .name(user.getName()) .profileImageUrl(user.getProfileImageUrl()) .build()) - .userCount(userCount) .build(); }).collect(Collectors.toList()); From 259d6fedf7c383e115253368f79b21a92c3f705e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Tue, 15 Feb 2022 16:17:46 +0900 Subject: [PATCH 228/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20null=20filter?= =?UTF-8?q?=20private=EC=9C=BC=EB=A1=9C=20=EB=B9=BC=EA=B8=B0,=20group=20us?= =?UTF-8?q?er.Authority?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ExerciseAnalysisRepositoryCustomImpl.java | 47 +++++++++++++------ 1 file changed, 33 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepositoryCustomImpl.java index 144757ee2..cfabff41e 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepositoryCustomImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepositoryCustomImpl.java @@ -7,6 +7,7 @@ import com.querydsl.core.BooleanBuilder; import com.querydsl.jpa.impl.JPAQueryFactory; +import com.walkhub.walkhub.domain.excel.presentation.dto.request.PrintExcelRequest; import com.walkhub.walkhub.domain.exercise.domain.repository.vo.PrintExcelVo; import com.walkhub.walkhub.domain.exercise.domain.repository.vo.QPrintExcelVo; import com.walkhub.walkhub.global.enums.Authority; @@ -19,18 +20,17 @@ public class ExerciseAnalysisRepositoryCustomImpl implements ExerciseAnalysisRep private final JPAQueryFactory queryFactory; @Override - public List getPrintExcelVoList(LocalDate startAt, LocalDate endAt, Authority authority, Integer grade, Integer classNum, Long schoolId) { + public List getPrintExcelVoList(PrintExcelRequest excelRequest, Long schoolId) { - BooleanBuilder builder = new BooleanBuilder(); + LocalDate startAt = excelRequest.getStartAt(); - if (authority.equals(Authority.STUDENT)) { - if (grade != null) { - builder.and(section.grade.eq(grade)); - } - if (classNum != null) { - builder.and(section.classNum.eq(classNum)); - } - } + LocalDate endAt = excelRequest.getEndAt(); + + Authority authority = excelRequest.getAuthority(); + + Integer grade = excelRequest.getGrade(); + + Integer classNum = excelRequest.getGrade(); return queryFactory .select(new QPrintExcelVo( @@ -41,7 +41,8 @@ public List getPrintExcelVoList(LocalDate startAt, LocalDate endAt exerciseAnalysis.walkCount.sum(), exerciseAnalysis.walkCount.avg().intValue(), exerciseAnalysis.distance.sum(), - exerciseAnalysis.distance.avg().intValue() + exerciseAnalysis.distance.avg().intValue(), + user.authority )) .from(exerciseAnalysis) .join(exerciseAnalysis.user, user) @@ -49,11 +50,29 @@ public List getPrintExcelVoList(LocalDate startAt, LocalDate endAt .join(user.section, section) .where( school.id.eq(schoolId), - user.authority.eq(authority), exerciseAnalysis.date.between(startAt, endAt), - builder + nullFilter(authority,grade,classNum) ) - .groupBy(user) + .groupBy(user.authority) .fetch(); } + + private BooleanBuilder nullFilter(Authority authority, Integer grade, Integer classNum) { + + BooleanBuilder builder = new BooleanBuilder(); + + if (authority != null) { + builder.and(user.authority.eq(authority)); + + if (authority.equals(Authority.USER)) { + if (grade != null) { + builder.and(section.grade.eq(grade)); + } + if (classNum != null) { + builder.and(section.classNum.eq(classNum)); + } + } + } + return builder; + } } From 470a0f6b5b77da217f6dd170062dff809307737d Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Tue, 15 Feb 2022 16:19:43 +0900 Subject: [PATCH 229/522] =?UTF-8?q?:recycle:=20::=20build=20error=20?= =?UTF-8?q?=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../walkhub/domain/exercise/domain/ExerciseAnalysis.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/ExerciseAnalysis.java b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/ExerciseAnalysis.java index 5cc0ce227..2486517f1 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/ExerciseAnalysis.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/ExerciseAnalysis.java @@ -48,11 +48,13 @@ public class ExerciseAnalysis { @Builder - public ExerciseAnalysis(Double calorie, Integer walkCount, Integer distance, LocalDate date, User user) { + public ExerciseAnalysis(Double calorie, Integer walkCount, Double exerciseTime, + Integer distance, LocalDate date, User user) { this.calorie = calorie; this.walkCount = walkCount; this.distance = distance; this.date = date; + this.exerciseTime = exerciseTime; this.user = user; } From 4fedae9b3c85be88a99b039309158b28b9866189 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Tue, 15 Feb 2022 16:22:13 +0900 Subject: [PATCH 230/522] =?UTF-8?q?:recycle:=20::=20error=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 --- .../walkhub/domain/user/domain/repository/UserRepository.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepository.java b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepository.java index dafe12821..7d5eb8281 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepository.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepository.java @@ -1,6 +1,8 @@ package com.walkhub.walkhub.domain.user.domain.repository; +import com.walkhub.walkhub.domain.user.domain.Section; import com.walkhub.walkhub.domain.user.domain.User; +import com.walkhub.walkhub.global.enums.Authority; import org.springframework.data.repository.CrudRepository; import java.util.List; From f330fdc5f7af1ebfaaa8bb2fdde9ce13d6a62f04 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Tue, 15 Feb 2022 16:50:04 +0900 Subject: [PATCH 231/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20=EB=A9=94?= =?UTF-8?q?=EC=86=8C=EB=93=9C=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 --- .../domain/repository/ChallengeStatusRepositoryCustom.java | 3 +-- .../domain/repository/ChallengeStatusRepositoryCustomImpl.java | 2 +- .../service/QueryChallengeParticipantsForStudentService.java | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustom.java b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustom.java index 63af43fa8..f4ef47e74 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustom.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustom.java @@ -1,12 +1,11 @@ package com.walkhub.walkhub.domain.challenge.domain.repository; import com.walkhub.walkhub.domain.challenge.domain.repository.vo.RelatedChallengeParticipantsVO; -import com.walkhub.walkhub.domain.challenge.presenstation.dto.response.QueryChallengeParticipantsForStudentResponse; import com.walkhub.walkhub.domain.school.domain.School; import java.util.List; public interface ChallengeStatusRepositoryCustom { - Integer getParticipantsListByChallengeId(Long challengeId); + Integer getParticipantsCountByChallengeId(Long challengeId); List getRelatedChallengeParticipantsList(Long challengeId, School school, Integer grade, Integer classNum); } diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java index dc5ca5f4b..9b1e0a46e 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java @@ -18,7 +18,7 @@ public class ChallengeStatusRepositoryCustomImpl implements ChallengeStatusRepos private final JPAQueryFactory queryFactory; @Override - public Integer getParticipantsListByChallengeId(Long challengeId) { + public Integer getParticipantsCountByChallengeId(Long challengeId) { List participantsList = queryFactory .select(challengeStatus) .from(challengeStatus) diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/service/QueryChallengeParticipantsForStudentService.java b/src/main/java/com/walkhub/walkhub/domain/challenge/service/QueryChallengeParticipantsForStudentService.java index f326e25f1..d31862d3f 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/service/QueryChallengeParticipantsForStudentService.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/service/QueryChallengeParticipantsForStudentService.java @@ -23,7 +23,7 @@ public QueryChallengeParticipantsForStudentResponse execute(Long challengeId) { Section section = user.getSection(); return QueryChallengeParticipantsForStudentResponse.builder() - .participantCount(challengeStatusRepository.getParticipantsListByChallengeId(challengeId)) + .participantCount(challengeStatusRepository.getParticipantsCountByChallengeId(challengeId)) .relatedChallengeParticipantList(challengeStatusRepository.getRelatedChallengeParticipantsList(challengeId, school, section.getGrade(), section.getClassNum()) .stream().map(participants -> QueryChallengeParticipantsForStudentResponse.RelatedChallengeParticipants.builder() .userId(participants.getUserId()) From 6e67cac2852c3b441d72ee44a41783a1f861f618 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Tue, 15 Feb 2022 16:56:48 +0900 Subject: [PATCH 232/522] =?UTF-8?q?=E2=9A=B0=EF=B8=8F=20::=20=EC=9D=B4?= =?UTF-8?q?=EA=B1=B0=20=EC=99=9C=20=EC=9E=88=EC=A7=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/rank/domain/SchoolRankInfo.java | 23 ------------ .../domain/rank/domain/UserRankInfo.java | 36 ------------------- 2 files changed, 59 deletions(-) delete mode 100644 src/main/java/com/walkhub/walkhub/domain/rank/domain/SchoolRankInfo.java delete mode 100644 src/main/java/com/walkhub/walkhub/domain/rank/domain/UserRankInfo.java diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/domain/SchoolRankInfo.java b/src/main/java/com/walkhub/walkhub/domain/rank/domain/SchoolRankInfo.java deleted file mode 100644 index 578f5ea17..000000000 --- a/src/main/java/com/walkhub/walkhub/domain/rank/domain/SchoolRankInfo.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.walkhub.walkhub.domain.rank.domain; - -import lombok.Getter; -import org.springframework.data.annotation.Immutable; - -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; -import java.time.LocalDateTime; - -@Getter -@Immutable -@Table(name = "school_rank_info") -@Entity -public class SchoolRankInfo { - - @Id - private String agencyCode; - private String name; - private Integer ranking; - private String logoImageUrl; - private Integer walkCount; -} diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/domain/UserRankInfo.java b/src/main/java/com/walkhub/walkhub/domain/rank/domain/UserRankInfo.java deleted file mode 100644 index c9c8c9a99..000000000 --- a/src/main/java/com/walkhub/walkhub/domain/rank/domain/UserRankInfo.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.walkhub.walkhub.domain.rank.domain; - -import lombok.AccessLevel; -import lombok.Getter; -import lombok.NoArgsConstructor; -import org.hibernate.annotations.Immutable; - -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; -import java.time.LocalDateTime; - -@Getter -@NoArgsConstructor(access = AccessLevel.PROTECTED) -@Immutable -@Table(name = "user_rank_info") -@Entity -public class UserRankInfo { - - @Id - private String accountId; - - private String name; - - private Integer grade; - - private Integer classNum; - - private String profileImageUrl; - - private Long walkCount; - - private Integer ranking; - - private String agencyCode; -} From 1eae2b58dfab591bebc6fe66224b21da46d8d326 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Tue, 15 Feb 2022 16:58:19 +0900 Subject: [PATCH 233/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20=ED=81=B4?= =?UTF-8?q?=EB=9E=98=EC=8A=A4=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 --- .../walkhub/domain/rank/presentation/RankController.java | 6 +++--- ...Service.java => QueryUserRankListByMySchoolService.java} | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) rename src/main/java/com/walkhub/walkhub/domain/rank/service/{QueryUserRankListService.java => QueryUserRankListByMySchoolService.java} (99%) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/presentation/RankController.java b/src/main/java/com/walkhub/walkhub/domain/rank/presentation/RankController.java index cb1694708..881109b82 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/presentation/RankController.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/presentation/RankController.java @@ -5,7 +5,7 @@ import com.walkhub.walkhub.domain.rank.presentation.dto.response.SchoolRankResponse; import com.walkhub.walkhub.domain.rank.presentation.dto.response.UserListResponse; import com.walkhub.walkhub.domain.rank.presentation.dto.response.UserRankListResponse; -import com.walkhub.walkhub.domain.rank.service.QueryUserRankListService; +import com.walkhub.walkhub.domain.rank.service.QueryUserRankListByMySchoolService; import com.walkhub.walkhub.domain.rank.service.QuerySchoolRankService; import com.walkhub.walkhub.domain.rank.service.UserSearchService; import com.walkhub.walkhub.global.enums.DateType; @@ -22,7 +22,7 @@ public class RankController { private final UserSearchService userSearchService; - private final QueryUserRankListService queryUserRankListService; + private final QueryUserRankListByMySchoolService queryUserRankListByMySchoolService; private final QuerySchoolRankService querySchoolRankService; @GetMapping("/users/search/{school-id}") @@ -39,6 +39,6 @@ public SchoolRankResponse querySchoolRank(@RequestParam SchoolDateType dateType) @GetMapping("/users/my-school") public UserRankListResponse queryUserRankListByMySchool(@RequestParam UserRankScope scope, @RequestParam DateType dateType) { - return queryUserRankListService.execute(scope, dateType); + return queryUserRankListByMySchoolService.execute(scope, dateType); } } diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListService.java b/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListByMySchoolService.java similarity index 99% rename from src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListService.java rename to src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListByMySchoolService.java index b91c5eb4a..87cac98c3 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListService.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListByMySchoolService.java @@ -19,7 +19,7 @@ @RequiredArgsConstructor @Service -public class QueryUserRankListService { +public class QueryUserRankListByMySchoolService { private final UserRankRepository userRankRepository; private final ExerciseAnalysisCacheRepository exerciseAnalysisCacheRepository; private final UserFacade userFacade; From 8c93c6ba8b79f344cc07c9a2916997807bbfb94e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Tue, 15 Feb 2022 17:10:41 +0900 Subject: [PATCH 234/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20schoolnum?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20left=20join=20,=20goup=20user?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/ExerciseAnalysisRepositoryCustomImpl.java | 9 +++++---- .../exercise/domain/repository/vo/PrintExcelVo.java | 4 +++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepositoryCustomImpl.java index cfabff41e..58f1458f8 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepositoryCustomImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepositoryCustomImpl.java @@ -30,7 +30,7 @@ public List getPrintExcelVoList(PrintExcelRequest excelRequest, Lo Integer grade = excelRequest.getGrade(); - Integer classNum = excelRequest.getGrade(); + Integer classNum = excelRequest.getClassNum(); return queryFactory .select(new QPrintExcelVo( @@ -42,18 +42,19 @@ public List getPrintExcelVoList(PrintExcelRequest excelRequest, Lo exerciseAnalysis.walkCount.avg().intValue(), exerciseAnalysis.distance.sum(), exerciseAnalysis.distance.avg().intValue(), - user.authority + user.authority, + school.name )) .from(exerciseAnalysis) .join(exerciseAnalysis.user, user) .join(user.school, school) - .join(user.section, section) + .leftJoin(user.section, section) .where( school.id.eq(schoolId), exerciseAnalysis.date.between(startAt, endAt), nullFilter(authority,grade,classNum) ) - .groupBy(user.authority) + .groupBy(user) .fetch(); } diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/vo/PrintExcelVo.java b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/vo/PrintExcelVo.java index 4ce5a1720..abba18722 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/vo/PrintExcelVo.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/vo/PrintExcelVo.java @@ -16,10 +16,11 @@ public class PrintExcelVo { private final Integer allDistance; private final Integer averageDistance; private final Authority authority; + private final String schoolName; @QueryProjection public PrintExcelVo(String name, Integer grade, Integer classNum, Integer number, - Integer allWalkCount, Integer averageWalkCount, Integer allDistance, Integer averageDistance, Authority authority) { + Integer allWalkCount, Integer averageWalkCount, Integer allDistance, Integer averageDistance, Authority authority, String schoolName) { this.name = name; this.grade = grade; this.classNum = classNum; @@ -29,5 +30,6 @@ public PrintExcelVo(String name, Integer grade, Integer classNum, Integer number this.allDistance = allDistance; this.averageDistance = averageDistance; this.authority = authority; + this.schoolName = schoolName; } } From f3a07d5ec1ff2b86a9c527ee23cc437e70097abf Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Tue, 15 Feb 2022 17:47:33 +0900 Subject: [PATCH 235/522] =?UTF-8?q?:recycle:=20::=20=EB=A9=94=EC=86=8C?= =?UTF-8?q?=EB=93=9C=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../teacher/service/ClassListService.java | 38 ++++++++++--------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/service/ClassListService.java b/src/main/java/com/walkhub/walkhub/domain/teacher/service/ClassListService.java index edefc69a3..68508d333 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/service/ClassListService.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/service/ClassListService.java @@ -5,6 +5,7 @@ import com.walkhub.walkhub.domain.teacher.presentation.dto.response.ClassListResponse.ClassResponse; import com.walkhub.walkhub.domain.teacher.presentation.dto.response.ClassListResponse.SectionResponse; import com.walkhub.walkhub.domain.teacher.presentation.dto.response.ClassListResponse.TeacherResponse; +import com.walkhub.walkhub.domain.user.domain.Section; import com.walkhub.walkhub.domain.user.domain.User; import com.walkhub.walkhub.domain.user.domain.repository.UserRepository; import com.walkhub.walkhub.domain.user.facade.UserFacade; @@ -30,26 +31,29 @@ public ClassListResponse execute() { List classList = school.getSections() .stream() - .map(section -> { - User user = userRepository.findBySectionAndAuthority(section, Authority.TEACHER); - Integer userCount = userRepository.findAllBySectionAndAuthority(section, Authority.USER).size(); - return ClassResponse.builder() - .userCount(userCount) - .section(SectionResponse.builder() - .sectionId(section.getId()) - .grade(section.getGrade()) - .classNum(section.getClassNum()) - .build()) - .teacher(TeacherResponse.builder() - .userId(user.getId()) - .name(user.getName()) - .profileImageUrl(user.getProfileImageUrl()) - .build()) - .build(); - }).collect(Collectors.toList()); + .map(this::buildClassList) + .collect(Collectors.toList()); return new ClassListResponse(classList); } + + private ClassResponse buildClassList(Section section) { + User user = userRepository.findBySectionAndAuthority(section, Authority.TEACHER); + Integer userCount = userRepository.findAllBySectionAndAuthority(section, Authority.USER).size(); + return ClassResponse.builder() + .userCount(userCount) + .section(SectionResponse.builder() + .sectionId(section.getId()) + .grade(section.getGrade()) + .classNum(section.getClassNum()) + .build()) + .teacher(TeacherResponse.builder() + .userId(user.getId()) + .name(user.getName()) + .profileImageUrl(user.getProfileImageUrl()) + .build()) + .build(); + } } From a0f7ddded349ad242b1897452b381b94774e24a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B2=94=EC=A7=84?= Date: Tue, 15 Feb 2022 18:31:19 +0900 Subject: [PATCH 236/522] =?UTF-8?q?=E2=99=BB=20::=20=EC=9D=B8=ED=84=B0?= =?UTF-8?q?=ED=8E=98=EC=9D=B4=EC=8A=A4,=20=EA=B5=AC=ED=98=84=EC=B2=B4=20?= =?UTF-8?q?=EC=9D=B4=EB=A6=84=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../challenge/domain/repository/ChallengeStatusRepository.java | 2 +- ...engeRepository.java => ChallengeStatusRepositoryCustom.java} | 2 +- ...sitoryImpl.java => ChallengeStatusRepositoryCustomImpl.java} | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) rename src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/{CustomChallengeRepository.java => ChallengeStatusRepositoryCustom.java} (89%) rename src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/{CustomChallengeRepositoryImpl.java => ChallengeStatusRepositoryCustomImpl.java} (97%) diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepository.java b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepository.java index 5a8d4426e..5ac769f31 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepository.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepository.java @@ -9,7 +9,7 @@ import java.util.List; import java.util.Optional; -public interface ChallengeStatusRepository extends CrudRepository, CustomChallengeRepository { +public interface ChallengeStatusRepository extends CrudRepository, ChallengeStatusRepositoryCustom { Optional findByChallengeAndUser(Challenge challenge, User user); List findAllByUser(User user); } diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/CustomChallengeRepository.java b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustom.java similarity index 89% rename from src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/CustomChallengeRepository.java rename to src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustom.java index 6dd4d1f7e..c7c2d0c89 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/CustomChallengeRepository.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustom.java @@ -6,6 +6,6 @@ import java.util.List; -public interface CustomChallengeRepository { +public interface ChallengeStatusRepositoryCustom { List queryChallengeParticipantsList(Challenge challenge, SuccessScope successScope); } diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/CustomChallengeRepositoryImpl.java b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java similarity index 97% rename from src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/CustomChallengeRepositoryImpl.java rename to src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java index 6e278b290..a3648ea86 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/CustomChallengeRepositoryImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java @@ -22,7 +22,7 @@ import static com.walkhub.walkhub.domain.user.domain.QUser.user; @RequiredArgsConstructor -public class CustomChallengeRepositoryImpl implements CustomChallengeRepository { +public class ChallengeStatusRepositoryCustomImpl implements ChallengeStatusRepositoryCustom { private final JPAQueryFactory jpaQueryFactory; From 49fb7d3ef947ac1e0f81625ae034d14615ca6b8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B2=94=EC=A7=84?= Date: Tue, 15 Feb 2022 18:43:38 +0900 Subject: [PATCH 237/522] =?UTF-8?q?=E2=9A=A1=20::=20response=20=EC=9A=94?= =?UTF-8?q?=EC=86=8C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../auth/presentation/dto/response/UserTokenResponse.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/auth/presentation/dto/response/UserTokenResponse.java b/src/main/java/com/walkhub/walkhub/domain/auth/presentation/dto/response/UserTokenResponse.java index d3dcb09d3..287c090c0 100644 --- a/src/main/java/com/walkhub/walkhub/domain/auth/presentation/dto/response/UserTokenResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/auth/presentation/dto/response/UserTokenResponse.java @@ -1,10 +1,12 @@ package com.walkhub.walkhub.domain.auth.presentation.dto.response; +import com.walkhub.walkhub.domain.user.domain.type.Sex; import com.walkhub.walkhub.global.enums.Authority; import lombok.Builder; import lombok.Getter; import org.springframework.format.annotation.DateTimeFormat; +import java.math.BigDecimal; import java.time.LocalDateTime; @Getter @@ -19,4 +21,10 @@ public class UserTokenResponse { private final LocalDateTime expiredAt; private final Authority authority; + + private final BigDecimal height; + + private final Integer weight; + + private final Sex sex; } From 1c443e4d57fd6bb2dfe4e3f7753e49bfca4d40e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B2=94=EC=A7=84?= Date: Tue, 15 Feb 2022 18:46:26 +0900 Subject: [PATCH 238/522] =?UTF-8?q?=E2=9A=A1=20::=20response=EC=97=90=20?= =?UTF-8?q?=EC=82=AC=EC=9A=A9=EC=9E=90=20=EC=A0=95=EB=B3=B4=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 --- .../domain/auth/service/UserSignInService.java | 7 +++++-- .../domain/user/service/UserSignUpService.java | 11 +++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/auth/service/UserSignInService.java b/src/main/java/com/walkhub/walkhub/domain/auth/service/UserSignInService.java index 56786feec..bc8a31028 100644 --- a/src/main/java/com/walkhub/walkhub/domain/auth/service/UserSignInService.java +++ b/src/main/java/com/walkhub/walkhub/domain/auth/service/UserSignInService.java @@ -7,6 +7,7 @@ import com.walkhub.walkhub.domain.auth.presentation.dto.response.UserTokenResponse; import com.walkhub.walkhub.domain.user.domain.User; import com.walkhub.walkhub.domain.user.domain.repository.UserRepository; +import com.walkhub.walkhub.domain.user.domain.type.HealthInfo; import com.walkhub.walkhub.domain.user.exception.UserNotFoundException; import com.walkhub.walkhub.global.security.jwt.JwtProperties; import com.walkhub.walkhub.global.security.jwt.JwtTokenProvider; @@ -31,7 +32,7 @@ public class UserSignInService { public UserTokenResponse execute(SignInRequest request) { User user = userRepository.findByAccountId(request.getAccountId()) .orElseThrow(() -> UserNotFoundException.EXCEPTION); - + HealthInfo healthInfo = user.getHealthInfo(); if (!passwordEncoder.matches(request.getPassword(), user.getPassword())) { throw PasswordMismatchException.EXCEPTION; } @@ -41,7 +42,6 @@ public UserTokenResponse execute(SignInRequest request) { String accessToken = jwtTokenProvider.generateAccessToken(user.getAccountId()); String refreshToken = jwtTokenProvider.generateRefreshToken(user.getAccountId()); - refreshTokenRepository.save( RefreshToken.builder() .accountId(user.getAccountId()) @@ -55,6 +55,9 @@ public UserTokenResponse execute(SignInRequest request) { .expiredAt(LocalDateTime.now().plusSeconds(jwtProperties.getAccessExp())) .refreshToken(refreshToken) .authority(user.getAuthority()) + .height(healthInfo.getHeight()) + .weight(healthInfo.getWeight()) + .sex(user.getSex()) .build(); } diff --git a/src/main/java/com/walkhub/walkhub/domain/user/service/UserSignUpService.java b/src/main/java/com/walkhub/walkhub/domain/user/service/UserSignUpService.java index 257757265..e8a0d5223 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/service/UserSignUpService.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/service/UserSignUpService.java @@ -7,6 +7,7 @@ import com.walkhub.walkhub.domain.user.domain.UserAuthCode; import com.walkhub.walkhub.domain.user.domain.repository.UserAuthCodeRepository; import com.walkhub.walkhub.domain.user.domain.repository.UserRepository; +import com.walkhub.walkhub.domain.user.domain.type.HealthInfo; import com.walkhub.walkhub.domain.user.exception.SchoolNotFoundException; import com.walkhub.walkhub.domain.user.exception.UnauthorizedUserAuthCodeException; import com.walkhub.walkhub.domain.user.exception.UserAuthCodeNotFoundException; @@ -45,7 +46,7 @@ public UserTokenResponse execute(UserSignUpRequest request) { School school = schoolRepository.findById(request.getSchoolId()) .orElseThrow(() -> SchoolNotFoundException.EXCEPTION); - userRepository.save(User.builder() + User user = User.builder() .accountId(request.getAccountId()) .password(passwordEncoder.encode(request.getPassword())) .phoneNumber(request.getPhoneNumber()) @@ -56,7 +57,10 @@ public UserTokenResponse execute(UserSignUpRequest request) { .weight(request.getWeight()) .sex(request.getSex()) .isMeasuring(false) - .build()); + .build(); + HealthInfo healthInfo = user.getHealthInfo(); + + userRepository.save(user); String accessToken = jwtTokenProvider.generateAccessToken(request.getAccountId()); String refreshToken = jwtTokenProvider.generateRefreshToken(request.getAccountId()); @@ -65,6 +69,9 @@ public UserTokenResponse execute(UserSignUpRequest request) { .accessToken(accessToken) .expiredAt(LocalDateTime.now().plusSeconds(jwtProperties.getAccessExp())) .refreshToken(refreshToken) + .height(healthInfo.getHeight()) + .weight(healthInfo.getWeight()) + .sex(user.getSex()) .build(); } } From a348865e47beabb6bba14978312ce0db0bb5d1f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B2=94=EC=A7=84?= Date: Tue, 15 Feb 2022 18:54:16 +0900 Subject: [PATCH 239/522] =?UTF-8?q?=E2=99=BB=20::=20=EC=A4=84=20=EB=B0=94?= =?UTF-8?q?=EA=BF=88=20&=20=EC=A4=84=20=EA=B0=84=EA=B2=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/dto/response/UserTokenResponse.java | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/auth/presentation/dto/response/UserTokenResponse.java b/src/main/java/com/walkhub/walkhub/domain/auth/presentation/dto/response/UserTokenResponse.java index 287c090c0..db231dded 100644 --- a/src/main/java/com/walkhub/walkhub/domain/auth/presentation/dto/response/UserTokenResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/auth/presentation/dto/response/UserTokenResponse.java @@ -14,17 +14,12 @@ public class UserTokenResponse { private final String accessToken; - - private final String refreshToken; - @DateTimeFormat(pattern = "yyyy-MM-ddThh:mm:SS") private final LocalDateTime expiredAt; - + private final String refreshToken; private final Authority authority; - private final BigDecimal height; - private final Integer weight; - private final Sex sex; + } From 28b47c77b99a2a094efb6a53d6df8dcb68be35c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B2=94=EC=A7=84?= Date: Tue, 15 Feb 2022 19:01:33 +0900 Subject: [PATCH 240/522] =?UTF-8?q?=E2=9A=A1=20::=20addUserCount?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/walkhub/walkhub/domain/school/domain/School.java | 4 ++++ .../walkhub/domain/user/service/UserSignUpService.java | 7 +++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/school/domain/School.java b/src/main/java/com/walkhub/walkhub/domain/school/domain/School.java index e2b23ff0e..bf2c5c6aa 100644 --- a/src/main/java/com/walkhub/walkhub/domain/school/domain/School.java +++ b/src/main/java/com/walkhub/walkhub/domain/school/domain/School.java @@ -42,6 +42,10 @@ public School(String name, String logoImageUrl) { this.logoImageUrl = logoImageUrl; } + public void addUserCount() { + this.userCount++; + } + public void setLogoImage(String logoImageUrl) { this.logoImageUrl = logoImageUrl; } diff --git a/src/main/java/com/walkhub/walkhub/domain/user/service/UserSignUpService.java b/src/main/java/com/walkhub/walkhub/domain/user/service/UserSignUpService.java index 31f9a8440..8e63d4298 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/service/UserSignUpService.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/service/UserSignUpService.java @@ -19,6 +19,7 @@ import lombok.RequiredArgsConstructor; import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.time.LocalDateTime; @@ -34,6 +35,7 @@ public class UserSignUpService { private final JwtTokenProvider jwtTokenProvider; private final JwtProperties jwtProperties; + @Transactional public UserTokenResponse execute(UserSignUpRequest request) { UserAuthCode code = userAuthCodeRepository.findById(request.getPhoneNumber()) .orElseThrow(() -> UserAuthCodeNotFoundException.EXCEPTION); @@ -58,10 +60,11 @@ public UserTokenResponse execute(UserSignUpRequest request) { .sex(request.getSex()) .isMeasuring(false) .build(); - HealthInfo healthInfo = user.getHealthInfo(); - userRepository.save(user); + school.addUserCount(); + + HealthInfo healthInfo = user.getHealthInfo(); String accessToken = jwtTokenProvider.generateAccessToken(request.getAccountId()); String refreshToken = jwtTokenProvider.generateRefreshToken(request.getAccountId()); From 055354da721b10bbecd15cbdc092425777ed5ae5 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Tue, 15 Feb 2022 19:04:32 +0900 Subject: [PATCH 241/522] =?UTF-8?q?:recycle:=20::=20=EB=B3=80=EC=88=98?= =?UTF-8?q?=EB=AA=85=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../walkhub/domain/teacher/service/ClassListService.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/service/ClassListService.java b/src/main/java/com/walkhub/walkhub/domain/teacher/service/ClassListService.java index 68508d333..c4f44c70a 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/service/ClassListService.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/service/ClassListService.java @@ -26,8 +26,8 @@ public class ClassListService { @Transactional(readOnly = true) public ClassListResponse execute() { - User teacher = userFacade.getCurrentUser(); - School school = teacher.getSchool(); + User user = userFacade.getCurrentUser(); + School school = user.getSchool(); List classList = school.getSections() .stream() @@ -38,7 +38,7 @@ public ClassListResponse execute() { } private ClassResponse buildClassList(Section section) { - User user = userRepository.findBySectionAndAuthority(section, Authority.TEACHER); + User teacher = userRepository.findBySectionAndAuthority(section, Authority.TEACHER); Integer userCount = userRepository.findAllBySectionAndAuthority(section, Authority.USER).size(); return ClassResponse.builder() .userCount(userCount) From e81ce8dc41a2bd301a14130169cef01430fd820e Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Tue, 15 Feb 2022 19:05:01 +0900 Subject: [PATCH 242/522] =?UTF-8?q?:recycle:=20::=20url=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 --- .../walkhub/domain/teacher/presentation/TeacherController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/TeacherController.java b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/TeacherController.java index 0e89e2e4b..8765621b8 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/TeacherController.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/TeacherController.java @@ -79,7 +79,7 @@ public void confirmTeacherCode(@RequestBody TeacherCodeRequest teacherCodeReques confirmTeacherCodeService.execute(teacherCodeRequest); } - @GetMapping("lists") + @GetMapping("/classes/lists") public ClassListResponse classList() { return classListService.execute(); } From 3e24a8211001aa22e9a0558e4cab32b98463fbeb Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Tue, 15 Feb 2022 19:05:31 +0900 Subject: [PATCH 243/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20error=20?= =?UTF-8?q?=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../walkhub/domain/teacher/service/ClassListService.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/service/ClassListService.java b/src/main/java/com/walkhub/walkhub/domain/teacher/service/ClassListService.java index c4f44c70a..b3ff489db 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/service/ClassListService.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/service/ClassListService.java @@ -48,9 +48,9 @@ private ClassResponse buildClassList(Section section) { .classNum(section.getClassNum()) .build()) .teacher(TeacherResponse.builder() - .userId(user.getId()) - .name(user.getName()) - .profileImageUrl(user.getProfileImageUrl()) + .userId(teacher.getId()) + .name(teacher.getName()) + .profileImageUrl(teacher.getProfileImageUrl()) .build()) .build(); } From e03ea31d369dd2e00803f013f30882264f9648e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B2=94=EC=A7=84?= Date: Tue, 15 Feb 2022 19:18:23 +0900 Subject: [PATCH 244/522] =?UTF-8?q?=E2=99=BB=20::=20=EA=B8=B0=EA=B0=84=20?= =?UTF-8?q?=EA=B2=80=EC=A6=9D=ED=95=98=EB=8A=94=20=EB=A1=9C=EC=A7=81=20?= =?UTF-8?q?=EC=A4=91=EB=B3=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ChallengeStatusRepositoryCustomImpl.java | 33 +++++++++---------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java index ae9974de0..8ba31b7a1 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java @@ -42,9 +42,8 @@ public List queryChallengeParticipantsList(Challenge ch .on(challengeStatus.challenge.eq(challenge)) .where( successScopeFilter(challenge, successScope), - isChallengeSuccessFilter(challenge),exerciseAnalysis.date.goe(challenge.getStartAt()), - exerciseAnalysis.date.goe(challengeStatus.createdAt), - exerciseAnalysis.date.loe(challenge.getEndAt()) + isChallengeSuccessFilter(challenge), + challengeDateFilter(challenge) ) .offset(page * size) .limit(size) @@ -61,11 +60,9 @@ public List queryChallengeParticipantsList(Challenge ch Expressions.asNumber(select(exerciseAnalysis.count()) .from(exerciseAnalysis) .where( - isChallengeSuccessFilter(challenge), exerciseAnalysis.user.eq(user), - exerciseAnalysis.date.goe(challenge.getStartAt()), - exerciseAnalysis.date.goe(challengeStatus.createdAt), - exerciseAnalysis.date.loe(challenge.getEndAt()) + isChallengeSuccessFilter(challenge), + challengeDateFilter(challenge) )) .goe(challenge.getSuccessStandard()).as("isSuccess"), GroupBy.list(exerciseAnalysis.date)) @@ -79,11 +76,9 @@ private BooleanExpression successScopeFilter(Challenge challenge, SuccessScope s return Expressions.asNumber(select(exerciseAnalysis.count()) .from(exerciseAnalysis) .where( - isChallengeSuccessFilter(challenge), exerciseAnalysis.user.eq(user), - exerciseAnalysis.date.goe(challenge.getStartAt()), - exerciseAnalysis.date.goe(challengeStatus.createdAt), - exerciseAnalysis.date.loe(challenge.getEndAt()) + isChallengeSuccessFilter(challenge), + challengeDateFilter(challenge) )) .goe(challenge.getSuccessStandard()); } @@ -91,11 +86,9 @@ private BooleanExpression successScopeFilter(Challenge challenge, SuccessScope s return Expressions.asNumber(select(exerciseAnalysis.count()) .from(exerciseAnalysis) .where( - isChallengeSuccessFilter(challenge), exerciseAnalysis.user.eq(user), - exerciseAnalysis.date.goe(challenge.getStartAt()), - exerciseAnalysis.date.goe(challengeStatus.createdAt), - exerciseAnalysis.date.loe(challenge.getEndAt()) + isChallengeSuccessFilter(challenge), + challengeDateFilter(challenge) )) .lt(challenge.getSuccessStandard()); } @@ -134,11 +127,15 @@ private BooleanExpression isChallengeSuccessInAllScope(Challenge challenge) { .from(exerciseAnalysis) .where( exerciseAnalysis.user.eq(user), - exerciseAnalysis.date.goe(challenge.getStartAt()), - exerciseAnalysis.date.goe(challengeStatus.createdAt), - exerciseAnalysis.date.loe(challenge.getEndAt()) + challengeDateFilter(challenge) ) .goe(challenge.getGoal()); } + private BooleanExpression challengeDateFilter(Challenge challenge) { + return exerciseAnalysis.date.goe(challenge.getStartAt()) + .and(exerciseAnalysis.date.goe(challengeStatus.createdAt)) + .and(exerciseAnalysis.date.loe(challenge.getEndAt())); + } + } From bbe85e46670ea3503734edc011785ea1abbab62c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B2=94=EC=A7=84?= Date: Tue, 15 Feb 2022 19:22:53 +0900 Subject: [PATCH 245/522] =?UTF-8?q?=E2=99=BB=20::=20job=20=EC=9D=B4?= =?UTF-8?q?=EB=A6=84=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/CD.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CD.yml b/.github/workflows/CD.yml index 80d88f4d6..b2d213b63 100644 --- a/.github/workflows/CD.yml +++ b/.github/workflows/CD.yml @@ -32,7 +32,7 @@ jobs: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - - name: Build on Dockerhub + - name: Docker Build run: docker build -t teamwalkhub/walkhub-server . - name: Push on Dockerhub From e19201be31b015afbdc7c2c9a8ac51f63dd4e9f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B2=94=EC=A7=84?= Date: Tue, 15 Feb 2022 20:59:48 +0900 Subject: [PATCH 246/522] =?UTF-8?q?=E2=9A=B0=20::=20ClassCodeNotMatchExcep?= =?UTF-8?q?tion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exception/ClassCodeNotMatchException.java | 15 --------------- .../walkhub/global/error/exception/ErrorCode.java | 1 - 2 files changed, 16 deletions(-) delete mode 100644 src/main/java/com/walkhub/walkhub/domain/user/exception/ClassCodeNotMatchException.java diff --git a/src/main/java/com/walkhub/walkhub/domain/user/exception/ClassCodeNotMatchException.java b/src/main/java/com/walkhub/walkhub/domain/user/exception/ClassCodeNotMatchException.java deleted file mode 100644 index c1cf52c56..000000000 --- a/src/main/java/com/walkhub/walkhub/domain/user/exception/ClassCodeNotMatchException.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.walkhub.walkhub.domain.user.exception; - -import com.walkhub.walkhub.global.error.exception.ErrorCode; -import com.walkhub.walkhub.global.error.exception.WalkhubException; - -public class ClassCodeNotMatchException extends WalkhubException { - - public static final WalkhubException EXCEPTION = - new ClassCodeNotMatchException(); - - private ClassCodeNotMatchException() { - super(ErrorCode.CLASS_CODE_NOT_MATCH); - } - -} diff --git a/src/main/java/com/walkhub/walkhub/global/error/exception/ErrorCode.java b/src/main/java/com/walkhub/walkhub/global/error/exception/ErrorCode.java index 572b1f56b..10626982f 100644 --- a/src/main/java/com/walkhub/walkhub/global/error/exception/ErrorCode.java +++ b/src/main/java/com/walkhub/walkhub/global/error/exception/ErrorCode.java @@ -18,7 +18,6 @@ public enum ErrorCode { EXPIRED_JWT(401, "COMMON-401-1", "Expired Jwt"), INVALID_JWT(401, "COMMON-401-2", "Invalid Jwt"), UNAUTHORIZED_USER_AUTH_CODE(401, "USER-401-1", "Unauthorized User AuthCode"), - CLASS_CODE_NOT_MATCH(401, "USER-401-2", "Class Code Not Match"), INVALID_SCOPE(401, "CHALLENGE-401-1", "Invalid Scope"), PASSWORD_MISMATCH(401, "AUTH-401-1", "Password Mismatch"), INVALID_ROLE(401, "GLOBAL-401-1", "Invalid Role"), From 8979a0f86a8ad9872f7076c627e2831f99111c8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B2=94=EC=A7=84?= Date: Tue, 15 Feb 2022 21:01:42 +0900 Subject: [PATCH 247/522] =?UTF-8?q?=E2=9A=A1=20::=20=EB=B0=98=20=EA=B0=80?= =?UTF-8?q?=EC=9E=85=20=EB=B0=A9=EC=8B=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/repository/SectionRepository.java | 4 ++++ .../user/presentation/UserController.java | 7 +++---- .../user/service/JoinSectionService.java | 20 ++++++------------- 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/SectionRepository.java b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/SectionRepository.java index 2e0cdef41..7498d3b8b 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/SectionRepository.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/SectionRepository.java @@ -1,7 +1,11 @@ package com.walkhub.walkhub.domain.user.domain.repository; +import com.walkhub.walkhub.domain.school.domain.School; import com.walkhub.walkhub.domain.user.domain.Section; import org.springframework.data.jpa.repository.JpaRepository; +import java.util.Optional; + public interface SectionRepository extends JpaRepository { + Optional
findByClassCodeAndSchool(String classCode, School school); } diff --git a/src/main/java/com/walkhub/walkhub/domain/user/presentation/UserController.java b/src/main/java/com/walkhub/walkhub/domain/user/presentation/UserController.java index 9038a0526..b8b483a20 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/presentation/UserController.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/presentation/UserController.java @@ -87,10 +87,9 @@ public void updateUserInfo(@RequestBody @Valid UpdateUserInfoRequest request) { } @ResponseStatus(HttpStatus.CREATED) - @PostMapping("/classes/{section-id}") - public void joinSection(@PathVariable(name = "section-id") Long sectionId, - @RequestBody @Valid JoinSectionRequest request) { - joinSectionService.execute(sectionId, request); + @PostMapping("/classes") + public void joinSection(@RequestBody @Valid JoinSectionRequest request) { + joinSectionService.execute(request); } @ResponseStatus(HttpStatus.NO_CONTENT) diff --git a/src/main/java/com/walkhub/walkhub/domain/user/service/JoinSectionService.java b/src/main/java/com/walkhub/walkhub/domain/user/service/JoinSectionService.java index 0532a898d..b85ae429e 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/service/JoinSectionService.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/service/JoinSectionService.java @@ -1,10 +1,9 @@ package com.walkhub.walkhub.domain.user.service; -import com.walkhub.walkhub.domain.school.exception.AgencyCodeNotMatchException; import com.walkhub.walkhub.domain.user.domain.Section; import com.walkhub.walkhub.domain.user.domain.User; -import com.walkhub.walkhub.domain.user.exception.ClassCodeNotMatchException; -import com.walkhub.walkhub.domain.user.facade.SectionFacade; +import com.walkhub.walkhub.domain.user.domain.repository.SectionRepository; +import com.walkhub.walkhub.domain.user.exception.SectionNotFoundException; import com.walkhub.walkhub.domain.user.facade.UserFacade; import com.walkhub.walkhub.domain.user.presentation.dto.request.JoinSectionRequest; import lombok.RequiredArgsConstructor; @@ -16,21 +15,14 @@ public class JoinSectionService { private final UserFacade userFacade; - private final SectionFacade sectionFacade; + private final SectionRepository sectionRepository; @Transactional - public void execute(Long sectionId, JoinSectionRequest request) { + public void execute(JoinSectionRequest request) { User user = userFacade.getCurrentUser(); - Section section = sectionFacade.getSectionById(sectionId); - - if (!section.getClassCode().equals(request.getClassCode())) { - throw ClassCodeNotMatchException.EXCEPTION; - } - - if (!user.getSchool().equals(section.getSchool())) { - throw AgencyCodeNotMatchException.EXCEPTION; - } + Section section = sectionRepository.findByClassCodeAndSchool(request.getClassCode(), user.getSchool()) + .orElseThrow(() -> SectionNotFoundException.EXCEPTION); user.setSection(section); user.setNumber(request.getNumber()); From 8cd11b1312ff56de1911a0fe0728b1c9ac754431 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B2=94=EC=A7=84?= Date: Tue, 15 Feb 2022 21:05:41 +0900 Subject: [PATCH 248/522] =?UTF-8?q?=E2=9A=A1=20::=20=20=EB=B0=98=20?= =?UTF-8?q?=EC=A4=91=EB=B3=B5=20=EA=B0=80=EC=9E=85=20=EB=B0=A9=EC=A7=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../walkhub/domain/user/service/JoinSectionService.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/user/service/JoinSectionService.java b/src/main/java/com/walkhub/walkhub/domain/user/service/JoinSectionService.java index b85ae429e..d06e324b0 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/service/JoinSectionService.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/service/JoinSectionService.java @@ -3,6 +3,7 @@ import com.walkhub.walkhub.domain.user.domain.Section; import com.walkhub.walkhub.domain.user.domain.User; import com.walkhub.walkhub.domain.user.domain.repository.SectionRepository; +import com.walkhub.walkhub.domain.user.exception.AlreadyJoinedException; import com.walkhub.walkhub.domain.user.exception.SectionNotFoundException; import com.walkhub.walkhub.domain.user.facade.UserFacade; import com.walkhub.walkhub.domain.user.presentation.dto.request.JoinSectionRequest; @@ -21,6 +22,10 @@ public class JoinSectionService { public void execute(JoinSectionRequest request) { User user = userFacade.getCurrentUser(); + if (user.getSection() != null) { + throw AlreadyJoinedException.EXCEPTION; + } + Section section = sectionRepository.findByClassCodeAndSchool(request.getClassCode(), user.getSchool()) .orElseThrow(() -> SectionNotFoundException.EXCEPTION); From afdc10bad6719d119f6a30016098a13c21becc62 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Tue, 15 Feb 2022 22:34:07 +0900 Subject: [PATCH 249/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20codesmell=20?= =?UTF-8?q?=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/repository/ChallengeStatusRepositoryCustomImpl.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java index 9590be264..c3a637e69 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java @@ -10,7 +10,6 @@ import com.querydsl.core.types.dsl.Expressions; import com.querydsl.core.types.dsl.NumberPath; import com.querydsl.jpa.JPAExpressions; -import com.querydsl.jpa.impl.JPAQueryFactory; import com.walkhub.walkhub.domain.challenge.domain.Challenge; import com.walkhub.walkhub.domain.challenge.domain.repository.vo.ChallengeParticipantsVO; import com.walkhub.walkhub.domain.challenge.domain.repository.vo.QChallengeParticipantsVO; @@ -24,7 +23,6 @@ import static com.walkhub.walkhub.domain.challenge.domain.QChallengeStatus.challengeStatus; import static com.querydsl.core.group.GroupBy.groupBy; import static com.querydsl.jpa.JPAExpressions.select; -import static com.walkhub.walkhub.domain.challenge.domain.QChallengeStatus.challengeStatus; import static com.walkhub.walkhub.domain.exercise.domain.QExerciseAnalysis.exerciseAnalysis; import static com.walkhub.walkhub.domain.school.domain.QSchool.school; import static com.walkhub.walkhub.domain.user.domain.QSection.section; From 66f41328c3798329826e9dbfc01cf49b2fb09ad2 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Tue, 15 Feb 2022 22:47:19 +0900 Subject: [PATCH 250/522] =?UTF-8?q?:recycle:=20::=20=EB=B6=88=ED=95=84?= =?UTF-8?q?=EC=9A=94=ED=95=9C=20=EC=BD=94=EB=93=9C=20=EC=82=AD=EC=A0=9C=20?= =?UTF-8?q?&=20=EC=BD=94=EB=93=9C=20=ED=86=B5=EC=9D=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ExerciseAnalysisRepository.java | 2 - .../service/QueryUserDetailsService.java | 77 ++++++++++--------- 2 files changed, 39 insertions(+), 40 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepository.java b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepository.java index 5b04a76e0..89da15cd4 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepository.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepository.java @@ -10,7 +10,5 @@ public interface ExerciseAnalysisRepository extends CrudRepository { Optional findByUserAndDate(User user, LocalDate date); - List findByUser(User user); List findAllByUserAndDateBetween(User user, LocalDate startAt, LocalDate endAt); - List findAllByDateBetweenAndUser(LocalDate startAt, LocalDate endAt, User user); } diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/service/QueryUserDetailsService.java b/src/main/java/com/walkhub/walkhub/domain/teacher/service/QueryUserDetailsService.java index 73d5dbaaa..96cedcdff 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/service/QueryUserDetailsService.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/service/QueryUserDetailsService.java @@ -7,50 +7,51 @@ import com.walkhub.walkhub.domain.teacher.presentation.dto.response.QueryUserDetailsResponse.ExerciseResponse; import com.walkhub.walkhub.domain.user.domain.User; import com.walkhub.walkhub.domain.user.facade.UserFacade; -import java.time.LocalDate; -import java.util.List; -import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.time.LocalDate; +import java.util.List; +import java.util.stream.Collectors; + @RequiredArgsConstructor @Service public class QueryUserDetailsService { - private final UserFacade userFacade; - private final LocationRepository locationRepository; - private final ExerciseAnalysisRepository exerciseAnalysisRepository; - - @Transactional(readOnly = true) - public QueryUserDetailsResponse execute(Long userId, LocalDate startAt, LocalDate endAt) { - User user = userFacade.getUserById(userId); - - List exerciseList = user.getExerciseList() - .stream() - .map(locationRepository::findTop1ByExerciseOrderBySequenceDesc) - .map(location -> ExerciseResponse.builder() - .imageUrl(location.getExercise().getImageUrl()) - .startAt(location.getExercise().getCreatedAt()) - .latitude(location.getLatitude()) - .longitude(location.getLongitude()) - .build()) - .collect(Collectors.toList()); - - List walkCountList = exerciseAnalysisRepository.findAllByDateBetweenAndUser(startAt, endAt, user) - .stream() - .map(ExerciseAnalysis::getWalkCount) - .collect(Collectors.toList()); - - return QueryUserDetailsResponse.builder() - .userId(user.getId()) - .name(user.getName()) - .profileImageUrl(user.getProfileImageUrl()) - .grade(user.getSection().getGrade()) - .classNum(user.getSection().getClassNum()) - .number(user.getNumber()) - .walkCountList(walkCountList) - .exerciseList(exerciseList) - .build(); - } + private final UserFacade userFacade; + private final LocationRepository locationRepository; + private final ExerciseAnalysisRepository exerciseAnalysisRepository; + + @Transactional(readOnly = true) + public QueryUserDetailsResponse execute(Long userId, LocalDate startAt, LocalDate endAt) { + User user = userFacade.getUserById(userId); + + List exerciseList = user.getExerciseList() + .stream() + .map(locationRepository::findTop1ByExerciseOrderBySequenceDesc) + .map(location -> ExerciseResponse.builder() + .imageUrl(location.getExercise().getImageUrl()) + .startAt(location.getExercise().getCreatedAt()) + .latitude(location.getLatitude()) + .longitude(location.getLongitude()) + .build()) + .collect(Collectors.toList()); + + List walkCountList = exerciseAnalysisRepository.findAllByUserAndDateBetween(user, startAt, endAt) + .stream() + .map(ExerciseAnalysis::getWalkCount) + .collect(Collectors.toList()); + + return QueryUserDetailsResponse.builder() + .userId(user.getId()) + .name(user.getName()) + .profileImageUrl(user.getProfileImageUrl()) + .grade(user.getSection().getGrade()) + .classNum(user.getSection().getClassNum()) + .number(user.getNumber()) + .walkCountList(walkCountList) + .exerciseList(exerciseList) + .build(); + } } From 8dec573aae9379decb404f7ae41c79e0381bfadb Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Tue, 15 Feb 2022 22:48:41 +0900 Subject: [PATCH 251/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20User=20?= =?UTF-8?q?=EC=B4=9D=20=EA=B1=B8=EC=9D=8C,=20=ED=8F=89=EA=B7=A0=20?= =?UTF-8?q?=EA=B1=B8=EC=9D=8C,=20=EC=B4=9D=20=EA=B1=B0=EB=A6=AC,=20?= =?UTF-8?q?=EC=B4=9D=20=EA=B1=B0=EB=A6=AC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/response/DetailsClassResponse.java | 5 ++++- .../domain/teacher/service/DetailsClassService.java | 12 ++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/DetailsClassResponse.java b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/DetailsClassResponse.java index b00a1e43c..08cbe95c0 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/DetailsClassResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/DetailsClassResponse.java @@ -28,6 +28,9 @@ public static class UserListResponse { private final Long userId; private final String name; private final String profileImageUrl; - private final Integer walkCount; + private final Integer averageWalkCount; + private final Integer totalWalkCount; + private final Integer averageDistance; + private final Integer totalDistance; } } diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/service/DetailsClassService.java b/src/main/java/com/walkhub/walkhub/domain/teacher/service/DetailsClassService.java index 1f173cfbd..f6111d19a 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/service/DetailsClassService.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/service/DetailsClassService.java @@ -54,14 +54,18 @@ public DetailsClassResponse execute(Long sectionId) { } private UserListResponse buildUserListResponse(User user) { - Integer walkCount = exerciseAnalysisRepository.findByUserAndDate(user, LocalDate.now()) - .map(ExerciseAnalysis::getWalkCount) - .orElse(0); + LocalDate start = LocalDate.now().minusDays(7); + LocalDate end = LocalDate.now(); + List exerciseAnalyses = exerciseAnalysisRepository.findAllByUserAndDateBetween(user, start, end); + return UserListResponse.builder() .userId(user.getId()) .name(user.getName()) .profileImageUrl(user.getProfileImageUrl()) - .walkCount(walkCount) + .averageWalkCount((int) exerciseAnalyses.stream().mapToInt(ExerciseAnalysis::getWalkCount).average().orElse(0)) + .totalWalkCount(exerciseAnalyses.stream().mapToInt(ExerciseAnalysis::getWalkCount).sum()) + .averageDistance((int) exerciseAnalyses.stream().mapToInt(ExerciseAnalysis::getDistance).average().orElse(0)) + .totalDistance(exerciseAnalyses.stream().mapToInt(ExerciseAnalysis::getDistance).sum()) .build(); } } From bd6381d6cf08b056a1441bb3d7cc95b01d7c56d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Tue, 15 Feb 2022 22:57:58 +0900 Subject: [PATCH 252/522] =?UTF-8?q?=F0=9F=93=91=20::=20UserType?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../walkhub/walkhub/domain/excel/domain/type/UserType.java | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 src/main/java/com/walkhub/walkhub/domain/excel/domain/type/UserType.java diff --git a/src/main/java/com/walkhub/walkhub/domain/excel/domain/type/UserType.java b/src/main/java/com/walkhub/walkhub/domain/excel/domain/type/UserType.java new file mode 100644 index 000000000..d1b9e4f90 --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/excel/domain/type/UserType.java @@ -0,0 +1,7 @@ +package com.walkhub.walkhub.domain.excel.domain.type; + +public enum UserType { + ALL, + STUDENT, + TEACHER +} From 19a676cdfbd93208d88af8eff28ca00eb2a60188 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Tue, 15 Feb 2022 22:58:59 +0900 Subject: [PATCH 253/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20userType?= =?UTF-8?q?=EC=9C=BC=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 --- .../dto/request/PrintExcelRequest.java | 4 +- .../ExerciseAnalysisRepositoryCustomImpl.java | 58 ++++++++++++------- 2 files changed, 38 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/excel/presentation/dto/request/PrintExcelRequest.java b/src/main/java/com/walkhub/walkhub/domain/excel/presentation/dto/request/PrintExcelRequest.java index 9ecc98ef8..9de793c8b 100644 --- a/src/main/java/com/walkhub/walkhub/domain/excel/presentation/dto/request/PrintExcelRequest.java +++ b/src/main/java/com/walkhub/walkhub/domain/excel/presentation/dto/request/PrintExcelRequest.java @@ -1,6 +1,6 @@ package com.walkhub.walkhub.domain.excel.presentation.dto.request; -import com.walkhub.walkhub.global.enums.Authority; +import com.walkhub.walkhub.domain.excel.domain.type.UserType; import java.time.LocalDate; import lombok.Data; import org.springframework.format.annotation.DateTimeFormat; @@ -14,7 +14,7 @@ public class PrintExcelRequest { @DateTimeFormat(pattern = "yyyy-MM-dd") private LocalDate endAt; - private Authority authority; + private UserType userType; private Integer grade; diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepositoryCustomImpl.java index 58f1458f8..181c8253e 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepositoryCustomImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepositoryCustomImpl.java @@ -7,6 +7,7 @@ import com.querydsl.core.BooleanBuilder; import com.querydsl.jpa.impl.JPAQueryFactory; +import com.walkhub.walkhub.domain.excel.domain.type.UserType; import com.walkhub.walkhub.domain.excel.presentation.dto.request.PrintExcelRequest; import com.walkhub.walkhub.domain.exercise.domain.repository.vo.PrintExcelVo; import com.walkhub.walkhub.domain.exercise.domain.repository.vo.QPrintExcelVo; @@ -17,20 +18,17 @@ @RequiredArgsConstructor public class ExerciseAnalysisRepositoryCustomImpl implements ExerciseAnalysisRepositoryCustom { + private final JPAQueryFactory queryFactory; @Override public List getPrintExcelVoList(PrintExcelRequest excelRequest, Long schoolId) { - LocalDate startAt = excelRequest.getStartAt(); - - LocalDate endAt = excelRequest.getEndAt(); - - Authority authority = excelRequest.getAuthority(); - - Integer grade = excelRequest.getGrade(); - - Integer classNum = excelRequest.getClassNum(); + LocalDate startAt = excelRequest.getStartAt(); + LocalDate endAt = excelRequest.getEndAt(); + UserType userType = excelRequest.getUserType(); + Integer grade = excelRequest.getGrade(); + Integer classNum = excelRequest.getClassNum(); return queryFactory .select(new QPrintExcelVo( @@ -52,28 +50,44 @@ public List getPrintExcelVoList(PrintExcelRequest excelRequest, Lo .where( school.id.eq(schoolId), exerciseAnalysis.date.between(startAt, endAt), - nullFilter(authority,grade,classNum) + userTypeFilter(userType, grade, classNum) ) .groupBy(user) .fetch(); } - private BooleanBuilder nullFilter(Authority authority, Integer grade, Integer classNum) { - + private BooleanBuilder userTypeFilter(UserType userType, Integer grade, Integer classNum) { BooleanBuilder builder = new BooleanBuilder(); - if (authority != null) { - builder.and(user.authority.eq(authority)); - - if (authority.equals(Authority.USER)) { - if (grade != null) { - builder.and(section.grade.eq(grade)); - } - if (classNum != null) { - builder.and(section.classNum.eq(classNum)); - } + switch (userType) { + case STUDENT: { + builder.and(user.authority.eq(Authority.USER)); + builder.and(nullFilter(builder, grade, classNum)); + break; + } + case TEACHER: { + builder.and(user.authority.eq(Authority.TEACHER)); + break; + } + case ALL: { + builder.and(user.authority.eq(Authority.USER).or( + user.authority.eq(Authority.TEACHER) + )); } } + + return builder; + } + + private BooleanBuilder nullFilter(BooleanBuilder builder, Integer grade, Integer classNum) { + if (grade != null) { + builder.and(section.grade.eq(grade)); + } + + if (classNum != null) { + builder.and(section.classNum.eq(classNum)); + } + return builder; } } From b0e08f42c879f0243a581510e6a76919a0fa5367 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B2=94=EC=A7=84?= Date: Tue, 15 Feb 2022 23:18:35 +0900 Subject: [PATCH 254/522] =?UTF-8?q?=E2=99=BB=20::=20hasSection=20method?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/walkhub/walkhub/domain/user/domain/User.java | 8 ++++++-- .../walkhub/domain/user/service/JoinSectionService.java | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/user/domain/User.java b/src/main/java/com/walkhub/walkhub/domain/user/domain/User.java index 5ae04049a..7a2e330af 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/domain/User.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/domain/User.java @@ -169,10 +169,14 @@ public void updateDailyWalkCountGoal(Integer dailyWalkCountGoal) { } public Section getSection() { - if (section == null) { + if (!hasSection()) { throw SectionNotFoundException.EXCEPTION; } - return section; + return this.section; + } + + public Boolean hasSection() { + return this.section != null; } public void setMaxLevel(CalorieLevel calorieLevel) { diff --git a/src/main/java/com/walkhub/walkhub/domain/user/service/JoinSectionService.java b/src/main/java/com/walkhub/walkhub/domain/user/service/JoinSectionService.java index d06e324b0..0b57ab91d 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/service/JoinSectionService.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/service/JoinSectionService.java @@ -22,7 +22,7 @@ public class JoinSectionService { public void execute(JoinSectionRequest request) { User user = userFacade.getCurrentUser(); - if (user.getSection() != null) { + if (user.hasSection()) { throw AlreadyJoinedException.EXCEPTION; } From c8b090f21979cbb8b85dc83c159ef38214111aaf Mon Sep 17 00:00:00 2001 From: lyutvs Date: Tue, 15 Feb 2022 23:46:20 +0900 Subject: [PATCH 255/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F::=20on=20=EC=9C=BC?= =?UTF-8?q?=EB=A1=9C=20=ED=86=B5=ED=95=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../badge/domain/repository/CustomBadgeRepositoryImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/CustomBadgeRepositoryImpl.java b/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/CustomBadgeRepositoryImpl.java index 567348ced..6d214f189 100644 --- a/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/CustomBadgeRepositoryImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/CustomBadgeRepositoryImpl.java @@ -49,7 +49,7 @@ public List findAllByBadgeCollections(Long userId) { .from(badge) .leftJoin(badgeCollection.badge, badge) .leftJoin(badgeCollection.user, user) - .where(user.isNull().or(user.id.eq(userId))) + .on(user.isNull().or(user.id.eq(userId))) .fetch(); } From 8f9204a777e96e2625be4d4a33b2f56a9bbaf49b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Tue, 15 Feb 2022 23:51:13 +0900 Subject: [PATCH 256/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20=EC=BF=BC?= =?UTF-8?q?=EB=A6=AC=20=EC=A4=91=EB=B3=B5=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/repository/ExerciseAnalysisRepositoryCustomImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepositoryCustomImpl.java index 181c8253e..1799696f7 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepositoryCustomImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepositoryCustomImpl.java @@ -62,7 +62,7 @@ private BooleanBuilder userTypeFilter(UserType userType, Integer grade, Integer switch (userType) { case STUDENT: { builder.and(user.authority.eq(Authority.USER)); - builder.and(nullFilter(builder, grade, classNum)); + builder = (nullFilter(builder, grade, classNum)); break; } case TEACHER: { From 046d6d9635fe182e50c8569267da580041bf1476 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Tue, 15 Feb 2022 23:56:26 +0900 Subject: [PATCH 257/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=EC=8A=A4=EB=A9=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/ExerciseAnalysisRepositoryCustomImpl.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepositoryCustomImpl.java index 1799696f7..5b15a14cb 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepositoryCustomImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepositoryCustomImpl.java @@ -62,7 +62,7 @@ private BooleanBuilder userTypeFilter(UserType userType, Integer grade, Integer switch (userType) { case STUDENT: { builder.and(user.authority.eq(Authority.USER)); - builder = (nullFilter(builder, grade, classNum)); + builder.and(nullFilter(grade, classNum)); break; } case TEACHER: { @@ -79,7 +79,9 @@ private BooleanBuilder userTypeFilter(UserType userType, Integer grade, Integer return builder; } - private BooleanBuilder nullFilter(BooleanBuilder builder, Integer grade, Integer classNum) { + private BooleanBuilder nullFilter(Integer grade, Integer classNum) { + BooleanBuilder builder = new BooleanBuilder(); + if (grade != null) { builder.and(section.grade.eq(grade)); } From ef2926f744ae042098ce2e2b75581c31cce3ae13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Wed, 16 Feb 2022 00:19:30 +0900 Subject: [PATCH 258/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20@data=20->=20?= =?UTF-8?q?getter,=20setter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../excel/presentation/dto/request/PrintExcelRequest.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/excel/presentation/dto/request/PrintExcelRequest.java b/src/main/java/com/walkhub/walkhub/domain/excel/presentation/dto/request/PrintExcelRequest.java index 9de793c8b..0f7d1a049 100644 --- a/src/main/java/com/walkhub/walkhub/domain/excel/presentation/dto/request/PrintExcelRequest.java +++ b/src/main/java/com/walkhub/walkhub/domain/excel/presentation/dto/request/PrintExcelRequest.java @@ -2,10 +2,12 @@ import com.walkhub.walkhub.domain.excel.domain.type.UserType; import java.time.LocalDate; -import lombok.Data; +import lombok.Getter; +import lombok.Setter; import org.springframework.format.annotation.DateTimeFormat; -@Data +@Getter +@Setter public class PrintExcelRequest { @DateTimeFormat(pattern = "yyyy-MM-dd") From e28688caf17907c2e31af910636dfff40f0d6acd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Wed, 16 Feb 2022 00:24:58 +0900 Subject: [PATCH 259/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20@setter=20->?= =?UTF-8?q?=20allargs,=20noargs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/dto/request/PrintExcelRequest.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/excel/presentation/dto/request/PrintExcelRequest.java b/src/main/java/com/walkhub/walkhub/domain/excel/presentation/dto/request/PrintExcelRequest.java index 0f7d1a049..74c2f612a 100644 --- a/src/main/java/com/walkhub/walkhub/domain/excel/presentation/dto/request/PrintExcelRequest.java +++ b/src/main/java/com/walkhub/walkhub/domain/excel/presentation/dto/request/PrintExcelRequest.java @@ -2,18 +2,17 @@ import com.walkhub.walkhub.domain.excel.domain.type.UserType; import java.time.LocalDate; +import lombok.AllArgsConstructor; import lombok.Getter; -import lombok.Setter; -import org.springframework.format.annotation.DateTimeFormat; +import lombok.NoArgsConstructor; @Getter -@Setter +@NoArgsConstructor +@AllArgsConstructor public class PrintExcelRequest { - @DateTimeFormat(pattern = "yyyy-MM-dd") private LocalDate startAt; - @DateTimeFormat(pattern = "yyyy-MM-dd") private LocalDate endAt; private UserType userType; From b8525f7189f8e9b036c74dde2fdff7dc24e034ba Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Wed, 16 Feb 2022 00:44:16 +0900 Subject: [PATCH 260/522] =?UTF-8?q?:recycle:=20::=20At=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 --- .../walkhub/domain/teacher/service/DetailsClassService.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/service/DetailsClassService.java b/src/main/java/com/walkhub/walkhub/domain/teacher/service/DetailsClassService.java index f6111d19a..86dfd1133 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/service/DetailsClassService.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/service/DetailsClassService.java @@ -54,9 +54,9 @@ public DetailsClassResponse execute(Long sectionId) { } private UserListResponse buildUserListResponse(User user) { - LocalDate start = LocalDate.now().minusDays(7); - LocalDate end = LocalDate.now(); - List exerciseAnalyses = exerciseAnalysisRepository.findAllByUserAndDateBetween(user, start, end); + LocalDate startAt = LocalDate.now().minusDays(7); + LocalDate endAt = LocalDate.now(); + List exerciseAnalyses = exerciseAnalysisRepository.findAllByUserAndDateBetween(user, startAt, endAt); return UserListResponse.builder() .userId(user.getId()) From e8e5bf2457f0f6ff0d7f2268d47a1224587cfb55 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Wed, 16 Feb 2022 00:46:28 +0900 Subject: [PATCH 261/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20number=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 --- .../teacher/presentation/dto/response/DetailsClassResponse.java | 1 + .../walkhub/domain/teacher/service/DetailsClassService.java | 1 + 2 files changed, 2 insertions(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/DetailsClassResponse.java b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/DetailsClassResponse.java index 08cbe95c0..f43dc5106 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/DetailsClassResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/DetailsClassResponse.java @@ -27,6 +27,7 @@ public static class TeacherResponse { public static class UserListResponse { private final Long userId; private final String name; + private final Integer number; private final String profileImageUrl; private final Integer averageWalkCount; private final Integer totalWalkCount; diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/service/DetailsClassService.java b/src/main/java/com/walkhub/walkhub/domain/teacher/service/DetailsClassService.java index 86dfd1133..11d511620 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/service/DetailsClassService.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/service/DetailsClassService.java @@ -62,6 +62,7 @@ private UserListResponse buildUserListResponse(User user) { .userId(user.getId()) .name(user.getName()) .profileImageUrl(user.getProfileImageUrl()) + .number(user.getNumber()) .averageWalkCount((int) exerciseAnalyses.stream().mapToInt(ExerciseAnalysis::getWalkCount).average().orElse(0)) .totalWalkCount(exerciseAnalyses.stream().mapToInt(ExerciseAnalysis::getWalkCount).sum()) .averageDistance((int) exerciseAnalyses.stream().mapToInt(ExerciseAnalysis::getDistance).average().orElse(0)) From 846cb28b5f35c7d6bf299ebac3812a80d4aa2568 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Wed, 16 Feb 2022 08:25:20 +0900 Subject: [PATCH 262/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20PrintExcelVo?= =?UTF-8?q?=20response=EC=97=90=EC=84=9C=20=EA=B4=80=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/request/PrintExcelRequest.java | 4 --- .../dto/response/PrintExcelResponse.java | 33 ++++++++++++++++- .../excel/service/PrintExcelService.java | 2 +- .../ExerciseAnalysisRepositoryCustom.java | 3 +- .../ExerciseAnalysisRepositoryCustomImpl.java | 6 ++-- .../domain/repository/vo/PrintExcelVo.java | 35 ------------------- 6 files changed, 38 insertions(+), 45 deletions(-) delete mode 100644 src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/vo/PrintExcelVo.java diff --git a/src/main/java/com/walkhub/walkhub/domain/excel/presentation/dto/request/PrintExcelRequest.java b/src/main/java/com/walkhub/walkhub/domain/excel/presentation/dto/request/PrintExcelRequest.java index 74c2f612a..0b94f3541 100644 --- a/src/main/java/com/walkhub/walkhub/domain/excel/presentation/dto/request/PrintExcelRequest.java +++ b/src/main/java/com/walkhub/walkhub/domain/excel/presentation/dto/request/PrintExcelRequest.java @@ -12,12 +12,8 @@ public class PrintExcelRequest { private LocalDate startAt; - private LocalDate endAt; - private UserType userType; - private Integer grade; - private Integer classNum; } diff --git a/src/main/java/com/walkhub/walkhub/domain/excel/presentation/dto/response/PrintExcelResponse.java b/src/main/java/com/walkhub/walkhub/domain/excel/presentation/dto/response/PrintExcelResponse.java index 8b5db0833..19038a721 100644 --- a/src/main/java/com/walkhub/walkhub/domain/excel/presentation/dto/response/PrintExcelResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/excel/presentation/dto/response/PrintExcelResponse.java @@ -1,6 +1,7 @@ package com.walkhub.walkhub.domain.excel.presentation.dto.response; -import com.walkhub.walkhub.domain.exercise.domain.repository.vo.PrintExcelVo; +import com.querydsl.core.annotations.QueryProjection; +import com.walkhub.walkhub.global.enums.Authority; import java.util.List; import lombok.AllArgsConstructor; import lombok.Getter; @@ -10,4 +11,34 @@ public class PrintExcelResponse { private final List userList; + + @Getter + public static class PrintExcelVo { + + private final String name; + private final Integer grade; + private final Integer classNum; + private final Integer number; + private final Integer allWalkCount; + private final Integer averageWalkCount; + private final Integer allDistance; + private final Integer averageDistance; + private final Authority authority; + private final String schoolName; + + @QueryProjection + public PrintExcelVo(String name, Integer grade, Integer classNum, Integer number, + Integer allWalkCount, Integer averageWalkCount, Integer allDistance, Integer averageDistance, Authority authority, String schoolName) { + this.name = name; + this.grade = grade; + this.classNum = classNum; + this.number = number; + this.allWalkCount = allWalkCount; + this.averageWalkCount = averageWalkCount; + this.allDistance = allDistance; + this.averageDistance = averageDistance; + this.authority = authority; + this.schoolName = schoolName; + } + } } diff --git a/src/main/java/com/walkhub/walkhub/domain/excel/service/PrintExcelService.java b/src/main/java/com/walkhub/walkhub/domain/excel/service/PrintExcelService.java index 50ccdb43e..d24768ab5 100644 --- a/src/main/java/com/walkhub/walkhub/domain/excel/service/PrintExcelService.java +++ b/src/main/java/com/walkhub/walkhub/domain/excel/service/PrintExcelService.java @@ -2,8 +2,8 @@ import com.walkhub.walkhub.domain.excel.presentation.dto.request.PrintExcelRequest; import com.walkhub.walkhub.domain.excel.presentation.dto.response.PrintExcelResponse; +import com.walkhub.walkhub.domain.excel.presentation.dto.response.PrintExcelResponse.PrintExcelVo; import com.walkhub.walkhub.domain.exercise.domain.repository.ExerciseAnalysisRepository; -import com.walkhub.walkhub.domain.exercise.domain.repository.vo.PrintExcelVo; import com.walkhub.walkhub.domain.user.facade.UserFacade; import java.util.List; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepositoryCustom.java b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepositoryCustom.java index 24612c44c..523b6d6ea 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepositoryCustom.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepositoryCustom.java @@ -1,9 +1,10 @@ package com.walkhub.walkhub.domain.exercise.domain.repository; import com.walkhub.walkhub.domain.excel.presentation.dto.request.PrintExcelRequest; -import com.walkhub.walkhub.domain.exercise.domain.repository.vo.PrintExcelVo; +import com.walkhub.walkhub.domain.excel.presentation.dto.response.PrintExcelResponse.PrintExcelVo; import java.util.List; + public interface ExerciseAnalysisRepositoryCustom { List getPrintExcelVoList(PrintExcelRequest printExcelRequest, Long schoolId); } diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepositoryCustomImpl.java index 5b15a14cb..1126d67e2 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepositoryCustomImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepositoryCustomImpl.java @@ -9,8 +9,8 @@ import com.querydsl.jpa.impl.JPAQueryFactory; import com.walkhub.walkhub.domain.excel.domain.type.UserType; import com.walkhub.walkhub.domain.excel.presentation.dto.request.PrintExcelRequest; -import com.walkhub.walkhub.domain.exercise.domain.repository.vo.PrintExcelVo; -import com.walkhub.walkhub.domain.exercise.domain.repository.vo.QPrintExcelVo; +import com.walkhub.walkhub.domain.excel.presentation.dto.response.PrintExcelResponse.PrintExcelVo; +import com.walkhub.walkhub.domain.excel.presentation.dto.response.QPrintExcelResponse_PrintExcelVo; import com.walkhub.walkhub.global.enums.Authority; import java.time.LocalDate; import java.util.List; @@ -31,7 +31,7 @@ public List getPrintExcelVoList(PrintExcelRequest excelRequest, Lo Integer classNum = excelRequest.getClassNum(); return queryFactory - .select(new QPrintExcelVo( + .select(new QPrintExcelResponse_PrintExcelVo( user.name, section.grade, section.classNum, diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/vo/PrintExcelVo.java b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/vo/PrintExcelVo.java deleted file mode 100644 index abba18722..000000000 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/vo/PrintExcelVo.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.walkhub.walkhub.domain.exercise.domain.repository.vo; - -import com.querydsl.core.annotations.QueryProjection; -import com.walkhub.walkhub.global.enums.Authority; -import lombok.Getter; - -@Getter -public class PrintExcelVo { - - private final String name; - private final Integer grade; - private final Integer classNum; - private final Integer number; - private final Integer allWalkCount; - private final Integer averageWalkCount; - private final Integer allDistance; - private final Integer averageDistance; - private final Authority authority; - private final String schoolName; - - @QueryProjection - public PrintExcelVo(String name, Integer grade, Integer classNum, Integer number, - Integer allWalkCount, Integer averageWalkCount, Integer allDistance, Integer averageDistance, Authority authority, String schoolName) { - this.name = name; - this.grade = grade; - this.classNum = classNum; - this.number = number; - this.allWalkCount = allWalkCount; - this.averageWalkCount = averageWalkCount; - this.allDistance = allDistance; - this.averageDistance = averageDistance; - this.authority = authority; - this.schoolName = schoolName; - } -} From 322b8f9a7b72b9c96f6594f8de99bf26bb01616c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Wed, 16 Feb 2022 09:12:51 +0900 Subject: [PATCH 263/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20grade?= =?UTF-8?q?=EA=B0=80=20=EC=9E=88=EC=96=B4=EC=95=BC=20classNum=EA=B2=80?= =?UTF-8?q?=EC=82=AC=EA=B0=80=EB=8A=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/ExerciseAnalysisRepositoryCustomImpl.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepositoryCustomImpl.java index 1126d67e2..e58467367 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepositoryCustomImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseAnalysisRepositoryCustomImpl.java @@ -84,10 +84,10 @@ private BooleanBuilder nullFilter(Integer grade, Integer classNum) { if (grade != null) { builder.and(section.grade.eq(grade)); - } - if (classNum != null) { - builder.and(section.classNum.eq(classNum)); + if (classNum != null) { + builder.and(section.classNum.eq(classNum)); + } } return builder; From 9144e231045b2579623e4f72e967a88cac9dc215 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B2=94=EC=A7=84?= Date: Wed, 16 Feb 2022 09:20:06 +0900 Subject: [PATCH 264/522] =?UTF-8?q?=E2=99=BB=20::=20npe=20=EC=B0=A1?= =?UTF-8?q?=EC=B0=A1=20=EB=B0=A9=EC=A7=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/walkhub/walkhub/domain/user/domain/User.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/user/domain/User.java b/src/main/java/com/walkhub/walkhub/domain/user/domain/User.java index 7a2e330af..2262b70cd 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/domain/User.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/domain/User.java @@ -175,7 +175,7 @@ public Section getSection() { return this.section; } - public Boolean hasSection() { + public boolean hasSection() { return this.section != null; } From 3bfbc9aab6f0ff7460134237d365e257aebb9bdc Mon Sep 17 00:00:00 2001 From: lyutvs Date: Wed, 16 Feb 2022 09:24:50 +0900 Subject: [PATCH 265/522] =?UTF-8?q?=F0=9F=90=9B::=20=EC=83=81=EB=8C=80?= =?UTF-8?q?=EA=B0=80=20=EB=82=B4=20=EB=B1=83=EC=A7=80=EB=A5=BC=20=EB=AA=BB?= =?UTF-8?q?=20=EB=B4=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../badge/domain/repository/CustomBadgeRepositoryImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/CustomBadgeRepositoryImpl.java b/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/CustomBadgeRepositoryImpl.java index 6d214f189..dc27f4a85 100644 --- a/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/CustomBadgeRepositoryImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/CustomBadgeRepositoryImpl.java @@ -49,7 +49,7 @@ public List findAllByBadgeCollections(Long userId) { .from(badge) .leftJoin(badgeCollection.badge, badge) .leftJoin(badgeCollection.user, user) - .on(user.isNull().or(user.id.eq(userId))) + .on(user.id.eq(userId)) .fetch(); } From 1465b4700a8f530d3368ede3513980bdcbcb819e Mon Sep 17 00:00:00 2001 From: jhhong0509 Date: Wed, 16 Feb 2022 12:25:54 +0900 Subject: [PATCH 266/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20(#363)=20Doma?= =?UTF-8?q?in=20=EA=B0=9D=EC=B2=B4=EC=97=90=20update=20=EB=A9=94=EC=86=8C?= =?UTF-8?q?=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../walkhub/domain/school/domain/School.java | 4 ++++ .../walkhub/walkhub/domain/user/domain/Section.java | 13 ++----------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/school/domain/School.java b/src/main/java/com/walkhub/walkhub/domain/school/domain/School.java index 918fa098a..127371e83 100644 --- a/src/main/java/com/walkhub/walkhub/domain/school/domain/School.java +++ b/src/main/java/com/walkhub/walkhub/domain/school/domain/School.java @@ -52,6 +52,10 @@ public void addUserCount() { this.userCount++; } + public void minusUserCount() { + this.userCount--; + } + public void setLogoImage(String logoImageUrl) { this.logoImageUrl = logoImageUrl; } diff --git a/src/main/java/com/walkhub/walkhub/domain/user/domain/Section.java b/src/main/java/com/walkhub/walkhub/domain/user/domain/Section.java index 02c337dde..c20cbf765 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/domain/Section.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/domain/Section.java @@ -7,16 +7,7 @@ import lombok.Getter; import lombok.NoArgsConstructor; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.OneToMany; -import javax.persistence.Table; +import javax.persistence.*; import java.util.List; @Getter @@ -42,7 +33,7 @@ public class Section extends BaseTimeEntity { @JoinColumn(name = "school_id") private School school; - @OneToMany(mappedBy = "section") + @OneToMany(mappedBy = "section", cascade = CascadeType.REMOVE) private List users; @Builder From a52e84120a4fbdd2954c8d1bd54b71691047ac9e Mon Sep 17 00:00:00 2001 From: jhhong0509 Date: Wed, 16 Feb 2022 12:26:18 +0900 Subject: [PATCH 267/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20(#363)=20Secu?= =?UTF-8?q?rityConfig=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/walkhub/walkhub/global/security/SecurityConfig.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java b/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java index fd49c839f..f544b11e3 100644 --- a/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java +++ b/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java @@ -55,7 +55,7 @@ protected void configure(HttpSecurity http) throws Exception { .antMatchers(HttpMethod.GET, "/users/accounts/{phone-number}").permitAll() .antMatchers(HttpMethod.PATCH, "/users/health").authenticated() .antMatchers(HttpMethod.PATCH, "/users/goal").authenticated() - .antMatchers(HttpMethod.PATCH, "/users/school").authenticated() + .antMatchers(HttpMethod.PATCH, "/users/schools").authenticated() .antMatchers(HttpMethod.GET, "/users/levels/lists").authenticated() @@ -115,6 +115,7 @@ protected void configure(HttpSecurity http) throws Exception { .antMatchers(HttpMethod.GET, "/teachers/classes").hasAuthority("TEACHER") .antMatchers(HttpMethod.GET, "/teachers/users/{user-id}").hasAnyAuthority("TEACHER") .antMatchers(HttpMethod.GET, "/teachers/users").hasAnyAuthority("TEACHER", "ROOT") + .antMatchers(HttpMethod.PATCH, "/teachers/schools").hasAuthority("TEACHER") .antMatchers(HttpMethod.GET, "/teachers/students/verification-codes").hasAnyAuthority("TEACHER") .antMatchers(HttpMethod.PATCH, "/teachers/classes/verification-codes").hasAuthority("TEACHER") From 68b79dd8f851c37161b06459f12551941d070594 Mon Sep 17 00:00:00 2001 From: jhhong0509 Date: Wed, 16 Feb 2022 12:26:44 +0900 Subject: [PATCH 268/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20(#363)=20Scho?= =?UTF-8?q?olFacade=EC=97=90=20findByAuthCOde=20cnrk?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../walkhub/walkhub/domain/school/facade/SchoolFacade.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/school/facade/SchoolFacade.java b/src/main/java/com/walkhub/walkhub/domain/school/facade/SchoolFacade.java index 405cd6f78..4edeedb69 100644 --- a/src/main/java/com/walkhub/walkhub/domain/school/facade/SchoolFacade.java +++ b/src/main/java/com/walkhub/walkhub/domain/school/facade/SchoolFacade.java @@ -16,4 +16,9 @@ public School getSchoolById(Long schoolId) { return schoolRepository.findById(schoolId) .orElseThrow(() -> SchoolNotFoundException.EXCEPTION); } + + public School getSchoolByAuthCode(String authCode) { + return schoolRepository.findByAuthCode(authCode) + .orElseThrow(() -> SchoolNotFoundException.EXCEPTION); + } } From 79bd9d9b7c7d965d861e53071f548f5e36ddebc6 Mon Sep 17 00:00:00 2001 From: jhhong0509 Date: Wed, 16 Feb 2022 12:27:14 +0900 Subject: [PATCH 269/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20(#363)=20user?= =?UTF-8?q?=EC=97=90=EC=84=9C=20=ED=95=99=EA=B5=90=20=EC=88=98=EC=A0=95=20?= =?UTF-8?q?=EB=B9=84=EC=A7=80=EB=8B=88=EC=8A=A4=20=EB=A1=9C=EC=A7=81=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 --- .../user/presentation/UserController.java | 2 +- .../user/service/UpdateSchoolInfoService.java | 17 +++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/user/presentation/UserController.java b/src/main/java/com/walkhub/walkhub/domain/user/presentation/UserController.java index b8b483a20..6e80f9d3b 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/presentation/UserController.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/presentation/UserController.java @@ -99,7 +99,7 @@ public void updatePassword(@RequestBody @Valid UpdatePasswordRequest request) { } @ResponseStatus(HttpStatus.NO_CONTENT) - @PatchMapping("/school") + @PatchMapping("/schools") public void updateSchoolInfo(@RequestBody @Valid UpdateSchoolInfoRequest request) { updateSchoolInfoService.execute(request); } diff --git a/src/main/java/com/walkhub/walkhub/domain/user/service/UpdateSchoolInfoService.java b/src/main/java/com/walkhub/walkhub/domain/user/service/UpdateSchoolInfoService.java index d761d2653..519a83b91 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/service/UpdateSchoolInfoService.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/service/UpdateSchoolInfoService.java @@ -1,9 +1,9 @@ package com.walkhub.walkhub.domain.user.service; +import com.walkhub.walkhub.domain.challenge.domain.repository.ChallengeStatusRepository; import com.walkhub.walkhub.domain.school.domain.School; -import com.walkhub.walkhub.domain.school.domain.repository.SchoolRepository; +import com.walkhub.walkhub.domain.school.facade.SchoolFacade; import com.walkhub.walkhub.domain.user.domain.User; -import com.walkhub.walkhub.domain.user.exception.SchoolNotFoundException; import com.walkhub.walkhub.domain.user.facade.UserFacade; import com.walkhub.walkhub.domain.user.presentation.dto.request.UpdateSchoolInfoRequest; import lombok.RequiredArgsConstructor; @@ -15,15 +15,20 @@ public class UpdateSchoolInfoService { private final UserFacade userFacade; - private final SchoolRepository schoolRepository; + private final ChallengeStatusRepository challengeStatusRepository; + private final SchoolFacade schoolFacade; @Transactional public void execute(UpdateSchoolInfoRequest request) { User user = userFacade.getCurrentUser(); + School school = schoolFacade.getSchoolById(request.getSchoolId()); - School school = schoolRepository.findById(request.getSchoolId()) - .orElseThrow(() -> SchoolNotFoundException.EXCEPTION); - + user.setSection(null); user.setSchool(school); + user.getSchool().minusUserCount(); + school.addUserCount(); + + + challengeStatusRepository.resignParticipatedChallenge(user); } } From 290cf1645abdbb495301303691c52a50d182cd9b Mon Sep 17 00:00:00 2001 From: jhhong0509 Date: Wed, 16 Feb 2022 12:27:45 +0900 Subject: [PATCH 270/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20(#363)=20Repo?= =?UTF-8?q?sitory=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/ChallengeRepository.java | 8 +++ .../ChallengeStatusRepositoryCustom.java | 2 + .../ChallengeStatusRepositoryCustomImpl.java | 61 +++++++++++-------- .../domain/repository/SchoolRepository.java | 2 + 4 files changed, 49 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeRepository.java b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeRepository.java index 1ca814cac..a5c6e0043 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeRepository.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeRepository.java @@ -2,7 +2,11 @@ import com.walkhub.walkhub.domain.challenge.domain.Challenge; import com.walkhub.walkhub.domain.school.domain.School; + +import java.time.LocalDate; import java.util.List; + +import com.walkhub.walkhub.domain.user.domain.User; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.CrudRepository; import org.springframework.data.repository.query.Param; @@ -11,4 +15,8 @@ public interface ChallengeRepository extends CrudRepository { @Query("select c from Challenge c where c.user.school = :school") List findAllBySchool(@Param("school") School school); + + List findAllByUser(User user); + + void deleteAllByUserAndEndAtAfter(User user, LocalDate now); } diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustom.java b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustom.java index 4d13fa77b..e088fc4a4 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustom.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustom.java @@ -5,6 +5,7 @@ import com.walkhub.walkhub.domain.challenge.domain.Challenge; import com.walkhub.walkhub.domain.challenge.domain.repository.vo.ChallengeParticipantsVO; import com.walkhub.walkhub.domain.challenge.domain.type.SuccessScope; +import com.walkhub.walkhub.domain.user.domain.User; import java.util.List; @@ -12,4 +13,5 @@ public interface ChallengeStatusRepositoryCustom { Integer getParticipantsCountByChallengeId(Long challengeId); List getRelatedChallengeParticipantsList(Long challengeId, School school, Integer grade, Integer classNum); List queryChallengeParticipantsList(Challenge challenge, SuccessScope successScope, Long page); + void resignParticipatedChallenge(User user); } diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java index c3a637e69..56142282f 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java @@ -1,28 +1,30 @@ package com.walkhub.walkhub.domain.challenge.domain.repository; -import com.querydsl.jpa.impl.JPAQueryFactory; -import com.walkhub.walkhub.domain.challenge.domain.ChallengeStatus; -import com.walkhub.walkhub.domain.challenge.domain.repository.vo.QRelatedChallengeParticipantsVO; -import com.walkhub.walkhub.domain.challenge.domain.repository.vo.RelatedChallengeParticipantsVO; -import com.walkhub.walkhub.domain.school.domain.School; import com.querydsl.core.group.GroupBy; import com.querydsl.core.types.dsl.BooleanExpression; import com.querydsl.core.types.dsl.Expressions; import com.querydsl.core.types.dsl.NumberPath; import com.querydsl.jpa.JPAExpressions; +import com.querydsl.jpa.impl.JPAQueryFactory; import com.walkhub.walkhub.domain.challenge.domain.Challenge; +import com.walkhub.walkhub.domain.challenge.domain.ChallengeStatus; import com.walkhub.walkhub.domain.challenge.domain.repository.vo.ChallengeParticipantsVO; import com.walkhub.walkhub.domain.challenge.domain.repository.vo.QChallengeParticipantsVO; +import com.walkhub.walkhub.domain.challenge.domain.repository.vo.QRelatedChallengeParticipantsVO; +import com.walkhub.walkhub.domain.challenge.domain.repository.vo.RelatedChallengeParticipantsVO; import com.walkhub.walkhub.domain.challenge.domain.type.GoalScope; import com.walkhub.walkhub.domain.challenge.domain.type.SuccessScope; import com.walkhub.walkhub.domain.exercise.domain.type.GoalType; +import com.walkhub.walkhub.domain.school.domain.School; +import com.walkhub.walkhub.domain.user.domain.User; import lombok.RequiredArgsConstructor; +import java.time.LocalDate; import java.util.List; -import static com.walkhub.walkhub.domain.challenge.domain.QChallengeStatus.challengeStatus; import static com.querydsl.core.group.GroupBy.groupBy; import static com.querydsl.jpa.JPAExpressions.select; +import static com.walkhub.walkhub.domain.challenge.domain.QChallengeStatus.challengeStatus; import static com.walkhub.walkhub.domain.exercise.domain.QExerciseAnalysis.exerciseAnalysis; import static com.walkhub.walkhub.domain.school.domain.QSchool.school; import static com.walkhub.walkhub.domain.user.domain.QSection.section; @@ -97,12 +99,12 @@ public List queryChallengeParticipantsList(Challenge ch user.profileImageUrl, user.school.name.as("schoolName"), Expressions.asNumber(select(exerciseAnalysis.count()) - .from(exerciseAnalysis) - .where( - exerciseAnalysis.user.eq(user), - isChallengeSuccessFilter(challenge), - challengeDateFilter(challenge) - )) + .from(exerciseAnalysis) + .where( + exerciseAnalysis.user.eq(user), + isChallengeSuccessFilter(challenge), + challengeDateFilter(challenge) + )) .goe(challenge.getSuccessStandard()).as("isSuccess"), GroupBy.list(exerciseAnalysis.date)) ) @@ -113,22 +115,22 @@ private BooleanExpression successScopeFilter(Challenge challenge, SuccessScope s switch (successScope) { case TRUE: { return Expressions.asNumber(select(exerciseAnalysis.count()) - .from(exerciseAnalysis) - .where( - exerciseAnalysis.user.eq(user), - isChallengeSuccessFilter(challenge), - challengeDateFilter(challenge) - )) + .from(exerciseAnalysis) + .where( + exerciseAnalysis.user.eq(user), + isChallengeSuccessFilter(challenge), + challengeDateFilter(challenge) + )) .goe(challenge.getSuccessStandard()); } case FALSE: { return Expressions.asNumber(select(exerciseAnalysis.count()) - .from(exerciseAnalysis) - .where( - exerciseAnalysis.user.eq(user), - isChallengeSuccessFilter(challenge), - challengeDateFilter(challenge) - )) + .from(exerciseAnalysis) + .where( + exerciseAnalysis.user.eq(user), + isChallengeSuccessFilter(challenge), + challengeDateFilter(challenge) + )) .lt(challenge.getSuccessStandard()); } default: { @@ -176,4 +178,15 @@ private BooleanExpression challengeDateFilter(Challenge challenge) { .and(exerciseAnalysis.date.goe(challengeStatus.createdAt)) .and(exerciseAnalysis.date.loe(challenge.getEndAt())); } + + @Override + public void resignParticipatedChallenge(User user) { + queryFactory.delete(challengeStatus) + .where(challengeStatus.user.eq(user) + .and(isChallengeFinished().not())); + } + + private BooleanExpression isChallengeFinished() { + return challengeStatus.challenge.endAt.before(LocalDate.now()); + } } diff --git a/src/main/java/com/walkhub/walkhub/domain/school/domain/repository/SchoolRepository.java b/src/main/java/com/walkhub/walkhub/domain/school/domain/repository/SchoolRepository.java index 8a55b5f7c..a6f64780d 100644 --- a/src/main/java/com/walkhub/walkhub/domain/school/domain/repository/SchoolRepository.java +++ b/src/main/java/com/walkhub/walkhub/domain/school/domain/repository/SchoolRepository.java @@ -6,8 +6,10 @@ import org.springframework.data.jpa.repository.JpaRepository; import java.util.List; +import java.util.Optional; public interface SchoolRepository extends JpaRepository { List findAllByNameContaining(String name); Page findAllBy(Pageable pageable); + Optional findByAuthCode(String authCode); } From 1e10516a0ce99b2ea00261edd208f592833efa26 Mon Sep 17 00:00:00 2001 From: jhhong0509 Date: Wed, 16 Feb 2022 12:28:05 +0900 Subject: [PATCH 271/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20(#363)=20?= =?UTF-8?q?=EC=84=A0=EC=83=9D=EB=8B=98=20=ED=95=99=EA=B5=90=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/challenge/domain/Challenge.java | 4 ++ .../presentation/TeacherController.java | 16 ++++--- .../request/UpdateTeacherSchoolRequest.java | 13 ++++++ .../service/UpdateTeacherSchoolService.java | 45 +++++++++++++++++++ 4 files changed, 71 insertions(+), 7 deletions(-) create mode 100644 src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/request/UpdateTeacherSchoolRequest.java create mode 100644 src/main/java/com/walkhub/walkhub/domain/teacher/service/UpdateTeacherSchoolService.java diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/Challenge.java b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/Challenge.java index eb1fc9793..226b168e2 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/Challenge.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/Challenge.java @@ -118,4 +118,8 @@ public void updateChallenge(UpdateChallengeRequest request) { public boolean isWriter(Long userId) { return user.getId().equals(userId); } + + public void setUserNull() { + this.user = null; + } } diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/TeacherController.java b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/TeacherController.java index 8765621b8..b513e2002 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/TeacherController.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/TeacherController.java @@ -2,17 +2,12 @@ import com.walkhub.walkhub.domain.teacher.presentation.dto.request.CreateClassRequest; import com.walkhub.walkhub.domain.teacher.presentation.dto.request.TeacherCodeRequest; +import com.walkhub.walkhub.domain.teacher.presentation.dto.request.UpdateTeacherSchoolRequest; import com.walkhub.walkhub.domain.teacher.presentation.dto.response.ClassListResponse; import com.walkhub.walkhub.domain.teacher.presentation.dto.response.CodeResponse; import com.walkhub.walkhub.domain.teacher.presentation.dto.response.DetailsClassResponse; import com.walkhub.walkhub.domain.teacher.presentation.dto.response.QueryUserDetailsResponse; -import com.walkhub.walkhub.domain.teacher.service.ClassListService; -import com.walkhub.walkhub.domain.teacher.service.ConfirmTeacherCodeService; -import com.walkhub.walkhub.domain.teacher.service.CreateClassService; -import com.walkhub.walkhub.domain.teacher.service.DeleteClassService; -import com.walkhub.walkhub.domain.teacher.service.DetailsClassService; -import com.walkhub.walkhub.domain.teacher.service.QueryUserDetailsService; -import com.walkhub.walkhub.domain.teacher.service.VerificationCodeService; +import com.walkhub.walkhub.domain.teacher.service.*; import lombok.RequiredArgsConstructor; import org.springframework.format.annotation.DateTimeFormat; import org.springframework.http.HttpStatus; @@ -42,6 +37,7 @@ public class TeacherController { private final QueryUserDetailsService queryUserDetailsService; private final ConfirmTeacherCodeService confirmTeacherCodeService; private final ClassListService classListService; + private final UpdateTeacherSchoolService updateTeacherSchoolService; @ResponseStatus(HttpStatus.CREATED) @PostMapping("/classes") @@ -84,4 +80,10 @@ public ClassListResponse classList() { return classListService.execute(); } + @PatchMapping("/schools") + @ResponseStatus(HttpStatus.NO_CONTENT) + public void updateTeacherSchool(@Valid @RequestBody UpdateTeacherSchoolRequest request) { + updateTeacherSchoolService.execute(request); + } + } diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/request/UpdateTeacherSchoolRequest.java b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/request/UpdateTeacherSchoolRequest.java new file mode 100644 index 000000000..de64659b6 --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/request/UpdateTeacherSchoolRequest.java @@ -0,0 +1,13 @@ +package com.walkhub.walkhub.domain.teacher.presentation.dto.request; + +import lombok.Getter; +import lombok.NoArgsConstructor; + +import javax.validation.constraints.NotBlank; + +@Getter +@NoArgsConstructor +public class UpdateTeacherSchoolRequest { + @NotBlank(message = "auth_code는 Null, 공백, 띄어쓰기를 허용하지 않습니다.") + private String authCode; +} diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/service/UpdateTeacherSchoolService.java b/src/main/java/com/walkhub/walkhub/domain/teacher/service/UpdateTeacherSchoolService.java new file mode 100644 index 000000000..f5b5b2ce1 --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/service/UpdateTeacherSchoolService.java @@ -0,0 +1,45 @@ +package com.walkhub.walkhub.domain.teacher.service; + +import com.walkhub.walkhub.domain.challenge.domain.Challenge; +import com.walkhub.walkhub.domain.challenge.domain.repository.ChallengeRepository; +import com.walkhub.walkhub.domain.school.domain.School; +import com.walkhub.walkhub.domain.school.facade.SchoolFacade; +import com.walkhub.walkhub.domain.teacher.presentation.dto.request.UpdateTeacherSchoolRequest; +import com.walkhub.walkhub.domain.user.domain.User; +import com.walkhub.walkhub.domain.user.domain.repository.SectionRepository; +import com.walkhub.walkhub.domain.user.facade.UserFacade; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.time.LocalDate; +import java.util.List; + +@RequiredArgsConstructor +@Service +public class UpdateTeacherSchoolService { + + private final UserFacade userFacade; + private final SchoolFacade schoolFacade; + private final ChallengeRepository challengeRepository; + private final SectionRepository sectionRepository; + + @Transactional + public void execute(UpdateTeacherSchoolRequest request) { + User user = userFacade.getCurrentUser(); + School school = schoolFacade.getSchoolByAuthCode(request.getAuthCode()); + List challenges = challengeRepository.findAllByUser(user); + + user.getSchool().minusUserCount(); + school.addUserCount(); + + challenges.forEach(Challenge::setUserNull); + user.setSchool(school); + + if (user.hasSection()) { + sectionRepository.delete(user.getSection()); + } + + challengeRepository.deleteAllByUserAndEndAtAfter(user, LocalDate.now()); + } +} From dc3129f86197fc1302baa80e2c8b2d11ecf984f3 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Wed, 16 Feb 2022 12:38:52 +0900 Subject: [PATCH 272/522] :bookmark_tabs: :: SchoolDetailsInfoService --- .../service/SchoolDetailsInfoService.java | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/main/java/com/walkhub/walkhub/domain/school/service/SchoolDetailsInfoService.java diff --git a/src/main/java/com/walkhub/walkhub/domain/school/service/SchoolDetailsInfoService.java b/src/main/java/com/walkhub/walkhub/domain/school/service/SchoolDetailsInfoService.java new file mode 100644 index 000000000..66a6b7a2f --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/school/service/SchoolDetailsInfoService.java @@ -0,0 +1,45 @@ +package com.walkhub.walkhub.domain.school.service; + +import com.walkhub.walkhub.domain.rank.domain.SchoolRank; +import com.walkhub.walkhub.domain.rank.domain.repository.SchoolRankRepository; +import com.walkhub.walkhub.domain.school.domain.School; +import com.walkhub.walkhub.domain.school.facade.SchoolFacade; +import com.walkhub.walkhub.domain.school.presentation.dto.response.SchoolDetailsInfoResponse; +import com.walkhub.walkhub.global.enums.DateType; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.time.LocalDate; + +@RequiredArgsConstructor +@Service +public class SchoolDetailsInfoService { + + private final SchoolRankRepository schoolRankRepository; + private final SchoolFacade schoolFacade; + + @Transactional(readOnly = true) + public SchoolDetailsInfoResponse execute(Long schoolId) { + School school = schoolFacade.getSchoolById(schoolId); + + LocalDate now = LocalDate.now(); + LocalDate weekCratedAt = now.minusWeeks(1); + LocalDate monthCreatedAt = now.minusMonths(1); + SchoolRank weekSchoolRanks = schoolRankRepository.findBySchoolIdAndDateTypeAndCreatedAtBetween( + schoolId, DateType.WEEK.toString(), weekCratedAt, now + ); + SchoolRank monthSchoolRanks = schoolRankRepository.findBySchoolIdAndDateTypeAndCreatedAtBetween( + schoolId, DateType.MONTH.toString(), monthCreatedAt, now + ); + + return SchoolDetailsInfoResponse.builder() + .totalUserCount(school.getUserCount()) + .weekTotalWalkCount(weekSchoolRanks.getWalkCount()) + .monthTotalWalkCount(monthSchoolRanks.getWalkCount()) + .weekRanking(weekSchoolRanks.getRanking()) + .monthRanking(monthSchoolRanks.getRanking()) + .build(); + } + +} From 0f6d365781405208203bc21481a9516e9a185f3f Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Wed, 16 Feb 2022 12:39:05 +0900 Subject: [PATCH 273/522] :bookmark_tabs: :: SchoolDetailsInfoResponse --- .../dto/response/SchoolDetailsInfoResponse.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/main/java/com/walkhub/walkhub/domain/school/presentation/dto/response/SchoolDetailsInfoResponse.java diff --git a/src/main/java/com/walkhub/walkhub/domain/school/presentation/dto/response/SchoolDetailsInfoResponse.java b/src/main/java/com/walkhub/walkhub/domain/school/presentation/dto/response/SchoolDetailsInfoResponse.java new file mode 100644 index 000000000..3cf93b84f --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/school/presentation/dto/response/SchoolDetailsInfoResponse.java @@ -0,0 +1,16 @@ +package com.walkhub.walkhub.domain.school.presentation.dto.response; + +import lombok.Builder; +import lombok.Getter; + +@Getter +@Builder +public class SchoolDetailsInfoResponse { + + private final Long totalUserCount; + private final Integer weekTotalWalkCount; + private final Integer monthTotalWalkCount; + private final Integer weekRanking; + private final Integer monthRanking; + +} From b1c36f3fce8c1e9b3bca1804506c82b70554b56d Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Wed, 16 Feb 2022 12:39:28 +0900 Subject: [PATCH 274/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EC=A0=95=EB=A0=AC=20&=20=EC=9D=B4=EB=A6=84=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 --- .../rank/domain/repository/SchoolRankRepository.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/SchoolRankRepository.java b/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/SchoolRankRepository.java index 1c413fdf7..501e01fd3 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/SchoolRankRepository.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/SchoolRankRepository.java @@ -2,12 +2,16 @@ import com.walkhub.walkhub.domain.rank.domain.SchoolRank; import com.walkhub.walkhub.domain.rank.domain.SchoolRankId; +import org.springframework.data.repository.CrudRepository; + import java.time.LocalDate; import java.util.List; -import org.springframework.data.repository.CrudRepository; public interface SchoolRankRepository extends CrudRepository { - SchoolRank findBySchoolIdAndDateTypeAndCreatedAtBetween(Long schoolId, - String dateType, LocalDate createdAt, LocalDate createdAt2); - List findAllByDateTypeAndCreatedAtBetweenOrderByRankingAsc(String dateType, LocalDate createdAt, LocalDate createdAt2); + SchoolRank findBySchoolIdAndDateTypeAndCreatedAtBetween( + Long schoolId, String dateType, LocalDate createdAt, LocalDate now + ); + List findAllByDateTypeAndCreatedAtBetweenOrderByRankingAsc( + String dateType, LocalDate createdAt, LocalDate now + ); } From 89dbd05a079224fd9aa994e18c32748314a50112 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Wed, 16 Feb 2022 12:40:03 +0900 Subject: [PATCH 275/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20=ED=95=99?= =?UTF-8?q?=EA=B5=90=20=EC=83=81=EC=84=B8=20=EC=A0=95=EB=B3=B4=20=EB=B3=B4?= =?UTF-8?q?=EA=B8=B0=20api=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/school/presentation/SchoolController.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/school/presentation/SchoolController.java b/src/main/java/com/walkhub/walkhub/domain/school/presentation/SchoolController.java index 6197eefa6..2178a4a96 100644 --- a/src/main/java/com/walkhub/walkhub/domain/school/presentation/SchoolController.java +++ b/src/main/java/com/walkhub/walkhub/domain/school/presentation/SchoolController.java @@ -1,13 +1,16 @@ package com.walkhub.walkhub.domain.school.presentation; import com.walkhub.walkhub.domain.school.presentation.dto.request.SchoolLogoRequest; +import com.walkhub.walkhub.domain.school.presentation.dto.response.SchoolDetailsInfoResponse; import com.walkhub.walkhub.domain.school.presentation.dto.response.SearchSchoolListResponse; +import com.walkhub.walkhub.domain.school.service.SchoolDetailsInfoService; import com.walkhub.walkhub.domain.school.service.SchoolLogoSettingService; import com.walkhub.walkhub.domain.school.service.SearchSchoolService; import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PatchMapping; +import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; @@ -23,6 +26,7 @@ public class SchoolController { private final SchoolLogoSettingService schoolLogoSettingService; private final SearchSchoolService searchSchoolService; + private final SchoolDetailsInfoService schoolDetailsInfoService; @ResponseStatus(HttpStatus.NO_CONTENT) @PatchMapping("/logos") @@ -34,4 +38,9 @@ public void schoolLogoSetting(@RequestBody @Valid SchoolLogoRequest request) { public SearchSchoolListResponse searchSchool(@RequestParam String name) { return searchSchoolService.execute(name); } + + @GetMapping("/details/{school-id}") + public SchoolDetailsInfoResponse schoolDetailsInfo(@PathVariable("school-id") Long schoolId) { + return schoolDetailsInfoService.execute(schoolId); + } } From 068b9eb431a6f6d17264c5080417e7bc4868d67a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B2=94=EC=A7=84?= Date: Wed, 16 Feb 2022 12:44:12 +0900 Subject: [PATCH 276/522] =?UTF-8?q?=E2=9A=A1=20::=20Forbidden?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/walkhub/walkhub/global/error/exception/ErrorCode.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/walkhub/walkhub/global/error/exception/ErrorCode.java b/src/main/java/com/walkhub/walkhub/global/error/exception/ErrorCode.java index 572b1f56b..66e28347b 100644 --- a/src/main/java/com/walkhub/walkhub/global/error/exception/ErrorCode.java +++ b/src/main/java/com/walkhub/walkhub/global/error/exception/ErrorCode.java @@ -24,6 +24,8 @@ public enum ErrorCode { INVALID_ROLE(401, "GLOBAL-401-1", "Invalid Role"), INVALID_VERIFICATION_CODE(401, "GLOBAL-401-2", "Invalid Verification Code"), + FORBIDDEN(403, "COMMON-403-1", "Forbidden"), + USER_NOT_FOUND(404, "USER-404-1", "User Not Found"), USER_AUTH_CODE_NOT_FOUND(404, "USER-404-2", "User AuthCode Not Found"), CREDENTIALS_NOT_FOUND(404, "USER-404-3", "Credentials Not Found"), From cda127f7e849fe01f202d73c4c56ab1d2e8e3587 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B2=94=EC=A7=84?= Date: Wed, 16 Feb 2022 12:44:36 +0900 Subject: [PATCH 277/522] =?UTF-8?q?=F0=9F=93=91=20::=20AuthenticationEntry?= =?UTF-8?q?Point=20Handling?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../error/CustomAuthenticationEntryPoint.java | 36 +++++++++++++++++++ .../global/security/SecurityConfig.java | 4 +++ 2 files changed, 40 insertions(+) create mode 100644 src/main/java/com/walkhub/walkhub/global/error/CustomAuthenticationEntryPoint.java diff --git a/src/main/java/com/walkhub/walkhub/global/error/CustomAuthenticationEntryPoint.java b/src/main/java/com/walkhub/walkhub/global/error/CustomAuthenticationEntryPoint.java new file mode 100644 index 000000000..cb8b0346f --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/global/error/CustomAuthenticationEntryPoint.java @@ -0,0 +1,36 @@ +package com.walkhub.walkhub.global.error; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.walkhub.walkhub.global.error.exception.ErrorCode; +import lombok.RequiredArgsConstructor; +import org.springframework.http.MediaType; +import org.springframework.security.core.AuthenticationException; +import org.springframework.security.web.AuthenticationEntryPoint; +import org.springframework.stereotype.Component; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +@RequiredArgsConstructor +@Component +public class CustomAuthenticationEntryPoint implements AuthenticationEntryPoint { + + private final ObjectMapper objectMapper; + + @Override + public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException { + ErrorCode errorCode = ErrorCode.FORBIDDEN; + String errorResponseJson = objectMapper.writeValueAsString( + ErrorResponse.builder() + .status(errorCode.getStatus()) + .code(errorCode.getCode()) + .message(errorCode.getMessage()) + .build()); + + response.setStatus(errorCode.getStatus()); + response.setContentType(MediaType.APPLICATION_JSON_VALUE); + response.getWriter().write(errorResponseJson); + } + +} diff --git a/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java b/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java index fd49c839f..f85ec1e55 100644 --- a/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java +++ b/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java @@ -1,6 +1,7 @@ package com.walkhub.walkhub.global.security; import com.fasterxml.jackson.databind.ObjectMapper; +import com.walkhub.walkhub.global.error.CustomAuthenticationEntryPoint; import com.walkhub.walkhub.global.security.jwt.JwtTokenProvider; import lombok.RequiredArgsConstructor; import org.springframework.context.annotation.Bean; @@ -132,6 +133,9 @@ protected void configure(HttpSecurity http) throws Exception { .antMatchers(HttpMethod.GET, "/excel").hasAnyAuthority("TEACHER", "ROOT") .anyRequest().denyAll() + .and() + .exceptionHandling().authenticationEntryPoint(new CustomAuthenticationEntryPoint(objectMapper)) + .and() .apply(new FilterConfig(jwtTokenProvider, objectMapper)); } From 4eeda05de23f51bd5197a515a406872550abcdde Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Wed, 16 Feb 2022 12:47:58 +0900 Subject: [PATCH 278/522] :recycle: :: totalUserCount -> userCount --- .../presentation/dto/response/SchoolDetailsInfoResponse.java | 2 +- .../walkhub/domain/school/service/SchoolDetailsInfoService.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/school/presentation/dto/response/SchoolDetailsInfoResponse.java b/src/main/java/com/walkhub/walkhub/domain/school/presentation/dto/response/SchoolDetailsInfoResponse.java index 3cf93b84f..7b4c37196 100644 --- a/src/main/java/com/walkhub/walkhub/domain/school/presentation/dto/response/SchoolDetailsInfoResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/school/presentation/dto/response/SchoolDetailsInfoResponse.java @@ -7,7 +7,7 @@ @Builder public class SchoolDetailsInfoResponse { - private final Long totalUserCount; + private final Long userCount; private final Integer weekTotalWalkCount; private final Integer monthTotalWalkCount; private final Integer weekRanking; diff --git a/src/main/java/com/walkhub/walkhub/domain/school/service/SchoolDetailsInfoService.java b/src/main/java/com/walkhub/walkhub/domain/school/service/SchoolDetailsInfoService.java index 66a6b7a2f..77258aea1 100644 --- a/src/main/java/com/walkhub/walkhub/domain/school/service/SchoolDetailsInfoService.java +++ b/src/main/java/com/walkhub/walkhub/domain/school/service/SchoolDetailsInfoService.java @@ -34,7 +34,7 @@ public SchoolDetailsInfoResponse execute(Long schoolId) { ); return SchoolDetailsInfoResponse.builder() - .totalUserCount(school.getUserCount()) + .userCount(school.getUserCount()) .weekTotalWalkCount(weekSchoolRanks.getWalkCount()) .monthTotalWalkCount(monthSchoolRanks.getWalkCount()) .weekRanking(weekSchoolRanks.getRanking()) From 6d20a7a065b565d106927220ede5ea6e78f8e1b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B2=94=EC=A7=84?= Date: Wed, 16 Feb 2022 14:50:03 +0900 Subject: [PATCH 279/522] =?UTF-8?q?=E2=9A=A1=20::=20setSectionNull?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/walkhub/walkhub/domain/user/domain/User.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/user/domain/User.java b/src/main/java/com/walkhub/walkhub/domain/user/domain/User.java index 2262b70cd..4c9b113d9 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/domain/User.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/domain/User.java @@ -183,4 +183,8 @@ public void setMaxLevel(CalorieLevel calorieLevel) { this.maxLevel = calorieLevel; } + public void setSectionNull() { + this.section = null; + } + } From 3881e1627952db0f7147a33a3845d9ec66896cd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B2=94=EC=A7=84?= Date: Wed, 16 Feb 2022 14:52:09 +0900 Subject: [PATCH 280/522] =?UTF-8?q?=E2=9A=A1=20::=20=EB=B0=98=20=ED=83=88?= =?UTF-8?q?=ED=87=B4=ED=95=98=EA=B8=B0=20=EC=BB=A8=ED=8A=B8=EB=A1=A4?= =?UTF-8?q?=EB=9F=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/user/presentation/UserController.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/user/presentation/UserController.java b/src/main/java/com/walkhub/walkhub/domain/user/presentation/UserController.java index b8b483a20..6e8fe8d1d 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/presentation/UserController.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/presentation/UserController.java @@ -11,6 +11,7 @@ import com.walkhub.walkhub.domain.user.presentation.dto.request.UserSignUpRequest; import com.walkhub.walkhub.domain.user.presentation.dto.response.QueryUserProfileResponse; import com.walkhub.walkhub.domain.user.presentation.dto.response.UserAccountIdResponse; +import com.walkhub.walkhub.domain.user.service.ExitSectionService; import com.walkhub.walkhub.domain.user.service.InputHealthInformationService; import com.walkhub.walkhub.domain.user.service.JoinSectionService; import com.walkhub.walkhub.domain.user.service.QueryMyPageService; @@ -24,6 +25,7 @@ import com.walkhub.walkhub.domain.user.service.UserSignUpService; import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PatchMapping; import org.springframework.web.bind.annotation.PathVariable; @@ -51,6 +53,7 @@ public class UserController { private final UpdateSchoolInfoService updateSchoolInfoService; private final SearchAccountIdService searchAccountIdService; private final UpdateGoalWalkCountService updateGoalWalkCountService; + private final ExitSectionService exitSectionService; @ResponseStatus(HttpStatus.CREATED) @PostMapping("/verification-codes") @@ -114,4 +117,11 @@ public UserAccountIdResponse searchAccountId(@PathVariable(name = "phone-number" public void updateGoalWalkCount(@RequestBody UpdateGoalWalkCountRequest updateGoalWalkCountRequest) { updateGoalWalkCountService.execute(updateGoalWalkCountRequest); } + + @ResponseStatus(HttpStatus.NO_CONTENT) + @DeleteMapping("/classes") + public void exitSection() { + exitSectionService.execute(); + } + } From 981755bb9f6e15d27bd5c5794af2e895c04f12c8 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Wed, 16 Feb 2022 15:30:55 +0900 Subject: [PATCH 281/522] :bookmark_tabs: :: ChallengeRepositoryCustomImp --- .../ChallengeRepositoryCustomImpl.java | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeRepositoryCustomImpl.java diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeRepositoryCustomImpl.java new file mode 100644 index 000000000..40ec2b71f --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeRepositoryCustomImpl.java @@ -0,0 +1,47 @@ +package com.walkhub.walkhub.domain.challenge.domain.repository; + +import com.querydsl.jpa.impl.JPAQueryFactory; +import com.walkhub.walkhub.domain.challenge.domain.repository.vo.QShowChallengeVO; +import com.walkhub.walkhub.domain.challenge.domain.repository.vo.ShowChallengeVO; +import com.walkhub.walkhub.domain.user.domain.User; +import com.walkhub.walkhub.global.enums.UserScope; +import lombok.RequiredArgsConstructor; + +import java.time.LocalDate; +import java.util.List; + +import static com.walkhub.walkhub.domain.challenge.domain.QChallenge.challenge; +import static com.walkhub.walkhub.domain.user.domain.QUser.user; + +@RequiredArgsConstructor +public class ChallengeRepositoryCustomImpl implements ChallengeRepositoryCustom { + + private final JPAQueryFactory query; + + @Override + public List queryChallenge(User user1) { + return query + .select(new QShowChallengeVO( + challenge.id.as("challengeId"), + challenge.name, + challenge.startAt, + challenge.endAt, + challenge.imageUrl, + challenge.userScope, + challenge.goalScope, + challenge.goalType, + user.id.as("writerId"), + user.name.as("writerName"), + user.profileImageUrl.as("profileImageUrl") + )) + .from(challenge) + .join(challenge.user, user) + .on(user.eq(user1)) + .where( + (challenge.userScope.eq(UserScope.ALL).or(challenge.user.school.eq(user1.getSchool()))), + (challenge.endAt.before(LocalDate.now())) + ) + .fetch(); + } + +} From fe1d99a92decfe5eaf9827cbb7a28ad34a4a04b6 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Wed, 16 Feb 2022 15:31:09 +0900 Subject: [PATCH 282/522] :bookmark_tabs: :: ChallengeRepositoryCustom --- .../domain/repository/ChallengeRepositoryCustom.java | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeRepositoryCustom.java diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeRepositoryCustom.java b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeRepositoryCustom.java new file mode 100644 index 000000000..173f1c4af --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeRepositoryCustom.java @@ -0,0 +1,10 @@ +package com.walkhub.walkhub.domain.challenge.domain.repository; + +import com.walkhub.walkhub.domain.challenge.domain.repository.vo.ShowChallengeVO; +import com.walkhub.walkhub.domain.user.domain.User; + +import java.util.List; + +public interface ChallengeRepositoryCustom { + List queryChallenge(User user); +} From 8c73a0f6e88827c63122de699329ba9722f76636 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Wed, 16 Feb 2022 15:31:25 +0900 Subject: [PATCH 283/522] :bookmark_tabs: :: ShowChallengeVO --- .../domain/repository/vo/ShowChallengeVO.java | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/vo/ShowChallengeVO.java diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/vo/ShowChallengeVO.java b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/vo/ShowChallengeVO.java new file mode 100644 index 000000000..dc8c8a4f6 --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/vo/ShowChallengeVO.java @@ -0,0 +1,42 @@ +package com.walkhub.walkhub.domain.challenge.domain.repository.vo; + +import com.querydsl.core.annotations.QueryProjection; +import com.walkhub.walkhub.domain.challenge.domain.type.GoalScope; +import com.walkhub.walkhub.domain.exercise.domain.type.GoalType; +import com.walkhub.walkhub.global.enums.UserScope; +import lombok.Getter; + +import java.time.LocalDate; + +@Getter +public class ShowChallengeVO { + + private final Long challengeId; + private final String name; + private final LocalDate startAt; + private final LocalDate endAt; + private final String imageUrl; + private final UserScope userScope; + private final GoalScope goalScope; + private final GoalType goalType; + private final Long writerId; + private final String writerName; + private final String profileImageUrl; + + @QueryProjection + public ShowChallengeVO(Long challengeId, String name, LocalDate startAt, LocalDate endAt, + String imageUrl, UserScope userScope, GoalScope goalScope, + GoalType goalType, Long writerId, String writerName, String profileImageUrl) { + this.challengeId = challengeId; + this.name = name; + this.startAt = startAt; + this.endAt = endAt; + this.imageUrl = imageUrl; + this.userScope = userScope; + this.goalScope = goalScope; + this.goalType = goalType; + this.writerId = writerId; + this.writerName = writerName; + this.profileImageUrl = profileImageUrl; + } +} From ab322f38ef924316ea6b4edfdc90575956c82799 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Wed, 16 Feb 2022 15:32:06 +0900 Subject: [PATCH 284/522] =?UTF-8?q?:coffin:=20::=20findAllByUserSchoolAndE?= =?UTF-8?q?ndAtBefore=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../challenge/domain/repository/ChallengeRepository.java | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeRepository.java b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeRepository.java index 1ca814cac..4620675f0 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeRepository.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeRepository.java @@ -1,14 +1,7 @@ package com.walkhub.walkhub.domain.challenge.domain.repository; import com.walkhub.walkhub.domain.challenge.domain.Challenge; -import com.walkhub.walkhub.domain.school.domain.School; -import java.util.List; -import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.CrudRepository; -import org.springframework.data.repository.query.Param; -public interface ChallengeRepository extends CrudRepository { - - @Query("select c from Challenge c where c.user.school = :school") - List findAllBySchool(@Param("school") School school); +public interface ChallengeRepository extends CrudRepository, ChallengeRepositoryCustom { } From 10d268df8d6a3f7cc60a355a1d1c996efca228ee Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Wed, 16 Feb 2022 15:33:13 +0900 Subject: [PATCH 285/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20jpa=20->=20qu?= =?UTF-8?q?erydsl?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ChallengeStatusRepositoryCustom.java | 7 +- .../ChallengeStatusRepositoryCustomImpl.java | 76 +++++++++++++------ 2 files changed, 57 insertions(+), 26 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustom.java b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustom.java index 4d13fa77b..263c70fa1 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustom.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustom.java @@ -1,10 +1,12 @@ package com.walkhub.walkhub.domain.challenge.domain.repository; -import com.walkhub.walkhub.domain.challenge.domain.repository.vo.RelatedChallengeParticipantsVO; -import com.walkhub.walkhub.domain.school.domain.School; import com.walkhub.walkhub.domain.challenge.domain.Challenge; import com.walkhub.walkhub.domain.challenge.domain.repository.vo.ChallengeParticipantsVO; +import com.walkhub.walkhub.domain.challenge.domain.repository.vo.RelatedChallengeParticipantsVO; +import com.walkhub.walkhub.domain.challenge.domain.repository.vo.ShowChallengeVO; import com.walkhub.walkhub.domain.challenge.domain.type.SuccessScope; +import com.walkhub.walkhub.domain.school.domain.School; +import com.walkhub.walkhub.domain.user.domain.User; import java.util.List; @@ -12,4 +14,5 @@ public interface ChallengeStatusRepositoryCustom { Integer getParticipantsCountByChallengeId(Long challengeId); List getRelatedChallengeParticipantsList(Long challengeId, School school, Integer grade, Integer classNum); List queryChallengeParticipantsList(Challenge challenge, SuccessScope successScope, Long page); + List getUser(User user); } diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java index c3a637e69..c30af6f78 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java @@ -1,28 +1,32 @@ package com.walkhub.walkhub.domain.challenge.domain.repository; -import com.querydsl.jpa.impl.JPAQueryFactory; -import com.walkhub.walkhub.domain.challenge.domain.ChallengeStatus; -import com.walkhub.walkhub.domain.challenge.domain.repository.vo.QRelatedChallengeParticipantsVO; -import com.walkhub.walkhub.domain.challenge.domain.repository.vo.RelatedChallengeParticipantsVO; -import com.walkhub.walkhub.domain.school.domain.School; import com.querydsl.core.group.GroupBy; import com.querydsl.core.types.dsl.BooleanExpression; import com.querydsl.core.types.dsl.Expressions; import com.querydsl.core.types.dsl.NumberPath; import com.querydsl.jpa.JPAExpressions; +import com.querydsl.jpa.impl.JPAQueryFactory; import com.walkhub.walkhub.domain.challenge.domain.Challenge; +import com.walkhub.walkhub.domain.challenge.domain.ChallengeStatus; import com.walkhub.walkhub.domain.challenge.domain.repository.vo.ChallengeParticipantsVO; import com.walkhub.walkhub.domain.challenge.domain.repository.vo.QChallengeParticipantsVO; +import com.walkhub.walkhub.domain.challenge.domain.repository.vo.QRelatedChallengeParticipantsVO; +import com.walkhub.walkhub.domain.challenge.domain.repository.vo.QShowChallengeVO; +import com.walkhub.walkhub.domain.challenge.domain.repository.vo.RelatedChallengeParticipantsVO; +import com.walkhub.walkhub.domain.challenge.domain.repository.vo.ShowChallengeVO; import com.walkhub.walkhub.domain.challenge.domain.type.GoalScope; import com.walkhub.walkhub.domain.challenge.domain.type.SuccessScope; import com.walkhub.walkhub.domain.exercise.domain.type.GoalType; +import com.walkhub.walkhub.domain.school.domain.School; +import com.walkhub.walkhub.domain.user.domain.User; import lombok.RequiredArgsConstructor; import java.util.List; -import static com.walkhub.walkhub.domain.challenge.domain.QChallengeStatus.challengeStatus; import static com.querydsl.core.group.GroupBy.groupBy; import static com.querydsl.jpa.JPAExpressions.select; +import static com.walkhub.walkhub.domain.challenge.domain.QChallenge.challenge; +import static com.walkhub.walkhub.domain.challenge.domain.QChallengeStatus.challengeStatus; import static com.walkhub.walkhub.domain.exercise.domain.QExerciseAnalysis.exerciseAnalysis; import static com.walkhub.walkhub.domain.school.domain.QSchool.school; import static com.walkhub.walkhub.domain.user.domain.QSection.section; @@ -97,38 +101,62 @@ public List queryChallengeParticipantsList(Challenge ch user.profileImageUrl, user.school.name.as("schoolName"), Expressions.asNumber(select(exerciseAnalysis.count()) - .from(exerciseAnalysis) - .where( - exerciseAnalysis.user.eq(user), - isChallengeSuccessFilter(challenge), - challengeDateFilter(challenge) - )) + .from(exerciseAnalysis) + .where( + exerciseAnalysis.user.eq(user), + isChallengeSuccessFilter(challenge), + challengeDateFilter(challenge) + )) .goe(challenge.getSuccessStandard()).as("isSuccess"), GroupBy.list(exerciseAnalysis.date)) ) ); } + @Override + public List getUser(User user1) { + return queryFactory + .select(new QShowChallengeVO( + challenge.id.as("challengeId"), + challenge.name, + challenge.startAt, + challenge.endAt, + challenge.imageUrl, + challenge.userScope, + challenge.goalScope, + challenge.goalType, + user.id.as("userId"), + user.name.as("writerName"), + user.profileImageUrl.as("profileImageUrl") + )) + .from(challenge) + .join(challenge.user, user) + .join(challengeStatus) + .on(challengeStatus.challenge.eq(challenge)) + .where(challengeStatus.user.eq(user1)) + .fetch(); + } + private BooleanExpression successScopeFilter(Challenge challenge, SuccessScope successScope) { switch (successScope) { case TRUE: { return Expressions.asNumber(select(exerciseAnalysis.count()) - .from(exerciseAnalysis) - .where( - exerciseAnalysis.user.eq(user), - isChallengeSuccessFilter(challenge), - challengeDateFilter(challenge) - )) + .from(exerciseAnalysis) + .where( + exerciseAnalysis.user.eq(user), + isChallengeSuccessFilter(challenge), + challengeDateFilter(challenge) + )) .goe(challenge.getSuccessStandard()); } case FALSE: { return Expressions.asNumber(select(exerciseAnalysis.count()) - .from(exerciseAnalysis) - .where( - exerciseAnalysis.user.eq(user), - isChallengeSuccessFilter(challenge), - challengeDateFilter(challenge) - )) + .from(exerciseAnalysis) + .where( + exerciseAnalysis.user.eq(user), + isChallengeSuccessFilter(challenge), + challengeDateFilter(challenge) + )) .lt(challenge.getSuccessStandard()); } default: { From b9a0158c85d9781608b8cbe7c55db4d36414bcc7 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Wed, 16 Feb 2022 15:33:55 +0900 Subject: [PATCH 286/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20querydsl?= =?UTF-8?q?=EC=97=90=20=EB=A7=9E=EA=B2=8C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...QueryParticipatedChallengeListService.java | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/service/QueryParticipatedChallengeListService.java b/src/main/java/com/walkhub/walkhub/domain/challenge/service/QueryParticipatedChallengeListService.java index 14ee51670..b16f798e6 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/service/QueryParticipatedChallengeListService.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/service/QueryParticipatedChallengeListService.java @@ -1,34 +1,34 @@ package com.walkhub.walkhub.domain.challenge.service; -import com.walkhub.walkhub.domain.challenge.domain.ChallengeStatus; import com.walkhub.walkhub.domain.challenge.domain.repository.ChallengeStatusRepository; import com.walkhub.walkhub.domain.challenge.facade.ChallengeFacade; import com.walkhub.walkhub.domain.challenge.presenstation.dto.response.QueryChallengeListResponse; import com.walkhub.walkhub.domain.challenge.presenstation.dto.response.QueryChallengeListResponse.ChallengeResponse; import com.walkhub.walkhub.domain.user.facade.UserFacade; -import java.util.List; -import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.util.List; +import java.util.stream.Collectors; + @RequiredArgsConstructor @Service public class QueryParticipatedChallengeListService { - private final ChallengeStatusRepository challengeStatusRepository; - private final UserFacade userFacade; - private final ChallengeFacade challengeFacade; + private final ChallengeStatusRepository challengeStatusRepository; + private final UserFacade userFacade; + private final ChallengeFacade challengeFacade; + + @Transactional(readOnly = true) + public QueryChallengeListResponse execute() { - @Transactional(readOnly = true) - public QueryChallengeListResponse execute() { + List challengeResponseList = challengeStatusRepository.getUser(userFacade.getCurrentUser()) + .stream() + .map(challengeFacade::challengeResponseBuilder) + .collect(Collectors.toList()); - List challengeResponseList = challengeStatusRepository.findAllByUser(userFacade.getCurrentUser()) - .stream() - .map(ChallengeStatus::getChallenge) - .map(challengeFacade::challengeResponseBuilder) - .collect(Collectors.toList()); - return new QueryChallengeListResponse(challengeResponseList); - } + return new QueryChallengeListResponse(challengeResponseList); + } } From 7ce22e584727166cad33dadca9610bf904a3fc4c Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Wed, 16 Feb 2022 15:34:18 +0900 Subject: [PATCH 287/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20id=20->=20cha?= =?UTF-8?q?llengeId=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presenstation/dto/response/QueryChallengeListResponse.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/dto/response/QueryChallengeListResponse.java b/src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/dto/response/QueryChallengeListResponse.java index 40fae2873..45f2dc500 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/dto/response/QueryChallengeListResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/dto/response/QueryChallengeListResponse.java @@ -19,7 +19,7 @@ public class QueryChallengeListResponse { @Getter @Builder public static class ChallengeResponse { - private final Long id; + private final Long challengeId; private final String name; private final LocalDate startAt; private final LocalDate endAt; From 7be3947ba8034622acb107da7193734c72b018ac Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Wed, 16 Feb 2022 15:34:38 +0900 Subject: [PATCH 288/522] =?UTF-8?q?:recycle:=20::=20Response=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 --- .../challenge/facade/ChallengeFacade.java | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/facade/ChallengeFacade.java b/src/main/java/com/walkhub/walkhub/domain/challenge/facade/ChallengeFacade.java index f7d36d459..3904a71bb 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/facade/ChallengeFacade.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/facade/ChallengeFacade.java @@ -3,6 +3,7 @@ import com.walkhub.walkhub.domain.challenge.domain.Challenge; import com.walkhub.walkhub.domain.challenge.domain.repository.ChallengeRepository; +import com.walkhub.walkhub.domain.challenge.domain.repository.vo.ShowChallengeVO; import com.walkhub.walkhub.domain.challenge.exception.ChallengeNotFoundException; import com.walkhub.walkhub.domain.challenge.presenstation.dto.response.QueryChallengeListResponse.ChallengeResponse; import com.walkhub.walkhub.domain.challenge.presenstation.dto.response.QueryChallengeListResponse.Writer; @@ -20,21 +21,21 @@ public Challenge getChallengeById(Long id) { .orElseThrow(() -> ChallengeNotFoundException.EXCEPTION); } - public ChallengeResponse challengeResponseBuilder(Challenge challenge) { + public ChallengeResponse challengeResponseBuilder(ShowChallengeVO vo) { return ChallengeResponse.builder() - .id(challenge.getId()) - .name(challenge.getName()) - .startAt(challenge.getStartAt()) - .endAt(challenge.getEndAt()) - .imageUrl(challenge.getImageUrl()) - .userScope(challenge.getUserScope()) - .goalScope(challenge.getGoalScope()) - .goalType(challenge.getGoalType()) - .writer(Writer.builder() - .userId(challenge.getUser().getId()) - .name(challenge.getUser().getName()) - .profileImageUrl(challenge.getUser().getProfileImageUrl()) - .build()) - .build(); + .challengeId(vo.getChallengeId()) + .name(vo.getName()) + .startAt(vo.getStartAt()) + .endAt(vo.getEndAt()) + .imageUrl(vo.getImageUrl()) + .userScope(vo.getUserScope()) + .goalScope(vo.getGoalScope()) + .goalType(vo.getGoalType()) + .writer(Writer.builder() + .userId(vo.getChallengeId()) + .name(vo.getWriterName()) + .profileImageUrl(vo.getProfileImageUrl()) + .build()) + .build(); } } From 2d2615bb4835cc12a2ccb00a25e5dbc6d89cd49a Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Wed, 16 Feb 2022 15:34:59 +0900 Subject: [PATCH 289/522] =?UTF-8?q?:recycle:=20::=20=EB=85=B8=EC=85=98?= =?UTF-8?q?=EC=97=90=20=EB=A7=9E=EA=B2=8C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/QueryChallengeListService.java | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/service/QueryChallengeListService.java b/src/main/java/com/walkhub/walkhub/domain/challenge/service/QueryChallengeListService.java index 55f7d4496..388807fa9 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/service/QueryChallengeListService.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/service/QueryChallengeListService.java @@ -4,29 +4,33 @@ import com.walkhub.walkhub.domain.challenge.facade.ChallengeFacade; import com.walkhub.walkhub.domain.challenge.presenstation.dto.response.QueryChallengeListResponse; import com.walkhub.walkhub.domain.challenge.presenstation.dto.response.QueryChallengeListResponse.ChallengeResponse; +import com.walkhub.walkhub.domain.user.domain.User; import com.walkhub.walkhub.domain.user.facade.UserFacade; -import java.util.List; -import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.util.List; +import java.util.stream.Collectors; + @RequiredArgsConstructor @Service public class QueryChallengeListService { - private final ChallengeRepository challengeRepository; - private final UserFacade userFacade; - private final ChallengeFacade challengeFacade; + private final UserFacade userFacade; + private final ChallengeRepository challengeRepository; + private final ChallengeFacade challengeFacade; + + @Transactional(readOnly = true) + public QueryChallengeListResponse execute() { + User user = userFacade.getCurrentUser(); - @Transactional(readOnly = true) - public QueryChallengeListResponse execute() { + List challengeResponseList = challengeRepository.queryChallenge(user) + .stream() + .map(challengeFacade::challengeResponseBuilder) + .collect(Collectors.toList()); - List challengeResponseList = challengeRepository.findAllBySchool(userFacade.getCurrentUser().getSchool()) - .stream() - .map(challengeFacade::challengeResponseBuilder) - .collect(Collectors.toList()); + return new QueryChallengeListResponse(challengeResponseList); + } - return new QueryChallengeListResponse(challengeResponseList); - } } From 3fc716c52826601a4c4a15a7c99a3e02675c34cd Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Wed, 16 Feb 2022 15:38:28 +0900 Subject: [PATCH 290/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20=ED=8C=8C?= =?UTF-8?q?=EB=9D=BC=EB=AF=B8=ED=84=B0=20=EA=B0=9D=EC=B2=B4=EB=A1=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../teacher/presentation/TeacherController.java | 15 +++++++-------- .../teacher/service/QueryUserListService.java | 5 +++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/TeacherController.java b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/TeacherController.java index 0e415586e..47ac3e62a 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/TeacherController.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/TeacherController.java @@ -1,6 +1,7 @@ package com.walkhub.walkhub.domain.teacher.presentation; import com.walkhub.walkhub.domain.teacher.presentation.dto.request.CreateClassRequest; +import com.walkhub.walkhub.domain.teacher.presentation.dto.request.QueryUserListRequest; import com.walkhub.walkhub.domain.teacher.presentation.dto.request.TeacherCodeRequest; import com.walkhub.walkhub.domain.teacher.presentation.dto.response.CodeResponse; import com.walkhub.walkhub.domain.teacher.presentation.dto.response.QueryUserListResponse; @@ -18,7 +19,9 @@ import com.walkhub.walkhub.domain.teacher.service.QueryUserDetailsService; import com.walkhub.walkhub.domain.teacher.service.RefreshClassCodeService; import com.walkhub.walkhub.domain.teacher.service.VerificationCodeService; + import java.time.LocalDate; + import org.springframework.format.annotation.DateTimeFormat; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; @@ -71,12 +74,8 @@ public CodeResponse refreshClassCode() { } @GetMapping("/users") - public QueryUserListResponse queryUserList(@RequestParam Integer page, - @RequestParam AuthorityScope scope, - @RequestParam SortStandard sort, - @RequestParam(required = false) Integer grade, - @RequestParam(required = false) Integer classNum) { - return queryUserListService.execute(page, scope, sort, grade, classNum); + public QueryUserListResponse queryUserList(QueryUserListRequest request) { + return queryUserListService.execute(request); } @GetMapping("/classes") @@ -86,8 +85,8 @@ public DetailsClassResponse queryStudentCode() { @GetMapping("/users/{user-id}") public QueryUserDetailsResponse queryUserDetails(@PathVariable Long userId, - @RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate startAt, - @RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate endAt) { + @RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate startAt, + @RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate endAt) { return queryUserDetailsService.execute(userId, startAt, endAt); } diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/service/QueryUserListService.java b/src/main/java/com/walkhub/walkhub/domain/teacher/service/QueryUserListService.java index ddd653d36..be0646eac 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/service/QueryUserListService.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/service/QueryUserListService.java @@ -1,5 +1,6 @@ package com.walkhub.walkhub.domain.teacher.service; +import com.walkhub.walkhub.domain.teacher.presentation.dto.request.QueryUserListRequest; import com.walkhub.walkhub.domain.teacher.presentation.dto.response.QueryUserListResponse; import com.walkhub.walkhub.domain.teacher.type.AuthorityScope; import com.walkhub.walkhub.domain.teacher.type.SortStandard; @@ -16,9 +17,9 @@ public class QueryUserListService { private final UserRepository userRepository; private final UserFacade userFacade; - public QueryUserListResponse execute(Integer page, AuthorityScope scope, SortStandard sort, Integer grade, Integer classNum) { + public QueryUserListResponse execute(QueryUserListRequest request) { return QueryUserListResponse.builder() - .userList(userRepository.queryUserList(page, scope, sort, grade, classNum, userFacade.getCurrentUser()) + .userList(userRepository.queryUserList(request.getPage(), request.getScope(), request.getSort(), request.getGrade(), request.getClassNum(), userFacade.getCurrentUser()) .stream().map(users -> QueryUserListResponse.UserListInfo.builder() .userId(users.getUserId()) .name(users.getName()) From d9975ea616bf5298f28734206ceb246353c3e12c Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Wed, 16 Feb 2022 15:38:48 +0900 Subject: [PATCH 291/522] =?UTF-8?q?=F0=9F=93=91=20::=20QueryUserListReques?= =?UTF-8?q?t=20DTO?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/request/QueryUserListRequest.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/request/QueryUserListRequest.java diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/request/QueryUserListRequest.java b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/request/QueryUserListRequest.java new file mode 100644 index 000000000..072f9cca5 --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/request/QueryUserListRequest.java @@ -0,0 +1,14 @@ +package com.walkhub.walkhub.domain.teacher.presentation.dto.request; + +import com.walkhub.walkhub.domain.teacher.type.AuthorityScope; +import com.walkhub.walkhub.domain.teacher.type.SortStandard; +import lombok.Data; + +@Data +public class QueryUserListRequest { + private Integer page; + private AuthorityScope scope; + private SortStandard sort; + private Integer grade; + private Integer classNum; +} From 37410ce391e8871f4de0b7011bd282234a2dccd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B2=94=EC=A7=84?= Date: Wed, 16 Feb 2022 15:50:18 +0900 Subject: [PATCH 292/522] =?UTF-8?q?=E2=9A=A1=20::=20=EC=A2=85=EB=A3=8C?= =?UTF-8?q?=EB=90=98=EC=A7=80=20=EC=95=8A=EC=9D=80=20=EC=B1=8C=EB=A6=B0?= =?UTF-8?q?=EC=A7=80=20=ED=83=88=ED=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ChallengeStatusRepositoryCustom.java | 1 + .../ChallengeStatusRepositoryCustomImpl.java | 26 ++++++++++++++----- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustom.java b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustom.java index 4d13fa77b..1e0ccb02b 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustom.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustom.java @@ -12,4 +12,5 @@ public interface ChallengeStatusRepositoryCustom { Integer getParticipantsCountByChallengeId(Long challengeId); List getRelatedChallengeParticipantsList(Long challengeId, School school, Integer grade, Integer classNum); List queryChallengeParticipantsList(Challenge challenge, SuccessScope successScope, Long page); + void deleteNotOverChallengeStatusByUserId(Long userId); } diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java index c3a637e69..0bdd5b432 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java @@ -1,28 +1,30 @@ package com.walkhub.walkhub.domain.challenge.domain.repository; -import com.querydsl.jpa.impl.JPAQueryFactory; -import com.walkhub.walkhub.domain.challenge.domain.ChallengeStatus; -import com.walkhub.walkhub.domain.challenge.domain.repository.vo.QRelatedChallengeParticipantsVO; -import com.walkhub.walkhub.domain.challenge.domain.repository.vo.RelatedChallengeParticipantsVO; -import com.walkhub.walkhub.domain.school.domain.School; import com.querydsl.core.group.GroupBy; import com.querydsl.core.types.dsl.BooleanExpression; import com.querydsl.core.types.dsl.Expressions; import com.querydsl.core.types.dsl.NumberPath; import com.querydsl.jpa.JPAExpressions; +import com.querydsl.jpa.impl.JPAQueryFactory; import com.walkhub.walkhub.domain.challenge.domain.Challenge; +import com.walkhub.walkhub.domain.challenge.domain.ChallengeStatus; import com.walkhub.walkhub.domain.challenge.domain.repository.vo.ChallengeParticipantsVO; import com.walkhub.walkhub.domain.challenge.domain.repository.vo.QChallengeParticipantsVO; +import com.walkhub.walkhub.domain.challenge.domain.repository.vo.QRelatedChallengeParticipantsVO; +import com.walkhub.walkhub.domain.challenge.domain.repository.vo.RelatedChallengeParticipantsVO; import com.walkhub.walkhub.domain.challenge.domain.type.GoalScope; import com.walkhub.walkhub.domain.challenge.domain.type.SuccessScope; import com.walkhub.walkhub.domain.exercise.domain.type.GoalType; +import com.walkhub.walkhub.domain.school.domain.School; +import com.walkhub.walkhub.global.enums.UserScope; import lombok.RequiredArgsConstructor; +import java.time.LocalDate; import java.util.List; -import static com.walkhub.walkhub.domain.challenge.domain.QChallengeStatus.challengeStatus; import static com.querydsl.core.group.GroupBy.groupBy; import static com.querydsl.jpa.JPAExpressions.select; +import static com.walkhub.walkhub.domain.challenge.domain.QChallengeStatus.challengeStatus; import static com.walkhub.walkhub.domain.exercise.domain.QExerciseAnalysis.exerciseAnalysis; import static com.walkhub.walkhub.domain.school.domain.QSchool.school; import static com.walkhub.walkhub.domain.user.domain.QSection.section; @@ -109,6 +111,18 @@ public List queryChallengeParticipantsList(Challenge ch ); } + @Override + public void deleteNotOverChallengeStatusByUserId(Long userId) { + queryFactory + .delete(challengeStatus) + .where( + (challengeStatus.challenge.userScope.eq(UserScope.CLASS).or(challengeStatus.challenge.userScope.eq(UserScope.GRADE))) + .and(challengeStatus.challenge.endAt.after(LocalDate.now())) + .and(challengeStatus.user.id.eq(userId)) + ) + .execute(); + } + private BooleanExpression successScopeFilter(Challenge challenge, SuccessScope successScope) { switch (successScope) { case TRUE: { From 9cc71135e611900341b34cfa62fe8adcfc1869bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B2=94=EC=A7=84?= Date: Wed, 16 Feb 2022 15:50:29 +0900 Subject: [PATCH 293/522] =?UTF-8?q?=F0=9F=93=91=20::=20ExitSectionService?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../user/service/ExitSectionService.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/main/java/com/walkhub/walkhub/domain/user/service/ExitSectionService.java diff --git a/src/main/java/com/walkhub/walkhub/domain/user/service/ExitSectionService.java b/src/main/java/com/walkhub/walkhub/domain/user/service/ExitSectionService.java new file mode 100644 index 000000000..00695d1c7 --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/user/service/ExitSectionService.java @@ -0,0 +1,25 @@ +package com.walkhub.walkhub.domain.user.service; + +import com.walkhub.walkhub.domain.challenge.domain.repository.ChallengeStatusRepository; +import com.walkhub.walkhub.domain.user.domain.User; +import com.walkhub.walkhub.domain.user.facade.UserFacade; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@RequiredArgsConstructor +@Service +public class ExitSectionService { + + private final UserFacade userFacade; + private final ChallengeStatusRepository challengeStatusRepository; + + @Transactional + public void execute() { + User user = userFacade.getCurrentUser(); + + challengeStatusRepository.deleteNotOverChallengeStatusByUserId(user.getId()); + user.setSectionNull(); + } + +} From 57ac6b9ea696936e832cc261e153b81b88514f98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B2=94=EC=A7=84?= Date: Wed, 16 Feb 2022 16:06:43 +0900 Subject: [PATCH 294/522] =?UTF-8?q?=E2=9A=A1=20::=20bulk=20=EC=97=B0?= =?UTF-8?q?=EC=82=B0=EC=9D=84=20=EC=9C=84=ED=95=B4=20=EC=96=B4=EB=85=B8?= =?UTF-8?q?=ED=85=8C=EC=9D=B4=EC=85=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/repository/ChallengeStatusRepositoryCustomImpl.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java index 0bdd5b432..3a77c9c88 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java @@ -18,6 +18,7 @@ import com.walkhub.walkhub.domain.school.domain.School; import com.walkhub.walkhub.global.enums.UserScope; import lombok.RequiredArgsConstructor; +import org.springframework.data.jpa.repository.Modifying; import java.time.LocalDate; import java.util.List; @@ -112,6 +113,7 @@ public List queryChallengeParticipantsList(Challenge ch } @Override + @Modifying(flushAutomatically = true, clearAutomatically = true) public void deleteNotOverChallengeStatusByUserId(Long userId) { queryFactory .delete(challengeStatus) From f6c44dbd16a246423140f7f709f06171793779c1 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Wed, 16 Feb 2022 19:42:21 +0900 Subject: [PATCH 295/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20codesmell=20?= =?UTF-8?q?=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../walkhub/domain/teacher/service/QueryUserListService.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/service/QueryUserListService.java b/src/main/java/com/walkhub/walkhub/domain/teacher/service/QueryUserListService.java index be0646eac..3743b1f02 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/service/QueryUserListService.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/service/QueryUserListService.java @@ -2,8 +2,6 @@ import com.walkhub.walkhub.domain.teacher.presentation.dto.request.QueryUserListRequest; import com.walkhub.walkhub.domain.teacher.presentation.dto.response.QueryUserListResponse; -import com.walkhub.walkhub.domain.teacher.type.AuthorityScope; -import com.walkhub.walkhub.domain.teacher.type.SortStandard; import com.walkhub.walkhub.domain.user.domain.repository.UserRepository; import com.walkhub.walkhub.domain.user.facade.UserFacade; import lombok.RequiredArgsConstructor; From dd66e57aa4635bf749dfb84fbda319e8384e4432 Mon Sep 17 00:00:00 2001 From: jhhong0509 Date: Wed, 16 Feb 2022 23:14:15 +0900 Subject: [PATCH 296/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20(#374)=20Futu?= =?UTF-8?q?reOrPresent=20=EC=96=B4=EB=85=B8=ED=85=8C=EC=9D=B4=EC=85=98=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 --- .../presenstation/dto/request/CreateChallengeRequest.java | 3 +++ .../presenstation/dto/request/UpdateChallengeRequest.java | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/dto/request/CreateChallengeRequest.java b/src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/dto/request/CreateChallengeRequest.java index ff23aad90..ec10442c6 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/dto/request/CreateChallengeRequest.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/dto/request/CreateChallengeRequest.java @@ -6,6 +6,7 @@ import lombok.Getter; import lombok.NoArgsConstructor; +import javax.validation.constraints.FutureOrPresent; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; import java.time.LocalDate; @@ -22,9 +23,11 @@ public class CreateChallengeRequest { private String imageUrl; @NotNull(message = "start_at은 Null일 수 없습니다.") + @FutureOrPresent(message = "start_at은 과거일 수 없습니다.") private LocalDate startAt; @NotNull(message = "end_at은 Null일 수 없습니다.") + @FutureOrPresent(message = "end_at은 과거일 수 없습니다.") private LocalDate endAt; @NotBlank(message = "award는 Null, 공백, 띄어쓰기를 허용하지 않습니다.") diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/dto/request/UpdateChallengeRequest.java b/src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/dto/request/UpdateChallengeRequest.java index cfed1f92e..26d2150e1 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/dto/request/UpdateChallengeRequest.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/dto/request/UpdateChallengeRequest.java @@ -5,6 +5,7 @@ import lombok.Getter; import lombok.NoArgsConstructor; +import javax.validation.constraints.FutureOrPresent; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; import java.time.LocalDate; @@ -22,9 +23,11 @@ public class UpdateChallengeRequest { private String imageUrl; @NotNull(message = "start_at은 Null일 수 없습니다.") + @FutureOrPresent private LocalDate startAt; @NotNull(message = "end_at은 Null일 수 없습니다.") + @FutureOrPresent(message = "end_at은 과거일 수 없습니다.") private LocalDate endAt; @NotBlank(message = "award는 Null, 공백, 띄어쓰기를 허용하지 않습니다.") From 2d9c0046a8f145506f6e250776b7ba65c9fe61bf Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Thu, 17 Feb 2022 00:05:07 +0900 Subject: [PATCH 297/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20CHUNKSIZE=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 --- .../java/com/walkhub/walkhub/domain/rank/job/UserRankJob.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/job/UserRankJob.java b/src/main/java/com/walkhub/walkhub/domain/rank/job/UserRankJob.java index 0da83dc8e..0fbce201f 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/job/UserRankJob.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/job/UserRankJob.java @@ -28,7 +28,7 @@ @RequiredArgsConstructor public class UserRankJob { - private static final Integer CHUNK_SIZE = 100; + private static final Integer CHUNK_SIZE = 50000; private final JobBuilderFactory jobBuilderFactory; private final StepBuilderFactory stepBuilderFactory; From ed7368eb656bc8b759789d456ca6eb3b7402899c Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Thu, 17 Feb 2022 00:11:41 +0900 Subject: [PATCH 298/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20codesmell=20?= =?UTF-8?q?=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/walkhub/walkhub/domain/rank/job/UserRankJob.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/job/UserRankJob.java b/src/main/java/com/walkhub/walkhub/domain/rank/job/UserRankJob.java index 0fbce201f..386ace591 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/job/UserRankJob.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/job/UserRankJob.java @@ -19,7 +19,6 @@ import org.springframework.jdbc.core.ArgumentPreparedStatementSetter; import org.springframework.jdbc.core.SqlParameter; -import javax.persistence.EntityManagerFactory; import javax.sql.DataSource; import java.sql.Types; import java.time.LocalDate; From 2ab4254f3375921a52c838ba90f3eb42f3726ee7 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Thu, 17 Feb 2022 00:12:53 +0900 Subject: [PATCH 299/522] =?UTF-8?q?:recycle:=20::=20=EB=A9=94=EC=86=8C?= =?UTF-8?q?=EB=93=9C=EB=AA=85=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/repository/ChallengeStatusRepositoryCustom.java | 2 +- .../service/QueryParticipatedChallengeListService.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustom.java b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustom.java index 263c70fa1..6e23bc18e 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustom.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustom.java @@ -14,5 +14,5 @@ public interface ChallengeStatusRepositoryCustom { Integer getParticipantsCountByChallengeId(Long challengeId); List getRelatedChallengeParticipantsList(Long challengeId, School school, Integer grade, Integer classNum); List queryChallengeParticipantsList(Challenge challenge, SuccessScope successScope, Long page); - List getUser(User user); + List getAllChallengesByUser(User user); } diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/service/QueryParticipatedChallengeListService.java b/src/main/java/com/walkhub/walkhub/domain/challenge/service/QueryParticipatedChallengeListService.java index b16f798e6..8ae6812df 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/service/QueryParticipatedChallengeListService.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/service/QueryParticipatedChallengeListService.java @@ -23,7 +23,7 @@ public class QueryParticipatedChallengeListService { @Transactional(readOnly = true) public QueryChallengeListResponse execute() { - List challengeResponseList = challengeStatusRepository.getUser(userFacade.getCurrentUser()) + List challengeResponseList = challengeStatusRepository.getAllChallengesByUser(userFacade.getCurrentUser()) .stream() .map(challengeFacade::challengeResponseBuilder) .collect(Collectors.toList()); From f64f0b9cb94780454b3c132c34ed20b5c7ad8931 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Thu, 17 Feb 2022 00:18:55 +0900 Subject: [PATCH 300/522] =?UTF-8?q?:recycle:=20::=20=EC=9D=B4=EB=A6=84=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=EC=97=90=20=EB=A7=9E=EC=B6=B0=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 --- .../domain/repository/ChallengeStatusRepositoryCustomImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java index c30af6f78..29d6dd4e4 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java @@ -114,7 +114,7 @@ public List queryChallengeParticipantsList(Challenge ch } @Override - public List getUser(User user1) { + public List getAllChallengesByUser(User user1) { return queryFactory .select(new QShowChallengeVO( challenge.id.as("challengeId"), From b69f73fb20000b3314680d6f4966f53f13f01bce Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Thu, 17 Feb 2022 00:29:51 +0900 Subject: [PATCH 301/522] =?UTF-8?q?:bug:=20::=20securityConfig=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 --- .../java/com/walkhub/walkhub/global/security/SecurityConfig.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java b/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java index f85ec1e55..7e473c89a 100644 --- a/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java +++ b/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java @@ -112,6 +112,7 @@ protected void configure(HttpSecurity http) throws Exception { .antMatchers(HttpMethod.POST, "/teachers/verification-codes").hasAuthority("ROOT") .antMatchers(HttpMethod.PATCH, "/teachers/verification-codes").hasAuthority("USER") .antMatchers(HttpMethod.POST, "/teachers/classes").hasAnyAuthority("TEACHER", "ROOT") + .antMatchers(HttpMethod.GET, "/teachers/classes/lists").hasAnyAuthority("TEACHER", "ROOT") .antMatchers(HttpMethod.DELETE, "/teachers/classes/{section-id}").hasAnyAuthority("TEACHER", "ROOT") .antMatchers(HttpMethod.GET, "/teachers/classes").hasAuthority("TEACHER") .antMatchers(HttpMethod.GET, "/teachers/users/{user-id}").hasAnyAuthority("TEACHER") From 8e15716ac9b34a1ad4ec8d8ae05d060c355610c3 Mon Sep 17 00:00:00 2001 From: jhhong0509 Date: Thu, 17 Feb 2022 00:44:11 +0900 Subject: [PATCH 302/522] =?UTF-8?q?:bug:=20::=20(#374)=20=EB=B9=A0?= =?UTF-8?q?=EC=A7=84=20=EB=A9=94=EC=84=B8=EC=A7=80=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presenstation/dto/request/UpdateChallengeRequest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/dto/request/UpdateChallengeRequest.java b/src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/dto/request/UpdateChallengeRequest.java index 26d2150e1..b73f6ff19 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/dto/request/UpdateChallengeRequest.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/dto/request/UpdateChallengeRequest.java @@ -23,7 +23,7 @@ public class UpdateChallengeRequest { private String imageUrl; @NotNull(message = "start_at은 Null일 수 없습니다.") - @FutureOrPresent + @FutureOrPresent(message = "start_at은 과거일 수 없습니다.") private LocalDate startAt; @NotNull(message = "end_at은 Null일 수 없습니다.") From 93cd27188167ab6626c0a4069a14f0062545350b Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Thu, 17 Feb 2022 00:52:21 +0900 Subject: [PATCH 303/522] =?UTF-8?q?:recycle:=20::=20void=20->=20token=20?= =?UTF-8?q?=EB=B0=9C=EA=B8=89=20=EB=A1=9C=EC=A7=81=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/TeacherController.java | 5 ++- .../dto/response/TokenResponse.java | 13 +++++++ .../service/ConfirmTeacherCodeService.java | 39 ++++++++++++++----- 3 files changed, 46 insertions(+), 11 deletions(-) create mode 100644 src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/TokenResponse.java diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/TeacherController.java b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/TeacherController.java index 8765621b8..bb0ed649d 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/TeacherController.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/TeacherController.java @@ -5,6 +5,7 @@ import com.walkhub.walkhub.domain.teacher.presentation.dto.response.ClassListResponse; import com.walkhub.walkhub.domain.teacher.presentation.dto.response.CodeResponse; import com.walkhub.walkhub.domain.teacher.presentation.dto.response.DetailsClassResponse; +import com.walkhub.walkhub.domain.teacher.presentation.dto.response.TokenResponse; import com.walkhub.walkhub.domain.teacher.presentation.dto.response.QueryUserDetailsResponse; import com.walkhub.walkhub.domain.teacher.service.ClassListService; import com.walkhub.walkhub.domain.teacher.service.ConfirmTeacherCodeService; @@ -75,8 +76,8 @@ public QueryUserDetailsResponse queryUserDetails(@PathVariable("user-id") Long u @ResponseStatus(HttpStatus.NO_CONTENT) @PatchMapping("/verification-codes") - public void confirmTeacherCode(@RequestBody TeacherCodeRequest teacherCodeRequest) { - confirmTeacherCodeService.execute(teacherCodeRequest); + public TokenResponse confirmTeacherCode(@RequestBody TeacherCodeRequest teacherCodeRequest) { + return confirmTeacherCodeService.execute(teacherCodeRequest); } @GetMapping("/classes/lists") diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/TokenResponse.java b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/TokenResponse.java new file mode 100644 index 000000000..cdc28815a --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/TokenResponse.java @@ -0,0 +1,13 @@ +package com.walkhub.walkhub.domain.teacher.presentation.dto.response; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@Getter +@RequiredArgsConstructor +public class TokenResponse { + + private final String accessToken; + private final String refreshToken; + +} diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/service/ConfirmTeacherCodeService.java b/src/main/java/com/walkhub/walkhub/domain/teacher/service/ConfirmTeacherCodeService.java index 4548dc267..b7c503114 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/service/ConfirmTeacherCodeService.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/service/ConfirmTeacherCodeService.java @@ -1,9 +1,14 @@ package com.walkhub.walkhub.domain.teacher.service; +import com.walkhub.walkhub.domain.auth.domain.RefreshToken; +import com.walkhub.walkhub.domain.auth.domain.repository.RefreshTokenRepository; import com.walkhub.walkhub.domain.teacher.presentation.dto.request.TeacherCodeRequest; +import com.walkhub.walkhub.domain.teacher.presentation.dto.response.TokenResponse; import com.walkhub.walkhub.domain.user.domain.User; import com.walkhub.walkhub.domain.user.facade.UserFacade; import com.walkhub.walkhub.global.exception.InvalidVerificationCodeException; +import com.walkhub.walkhub.global.security.jwt.JwtProperties; +import com.walkhub.walkhub.global.security.jwt.JwtTokenProvider; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -12,15 +17,31 @@ @Service public class ConfirmTeacherCodeService { - private final UserFacade userFacade; + private final UserFacade userFacade; + private final JwtTokenProvider jwtTokenProvider; + private final RefreshTokenRepository refreshTokenRepository; + private final JwtProperties jwtProperties; - @Transactional - public void execute(TeacherCodeRequest request) { - User user = userFacade.getCurrentUser(); + @Transactional + public TokenResponse execute(TeacherCodeRequest request) { + User user = userFacade.getCurrentUser(); - if (!user.getSchool().getAuthCode().equals(request.getCode())) { - throw InvalidVerificationCodeException.EXCEPTION; - } - user.setAuthorityTeacher(); - } + if (!user.getSchool().getAuthCode().equals(request.getCode())) { + throw InvalidVerificationCodeException.EXCEPTION; + } + user.setAuthorityTeacher(); + + String accessToken = jwtTokenProvider.generateAccessToken(user.getAccountId()); + String refreshToken = jwtTokenProvider.generateRefreshToken(user.getAccountId()); + + refreshTokenRepository.save( + RefreshToken.builder() + .accountId(user.getAccountId()) + .token(refreshToken) + .timeToLive(jwtProperties.getRefreshExp()) + .build() + ); + + return new TokenResponse(accessToken, refreshToken); + } } From ea0e6cf696961eb74ef1a1f13823c7eaba9801c8 Mon Sep 17 00:00:00 2001 From: jhhong0509 Date: Thu, 17 Feb 2022 00:53:13 +0900 Subject: [PATCH 304/522] =?UTF-8?q?:bug:=20::=20(#363)=20Param=20=EC=96=B4?= =?UTF-8?q?=EB=85=B8=ED=85=8C=EC=9D=B4=EC=85=98=20import=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 --- .../domain/repository/ChallengeRepository.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeRepository.java b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeRepository.java index adcadfb7a..056a1eb0a 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeRepository.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeRepository.java @@ -2,21 +2,21 @@ import com.walkhub.walkhub.domain.challenge.domain.Challenge; import com.walkhub.walkhub.domain.school.domain.School; - -import java.time.LocalDate; -import java.util.List; - import com.walkhub.walkhub.domain.user.domain.User; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.query.Param; + +import java.time.LocalDate; +import java.util.List; public interface ChallengeRepository extends CrudRepository, ChallengeRepositoryCustom { - @Query("select c from Challenge c where c.user.school = :school") - List findAllBySchool(@Param("school") School school); + @Query("select c from Challenge c where c.user.school = :school") + List findAllBySchool(@Param("school") School school); - List findAllByUser(User user); + List findAllByUser(User user); - void deleteAllByUserAndEndAtAfter(User user, LocalDate now); + void deleteAllByUserAndEndAtAfter(User user, LocalDate now); } From f3e737da8b8f4cafe3a14e1e2f1157ed844549aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B2=94=EC=A7=84?= Date: Thu, 17 Feb 2022 00:57:38 +0900 Subject: [PATCH 305/522] =?UTF-8?q?=E2=9A=A1=20::=20=EB=B0=98=20=ED=83=88?= =?UTF-8?q?=ED=87=B4=ED=95=98=EA=B8=B0=20permission?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/walkhub/walkhub/global/security/SecurityConfig.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java b/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java index fd49c839f..29df42321 100644 --- a/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java +++ b/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java @@ -51,7 +51,8 @@ protected void configure(HttpSecurity http) throws Exception { .antMatchers(HttpMethod.GET, "/users/{user-id}").authenticated() .antMatchers(HttpMethod.GET, "/users").authenticated() .antMatchers(HttpMethod.PATCH, "/users").authenticated() - .antMatchers(HttpMethod.POST, "/users/classes/{section-id}").authenticated() + .antMatchers(HttpMethod.POST, "/users/classes").authenticated() + .antMatchers(HttpMethod.DELETE, "/users/classes").hasAuthority("USER") .antMatchers(HttpMethod.GET, "/users/accounts/{phone-number}").permitAll() .antMatchers(HttpMethod.PATCH, "/users/health").authenticated() .antMatchers(HttpMethod.PATCH, "/users/goal").authenticated() @@ -128,8 +129,6 @@ protected void configure(HttpSecurity http) throws Exception { // socket.io .antMatchers(HttpMethod.GET, "/socket.io").authenticated() - // excel - .antMatchers(HttpMethod.GET, "/excel").hasAnyAuthority("TEACHER", "ROOT") .anyRequest().denyAll() .and() From ee3a8f5814d2395f4aa139145302c1a3897044e1 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Thu, 17 Feb 2022 01:00:15 +0900 Subject: [PATCH 306/522] =?UTF-8?q?:recycle:=20::=20refreshToken=20?= =?UTF-8?q?=EC=A0=80=EC=9E=A5=20=EB=A1=9C=EC=A7=81=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../teacher/service/ConfirmTeacherCodeService.java | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/service/ConfirmTeacherCodeService.java b/src/main/java/com/walkhub/walkhub/domain/teacher/service/ConfirmTeacherCodeService.java index b7c503114..b7ea89c2c 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/service/ConfirmTeacherCodeService.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/service/ConfirmTeacherCodeService.java @@ -1,13 +1,10 @@ package com.walkhub.walkhub.domain.teacher.service; -import com.walkhub.walkhub.domain.auth.domain.RefreshToken; -import com.walkhub.walkhub.domain.auth.domain.repository.RefreshTokenRepository; import com.walkhub.walkhub.domain.teacher.presentation.dto.request.TeacherCodeRequest; import com.walkhub.walkhub.domain.teacher.presentation.dto.response.TokenResponse; import com.walkhub.walkhub.domain.user.domain.User; import com.walkhub.walkhub.domain.user.facade.UserFacade; import com.walkhub.walkhub.global.exception.InvalidVerificationCodeException; -import com.walkhub.walkhub.global.security.jwt.JwtProperties; import com.walkhub.walkhub.global.security.jwt.JwtTokenProvider; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -19,8 +16,6 @@ public class ConfirmTeacherCodeService { private final UserFacade userFacade; private final JwtTokenProvider jwtTokenProvider; - private final RefreshTokenRepository refreshTokenRepository; - private final JwtProperties jwtProperties; @Transactional public TokenResponse execute(TeacherCodeRequest request) { @@ -34,14 +29,6 @@ public TokenResponse execute(TeacherCodeRequest request) { String accessToken = jwtTokenProvider.generateAccessToken(user.getAccountId()); String refreshToken = jwtTokenProvider.generateRefreshToken(user.getAccountId()); - refreshTokenRepository.save( - RefreshToken.builder() - .accountId(user.getAccountId()) - .token(refreshToken) - .timeToLive(jwtProperties.getRefreshExp()) - .build() - ); - return new TokenResponse(accessToken, refreshToken); } } From 3ce4a9226d9acbf0514da411824d36d6fa25828c Mon Sep 17 00:00:00 2001 From: jhhong0509 Date: Thu, 17 Feb 2022 01:08:35 +0900 Subject: [PATCH 307/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20(#363)=20Code?= =?UTF-8?q?Smell:=20import=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/ChallengeStatusRepositoryCustomImpl.java | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java index 69c7ec12d..807bc79f8 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java @@ -8,13 +8,7 @@ import com.querydsl.jpa.impl.JPAQueryFactory; import com.walkhub.walkhub.domain.challenge.domain.Challenge; import com.walkhub.walkhub.domain.challenge.domain.ChallengeStatus; -import com.walkhub.walkhub.domain.challenge.domain.repository.vo.ChallengeParticipantsVO; -import com.walkhub.walkhub.domain.challenge.domain.repository.vo.QChallengeParticipantsVO; -import com.walkhub.walkhub.domain.challenge.domain.repository.vo.QRelatedChallengeParticipantsVO; -import com.walkhub.walkhub.domain.challenge.domain.repository.vo.RelatedChallengeParticipantsVO; -import com.walkhub.walkhub.domain.challenge.domain.repository.vo.QShowChallengeVO; -import com.walkhub.walkhub.domain.challenge.domain.repository.vo.RelatedChallengeParticipantsVO; -import com.walkhub.walkhub.domain.challenge.domain.repository.vo.ShowChallengeVO; +import com.walkhub.walkhub.domain.challenge.domain.repository.vo.*; import com.walkhub.walkhub.domain.challenge.domain.type.GoalScope; import com.walkhub.walkhub.domain.challenge.domain.type.SuccessScope; import com.walkhub.walkhub.domain.exercise.domain.type.GoalType; From abb3ec81796a02c4d6d12a7c2ddb8979f459fe9a Mon Sep 17 00:00:00 2001 From: jhhong0509 Date: Thu, 17 Feb 2022 01:15:24 +0900 Subject: [PATCH 308/522] =?UTF-8?q?:bug:=20::=20(#363)=20section=20?= =?UTF-8?q?=EC=A7=80=EC=9A=B8=20=EB=95=8C=20=ED=95=99=EC=83=9D=20null?= =?UTF-8?q?=EB=A1=9C=20=EC=A7=80=EC=9A=B0=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/teacher/service/UpdateTeacherSchoolService.java | 3 +++ .../java/com/walkhub/walkhub/domain/user/domain/Section.java | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/service/UpdateTeacherSchoolService.java b/src/main/java/com/walkhub/walkhub/domain/teacher/service/UpdateTeacherSchoolService.java index f5b5b2ce1..32f26b034 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/service/UpdateTeacherSchoolService.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/service/UpdateTeacherSchoolService.java @@ -7,6 +7,7 @@ import com.walkhub.walkhub.domain.teacher.presentation.dto.request.UpdateTeacherSchoolRequest; import com.walkhub.walkhub.domain.user.domain.User; import com.walkhub.walkhub.domain.user.domain.repository.SectionRepository; +import com.walkhub.walkhub.domain.user.domain.repository.UserRepository; import com.walkhub.walkhub.domain.user.facade.UserFacade; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -23,6 +24,7 @@ public class UpdateTeacherSchoolService { private final SchoolFacade schoolFacade; private final ChallengeRepository challengeRepository; private final SectionRepository sectionRepository; + private final UserRepository userRepository; @Transactional public void execute(UpdateTeacherSchoolRequest request) { @@ -37,6 +39,7 @@ public void execute(UpdateTeacherSchoolRequest request) { user.setSchool(school); if (user.hasSection()) { + userRepository.setUserSectionNull(user.getSection()); sectionRepository.delete(user.getSection()); } diff --git a/src/main/java/com/walkhub/walkhub/domain/user/domain/Section.java b/src/main/java/com/walkhub/walkhub/domain/user/domain/Section.java index c20cbf765..423abd419 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/domain/Section.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/domain/Section.java @@ -33,7 +33,7 @@ public class Section extends BaseTimeEntity { @JoinColumn(name = "school_id") private School school; - @OneToMany(mappedBy = "section", cascade = CascadeType.REMOVE) + @OneToMany(mappedBy = "section") private List users; @Builder From 5f67847345183be7aca29f32603e5e615745c748 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8C=E1=85=A5=E1=86=BC=E1=84=8C=E1=85=B5=E1=84=8B?= =?UTF-8?q?=E1=85=AE?= Date: Thu, 17 Feb 2022 01:19:15 +0900 Subject: [PATCH 309/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20(#365)=20Chal?= =?UTF-8?q?lengeRepositoryCustom=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= =?UTF-8?q?,=20=EB=A6=AC=ED=8C=A9=ED=84=B0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/ChallengeRepositoryCustom.java | 1 + .../ChallengeRepositoryCustomImpl.java | 48 ++++++++++++------- 2 files changed, 33 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeRepositoryCustom.java b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeRepositoryCustom.java index 173f1c4af..cab38e825 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeRepositoryCustom.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeRepositoryCustom.java @@ -7,4 +7,5 @@ public interface ChallengeRepositoryCustom { List queryChallenge(User user); + public List queryClosedChallenge(User user); } diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeRepositoryCustomImpl.java index 40ec2b71f..21aac7785 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeRepositoryCustomImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeRepositoryCustomImpl.java @@ -3,6 +3,7 @@ import com.querydsl.jpa.impl.JPAQueryFactory; import com.walkhub.walkhub.domain.challenge.domain.repository.vo.QShowChallengeVO; import com.walkhub.walkhub.domain.challenge.domain.repository.vo.ShowChallengeVO; +import com.walkhub.walkhub.domain.user.domain.QUser; import com.walkhub.walkhub.domain.user.domain.User; import com.walkhub.walkhub.global.enums.UserScope; import lombok.RequiredArgsConstructor; @@ -19,29 +20,44 @@ public class ChallengeRepositoryCustomImpl implements ChallengeRepositoryCustom private final JPAQueryFactory query; @Override - public List queryChallenge(User user1) { + public List queryChallenge(User userParam) { return query - .select(new QShowChallengeVO( - challenge.id.as("challengeId"), - challenge.name, - challenge.startAt, - challenge.endAt, - challenge.imageUrl, - challenge.userScope, - challenge.goalScope, - challenge.goalType, - user.id.as("writerId"), - user.name.as("writerName"), - user.profileImageUrl.as("profileImageUrl") - )) + .select(showChallengeVO()) .from(challenge) .join(challenge.user, user) - .on(user.eq(user1)) .where( - (challenge.userScope.eq(UserScope.ALL).or(challenge.user.school.eq(user1.getSchool()))), + (challenge.userScope.eq(UserScope.ALL).or(challenge.user.school.eq(userParam.getSchool()))), + (challenge.endAt.after(LocalDate.now())) + ) + .fetch(); + } + + @Override + public List queryClosedChallenge(User userParam) { + return query + .select(showChallengeVO()) + .from(challenge) + .join(challenge.user, user) + .where( + (challenge.userScope.eq(UserScope.ALL).or(challenge.user.school.eq(userParam.getSchool()))), (challenge.endAt.before(LocalDate.now())) ) .fetch(); } + private QShowChallengeVO showChallengeVO() { + return new QShowChallengeVO( + challenge.id.as("challengeId"), + challenge.name, + challenge.startAt, + challenge.endAt, + challenge.imageUrl, + challenge.userScope, + challenge.goalScope, + challenge.goalType, + user.id.as("writerId"), + user.name.as("writerName"), + user.profileImageUrl.as("profileImageUrl") + ); + } } From b3b56cf6191fc47fc4276b716232d4c627c10ab6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8C=E1=85=A5=E1=86=BC=E1=84=8C=E1=85=B5=E1=84=8B?= =?UTF-8?q?=E1=85=AE?= Date: Thu, 17 Feb 2022 01:21:02 +0900 Subject: [PATCH 310/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20(#365)=20?= =?UTF-8?q?=EC=A2=85=EB=A3=8C=EB=90=9C=20=EC=B1=8C=EB=A6=B0=EC=A7=80=20?= =?UTF-8?q?=EB=AA=A9=EB=A1=9D=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 --- .../presenstation/ChallengeController.java | 6 ++++ .../service/QueryClosesChallengeService.java | 32 +++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 src/main/java/com/walkhub/walkhub/domain/challenge/service/QueryClosesChallengeService.java diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/ChallengeController.java b/src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/ChallengeController.java index 318a1f799..6a40ef544 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/ChallengeController.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/ChallengeController.java @@ -39,6 +39,7 @@ public class ChallengeController { private final RemoveChallengeService removeChallengeService; private final CreateChallengeService createChallengeService; private final QueryChallengeListService queryChallengeListService; + private final QueryClosesChallengeService queryClosesChallengeService; private final UpdateChallengeService updateChallengeService; private final QueryChallengeDetailsService queryChallengeDetailsService; private final ParticipateChallengeService participateChallengeService; @@ -63,6 +64,11 @@ public QueryChallengeListResponse queryChallengeList() { return queryChallengeListService.execute(); } + @GetMapping("/lists/closed") + public QueryChallengeListResponse queryClosedChallengeList() { + return queryClosesChallengeService.execute(); + } + @ResponseStatus(HttpStatus.NO_CONTENT) @PatchMapping("/{challenge-id}") public void updateChallenge(@PathVariable("challenge-id") Long id, diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/service/QueryClosesChallengeService.java b/src/main/java/com/walkhub/walkhub/domain/challenge/service/QueryClosesChallengeService.java new file mode 100644 index 000000000..5648dda25 --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/service/QueryClosesChallengeService.java @@ -0,0 +1,32 @@ +package com.walkhub.walkhub.domain.challenge.service; + +import com.walkhub.walkhub.domain.challenge.domain.repository.ChallengeStatusRepository; +import com.walkhub.walkhub.domain.challenge.facade.ChallengeFacade; +import com.walkhub.walkhub.domain.challenge.presenstation.dto.response.QueryChallengeListResponse; +import com.walkhub.walkhub.domain.user.facade.UserFacade; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; +import java.util.stream.Collectors; + +@RequiredArgsConstructor +@Service +public class QueryClosesChallengeService { + + private final ChallengeStatusRepository challengeStatusRepository; + private final UserFacade userFacade; + private final ChallengeFacade challengeFacade; + + @Transactional(readOnly = true) + public QueryChallengeListResponse execute() { + + List challengeResponseList = challengeStatusRepository.getAllChallengesByUser(userFacade.getCurrentUser()) + .stream() + .map(challengeFacade::challengeResponseBuilder) + .collect(Collectors.toList()); + + return new QueryChallengeListResponse(challengeResponseList); + } +} From abecfb1a59730febe7f5523621c02697bfd21807 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Thu, 17 Feb 2022 01:21:18 +0900 Subject: [PATCH 311/522] =?UTF-8?q?:recycle:=20::=20refershToken=20?= =?UTF-8?q?=EC=A0=80=EC=9E=A5=20=EB=A1=9C=EC=A7=81=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/auth/service/UserSignInService.java | 11 ----------- ...on.java => VerificationCodeNotFoundException.java} | 2 +- 2 files changed, 1 insertion(+), 12 deletions(-) rename src/main/java/com/walkhub/walkhub/global/exception/{InvalidVerificationCodeException.java => VerificationCodeNotFoundException.java} (89%) diff --git a/src/main/java/com/walkhub/walkhub/domain/auth/service/UserSignInService.java b/src/main/java/com/walkhub/walkhub/domain/auth/service/UserSignInService.java index bc8a31028..cec6a7ee3 100644 --- a/src/main/java/com/walkhub/walkhub/domain/auth/service/UserSignInService.java +++ b/src/main/java/com/walkhub/walkhub/domain/auth/service/UserSignInService.java @@ -1,7 +1,5 @@ package com.walkhub.walkhub.domain.auth.service; -import com.walkhub.walkhub.domain.auth.domain.RefreshToken; -import com.walkhub.walkhub.domain.auth.domain.repository.RefreshTokenRepository; import com.walkhub.walkhub.domain.auth.exception.PasswordMismatchException; import com.walkhub.walkhub.domain.auth.presentation.dto.request.SignInRequest; import com.walkhub.walkhub.domain.auth.presentation.dto.response.UserTokenResponse; @@ -24,7 +22,6 @@ public class UserSignInService { private final UserRepository userRepository; private final JwtProperties jwtProperties; - private final RefreshTokenRepository refreshTokenRepository; private final JwtTokenProvider jwtTokenProvider; private final PasswordEncoder passwordEncoder; @@ -42,14 +39,6 @@ public UserTokenResponse execute(SignInRequest request) { String accessToken = jwtTokenProvider.generateAccessToken(user.getAccountId()); String refreshToken = jwtTokenProvider.generateRefreshToken(user.getAccountId()); - refreshTokenRepository.save( - RefreshToken.builder() - .accountId(user.getAccountId()) - .token(refreshToken) - .timeToLive(jwtProperties.getRefreshExp()) - .build() - ); - return UserTokenResponse.builder() .accessToken(accessToken) .expiredAt(LocalDateTime.now().plusSeconds(jwtProperties.getAccessExp())) diff --git a/src/main/java/com/walkhub/walkhub/global/exception/InvalidVerificationCodeException.java b/src/main/java/com/walkhub/walkhub/global/exception/VerificationCodeNotFoundException.java similarity index 89% rename from src/main/java/com/walkhub/walkhub/global/exception/InvalidVerificationCodeException.java rename to src/main/java/com/walkhub/walkhub/global/exception/VerificationCodeNotFoundException.java index bf77f357f..9886f82a9 100644 --- a/src/main/java/com/walkhub/walkhub/global/exception/InvalidVerificationCodeException.java +++ b/src/main/java/com/walkhub/walkhub/global/exception/VerificationCodeNotFoundException.java @@ -9,6 +9,6 @@ public class InvalidVerificationCodeException extends WalkhubException { new InvalidVerificationCodeException(); private InvalidVerificationCodeException() { - super(ErrorCode.INVALID_VERIFICATION_CODE); + super(ErrorCode.VERIFICATION_CODE_NOT_FOUND); } } From 5b47061017ba47db8db07f5f5cf212bc7cbd9d5f Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Thu, 17 Feb 2022 01:22:07 +0900 Subject: [PATCH 312/522] =?UTF-8?q?:recycle:=20::=20builder=EB=A1=9C=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 --- .../teacher/presentation/dto/response/TokenResponse.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/TokenResponse.java b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/TokenResponse.java index cdc28815a..255c7d884 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/TokenResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/TokenResponse.java @@ -1,10 +1,10 @@ package com.walkhub.walkhub.domain.teacher.presentation.dto.response; +import lombok.Builder; import lombok.Getter; -import lombok.RequiredArgsConstructor; @Getter -@RequiredArgsConstructor +@Builder public class TokenResponse { private final String accessToken; From e56865086b659094be5b5d286e7a7bb204433e3d Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Thu, 17 Feb 2022 01:22:37 +0900 Subject: [PATCH 313/522] =?UTF-8?q?:recycle:=20::=20teacher=20code=20?= =?UTF-8?q?=EB=B6=88=EC=9D=BC=EC=B9=98=ED=95=98=EB=A9=B4=20401=20->=20404?= =?UTF-8?q?=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 --- .../teacher/service/ConfirmTeacherCodeService.java | 9 ++++++--- .../walkhub/global/error/exception/ErrorCode.java | 2 +- .../exception/VerificationCodeNotFoundException.java | 12 ++++++------ 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/service/ConfirmTeacherCodeService.java b/src/main/java/com/walkhub/walkhub/domain/teacher/service/ConfirmTeacherCodeService.java index b7ea89c2c..5e727f92e 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/service/ConfirmTeacherCodeService.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/service/ConfirmTeacherCodeService.java @@ -4,7 +4,7 @@ import com.walkhub.walkhub.domain.teacher.presentation.dto.response.TokenResponse; import com.walkhub.walkhub.domain.user.domain.User; import com.walkhub.walkhub.domain.user.facade.UserFacade; -import com.walkhub.walkhub.global.exception.InvalidVerificationCodeException; +import com.walkhub.walkhub.global.exception.VerificationCodeNotFoundException; import com.walkhub.walkhub.global.security.jwt.JwtTokenProvider; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -22,13 +22,16 @@ public TokenResponse execute(TeacherCodeRequest request) { User user = userFacade.getCurrentUser(); if (!user.getSchool().getAuthCode().equals(request.getCode())) { - throw InvalidVerificationCodeException.EXCEPTION; + throw VerificationCodeNotFoundException.EXCEPTION; } user.setAuthorityTeacher(); String accessToken = jwtTokenProvider.generateAccessToken(user.getAccountId()); String refreshToken = jwtTokenProvider.generateRefreshToken(user.getAccountId()); - return new TokenResponse(accessToken, refreshToken); + return TokenResponse.builder() + .accessToken(accessToken) + .refreshToken(refreshToken) + .build(); } } diff --git a/src/main/java/com/walkhub/walkhub/global/error/exception/ErrorCode.java b/src/main/java/com/walkhub/walkhub/global/error/exception/ErrorCode.java index 8c935f13a..786393251 100644 --- a/src/main/java/com/walkhub/walkhub/global/error/exception/ErrorCode.java +++ b/src/main/java/com/walkhub/walkhub/global/error/exception/ErrorCode.java @@ -21,7 +21,6 @@ public enum ErrorCode { INVALID_SCOPE(401, "CHALLENGE-401-1", "Invalid Scope"), PASSWORD_MISMATCH(401, "AUTH-401-1", "Password Mismatch"), INVALID_ROLE(401, "GLOBAL-401-1", "Invalid Role"), - INVALID_VERIFICATION_CODE(401, "GLOBAL-401-2", "Invalid Verification Code"), FORBIDDEN(403, "COMMON-403-1", "Forbidden"), @@ -31,6 +30,7 @@ public enum ErrorCode { SCHOOL_NOT_FOUND(404, "USER-404-4", "School Not Found"), SECTION_NOT_FOUND(404, "SECTION-404-1", "Section Not Found"), REFRESH_TOKEN_NOT_FOUND(404, "AUTH-404-1", "Refresh Token Not Found"), + VERIFICATION_CODE_NOT_FOUND(404, "GLOBAL-404-1", "Verification Code Not Found"), CHALLENGE_NOT_FOUND(404, "CHALLENGE-404-1", "Challenge Not Found"), diff --git a/src/main/java/com/walkhub/walkhub/global/exception/VerificationCodeNotFoundException.java b/src/main/java/com/walkhub/walkhub/global/exception/VerificationCodeNotFoundException.java index 9886f82a9..35739b166 100644 --- a/src/main/java/com/walkhub/walkhub/global/exception/VerificationCodeNotFoundException.java +++ b/src/main/java/com/walkhub/walkhub/global/exception/VerificationCodeNotFoundException.java @@ -3,12 +3,12 @@ import com.walkhub.walkhub.global.error.exception.ErrorCode; import com.walkhub.walkhub.global.error.exception.WalkhubException; -public class InvalidVerificationCodeException extends WalkhubException { +public class VerificationCodeNotFoundException extends WalkhubException { - public static final WalkhubException EXCEPTION = - new InvalidVerificationCodeException(); + public static final WalkhubException EXCEPTION = + new VerificationCodeNotFoundException(); - private InvalidVerificationCodeException() { - super(ErrorCode.VERIFICATION_CODE_NOT_FOUND); - } + private VerificationCodeNotFoundException() { + super(ErrorCode.VERIFICATION_CODE_NOT_FOUND); + } } From 215acd86547f7ac7bbec2211fce497bdf9eb0406 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B2=94=EC=A7=84?= Date: Thu, 17 Feb 2022 01:22:49 +0900 Subject: [PATCH 314/522] =?UTF-8?q?=E2=99=BB=20::=20duplicate=20import?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/ChallengeStatusRepositoryCustomImpl.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java index e2eb073f4..3627296ab 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java @@ -11,7 +11,6 @@ import com.walkhub.walkhub.domain.challenge.domain.repository.vo.ChallengeParticipantsVO; import com.walkhub.walkhub.domain.challenge.domain.repository.vo.QChallengeParticipantsVO; import com.walkhub.walkhub.domain.challenge.domain.repository.vo.QRelatedChallengeParticipantsVO; -import com.walkhub.walkhub.domain.challenge.domain.repository.vo.RelatedChallengeParticipantsVO; import com.walkhub.walkhub.domain.challenge.domain.repository.vo.QShowChallengeVO; import com.walkhub.walkhub.domain.challenge.domain.repository.vo.RelatedChallengeParticipantsVO; import com.walkhub.walkhub.domain.challenge.domain.repository.vo.ShowChallengeVO; @@ -19,10 +18,9 @@ import com.walkhub.walkhub.domain.challenge.domain.type.SuccessScope; import com.walkhub.walkhub.domain.exercise.domain.type.GoalType; import com.walkhub.walkhub.domain.school.domain.School; -import com.walkhub.walkhub.global.enums.UserScope; import com.walkhub.walkhub.domain.user.domain.User; +import com.walkhub.walkhub.global.enums.UserScope; import lombok.RequiredArgsConstructor; -import org.springframework.data.jpa.repository.Modifying; import java.time.LocalDate; import java.util.List; @@ -118,7 +116,6 @@ public List queryChallengeParticipantsList(Challenge ch } @Override - @Modifying(flushAutomatically = true, clearAutomatically = true) public void deleteNotOverChallengeStatusByUserId(Long userId) { queryFactory .delete(challengeStatus) @@ -129,7 +126,8 @@ public void deleteNotOverChallengeStatusByUserId(Long userId) { ) .execute(); } - + + @Override public List getAllChallengesByUser(User user1) { return queryFactory .select(new QShowChallengeVO( From 224d0debb8f43299bcc7929abd1a78ee99a8887d Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Thu, 17 Feb 2022 01:25:59 +0900 Subject: [PATCH 315/522] =?UTF-8?q?:recycle:=20::=20204=20->=20200?= =?UTF-8?q?=EC=9C=BC=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 --- .../walkhub/domain/teacher/presentation/TeacherController.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/TeacherController.java b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/TeacherController.java index bb0ed649d..fb0b6a946 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/TeacherController.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/TeacherController.java @@ -74,7 +74,6 @@ public QueryUserDetailsResponse queryUserDetails(@PathVariable("user-id") Long u return queryUserDetailsService.execute(userId, startAt, endAt); } - @ResponseStatus(HttpStatus.NO_CONTENT) @PatchMapping("/verification-codes") public TokenResponse confirmTeacherCode(@RequestBody TeacherCodeRequest teacherCodeRequest) { return confirmTeacherCodeService.execute(teacherCodeRequest); From 1497c72d9874561ef18494db833dc9c46bf67613 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8C=E1=85=A5=E1=86=BC=E1=84=8C=E1=85=B5=E1=84=8B?= =?UTF-8?q?=E1=85=AE?= Date: Thu, 17 Feb 2022 01:28:30 +0900 Subject: [PATCH 316/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20(#365)=20Secr?= =?UTF-8?q?utyConfig=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/walkhub/walkhub/global/security/SecurityConfig.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java b/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java index f85ec1e55..a5ad61f8c 100644 --- a/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java +++ b/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java @@ -94,12 +94,13 @@ protected void configure(HttpSecurity http) throws Exception { .antMatchers(HttpMethod.POST, "/challenges").hasAnyAuthority("TEACHER", "ROOT", "SU") .antMatchers(HttpMethod.PATCH, "/challenges/{challenge-id}").hasAnyAuthority("TEACHER", "ROOT", "SU") .antMatchers(HttpMethod.DELETE, "/challenges/{challenge-id}").hasAnyAuthority("TEACHER", "ROOT", "SU") - .antMatchers(HttpMethod.GET, "/challenges/list").authenticated() .antMatchers(HttpMethod.GET, "/challenges/{challenge-id}").authenticated() .antMatchers(HttpMethod.POST, "/challenges/{challenge-id}").authenticated() - .antMatchers(HttpMethod.GET, "/challenges/participated").authenticated() .antMatchers(HttpMethod.GET, "/challenges/{challenge-id}/participants/students").authenticated() .antMatchers(HttpMethod.GET, "/challenges/{challenge-id}/participants/teachers").hasAnyAuthority("TEACHER", "ROOT", "SU") + .antMatchers(HttpMethod.GET, "/challenges/list").authenticated() + .antMatchers(HttpMethod.GET, "/challenges/list/closed").authenticated() + .antMatchers(HttpMethod.GET, "/challenges/participated").authenticated() // images .antMatchers(HttpMethod.POST, "/images").permitAll() From 87770ab858163ce42664319d5534bae7363dce9b Mon Sep 17 00:00:00 2001 From: jhhong0509 Date: Thu, 17 Feb 2022 01:55:58 +0900 Subject: [PATCH 317/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20(#382)=20acco?= =?UTF-8?q?unt-id=20=EC=A4=91=EB=B3=B5=EC=B2=B4=ED=81=AC=20API=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 --- .../auth/presentation/AuthController.java | 21 +++++++++++-------- .../dto/request/CheckAccountIdRequest.java | 13 ++++++++++++ .../service/CheckAccountIdExistsService.java | 17 +++++++++++++++ 3 files changed, 42 insertions(+), 9 deletions(-) create mode 100644 src/main/java/com/walkhub/walkhub/domain/auth/presentation/dto/request/CheckAccountIdRequest.java create mode 100644 src/main/java/com/walkhub/walkhub/domain/auth/service/CheckAccountIdExistsService.java diff --git a/src/main/java/com/walkhub/walkhub/domain/auth/presentation/AuthController.java b/src/main/java/com/walkhub/walkhub/domain/auth/presentation/AuthController.java index b0ccd1e58..efdf96410 100644 --- a/src/main/java/com/walkhub/walkhub/domain/auth/presentation/AuthController.java +++ b/src/main/java/com/walkhub/walkhub/domain/auth/presentation/AuthController.java @@ -1,35 +1,38 @@ package com.walkhub.walkhub.domain.auth.presentation; +import com.walkhub.walkhub.domain.auth.presentation.dto.request.CheckAccountIdRequest; import com.walkhub.walkhub.domain.auth.presentation.dto.request.SignInRequest; import com.walkhub.walkhub.domain.auth.presentation.dto.response.UserAccessTokenResponse; import com.walkhub.walkhub.domain.auth.presentation.dto.response.UserTokenResponse; +import com.walkhub.walkhub.domain.auth.service.CheckAccountIdExistsService; import com.walkhub.walkhub.domain.auth.service.TokenRefreshService; import com.walkhub.walkhub.domain.auth.service.UserSignInService; import lombok.RequiredArgsConstructor; -import org.springframework.web.bind.annotation.PatchMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import javax.validation.Valid; @RequiredArgsConstructor @RestController -@RequestMapping("/users/token") +@RequestMapping("/users") public class AuthController { private final UserSignInService userSignInService; private final TokenRefreshService tokenRefreshService; + private final CheckAccountIdExistsService checkAccountIdExistsService; - @PostMapping + @PostMapping("/token") public UserTokenResponse userSignIn(@RequestBody @Valid SignInRequest request) { return userSignInService.execute(request); } - @PatchMapping + @PatchMapping("/token") public UserAccessTokenResponse userTokenRefresh(@RequestHeader("Refresh-Token") String refreshToken) { return tokenRefreshService.execute(refreshToken); } + + @RequestMapping(value = "/account-id", method = RequestMethod.HEAD) + public void checkAccountIdExists(@RequestBody @Valid CheckAccountIdRequest request) { + checkAccountIdExistsService.execute(request); + } } diff --git a/src/main/java/com/walkhub/walkhub/domain/auth/presentation/dto/request/CheckAccountIdRequest.java b/src/main/java/com/walkhub/walkhub/domain/auth/presentation/dto/request/CheckAccountIdRequest.java new file mode 100644 index 000000000..061815b37 --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/auth/presentation/dto/request/CheckAccountIdRequest.java @@ -0,0 +1,13 @@ +package com.walkhub.walkhub.domain.auth.presentation.dto.request; + +import lombok.Getter; +import lombok.NoArgsConstructor; + +import javax.validation.constraints.NotBlank; + +@Getter +@NoArgsConstructor +public class CheckAccountIdRequest { + @NotBlank(message = "account_id는 Null, 공백, 띄어쓰기를 허용하지 않습니다.") + private String accountId; +} diff --git a/src/main/java/com/walkhub/walkhub/domain/auth/service/CheckAccountIdExistsService.java b/src/main/java/com/walkhub/walkhub/domain/auth/service/CheckAccountIdExistsService.java new file mode 100644 index 000000000..caf71055c --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/auth/service/CheckAccountIdExistsService.java @@ -0,0 +1,17 @@ +package com.walkhub.walkhub.domain.auth.service; + +import com.walkhub.walkhub.domain.auth.presentation.dto.request.CheckAccountIdRequest; +import com.walkhub.walkhub.domain.user.facade.UserFacade; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +@RequiredArgsConstructor +@Service +public class CheckAccountIdExistsService { + + private final UserFacade userFacade; + + public void execute(CheckAccountIdRequest request) { + userFacade.checkUserExists(request.getAccountId()); + } +} From 605331f5a66b67f9ade381b336bad44ac5f5eaa0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B2=94=EC=A7=84?= Date: Thu, 17 Feb 2022 02:05:52 +0900 Subject: [PATCH 318/522] =?UTF-8?q?=F0=9F=93=91=20::=20UserRankFacade?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/rank/facade/UserRankFacade.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/main/java/com/walkhub/walkhub/domain/rank/facade/UserRankFacade.java diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/facade/UserRankFacade.java b/src/main/java/com/walkhub/walkhub/domain/rank/facade/UserRankFacade.java new file mode 100644 index 000000000..38a66c214 --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/rank/facade/UserRankFacade.java @@ -0,0 +1,29 @@ +package com.walkhub.walkhub.domain.rank.facade; + +import com.walkhub.walkhub.domain.rank.domain.repository.vo.UserRankVO; +import com.walkhub.walkhub.domain.rank.presentation.dto.response.UserRankListResponse; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Component; + +import java.util.List; +import java.util.stream.Collectors; + +@RequiredArgsConstructor +@Component +public class UserRankFacade { + + public List buildWeekOrMonthUsersRankResponse(List userRanks) { + return userRanks.stream() + .map(userRank -> UserRankListResponse.UserRankResponse.builder() + .userId(userRank.getUserId()) + .name(userRank.getName()) + .grade(userRank.getGrade()) + .classNum(userRank.getClassNum()) + .ranking(userRank.getRanking()) + .profileImageUrl(userRank.getProfileImageUrl()) + .walkCount(userRank.getWalkCount()) + .build() + ).collect(Collectors.toList()); + } + +} From 1dd179bc7b63dcef4a517607c838157bf57e6fb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B2=94=EC=A7=84?= Date: Thu, 17 Feb 2022 02:06:07 +0900 Subject: [PATCH 319/522] =?UTF-8?q?=E2=9A=A1=20::=20=ED=8D=BC=EC=82=AC?= =?UTF-8?q?=EB=93=9C=20method?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../QueryUserRankListByMySchoolService.java | 21 ++++--------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListByMySchoolService.java b/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListByMySchoolService.java index 87cac98c3..dd0ea6d88 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListByMySchoolService.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListByMySchoolService.java @@ -5,6 +5,7 @@ import com.walkhub.walkhub.domain.rank.domain.repository.UserRankRepository; import com.walkhub.walkhub.domain.rank.domain.repository.vo.UserRankVO; import com.walkhub.walkhub.domain.rank.domain.type.UserRankScope; +import com.walkhub.walkhub.domain.rank.facade.UserRankFacade; import com.walkhub.walkhub.domain.rank.presentation.dto.response.UserRankListResponse; import com.walkhub.walkhub.domain.user.domain.User; import com.walkhub.walkhub.domain.user.facade.UserFacade; @@ -15,7 +16,6 @@ import java.time.LocalDate; import java.util.ArrayList; import java.util.List; -import java.util.stream.Collectors; @RequiredArgsConstructor @Service @@ -23,6 +23,7 @@ public class QueryUserRankListByMySchoolService { private final UserRankRepository userRankRepository; private final ExerciseAnalysisCacheRepository exerciseAnalysisCacheRepository; private final UserFacade userFacade; + private final UserRankFacade userRankFacade; public UserRankListResponse execute(UserRankScope scope, DateType dateType) { User user = userFacade.getCurrentUser(); @@ -38,11 +39,11 @@ public UserRankListResponse execute(UserRankScope scope, DateType dateType) { } else if (scope.equals(UserRankScope.ALL)) { myRank = buildWeekOrMonthMyRankResponse(user.getId(), null, dateType, date); List usersWeekOrMonthRank = userRankRepository.getUserRankListBySchoolId(user.getSchool().getId(), null, dateType, date); - userRankList = buildWeekOrMonthUsersRankResponse(usersWeekOrMonthRank); + userRankList = userRankFacade.buildWeekOrMonthUsersRankResponse(usersWeekOrMonthRank); } else if (scope.equals(UserRankScope.CLASS)) { myRank = buildWeekOrMonthMyRankResponse(user.getId(), user.getSection().getClassNum(), dateType, date); List usersWeekOrMonthRank = userRankRepository.getUserRankListBySchoolId(user.getSchool().getId(), user.getSection().getClassNum(), dateType, date); - userRankList = buildWeekOrMonthUsersRankResponse(usersWeekOrMonthRank); + userRankList = userRankFacade.buildWeekOrMonthUsersRankResponse(usersWeekOrMonthRank); } return UserRankListResponse.builder() .myRank(myRank) @@ -94,18 +95,4 @@ private UserRankListResponse.UserRankResponse buildWeekOrMonthMyRankResponse(Lon .walkCount(myRank.getWalkCount()) .build(); } - - private List buildWeekOrMonthUsersRankResponse(List userRanks) { - return userRanks.stream() - .map(userRank -> UserRankListResponse.UserRankResponse.builder() - .userId(userRank.getUserId()) - .name(userRank.getName()) - .grade(userRank.getGrade()) - .classNum(userRank.getClassNum()) - .ranking(userRank.getRanking()) - .profileImageUrl(userRank.getProfileImageUrl()) - .walkCount(userRank.getWalkCount()) - .build() - ).collect(Collectors.toList()); - } } From cfa4c36b891199dfbd0976828a3abb281aad5f45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B2=94=EC=A7=84?= Date: Thu, 17 Feb 2022 02:07:57 +0900 Subject: [PATCH 320/522] =?UTF-8?q?=F0=9F=93=91=20::=20QueryUserRankListSe?= =?UTF-8?q?rvice?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/QueryUserRankListService.java | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListService.java diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListService.java b/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListService.java new file mode 100644 index 000000000..2dc28acc8 --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListService.java @@ -0,0 +1,33 @@ +package com.walkhub.walkhub.domain.rank.service; + +import com.walkhub.walkhub.domain.rank.domain.repository.UserRankRepository; +import com.walkhub.walkhub.domain.rank.domain.repository.vo.UserRankVO; +import com.walkhub.walkhub.domain.rank.facade.UserRankFacade; +import com.walkhub.walkhub.domain.rank.presentation.dto.response.UserRankListResponse; +import com.walkhub.walkhub.global.enums.DateType; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.time.LocalDate; +import java.util.List; + +@RequiredArgsConstructor +@Service +public class QueryUserRankListService { + + private final UserRankRepository userRankRepository; + private final UserRankFacade userRankFacade; + + @Transactional(readOnly = true) + public UserRankListResponse execute(Long schoolId, DateType dateType) { + LocalDate now = LocalDate.now(); + List usersWeekOrMonthRank = userRankRepository.getUserRankListBySchoolId(schoolId, null, dateType, now); + List rankList = userRankFacade.buildWeekOrMonthUsersRankResponse(usersWeekOrMonthRank); + + return UserRankListResponse.builder() + .rankList(rankList) + .build(); + } + +} From c161898119556e7fe6422b8be3f65b2e437c2732 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B2=94=EC=A7=84?= Date: Thu, 17 Feb 2022 02:08:11 +0900 Subject: [PATCH 321/522] =?UTF-8?q?=E2=9A=A1=20::=20=EB=8B=A4=EB=A5=B8=20?= =?UTF-8?q?=ED=95=99=EA=B5=90=20=EC=9C=A0=EC=A0=80=20=EB=9E=AD=ED=81=AC=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=20=EC=BB=A8=ED=8A=B8=EB=A1=A4=EB=9F=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../walkhub/domain/rank/presentation/RankController.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/presentation/RankController.java b/src/main/java/com/walkhub/walkhub/domain/rank/presentation/RankController.java index 881109b82..1e8e3bc19 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/presentation/RankController.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/presentation/RankController.java @@ -7,6 +7,7 @@ import com.walkhub.walkhub.domain.rank.presentation.dto.response.UserRankListResponse; import com.walkhub.walkhub.domain.rank.service.QueryUserRankListByMySchoolService; import com.walkhub.walkhub.domain.rank.service.QuerySchoolRankService; +import com.walkhub.walkhub.domain.rank.service.QueryUserRankListService; import com.walkhub.walkhub.domain.rank.service.UserSearchService; import com.walkhub.walkhub.global.enums.DateType; import lombok.RequiredArgsConstructor; @@ -24,6 +25,7 @@ public class RankController { private final UserSearchService userSearchService; private final QueryUserRankListByMySchoolService queryUserRankListByMySchoolService; private final QuerySchoolRankService querySchoolRankService; + private final QueryUserRankListService queryUserRankListService; @GetMapping("/users/search/{school-id}") public UserListResponse userSearch(@PathVariable("school-id") Long schoolId, @@ -41,4 +43,10 @@ public SchoolRankResponse querySchoolRank(@RequestParam SchoolDateType dateType) public UserRankListResponse queryUserRankListByMySchool(@RequestParam UserRankScope scope, @RequestParam DateType dateType) { return queryUserRankListByMySchoolService.execute(scope, dateType); } + + @GetMapping("/users/{school-id}") + public UserRankListResponse queryUserRankList(@RequestParam DateType dateType, + @PathVariable("school-id") Long schoolId) { + return queryUserRankListService.execute(schoolId, dateType); + } } From d104a10a86d5e467b9651186e967aa280889a0a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B2=94=EC=A7=84?= Date: Thu, 17 Feb 2022 02:08:22 +0900 Subject: [PATCH 322/522] =?UTF-8?q?=E2=9A=A1=20::=20null=EC=9D=BC=20?= =?UTF-8?q?=EA=B2=BD=EC=9A=B0=20=EB=B0=98=ED=99=98=20x?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rank/presentation/dto/response/UserRankListResponse.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/presentation/dto/response/UserRankListResponse.java b/src/main/java/com/walkhub/walkhub/domain/rank/presentation/dto/response/UserRankListResponse.java index 81067c8d3..4eff771d2 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/presentation/dto/response/UserRankListResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/presentation/dto/response/UserRankListResponse.java @@ -1,5 +1,6 @@ package com.walkhub.walkhub.domain.rank.presentation.dto.response; +import com.fasterxml.jackson.annotation.JsonInclude; import lombok.Builder; import lombok.Getter; @@ -7,6 +8,7 @@ @Getter @Builder +@JsonInclude(JsonInclude.Include.NON_NULL) public class UserRankListResponse { private final UserRankResponse myRank; From b0310e1079f498d8d3a2c863fb6d2b427321f129 Mon Sep 17 00:00:00 2001 From: Jiwoo <63524088+jeongjiwoo0522@users.noreply.github.com> Date: Thu, 17 Feb 2022 02:39:16 +0900 Subject: [PATCH 323/522] =?UTF-8?q?=F0=9F=90=9B=20::=20cors=20=EC=97=90?= =?UTF-8?q?=EB=9F=AC=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/com/walkhub/walkhub/global/web/WebMvcConfig.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/walkhub/walkhub/global/web/WebMvcConfig.java b/src/main/java/com/walkhub/walkhub/global/web/WebMvcConfig.java index fecfc7d49..045cc4e8d 100644 --- a/src/main/java/com/walkhub/walkhub/global/web/WebMvcConfig.java +++ b/src/main/java/com/walkhub/walkhub/global/web/WebMvcConfig.java @@ -11,6 +11,7 @@ public class WebMvcConfig implements WebMvcConfigurer { public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**") .allowedOrigins("*") + .allowedMethods("*") .allowedHeaders("*"); } } From 0f7ba911391a8ac397c2a74e090fccebe01e2168 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Thu, 17 Feb 2022 03:04:34 +0900 Subject: [PATCH 324/522] :recycle: :: GLOBAL -> TEACHER --- .../com/walkhub/walkhub/global/error/exception/ErrorCode.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/global/error/exception/ErrorCode.java b/src/main/java/com/walkhub/walkhub/global/error/exception/ErrorCode.java index 786393251..7fbf29987 100644 --- a/src/main/java/com/walkhub/walkhub/global/error/exception/ErrorCode.java +++ b/src/main/java/com/walkhub/walkhub/global/error/exception/ErrorCode.java @@ -30,7 +30,7 @@ public enum ErrorCode { SCHOOL_NOT_FOUND(404, "USER-404-4", "School Not Found"), SECTION_NOT_FOUND(404, "SECTION-404-1", "Section Not Found"), REFRESH_TOKEN_NOT_FOUND(404, "AUTH-404-1", "Refresh Token Not Found"), - VERIFICATION_CODE_NOT_FOUND(404, "GLOBAL-404-1", "Verification Code Not Found"), + VERIFICATION_CODE_NOT_FOUND(404, "TEACHER-404-1", "Verification Code Not Found"), CHALLENGE_NOT_FOUND(404, "CHALLENGE-404-1", "Challenge Not Found"), From 4284033e6c2b30f0cf027df5309d3290e105d0a5 Mon Sep 17 00:00:00 2001 From: jeongjiwoo0522 Date: Thu, 17 Feb 2022 03:06:29 +0900 Subject: [PATCH 325/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20=EC=82=AC?= =?UTF-8?q?=EC=9A=A9=EB=90=98=EC=A7=80=20=EC=95=8A=EB=8A=94=20import=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/repository/ChallengeRepositoryCustomImpl.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeRepositoryCustomImpl.java index 21aac7785..e5b842b2e 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeRepositoryCustomImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeRepositoryCustomImpl.java @@ -3,7 +3,6 @@ import com.querydsl.jpa.impl.JPAQueryFactory; import com.walkhub.walkhub.domain.challenge.domain.repository.vo.QShowChallengeVO; import com.walkhub.walkhub.domain.challenge.domain.repository.vo.ShowChallengeVO; -import com.walkhub.walkhub.domain.user.domain.QUser; import com.walkhub.walkhub.domain.user.domain.User; import com.walkhub.walkhub.global.enums.UserScope; import lombok.RequiredArgsConstructor; From 5479b68bf1489bd55fa582fd620159a4eb867401 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Thu, 17 Feb 2022 03:07:22 +0900 Subject: [PATCH 326/522] :bookmark_tabs: :: PhoneNumberNotFoundException --- .../exception/PhoneNumberNotFoundException.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/main/java/com/walkhub/walkhub/domain/auth/exception/PhoneNumberNotFoundException.java diff --git a/src/main/java/com/walkhub/walkhub/domain/auth/exception/PhoneNumberNotFoundException.java b/src/main/java/com/walkhub/walkhub/domain/auth/exception/PhoneNumberNotFoundException.java new file mode 100644 index 000000000..75c924a7d --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/auth/exception/PhoneNumberNotFoundException.java @@ -0,0 +1,14 @@ +package com.walkhub.walkhub.domain.auth.exception; + +import com.walkhub.walkhub.global.error.exception.ErrorCode; +import com.walkhub.walkhub.global.error.exception.WalkhubException; + +public class PhoneNumberNotFoundException extends WalkhubException { + + public static final WalkhubException EXCEPTION = + new PhoneNumberNotFoundException(); + + private PhoneNumberNotFoundException() { + super(ErrorCode.PHONE_NUMBER_NOT_FOUND); + } +} From e288e2c53c6229e12cb95a41fd92f54ce931a15a Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Thu, 17 Feb 2022 03:08:15 +0900 Subject: [PATCH 327/522] :bookmark_tabs: :: CHeckAuthCodeRequest --- .../dto/request/CHeckAuthCodeRequest.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/main/java/com/walkhub/walkhub/domain/auth/presentation/dto/request/CHeckAuthCodeRequest.java diff --git a/src/main/java/com/walkhub/walkhub/domain/auth/presentation/dto/request/CHeckAuthCodeRequest.java b/src/main/java/com/walkhub/walkhub/domain/auth/presentation/dto/request/CHeckAuthCodeRequest.java new file mode 100644 index 000000000..6bfe3efb7 --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/auth/presentation/dto/request/CHeckAuthCodeRequest.java @@ -0,0 +1,18 @@ +package com.walkhub.walkhub.domain.auth.presentation.dto.request; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +import javax.validation.constraints.NotBlank; + +@Getter +@AllArgsConstructor +public class CHeckAuthCodeRequest { + + @NotBlank(message = "phone_number는 Null, 공백, 띄어쓰기를 허용하지 않습니다.") + private final String phoneNumber; + + @NotBlank(message = "auth_code는 Null, 공백, 띄어쓰기를 허용하지 않습니다.") + private final String authCode; + +} From 426346776bc687f3d7ec09dd99c891ca837bcb3d Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Thu, 17 Feb 2022 03:08:31 +0900 Subject: [PATCH 328/522] :bookmark_tabs: :: CheckAuthCodeExistsService --- .../service/CheckAuthCodeExistsService.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/main/java/com/walkhub/walkhub/domain/auth/service/CheckAuthCodeExistsService.java diff --git a/src/main/java/com/walkhub/walkhub/domain/auth/service/CheckAuthCodeExistsService.java b/src/main/java/com/walkhub/walkhub/domain/auth/service/CheckAuthCodeExistsService.java new file mode 100644 index 000000000..8216422cd --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/auth/service/CheckAuthCodeExistsService.java @@ -0,0 +1,26 @@ +package com.walkhub.walkhub.domain.auth.service; + +import com.walkhub.walkhub.domain.auth.exception.PhoneNumberNotFoundException; +import com.walkhub.walkhub.domain.auth.presentation.dto.request.CHeckAuthCodeRequest; +import com.walkhub.walkhub.domain.user.domain.UserAuthCode; +import com.walkhub.walkhub.domain.user.domain.repository.UserAuthCodeRepository; +import com.walkhub.walkhub.domain.user.exception.UserAuthCodeNotFoundException; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +@RequiredArgsConstructor +@Service +public class CheckAuthCodeExistsService { + + private final UserAuthCodeRepository userAuthCodeRepository; + + public void execute(CHeckAuthCodeRequest request) { + UserAuthCode authCode = userAuthCodeRepository.findById(request.getPhoneNumber()) + .orElseThrow(() -> PhoneNumberNotFoundException.EXCEPTION); + + if (!authCode.getCode().equals(request.getAuthCode())) { + throw UserAuthCodeNotFoundException.EXCEPTION; + } + } + +} From 9531ee2df74db422c877a2b87a2091103f7e8375 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Thu, 17 Feb 2022 03:09:34 +0900 Subject: [PATCH 329/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20PHONE=5FNUMBE?= =?UTF-8?q?R=5FNOT=5FFOUND=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/walkhub/walkhub/global/error/exception/ErrorCode.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/walkhub/walkhub/global/error/exception/ErrorCode.java b/src/main/java/com/walkhub/walkhub/global/error/exception/ErrorCode.java index 8c935f13a..923d24a8b 100644 --- a/src/main/java/com/walkhub/walkhub/global/error/exception/ErrorCode.java +++ b/src/main/java/com/walkhub/walkhub/global/error/exception/ErrorCode.java @@ -31,6 +31,7 @@ public enum ErrorCode { SCHOOL_NOT_FOUND(404, "USER-404-4", "School Not Found"), SECTION_NOT_FOUND(404, "SECTION-404-1", "Section Not Found"), REFRESH_TOKEN_NOT_FOUND(404, "AUTH-404-1", "Refresh Token Not Found"), + PHONE_NUMBER_NOT_FOUND(404, "USER-404-5", "PhoneNumber Not Found"), CHALLENGE_NOT_FOUND(404, "CHALLENGE-404-1", "Challenge Not Found"), From 6d451dfdfd2ddbd3cea482725b714d701e1a52e7 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Thu, 17 Feb 2022 03:10:04 +0900 Subject: [PATCH 330/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20=EC=A0=84?= =?UTF-8?q?=ED=99=94=EB=B2=88=ED=98=B8=20=EC=9D=B8=EC=A6=9D=20api=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 --- .../domain/auth/presentation/AuthController.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/auth/presentation/AuthController.java b/src/main/java/com/walkhub/walkhub/domain/auth/presentation/AuthController.java index efdf96410..33d6c8b33 100644 --- a/src/main/java/com/walkhub/walkhub/domain/auth/presentation/AuthController.java +++ b/src/main/java/com/walkhub/walkhub/domain/auth/presentation/AuthController.java @@ -1,14 +1,22 @@ package com.walkhub.walkhub.domain.auth.presentation; +import com.walkhub.walkhub.domain.auth.presentation.dto.request.CHeckAuthCodeRequest; import com.walkhub.walkhub.domain.auth.presentation.dto.request.CheckAccountIdRequest; import com.walkhub.walkhub.domain.auth.presentation.dto.request.SignInRequest; import com.walkhub.walkhub.domain.auth.presentation.dto.response.UserAccessTokenResponse; import com.walkhub.walkhub.domain.auth.presentation.dto.response.UserTokenResponse; import com.walkhub.walkhub.domain.auth.service.CheckAccountIdExistsService; +import com.walkhub.walkhub.domain.auth.service.CheckAuthCodeExistsService; import com.walkhub.walkhub.domain.auth.service.TokenRefreshService; import com.walkhub.walkhub.domain.auth.service.UserSignInService; import lombok.RequiredArgsConstructor; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.PatchMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; import javax.validation.Valid; @@ -20,6 +28,7 @@ public class AuthController { private final UserSignInService userSignInService; private final TokenRefreshService tokenRefreshService; private final CheckAccountIdExistsService checkAccountIdExistsService; + private final CheckAuthCodeExistsService checkAuthCodeExistsService; @PostMapping("/token") public UserTokenResponse userSignIn(@RequestBody @Valid SignInRequest request) { @@ -35,4 +44,9 @@ public UserAccessTokenResponse userTokenRefresh(@RequestHeader("Refresh-Token") public void checkAccountIdExists(@RequestBody @Valid CheckAccountIdRequest request) { checkAccountIdExistsService.execute(request); } + + @RequestMapping(value = "verification-codes", method = RequestMethod.HEAD) + public void checkAuthCodeExists(@RequestBody @Valid CHeckAuthCodeRequest request) { + checkAuthCodeExistsService.execute(request); + } } From ca5d38b081331ec703085843ab8b51c0ce2afc2b Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Thu, 17 Feb 2022 03:11:55 +0900 Subject: [PATCH 331/522] =?UTF-8?q?:recycle:=20::=20/=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../walkhub/domain/auth/presentation/AuthController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/auth/presentation/AuthController.java b/src/main/java/com/walkhub/walkhub/domain/auth/presentation/AuthController.java index 33d6c8b33..4970690b2 100644 --- a/src/main/java/com/walkhub/walkhub/domain/auth/presentation/AuthController.java +++ b/src/main/java/com/walkhub/walkhub/domain/auth/presentation/AuthController.java @@ -45,7 +45,7 @@ public void checkAccountIdExists(@RequestBody @Valid CheckAccountIdRequest reque checkAccountIdExistsService.execute(request); } - @RequestMapping(value = "verification-codes", method = RequestMethod.HEAD) + @RequestMapping(value = "/verification-codes", method = RequestMethod.HEAD) public void checkAuthCodeExists(@RequestBody @Valid CHeckAuthCodeRequest request) { checkAuthCodeExistsService.execute(request); } From d35add50340fb423081d5b0bb03e64b37f0cdb79 Mon Sep 17 00:00:00 2001 From: lyutvs Date: Thu, 17 Feb 2022 03:31:03 +0900 Subject: [PATCH 332/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F::=20groupBy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../badge/domain/repository/CustomBadgeRepositoryImpl.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/CustomBadgeRepositoryImpl.java b/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/CustomBadgeRepositoryImpl.java index dc27f4a85..3f3e6f6f1 100644 --- a/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/CustomBadgeRepositoryImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/CustomBadgeRepositoryImpl.java @@ -33,7 +33,6 @@ public List findAllByBadgeCollectionsNotIn(Long userId) { .on(badgeCollection.badge.eq(badge)) .leftJoin(user) .on(badgeCollection.user.eq(user)) - .where(user.isNull().or(user.id.eq(userId).not())) .fetch(); } @@ -49,7 +48,7 @@ public List findAllByBadgeCollections(Long userId) { .from(badge) .leftJoin(badgeCollection.badge, badge) .leftJoin(badgeCollection.user, user) - .on(user.id.eq(userId)) + .groupBy(badge.id) p .fetch(); } From a73afaa2d794db4a27ef036c50656123bc1b5e7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B2=94=EC=A7=84?= Date: Thu, 17 Feb 2022 03:31:22 +0900 Subject: [PATCH 333/522] =?UTF-8?q?=E2=9A=A1=20::=20gradeEq=20filter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rank/domain/repository/UserRankRepositoryCustom.java | 2 +- .../domain/repository/UserRankRepositoryCustomImpl.java | 7 ++++++- .../rank/service/QueryUserRankListByMySchoolService.java | 4 ++-- .../domain/rank/service/QueryUserRankListService.java | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustom.java b/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustom.java index b382c2f2d..94e870a63 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustom.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustom.java @@ -8,5 +8,5 @@ public interface UserRankRepositoryCustom { UserRankVO getMyRankByUserId(Long userId, Integer classNum, DateType dateType, LocalDate date); - List getUserRankListBySchoolId(Long schoolId, Integer classNum, DateType dateType, LocalDate date); + List getUserRankListBySchoolId(Long schoolId, Integer grade, Integer classNum, DateType dateType, LocalDate date); } diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustomImpl.java index b498fd0cc..99777838a 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustomImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustomImpl.java @@ -41,7 +41,7 @@ public UserRankVO getMyRankByUserId(Long userId, Integer classNum, DateType date } @Override - public List getUserRankListBySchoolId(Long schoolId, Integer classNum, DateType dateType, LocalDate date) { + public List getUserRankListBySchoolId(Long schoolId, Integer grade, Integer classNum, DateType dateType, LocalDate date) { return queryFactory .select(new QUserRankVO( userRank.userId, @@ -55,6 +55,7 @@ public List getUserRankListBySchoolId(Long schoolId, Integer classNu .from(userRank) .where( schoolIdEq(schoolId), + gradeEq(grade), classNumEq(classNum), dateTypeEq(dateType), createdAtEq(date) @@ -72,6 +73,10 @@ private BooleanExpression schoolIdEq(Long schoolId) { return schoolId != null ? userRank.schoolId.eq(schoolId) : null; } + private BooleanExpression gradeEq(Integer grade) { + return grade != null ? userRank.scopeType.eq("GRADE").and(userRank.grade.eq(grade)) : userRank.scopeType.eq("SCHOOL"); + } + private BooleanExpression classNumEq(Integer classNum) { return classNum != null ? userRank.scopeType.eq("CLASS").and(userRank.classNum.eq(classNum)) : userRank.scopeType.eq("SCHOOL"); } diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListByMySchoolService.java b/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListByMySchoolService.java index dd0ea6d88..433beb8b4 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListByMySchoolService.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListByMySchoolService.java @@ -38,11 +38,11 @@ public UserRankListResponse execute(UserRankScope scope, DateType dateType) { } } else if (scope.equals(UserRankScope.ALL)) { myRank = buildWeekOrMonthMyRankResponse(user.getId(), null, dateType, date); - List usersWeekOrMonthRank = userRankRepository.getUserRankListBySchoolId(user.getSchool().getId(), null, dateType, date); + List usersWeekOrMonthRank = userRankRepository.getUserRankListBySchoolId(user.getSchool().getId(), user.getSection().getGrade(), null, dateType, date); userRankList = userRankFacade.buildWeekOrMonthUsersRankResponse(usersWeekOrMonthRank); } else if (scope.equals(UserRankScope.CLASS)) { myRank = buildWeekOrMonthMyRankResponse(user.getId(), user.getSection().getClassNum(), dateType, date); - List usersWeekOrMonthRank = userRankRepository.getUserRankListBySchoolId(user.getSchool().getId(), user.getSection().getClassNum(), dateType, date); + List usersWeekOrMonthRank = userRankRepository.getUserRankListBySchoolId(user.getSchool().getId(), user.getSection().getGrade(), user.getSection().getClassNum(), dateType, date); userRankList = userRankFacade.buildWeekOrMonthUsersRankResponse(usersWeekOrMonthRank); } return UserRankListResponse.builder() diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListService.java b/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListService.java index 2dc28acc8..be72a1d79 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListService.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListService.java @@ -22,7 +22,7 @@ public class QueryUserRankListService { @Transactional(readOnly = true) public UserRankListResponse execute(Long schoolId, DateType dateType) { LocalDate now = LocalDate.now(); - List usersWeekOrMonthRank = userRankRepository.getUserRankListBySchoolId(schoolId, null, dateType, now); + List usersWeekOrMonthRank = userRankRepository.getUserRankListBySchoolId(schoolId, null, null, dateType, now); List rankList = userRankFacade.buildWeekOrMonthUsersRankResponse(usersWeekOrMonthRank); return UserRankListResponse.builder() From 14fd94c30f46bc8167adf528fd78ed2acd36209e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B2=94=EC=A7=84?= Date: Thu, 17 Feb 2022 03:40:28 +0900 Subject: [PATCH 334/522] =?UTF-8?q?=E2=9A=A1=20::=20grade=20condition=20at?= =?UTF-8?q?=20my=20rank=20response?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rank/domain/repository/UserRankRepositoryCustom.java | 2 +- .../domain/repository/UserRankRepositoryCustomImpl.java | 2 +- .../rank/service/QueryUserRankListByMySchoolService.java | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustom.java b/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustom.java index 94e870a63..e918900a4 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustom.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustom.java @@ -7,6 +7,6 @@ import java.util.List; public interface UserRankRepositoryCustom { - UserRankVO getMyRankByUserId(Long userId, Integer classNum, DateType dateType, LocalDate date); + UserRankVO getMyRankByUserId(Long userId, Integer grade, Integer classNum, DateType dateType, LocalDate date); List getUserRankListBySchoolId(Long schoolId, Integer grade, Integer classNum, DateType dateType, LocalDate date); } diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustomImpl.java index 99777838a..2c7a9fdef 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustomImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustomImpl.java @@ -74,7 +74,7 @@ private BooleanExpression schoolIdEq(Long schoolId) { } private BooleanExpression gradeEq(Integer grade) { - return grade != null ? userRank.scopeType.eq("GRADE").and(userRank.grade.eq(grade)) : userRank.scopeType.eq("SCHOOL"); + return grade != null ? userRank.grade.eq(grade) : userRank.scopeType.eq("SCHOOL"); } private BooleanExpression classNumEq(Integer classNum) { diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListByMySchoolService.java b/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListByMySchoolService.java index 433beb8b4..93fe1d10e 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListByMySchoolService.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListByMySchoolService.java @@ -37,11 +37,11 @@ public UserRankListResponse execute(UserRankScope scope, DateType dateType) { userRankList.add(buildDayUsersRankResponse(users)); } } else if (scope.equals(UserRankScope.ALL)) { - myRank = buildWeekOrMonthMyRankResponse(user.getId(), null, dateType, date); + myRank = buildWeekOrMonthMyRankResponse(user.getId(), null, null, dateType, date); List usersWeekOrMonthRank = userRankRepository.getUserRankListBySchoolId(user.getSchool().getId(), user.getSection().getGrade(), null, dateType, date); userRankList = userRankFacade.buildWeekOrMonthUsersRankResponse(usersWeekOrMonthRank); } else if (scope.equals(UserRankScope.CLASS)) { - myRank = buildWeekOrMonthMyRankResponse(user.getId(), user.getSection().getClassNum(), dateType, date); + myRank = buildWeekOrMonthMyRankResponse(user.getId(), user.getSection().getGrade(), user.getSection().getClassNum(), dateType, date); List usersWeekOrMonthRank = userRankRepository.getUserRankListBySchoolId(user.getSchool().getId(), user.getSection().getGrade(), user.getSection().getClassNum(), dateType, date); userRankList = userRankFacade.buildWeekOrMonthUsersRankResponse(usersWeekOrMonthRank); } @@ -80,8 +80,8 @@ private UserRankListResponse.UserRankResponse buildDayUsersRankResponse(Exercise .build(); } - private UserRankListResponse.UserRankResponse buildWeekOrMonthMyRankResponse(Long userId, Integer classNum, DateType dateType, LocalDate date) { - UserRankVO myRank = userRankRepository.getMyRankByUserId(userId, classNum, dateType, date); + private UserRankListResponse.UserRankResponse buildWeekOrMonthMyRankResponse(Long userId, Integer grade, Integer classNum, DateType dateType, LocalDate date) { + UserRankVO myRank = userRankRepository.getMyRankByUserId(userId, grade, classNum, dateType, date); if (myRank == null) { return null; } From 35980fcd68e8dde404899c5ebe7d08b65d42d50c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B2=94=EC=A7=84?= Date: Thu, 17 Feb 2022 03:44:22 +0900 Subject: [PATCH 335/522] =?UTF-8?q?=F0=9F=90=9B=20::=20=EB=B9=A0=EC=A7=84?= =?UTF-8?q?=20=ED=8C=8C=EB=9D=BC=EB=AF=B8=ED=84=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rank/domain/repository/UserRankRepositoryCustomImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustomImpl.java index 2c7a9fdef..610f800a4 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustomImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustomImpl.java @@ -19,7 +19,7 @@ public class UserRankRepositoryCustomImpl implements UserRankRepositoryCustom { private static final Long LIMIT = 100L; @Override - public UserRankVO getMyRankByUserId(Long userId, Integer classNum, DateType dateType, LocalDate date) { + public UserRankVO getMyRankByUserId(Long userId, Integer grade, Integer classNum, DateType dateType, LocalDate date) { return queryFactory .select(new QUserRankVO( userRank.userId, From c00eabb1dc26a08aeba6fe1c122d125aa20757a3 Mon Sep 17 00:00:00 2001 From: lyutvs Date: Thu, 17 Feb 2022 03:47:22 +0900 Subject: [PATCH 336/522] =?UTF-8?q?=F0=9F=90=9B::=20=EC=98=A4=ED=83=80?= =?UTF-8?q?=EC=98=A4=ED=83=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../badge/domain/repository/CustomBadgeRepositoryImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/CustomBadgeRepositoryImpl.java b/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/CustomBadgeRepositoryImpl.java index 3f3e6f6f1..d543dd757 100644 --- a/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/CustomBadgeRepositoryImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/CustomBadgeRepositoryImpl.java @@ -48,7 +48,7 @@ public List findAllByBadgeCollections(Long userId) { .from(badge) .leftJoin(badgeCollection.badge, badge) .leftJoin(badgeCollection.user, user) - .groupBy(badge.id) p + .groupBy(badge.id) .fetch(); } From ee56c6460beaa6a020b92c9f65427cea232b50ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B2=94=EC=A7=84?= Date: Thu, 17 Feb 2022 04:19:28 +0900 Subject: [PATCH 337/522] =?UTF-8?q?=E2=9A=A1=20::=20=EB=B9=84=EA=B5=90=20?= =?UTF-8?q?=ED=95=9C=20=EB=B2=88=EB=A7=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rank/domain/repository/UserRankRepositoryCustomImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustomImpl.java index 610f800a4..5dac10207 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustomImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustomImpl.java @@ -74,7 +74,7 @@ private BooleanExpression schoolIdEq(Long schoolId) { } private BooleanExpression gradeEq(Integer grade) { - return grade != null ? userRank.grade.eq(grade) : userRank.scopeType.eq("SCHOOL"); + return grade != null ? userRank.grade.eq(grade) : null; } private BooleanExpression classNumEq(Integer classNum) { From d7a88772ffa4bc568467c12aac3566f9294e4b1b Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Thu, 17 Feb 2022 04:22:37 +0900 Subject: [PATCH 338/522] =?UTF-8?q?:recycle:=20::=20=EC=B1=8C=EB=A6=B0?= =?UTF-8?q?=EC=A7=80=20=EC=83=9D=EC=84=B1=20=EC=8B=9C=20=EB=B0=98=20?= =?UTF-8?q?=EC=A0=80=EC=9E=A5=EC=95=88=EB=90=98=EB=8A=94=20=EC=97=90?= =?UTF-8?q?=EB=9F=AC=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../walkhub/domain/teacher/service/CreateClassService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/service/CreateClassService.java b/src/main/java/com/walkhub/walkhub/domain/teacher/service/CreateClassService.java index 8c3d49b66..5ffbe73d2 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/service/CreateClassService.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/service/CreateClassService.java @@ -36,8 +36,8 @@ public CodeResponse execute(CreateClassRequest request) { .build(); try { - sectionRepository.save(section); - user.setSection(section); + Section savedSection = sectionRepository.save(section); + user.setSection(savedSection); } catch (DataIntegrityViolationException e) { throw AlreadyCreatedException.EXCEPTION; } From 5a3b1485f84a8c32a13ab80d828f1bf28b43da6d Mon Sep 17 00:00:00 2001 From: jhhong0509 Date: Thu, 17 Feb 2022 04:23:00 +0900 Subject: [PATCH 339/522] =?UTF-8?q?:bug:=20::=20(#387)=20@DateTimeFormatte?= =?UTF-8?q?r=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/dto/response/ExerciseListResponse.java | 3 +++ .../presentation/dto/response/QueryNoticeListResponse.java | 3 +++ .../presentation/dto/response/QueryUserDetailsResponse.java | 2 ++ 3 files changed, 8 insertions(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/response/ExerciseListResponse.java b/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/response/ExerciseListResponse.java index e5f3d327d..ad91e385b 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/response/ExerciseListResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/response/ExerciseListResponse.java @@ -6,6 +6,7 @@ import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; +import org.springframework.format.annotation.DateTimeFormat; @Getter @AllArgsConstructor @@ -18,6 +19,8 @@ public class ExerciseListResponse { public static class ExerciseResponse { private final Long exerciseId; private final String imageUrl; + + @DateTimeFormat(pattern = "yyyy-MM-ddThh:mm:SS") private final LocalDateTime startAt; private final BigDecimal latitude; private final BigDecimal longitude; diff --git a/src/main/java/com/walkhub/walkhub/domain/notice/presentation/dto/response/QueryNoticeListResponse.java b/src/main/java/com/walkhub/walkhub/domain/notice/presentation/dto/response/QueryNoticeListResponse.java index 59bc56c4e..317f39016 100644 --- a/src/main/java/com/walkhub/walkhub/domain/notice/presentation/dto/response/QueryNoticeListResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/notice/presentation/dto/response/QueryNoticeListResponse.java @@ -6,6 +6,7 @@ import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; +import org.springframework.format.annotation.DateTimeFormat; @Getter @AllArgsConstructor @@ -19,6 +20,8 @@ public static class NoticeResponse { private final Long id; private final String title; private final String content; + + @DateTimeFormat(pattern = "yyyy-MM-ddThh:mm:SS") private final LocalDateTime createdAt; private final Writer writer; } diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/QueryUserDetailsResponse.java b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/QueryUserDetailsResponse.java index 5cada11fc..45ded89cd 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/QueryUserDetailsResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/QueryUserDetailsResponse.java @@ -5,6 +5,7 @@ import java.util.List; import lombok.Builder; import lombok.Getter; +import org.springframework.format.annotation.DateTimeFormat; @Getter @Builder @@ -22,6 +23,7 @@ public class QueryUserDetailsResponse { @Builder public static class ExerciseResponse { private final String imageUrl; + @DateTimeFormat(pattern = "yyyy-MM-ddThh:mm:SS") private final LocalDateTime startAt; private final BigDecimal latitude; private final BigDecimal longitude; From b7f50ef4e0340fb9101949751b7393da9f61761d Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Thu, 17 Feb 2022 04:26:43 +0900 Subject: [PATCH 340/522] :recycle: :: AllArgs -> NoArgs --- ...uthCodeRequest.java => CheckAuthCodeRequest.java} | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) rename src/main/java/com/walkhub/walkhub/domain/auth/presentation/dto/request/{CHeckAuthCodeRequest.java => CheckAuthCodeRequest.java} (67%) diff --git a/src/main/java/com/walkhub/walkhub/domain/auth/presentation/dto/request/CHeckAuthCodeRequest.java b/src/main/java/com/walkhub/walkhub/domain/auth/presentation/dto/request/CheckAuthCodeRequest.java similarity index 67% rename from src/main/java/com/walkhub/walkhub/domain/auth/presentation/dto/request/CHeckAuthCodeRequest.java rename to src/main/java/com/walkhub/walkhub/domain/auth/presentation/dto/request/CheckAuthCodeRequest.java index 6bfe3efb7..b18ab1610 100644 --- a/src/main/java/com/walkhub/walkhub/domain/auth/presentation/dto/request/CHeckAuthCodeRequest.java +++ b/src/main/java/com/walkhub/walkhub/domain/auth/presentation/dto/request/CheckAuthCodeRequest.java @@ -1,18 +1,18 @@ package com.walkhub.walkhub.domain.auth.presentation.dto.request; -import lombok.AllArgsConstructor; import lombok.Getter; +import lombok.NoArgsConstructor; import javax.validation.constraints.NotBlank; @Getter -@AllArgsConstructor -public class CHeckAuthCodeRequest { +@NoArgsConstructor +public class CheckAuthCodeRequest { @NotBlank(message = "phone_number는 Null, 공백, 띄어쓰기를 허용하지 않습니다.") - private final String phoneNumber; + private String phoneNumber; @NotBlank(message = "auth_code는 Null, 공백, 띄어쓰기를 허용하지 않습니다.") - private final String authCode; - + private String authCode; + } From 97dc651100738dd089d9ab66fa73af025a524765 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Thu, 17 Feb 2022 04:27:11 +0900 Subject: [PATCH 341/522] :recycle: :: CHeckAuthCodeRequest -> CheckAuthCodeRequest --- .../walkhub/domain/auth/presentation/AuthController.java | 4 ++-- .../domain/auth/service/CheckAuthCodeExistsService.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/auth/presentation/AuthController.java b/src/main/java/com/walkhub/walkhub/domain/auth/presentation/AuthController.java index 4970690b2..a72c98bcf 100644 --- a/src/main/java/com/walkhub/walkhub/domain/auth/presentation/AuthController.java +++ b/src/main/java/com/walkhub/walkhub/domain/auth/presentation/AuthController.java @@ -1,6 +1,6 @@ package com.walkhub.walkhub.domain.auth.presentation; -import com.walkhub.walkhub.domain.auth.presentation.dto.request.CHeckAuthCodeRequest; +import com.walkhub.walkhub.domain.auth.presentation.dto.request.CheckAuthCodeRequest; import com.walkhub.walkhub.domain.auth.presentation.dto.request.CheckAccountIdRequest; import com.walkhub.walkhub.domain.auth.presentation.dto.request.SignInRequest; import com.walkhub.walkhub.domain.auth.presentation.dto.response.UserAccessTokenResponse; @@ -46,7 +46,7 @@ public void checkAccountIdExists(@RequestBody @Valid CheckAccountIdRequest reque } @RequestMapping(value = "/verification-codes", method = RequestMethod.HEAD) - public void checkAuthCodeExists(@RequestBody @Valid CHeckAuthCodeRequest request) { + public void checkAuthCodeExists(@RequestBody @Valid CheckAuthCodeRequest request) { checkAuthCodeExistsService.execute(request); } } diff --git a/src/main/java/com/walkhub/walkhub/domain/auth/service/CheckAuthCodeExistsService.java b/src/main/java/com/walkhub/walkhub/domain/auth/service/CheckAuthCodeExistsService.java index 8216422cd..9f396984c 100644 --- a/src/main/java/com/walkhub/walkhub/domain/auth/service/CheckAuthCodeExistsService.java +++ b/src/main/java/com/walkhub/walkhub/domain/auth/service/CheckAuthCodeExistsService.java @@ -1,7 +1,7 @@ package com.walkhub.walkhub.domain.auth.service; import com.walkhub.walkhub.domain.auth.exception.PhoneNumberNotFoundException; -import com.walkhub.walkhub.domain.auth.presentation.dto.request.CHeckAuthCodeRequest; +import com.walkhub.walkhub.domain.auth.presentation.dto.request.CheckAuthCodeRequest; import com.walkhub.walkhub.domain.user.domain.UserAuthCode; import com.walkhub.walkhub.domain.user.domain.repository.UserAuthCodeRepository; import com.walkhub.walkhub.domain.user.exception.UserAuthCodeNotFoundException; @@ -14,7 +14,7 @@ public class CheckAuthCodeExistsService { private final UserAuthCodeRepository userAuthCodeRepository; - public void execute(CHeckAuthCodeRequest request) { + public void execute(CheckAuthCodeRequest request) { UserAuthCode authCode = userAuthCodeRepository.findById(request.getPhoneNumber()) .orElseThrow(() -> PhoneNumberNotFoundException.EXCEPTION); From e0cdbbf280db52950b73d7f97b6670a16377d27a Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Thu, 17 Feb 2022 04:59:28 +0900 Subject: [PATCH 342/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20section=20nul?= =?UTF-8?q?l=20error=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../walkhub/domain/teacher/service/ClassListService.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/service/ClassListService.java b/src/main/java/com/walkhub/walkhub/domain/teacher/service/ClassListService.java index b3ff489db..0302b5c31 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/service/ClassListService.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/service/ClassListService.java @@ -8,6 +8,7 @@ import com.walkhub.walkhub.domain.user.domain.Section; import com.walkhub.walkhub.domain.user.domain.User; import com.walkhub.walkhub.domain.user.domain.repository.UserRepository; +import com.walkhub.walkhub.domain.user.exception.AlreadyJoinedException; import com.walkhub.walkhub.domain.user.facade.UserFacade; import com.walkhub.walkhub.global.enums.Authority; import lombok.RequiredArgsConstructor; @@ -27,6 +28,11 @@ public class ClassListService { @Transactional(readOnly = true) public ClassListResponse execute() { User user = userFacade.getCurrentUser(); + + if (!user.hasSection()) { + throw AlreadyJoinedException.EXCEPTION; + } + School school = user.getSchool(); List classList = school.getSections() From aa2bdceab35869809f6f45e7c7f6478fdb2a1425 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Thu, 17 Feb 2022 04:59:46 +0900 Subject: [PATCH 343/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20ROOT=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/walkhub/walkhub/global/security/SecurityConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java b/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java index d2c480585..8a86dfcb2 100644 --- a/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java +++ b/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java @@ -113,7 +113,7 @@ protected void configure(HttpSecurity http) throws Exception { // teachers .antMatchers(HttpMethod.POST, "/teachers/verification-codes").hasAuthority("ROOT") .antMatchers(HttpMethod.PATCH, "/teachers/verification-codes").hasAuthority("USER") - .antMatchers(HttpMethod.POST, "/teachers/classes").hasAnyAuthority("TEACHER", "ROOT") + .antMatchers(HttpMethod.POST, "/teachers/classes").hasAuthority("TEACHER") .antMatchers(HttpMethod.GET, "/teachers/classes/lists").hasAnyAuthority("TEACHER", "ROOT") .antMatchers(HttpMethod.DELETE, "/teachers/classes/{section-id}").hasAnyAuthority("TEACHER", "ROOT") .antMatchers(HttpMethod.GET, "/teachers/classes").hasAuthority("TEACHER") From a1cd6e4648ce67436d81b449893a75a58e2cbe8e Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Thu, 17 Feb 2022 05:02:32 +0900 Subject: [PATCH 344/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20!=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../walkhub/domain/teacher/service/ClassListService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/service/ClassListService.java b/src/main/java/com/walkhub/walkhub/domain/teacher/service/ClassListService.java index 0302b5c31..fd9735117 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/service/ClassListService.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/service/ClassListService.java @@ -29,7 +29,7 @@ public class ClassListService { public ClassListResponse execute() { User user = userFacade.getCurrentUser(); - if (!user.hasSection()) { + if (user.hasSection()) { throw AlreadyJoinedException.EXCEPTION; } From 62b9713fae979fe9ef9d84187c08f09e01dac5e5 Mon Sep 17 00:00:00 2001 From: jhhong0509 Date: Thu, 17 Feb 2022 05:14:20 +0900 Subject: [PATCH 345/522] =?UTF-8?q?:bug:=20::=20(#387)=20JsonFormat?= =?UTF-8?q?=EC=9C=BC=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 --- .../presentation/dto/response/UserAccessTokenResponse.java | 3 ++- .../auth/presentation/dto/response/UserTokenResponse.java | 3 ++- .../presentation/dto/response/ExerciseListResponse.java | 5 +++-- .../presentation/dto/response/QueryNoticeListResponse.java | 4 +++- .../presentation/dto/response/QueryUserDetailsResponse.java | 4 +++- src/main/resources/application.yml | 2 ++ 6 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/auth/presentation/dto/response/UserAccessTokenResponse.java b/src/main/java/com/walkhub/walkhub/domain/auth/presentation/dto/response/UserAccessTokenResponse.java index 7b345fc87..3f9804a35 100644 --- a/src/main/java/com/walkhub/walkhub/domain/auth/presentation/dto/response/UserAccessTokenResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/auth/presentation/dto/response/UserAccessTokenResponse.java @@ -1,5 +1,6 @@ package com.walkhub.walkhub.domain.auth.presentation.dto.response; +import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Builder; import lombok.Getter; import org.springframework.format.annotation.DateTimeFormat; @@ -12,6 +13,6 @@ public class UserAccessTokenResponse { private final String accessToken; - @DateTimeFormat(pattern = "yyyy-MM-ddThh:mm:SS") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'hh:mm:SS") private final LocalDateTime expiredAt; } diff --git a/src/main/java/com/walkhub/walkhub/domain/auth/presentation/dto/response/UserTokenResponse.java b/src/main/java/com/walkhub/walkhub/domain/auth/presentation/dto/response/UserTokenResponse.java index db231dded..e0402343e 100644 --- a/src/main/java/com/walkhub/walkhub/domain/auth/presentation/dto/response/UserTokenResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/auth/presentation/dto/response/UserTokenResponse.java @@ -1,5 +1,6 @@ package com.walkhub.walkhub.domain.auth.presentation.dto.response; +import com.fasterxml.jackson.annotation.JsonFormat; import com.walkhub.walkhub.domain.user.domain.type.Sex; import com.walkhub.walkhub.global.enums.Authority; import lombok.Builder; @@ -14,7 +15,7 @@ public class UserTokenResponse { private final String accessToken; - @DateTimeFormat(pattern = "yyyy-MM-ddThh:mm:SS") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'hh:mm:SS") private final LocalDateTime expiredAt; private final String refreshToken; private final Authority authority; diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/response/ExerciseListResponse.java b/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/response/ExerciseListResponse.java index ad91e385b..69274bb33 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/response/ExerciseListResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/response/ExerciseListResponse.java @@ -3,6 +3,8 @@ import java.math.BigDecimal; import java.time.LocalDateTime; import java.util.List; + +import com.fasterxml.jackson.annotation.JsonFormat; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; @@ -19,8 +21,7 @@ public class ExerciseListResponse { public static class ExerciseResponse { private final Long exerciseId; private final String imageUrl; - - @DateTimeFormat(pattern = "yyyy-MM-ddThh:mm:SS") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'hh:mm:SS") private final LocalDateTime startAt; private final BigDecimal latitude; private final BigDecimal longitude; diff --git a/src/main/java/com/walkhub/walkhub/domain/notice/presentation/dto/response/QueryNoticeListResponse.java b/src/main/java/com/walkhub/walkhub/domain/notice/presentation/dto/response/QueryNoticeListResponse.java index 317f39016..1722b0083 100644 --- a/src/main/java/com/walkhub/walkhub/domain/notice/presentation/dto/response/QueryNoticeListResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/notice/presentation/dto/response/QueryNoticeListResponse.java @@ -3,6 +3,8 @@ import java.time.LocalDateTime; import java.util.List; + +import com.fasterxml.jackson.annotation.JsonFormat; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; @@ -21,7 +23,7 @@ public static class NoticeResponse { private final String title; private final String content; - @DateTimeFormat(pattern = "yyyy-MM-ddThh:mm:SS") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'hh:mm:SS") private final LocalDateTime createdAt; private final Writer writer; } diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/QueryUserDetailsResponse.java b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/QueryUserDetailsResponse.java index 45ded89cd..725c0ad17 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/QueryUserDetailsResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/QueryUserDetailsResponse.java @@ -3,6 +3,8 @@ import java.math.BigDecimal; import java.time.LocalDateTime; import java.util.List; + +import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Builder; import lombok.Getter; import org.springframework.format.annotation.DateTimeFormat; @@ -23,7 +25,7 @@ public class QueryUserDetailsResponse { @Builder public static class ExerciseResponse { private final String imageUrl; - @DateTimeFormat(pattern = "yyyy-MM-ddThh:mm:SS") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'hh:mm:SS") private final LocalDateTime startAt; private final BigDecimal latitude; private final BigDecimal longitude; diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index a794edb91..f5c035b84 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -53,6 +53,8 @@ spring: jdbc: initialize-schema: always table-prefix: BATCH_ + profiles: + active: local coolsms: key: ${SMS_KEY} From 1ed03146c75ab19d2dd1a4e17ed62c7a6a6ce291 Mon Sep 17 00:00:00 2001 From: jhhong0509 Date: Thu, 17 Feb 2022 05:16:39 +0900 Subject: [PATCH 346/522] =?UTF-8?q?:bug:=20::=20(#387)=20profile:=20local?= =?UTF-8?q?=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/application.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index f5c035b84..a794edb91 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -53,8 +53,6 @@ spring: jdbc: initialize-schema: always table-prefix: BATCH_ - profiles: - active: local coolsms: key: ${SMS_KEY} From 7d906eeac04faf70812e9e4a84ab6b80028139a7 Mon Sep 17 00:00:00 2001 From: jhhong0509 Date: Thu, 17 Feb 2022 05:19:16 +0900 Subject: [PATCH 347/522] =?UTF-8?q?:bug:=20::=20(#387)=20CodeSmell=20?= =?UTF-8?q?=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/response/UserAccessTokenResponse.java | 1 - .../dto/response/UserTokenResponse.java | 1 - .../dto/response/ExerciseListResponse.java | 31 ++++++------ .../dto/response/QueryNoticeListResponse.java | 49 +++++++++---------- .../response/QueryUserDetailsResponse.java | 43 ++++++++-------- 5 files changed, 60 insertions(+), 65 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/auth/presentation/dto/response/UserAccessTokenResponse.java b/src/main/java/com/walkhub/walkhub/domain/auth/presentation/dto/response/UserAccessTokenResponse.java index 3f9804a35..b113d1647 100644 --- a/src/main/java/com/walkhub/walkhub/domain/auth/presentation/dto/response/UserAccessTokenResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/auth/presentation/dto/response/UserAccessTokenResponse.java @@ -3,7 +3,6 @@ import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Builder; import lombok.Getter; -import org.springframework.format.annotation.DateTimeFormat; import java.time.LocalDateTime; diff --git a/src/main/java/com/walkhub/walkhub/domain/auth/presentation/dto/response/UserTokenResponse.java b/src/main/java/com/walkhub/walkhub/domain/auth/presentation/dto/response/UserTokenResponse.java index e0402343e..93e003cf7 100644 --- a/src/main/java/com/walkhub/walkhub/domain/auth/presentation/dto/response/UserTokenResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/auth/presentation/dto/response/UserTokenResponse.java @@ -5,7 +5,6 @@ import com.walkhub.walkhub.global.enums.Authority; import lombok.Builder; import lombok.Getter; -import org.springframework.format.annotation.DateTimeFormat; import java.math.BigDecimal; import java.time.LocalDateTime; diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/response/ExerciseListResponse.java b/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/response/ExerciseListResponse.java index 69274bb33..41ece0af2 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/response/ExerciseListResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/response/ExerciseListResponse.java @@ -1,29 +1,28 @@ package com.walkhub.walkhub.domain.exercise.presentation.dto.response; -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.List; - import com.fasterxml.jackson.annotation.JsonFormat; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; -import org.springframework.format.annotation.DateTimeFormat; + +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.util.List; @Getter @AllArgsConstructor public class ExerciseListResponse { - private final List exerciseList; + private final List exerciseList; - @Getter - @Builder - public static class ExerciseResponse { - private final Long exerciseId; - private final String imageUrl; - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'hh:mm:SS") - private final LocalDateTime startAt; - private final BigDecimal latitude; - private final BigDecimal longitude; - } + @Getter + @Builder + public static class ExerciseResponse { + private final Long exerciseId; + private final String imageUrl; + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'hh:mm:SS") + private final LocalDateTime startAt; + private final BigDecimal latitude; + private final BigDecimal longitude; + } } diff --git a/src/main/java/com/walkhub/walkhub/domain/notice/presentation/dto/response/QueryNoticeListResponse.java b/src/main/java/com/walkhub/walkhub/domain/notice/presentation/dto/response/QueryNoticeListResponse.java index 1722b0083..eb7f083c4 100644 --- a/src/main/java/com/walkhub/walkhub/domain/notice/presentation/dto/response/QueryNoticeListResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/notice/presentation/dto/response/QueryNoticeListResponse.java @@ -1,38 +1,37 @@ package com.walkhub.walkhub.domain.notice.presentation.dto.response; -import java.time.LocalDateTime; -import java.util.List; - import com.fasterxml.jackson.annotation.JsonFormat; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; -import org.springframework.format.annotation.DateTimeFormat; + +import java.time.LocalDateTime; +import java.util.List; @Getter @AllArgsConstructor public class QueryNoticeListResponse { - public final List noticeList; - - @Getter - @Builder - public static class NoticeResponse { - private final Long id; - private final String title; - private final String content; - - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'hh:mm:SS") - private final LocalDateTime createdAt; - private final Writer writer; - } - - @Getter - @Builder - public static class Writer { - private final Long id; - private final String name; - private final String profileImageUrl; - } + public final List noticeList; + + @Getter + @Builder + public static class NoticeResponse { + private final Long id; + private final String title; + private final String content; + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'hh:mm:SS") + private final LocalDateTime createdAt; + private final Writer writer; + } + + @Getter + @Builder + public static class Writer { + private final Long id; + private final String name; + private final String profileImageUrl; + } } diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/QueryUserDetailsResponse.java b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/QueryUserDetailsResponse.java index 725c0ad17..e4c20b4b5 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/QueryUserDetailsResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/QueryUserDetailsResponse.java @@ -1,33 +1,32 @@ package com.walkhub.walkhub.domain.teacher.presentation.dto.response; -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.List; - import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Builder; import lombok.Getter; -import org.springframework.format.annotation.DateTimeFormat; + +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.util.List; @Getter @Builder public class QueryUserDetailsResponse { - private final Long userId; - private final String name; - private final String profileImageUrl; - private final Integer grade; - private final Integer classNum; - private final Integer number; - private final List walkCountList; - private final List exerciseList; + private final Long userId; + private final String name; + private final String profileImageUrl; + private final Integer grade; + private final Integer classNum; + private final Integer number; + private final List walkCountList; + private final List exerciseList; - @Getter - @Builder - public static class ExerciseResponse { - private final String imageUrl; - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'hh:mm:SS") - private final LocalDateTime startAt; - private final BigDecimal latitude; - private final BigDecimal longitude; - } + @Getter + @Builder + public static class ExerciseResponse { + private final String imageUrl; + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'hh:mm:SS") + private final LocalDateTime startAt; + private final BigDecimal latitude; + private final BigDecimal longitude; + } } From afe137cfdff66ee32bc2c591e1870e3e2a5fdcda Mon Sep 17 00:00:00 2001 From: jeongjiwoo0522 Date: Thu, 17 Feb 2022 05:26:47 +0900 Subject: [PATCH 348/522] =?UTF-8?q?=F0=9F=90=9B=20::=20(#331)=20query=20?= =?UTF-8?q?=EC=A0=9C=EB=8C=80=EB=A1=9C=20=EC=8B=A4=ED=96=89=EB=90=98?= =?UTF-8?q?=EA=B2=8C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../badge/domain/repository/CustomBadgeRepositoryImpl.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/CustomBadgeRepositoryImpl.java b/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/CustomBadgeRepositoryImpl.java index d543dd757..0558e8298 100644 --- a/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/CustomBadgeRepositoryImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/CustomBadgeRepositoryImpl.java @@ -38,16 +38,17 @@ public List findAllByBadgeCollectionsNotIn(Long userId) { @Override public List findAllByBadgeCollections(Long userId) { + Object max; return query .select(new QMyBadgeVo( badge.id, badge.name, badge.imageUrl, - user.id.eq(userId) + user.id.max().eq(userId) )) .from(badge) - .leftJoin(badgeCollection.badge, badge) - .leftJoin(badgeCollection.user, user) + .leftJoin(badge.badgeCollections, badgeCollection) + .leftJoin(badgeCollection.user, user).on(user.id.eq(userId)) .groupBy(badge.id) .fetch(); } From 0317848ef46c8f4c233d0bcf8ce202da1a534e4d Mon Sep 17 00:00:00 2001 From: jeongjiwoo0522 Date: Thu, 17 Feb 2022 05:37:24 +0900 Subject: [PATCH 349/522] =?UTF-8?q?=F0=9F=90=9B=20::=20(#331)=20=08refacto?= =?UTF-8?q?ring?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../badge/domain/repository/CustomBadgeRepositoryImpl.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/CustomBadgeRepositoryImpl.java b/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/CustomBadgeRepositoryImpl.java index 0558e8298..6f9d92ece 100644 --- a/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/CustomBadgeRepositoryImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/badge/domain/repository/CustomBadgeRepositoryImpl.java @@ -38,7 +38,6 @@ public List findAllByBadgeCollectionsNotIn(Long userId) { @Override public List findAllByBadgeCollections(Long userId) { - Object max; return query .select(new QMyBadgeVo( badge.id, From 96f32cf0d54fd8fd68fa91d70a0773df4b44f635 Mon Sep 17 00:00:00 2001 From: jhhong0509 Date: Thu, 17 Feb 2022 06:49:53 +0900 Subject: [PATCH 350/522] =?UTF-8?q?:bug:=20::=20(#394)=20Repository?= =?UTF-8?q?=EC=97=90=20exp=20=EC=84=A4=EC=A0=95,=20Key=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 --- .../ExerciseAnalysisCacheRepository.java | 6 ++-- .../ExerciseAnalysisCacheRepositoryImpl.java | 29 ++++++++++--------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/cache/ExerciseAnalysisCacheRepository.java b/src/main/java/com/walkhub/walkhub/domain/exercise/cache/ExerciseAnalysisCacheRepository.java index 99ee4ac78..d6269dc64 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/cache/ExerciseAnalysisCacheRepository.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/cache/ExerciseAnalysisCacheRepository.java @@ -3,9 +3,9 @@ import java.util.List; public interface ExerciseAnalysisCacheRepository { - void saveExerciseCache(Long userId, Double walkCount); + void saveExerciseCache(Long schoolId, Long userId, Double walkCount); - ExerciseAnalysisDto getUserTodayRank(Long userId); + ExerciseAnalysisDto getUserTodayRank(Long schoolId, Long userId); - List getUserIdsByRankTop100(); + List getUserIdsByRankTop100(Long schoolId); } diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/cache/ExerciseAnalysisCacheRepositoryImpl.java b/src/main/java/com/walkhub/walkhub/domain/exercise/cache/ExerciseAnalysisCacheRepositoryImpl.java index 79e009460..4110d2aad 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/cache/ExerciseAnalysisCacheRepositoryImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/cache/ExerciseAnalysisCacheRepositoryImpl.java @@ -5,32 +5,31 @@ import org.springframework.data.redis.core.ZSetOperations; import org.springframework.stereotype.Repository; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; -import java.util.Optional; -import java.util.Set; +import java.time.LocalDate; +import java.util.*; @RequiredArgsConstructor @Repository public class ExerciseAnalysisCacheRepositoryImpl implements ExerciseAnalysisCacheRepository { - public static final String EXERCISE_ANALYSIS_KEY = "exercise_analysis"; + public static final String EXERCISE_ANALYSIS_KEY = "exercise_analysis_"; private final ZSetOperations zSetOperations; @Override - public void saveExerciseCache(Long userId, Double walkCount) { - zSetOperations.add(EXERCISE_ANALYSIS_KEY, userId, walkCount); + public void saveExerciseCache(Long schoolId, Long userId, Double walkCount) { + zSetOperations.add(getExerciseAnalysisKey(schoolId), userId, walkCount); + Date today = java.sql.Date.valueOf(LocalDate.now()); + zSetOperations.getOperations().expireAt(getExerciseAnalysisKey(schoolId), today); } @Override - public ExerciseAnalysisDto getUserTodayRank(Long userId) { - Double doubleWalkCount = Optional.ofNullable(zSetOperations.score(EXERCISE_ANALYSIS_KEY, userId)) + public ExerciseAnalysisDto getUserTodayRank(Long schoolId, Long userId) { + Double doubleWalkCount = Optional.ofNullable(zSetOperations.score(getExerciseAnalysisKey(schoolId), userId)) .orElseThrow(() -> RedisTransactionException.EXCEPTION); Integer walkCount = doubleWalkCount.intValue(); - Long ranking = zSetOperations.rank(EXERCISE_ANALYSIS_KEY, userId); + Long ranking = zSetOperations.rank(getExerciseAnalysisKey(schoolId), userId); try { return ExerciseAnalysisDto.builder() @@ -44,9 +43,9 @@ public ExerciseAnalysisDto getUserTodayRank(Long userId) { } @Override - public List getUserIdsByRankTop100() { + public List getUserIdsByRankTop100(Long schoolId) { Set> rankUserIds = Optional.ofNullable( - zSetOperations.reverseRangeWithScores(EXERCISE_ANALYSIS_KEY, 0, 99)) + zSetOperations.reverseRangeWithScores(getExerciseAnalysisKey(schoolId), 0, 99)) .orElseThrow(() -> RedisTransactionException.EXCEPTION); int rank = 1; @@ -68,4 +67,8 @@ public List getUserIdsByRankTop100() { return exerciseAnalysisDtos; } + + private String getExerciseAnalysisKey(Long schoolId) { + return EXERCISE_ANALYSIS_KEY + schoolId; + } } From ba1d5d1a88bcf262f30e37a97b9fa32c779f8e4f Mon Sep 17 00:00:00 2001 From: jhhong0509 Date: Thu, 17 Feb 2022 06:50:10 +0900 Subject: [PATCH 351/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20(#394)=20Repo?= =?UTF-8?q?sitory=20=ED=98=B8=EC=B6=9C=ED=95=98=EB=8A=94=20=EB=B6=80?= =?UTF-8?q?=EB=B6=84=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/SaveOrUpdateExerciseAnalysisService.java | 3 +++ .../rank/service/QueryUserRankListByMySchoolService.java | 6 ++++-- .../walkhub/domain/rank/service/UserSearchService.java | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/service/SaveOrUpdateExerciseAnalysisService.java b/src/main/java/com/walkhub/walkhub/domain/exercise/service/SaveOrUpdateExerciseAnalysisService.java index 7419816e0..e90bbadb2 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/service/SaveOrUpdateExerciseAnalysisService.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/service/SaveOrUpdateExerciseAnalysisService.java @@ -1,5 +1,6 @@ package com.walkhub.walkhub.domain.exercise.service; +import com.walkhub.walkhub.domain.exercise.cache.ExerciseAnalysisCacheRepository; import com.walkhub.walkhub.domain.exercise.domain.ExerciseAnalysis; import com.walkhub.walkhub.domain.exercise.domain.repository.ExerciseAnalysisRepository; import com.walkhub.walkhub.domain.exercise.presentation.dto.request.SaveExerciseAnalysisRequest; @@ -16,11 +17,13 @@ public class SaveOrUpdateExerciseAnalysisService { private final ExerciseAnalysisRepository exerciseAnalysisRepository; + private final ExerciseAnalysisCacheRepository exerciseAnalysisCacheRepository; private final UserFacade userFacade; @Transactional public void execute(SaveExerciseAnalysisRequest request) { User user = userFacade.getCurrentUser(); + exerciseAnalysisCacheRepository.saveExerciseCache(user.getSchool().getId(), user.getId(), request.getWalkCount().doubleValue()); ExerciseAnalysis exerciseAnalysisToSave = buildOrUpdateExerciseAnalysis(request, user); exerciseAnalysisRepository.save(exerciseAnalysisToSave); } diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListByMySchoolService.java b/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListByMySchoolService.java index 87cac98c3..1dae7c9a0 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListByMySchoolService.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListByMySchoolService.java @@ -6,6 +6,7 @@ import com.walkhub.walkhub.domain.rank.domain.repository.vo.UserRankVO; import com.walkhub.walkhub.domain.rank.domain.type.UserRankScope; import com.walkhub.walkhub.domain.rank.presentation.dto.response.UserRankListResponse; +import com.walkhub.walkhub.domain.school.domain.School; import com.walkhub.walkhub.domain.user.domain.User; import com.walkhub.walkhub.domain.user.facade.UserFacade; import com.walkhub.walkhub.global.enums.DateType; @@ -26,12 +27,13 @@ public class QueryUserRankListByMySchoolService { public UserRankListResponse execute(UserRankScope scope, DateType dateType) { User user = userFacade.getCurrentUser(); + School school = user.getSchool(); LocalDate date = LocalDate.now(); UserRankListResponse.UserRankResponse myRank = null; List userRankList = new ArrayList<>(); if (dateType.equals(DateType.DAY)) { myRank = buildDayMyRankResponse(user); - List usersDayRank = exerciseAnalysisCacheRepository.getUserIdsByRankTop100(); + List usersDayRank = exerciseAnalysisCacheRepository.getUserIdsByRankTop100(school.getId()); for (ExerciseAnalysisDto users : usersDayRank) { userRankList.add(buildDayUsersRankResponse(users)); } @@ -51,7 +53,7 @@ public UserRankListResponse execute(UserRankScope scope, DateType dateType) { } private UserRankListResponse.UserRankResponse buildDayMyRankResponse(User user) { - ExerciseAnalysisDto exerciseAnalysisDto = exerciseAnalysisCacheRepository.getUserTodayRank(user.getId()); + ExerciseAnalysisDto exerciseAnalysisDto = exerciseAnalysisCacheRepository.getUserTodayRank(user.getSchool().getId(), user.getId()); if (exerciseAnalysisDto == null) { return null; } diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/service/UserSearchService.java b/src/main/java/com/walkhub/walkhub/domain/rank/service/UserSearchService.java index 720be3a7c..63ece06be 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/service/UserSearchService.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/service/UserSearchService.java @@ -43,7 +43,7 @@ public UserListResponse execute(Long schoolId, String name, DateType dateType) { } private UserListResponse.UserSearchResponse buildDayUserSearchResponse(User user) { - ExerciseAnalysisDto exerciseAnalysisDto = exerciseAnalysisCacheRepository.getUserTodayRank(user.getId()); + ExerciseAnalysisDto exerciseAnalysisDto = exerciseAnalysisCacheRepository.getUserTodayRank(user.getSchool().getId(), user.getId()); return UserListResponse.UserSearchResponse.builder() .userId(user.getId()) From 5820fca5aea48b1a471606a5d0b5902bdfd0275d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Thu, 17 Feb 2022 09:38:08 +0900 Subject: [PATCH 352/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20Optional,=20f?= =?UTF-8?q?indAllByDateTypeAndNameContainingAndCreatedAtBetweenOrderByRank?= =?UTF-8?q?ingAsc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/SchoolRankRepository.java | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/SchoolRankRepository.java b/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/SchoolRankRepository.java index 501e01fd3..c304871c2 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/SchoolRankRepository.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/SchoolRankRepository.java @@ -6,12 +6,20 @@ import java.time.LocalDate; import java.util.List; +import java.util.Optional; public interface SchoolRankRepository extends CrudRepository { - SchoolRank findBySchoolIdAndDateTypeAndCreatedAtBetween( - Long schoolId, String dateType, LocalDate createdAt, LocalDate now - ); - List findAllByDateTypeAndCreatedAtBetweenOrderByRankingAsc( - String dateType, LocalDate createdAt, LocalDate now - ); + Optional findBySchoolIdAndDateTypeAndCreatedAtBetween( + Long schoolId, + String dateType, LocalDate startAt, LocalDate endAt + ); + + List findAllByDateTypeAndCreatedAtBetweenOrderByRankingAsc( + String dateType, LocalDate createdAt, LocalDate createdAt2 + ); + + List findAllByDateTypeAndNameContainingAndCreatedAtBetweenOrderByRankingAsc( + String dateType, String name, LocalDate startAt, + LocalDate endAt + ); } From a0e134bdaf05d7c5295a0853924c26f665073fe0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Thu, 17 Feb 2022 09:38:24 +0900 Subject: [PATCH 353/522] =?UTF-8?q?=F0=9F=93=91=20::=20SchoolListResponse?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/response/SchoolListResponse.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/main/java/com/walkhub/walkhub/domain/rank/presentation/dto/response/SchoolListResponse.java diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/presentation/dto/response/SchoolListResponse.java b/src/main/java/com/walkhub/walkhub/domain/rank/presentation/dto/response/SchoolListResponse.java new file mode 100644 index 000000000..8f2503340 --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/rank/presentation/dto/response/SchoolListResponse.java @@ -0,0 +1,23 @@ +package com.walkhub.walkhub.domain.rank.presentation.dto.response; + +import java.util.List; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public class SchoolListResponse { + + private final List schoolList; + + @Getter + @Builder + public static class SchoolResponse { + private final Long schoolId; + private final String schoolName; + private final Integer ranking; + private final String logoImageUrl; + private final Integer walkCount; + } +} From 353914854a39ad59a0bdfb079b2f8df2d7898070 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Thu, 17 Feb 2022 09:38:39 +0900 Subject: [PATCH 354/522] =?UTF-8?q?=F0=9F=93=91=20::=20SchoolSearchService?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rank/service/SchoolSearchService.java | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/main/java/com/walkhub/walkhub/domain/rank/service/SchoolSearchService.java diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/service/SchoolSearchService.java b/src/main/java/com/walkhub/walkhub/domain/rank/service/SchoolSearchService.java new file mode 100644 index 000000000..1877778ef --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/rank/service/SchoolSearchService.java @@ -0,0 +1,36 @@ +package com.walkhub.walkhub.domain.rank.service; + +import com.walkhub.walkhub.domain.rank.domain.repository.SchoolRankRepository; +import com.walkhub.walkhub.domain.rank.domain.type.SchoolDateType; +import com.walkhub.walkhub.domain.rank.presentation.dto.response.SchoolListResponse; +import com.walkhub.walkhub.domain.rank.presentation.dto.response.SchoolListResponse.SchoolResponse; +import java.time.LocalDate; +import java.util.List; +import java.util.stream.Collectors; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +@RequiredArgsConstructor +@Service +public class SchoolSearchService { + + private final SchoolRankRepository schoolRankRepository; + + public SchoolListResponse execute(String name, SchoolDateType dateType) { + List schoolResponseList = schoolRankRepository + .findAllByDateTypeAndNameContainingAndCreatedAtBetweenOrderByRankingAsc(dateType.toString(), name, + LocalDate + .now().minusWeeks(1), LocalDate.now()) + .stream() + .map(schoolRank -> SchoolResponse.builder() + .schoolId(schoolRank.getSchoolId()) + .logoImageUrl(schoolRank.getLogoImageUrl()) + .schoolName(schoolRank.getName()) + .ranking(schoolRank.getRanking()) + .walkCount(schoolRank.getWalkCount()) + .build()) + .collect(Collectors.toList()); + + return new SchoolListResponse(schoolResponseList); + } +} From f4172cb10d5dad1bc9d680f9f0153ca3652b5332 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Thu, 17 Feb 2022 09:39:27 +0900 Subject: [PATCH 355/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20SchoolSearch?= =?UTF-8?q?=20api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/rank/presentation/RankController.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/presentation/RankController.java b/src/main/java/com/walkhub/walkhub/domain/rank/presentation/RankController.java index 1e8e3bc19..c4cee281f 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/presentation/RankController.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/presentation/RankController.java @@ -1,15 +1,19 @@ package com.walkhub.walkhub.domain.rank.presentation; import com.walkhub.walkhub.domain.rank.domain.type.SchoolDateType; +import com.walkhub.walkhub.domain.rank.presentation.dto.response.SchoolListResponse; import com.walkhub.walkhub.domain.rank.domain.type.UserRankScope; import com.walkhub.walkhub.domain.rank.presentation.dto.response.SchoolRankResponse; import com.walkhub.walkhub.domain.rank.presentation.dto.response.UserListResponse; import com.walkhub.walkhub.domain.rank.presentation.dto.response.UserRankListResponse; import com.walkhub.walkhub.domain.rank.service.QueryUserRankListByMySchoolService; import com.walkhub.walkhub.domain.rank.service.QuerySchoolRankService; +import com.walkhub.walkhub.domain.rank.service.SchoolSearchService; import com.walkhub.walkhub.domain.rank.service.QueryUserRankListService; import com.walkhub.walkhub.domain.rank.service.UserSearchService; import com.walkhub.walkhub.global.enums.DateType; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; @@ -25,6 +29,7 @@ public class RankController { private final UserSearchService userSearchService; private final QueryUserRankListByMySchoolService queryUserRankListByMySchoolService; private final QuerySchoolRankService querySchoolRankService; + private final SchoolSearchService schoolSearchService; private final QueryUserRankListService queryUserRankListService; @GetMapping("/users/search/{school-id}") @@ -39,6 +44,12 @@ public SchoolRankResponse querySchoolRank(@RequestParam SchoolDateType dateType) return querySchoolRankService.execute(dateType); } + @GetMapping("/schools/search") + public SchoolListResponse schoolSearch(@RequestParam("name") @NotNull @Size(max = 20) String name, + @RequestParam("schoolDateType") SchoolDateType dateType) { + return schoolSearchService.execute(name, dateType); + } + @GetMapping("/users/my-school") public UserRankListResponse queryUserRankListByMySchool(@RequestParam UserRankScope scope, @RequestParam DateType dateType) { return queryUserRankListByMySchoolService.execute(scope, dateType); From 901581425c1c96871be0972f0180c52cf46d5198 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Thu, 17 Feb 2022 09:39:43 +0900 Subject: [PATCH 356/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20nullPointExce?= =?UTF-8?q?ption=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rank/service/QuerySchoolRankService.java | 52 ++++++++++--------- .../service/SchoolDetailsInfoService.java | 34 ++++++------ 2 files changed, 46 insertions(+), 40 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/service/QuerySchoolRankService.java b/src/main/java/com/walkhub/walkhub/domain/rank/service/QuerySchoolRankService.java index f13b2a42c..dfe9cc61a 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/service/QuerySchoolRankService.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/service/QuerySchoolRankService.java @@ -24,38 +24,40 @@ public class QuerySchoolRankService { @Transactional(readOnly = true) public SchoolRankResponse execute(SchoolDateType dateType) { - LocalDate localDate = LocalDate.now(); - if (dateType.equals(SchoolDateType.MONTH)) { - localDate = localDate.minusMonths(1); - } else { - localDate = localDate.minusWeeks(1); - } - User user = userFacade.getCurrentUser(); - SchoolRank mySchoolRank = schoolRankRepository. - findBySchoolIdAndDateTypeAndCreatedAtBetween(user.getSchool().getId(), dateType.toString(), localDate, LocalDate.now()); - MySchoolResponse mySchoolResponse = MySchoolResponse.builder() - .schoolId(mySchoolRank.getSchoolId()) - .name(mySchoolRank.getName()) - .logoImageUrl(mySchoolRank.getLogoImageUrl()) - .grade(user.getSection().getGrade()) - .classNum(user.getSection().getClassNum()) - .build(); + MySchoolResponse mySchoolResponse = schoolRankRepository. + findBySchoolIdAndDateTypeAndCreatedAtBetween(user.getSchool().getId(), dateType.toString(), LocalDate.now().minusWeeks(1), LocalDate.now()) + .map(schoolRank -> mySchoolResponseBuilder(schoolRank, user)) + .orElse(null); List schoolResponseList = schoolRankRepository - .findAllByDateTypeAndCreatedAtBetweenOrderByRankingAsc(dateType.toString(), localDate, LocalDate.now()) + .findAllByDateTypeAndCreatedAtBetweenOrderByRankingAsc(dateType.toString(), LocalDate.now().minusWeeks(1), LocalDate.now()) .stream() - .map(schoolRank -> SchoolResponse.builder() - .schoolId(schoolRank.getSchoolId()) - .name(schoolRank.getName()) - .ranking(schoolRank.getRanking()) - .studentCount(schoolRank.getUserCount()) - .logoImageUrl(schoolRank.getLogoImageUrl()) - .walkCount(schoolRank.getWalkCount()) - .build()) + .map(this::schoolResponseBuilder) .collect(Collectors.toList()); return new SchoolRankResponse(mySchoolResponse, schoolResponseList); } + + private MySchoolResponse mySchoolResponseBuilder(SchoolRank schoolRank, User user) { + return MySchoolResponse.builder() + .schoolId(schoolRank.getSchoolId()) + .name(schoolRank.getName()) + .logoImageUrl(schoolRank.getLogoImageUrl()) + .grade(user.getSection().getGrade()) + .classNum(user.getSection().getClassNum()) + .build(); + } + + private SchoolResponse schoolResponseBuilder(SchoolRank schoolRank) { + return SchoolResponse.builder() + .schoolId(schoolRank.getSchoolId()) + .name(schoolRank.getName()) + .ranking(schoolRank.getRanking()) + .studentCount(schoolRank.getUserCount()) + .logoImageUrl(schoolRank.getLogoImageUrl()) + .walkCount(schoolRank.getWalkCount()) + .build(); + } } diff --git a/src/main/java/com/walkhub/walkhub/domain/school/service/SchoolDetailsInfoService.java b/src/main/java/com/walkhub/walkhub/domain/school/service/SchoolDetailsInfoService.java index 77258aea1..a6202bf55 100644 --- a/src/main/java/com/walkhub/walkhub/domain/school/service/SchoolDetailsInfoService.java +++ b/src/main/java/com/walkhub/walkhub/domain/school/service/SchoolDetailsInfoService.java @@ -6,6 +6,7 @@ import com.walkhub.walkhub.domain.school.facade.SchoolFacade; import com.walkhub.walkhub.domain.school.presentation.dto.response.SchoolDetailsInfoResponse; import com.walkhub.walkhub.global.enums.DateType; +import java.util.Optional; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -22,24 +23,27 @@ public class SchoolDetailsInfoService { @Transactional(readOnly = true) public SchoolDetailsInfoResponse execute(Long schoolId) { School school = schoolFacade.getSchoolById(schoolId); - LocalDate now = LocalDate.now(); - LocalDate weekCratedAt = now.minusWeeks(1); - LocalDate monthCreatedAt = now.minusMonths(1); - SchoolRank weekSchoolRanks = schoolRankRepository.findBySchoolIdAndDateTypeAndCreatedAtBetween( - schoolId, DateType.WEEK.toString(), weekCratedAt, now - ); - SchoolRank monthSchoolRanks = schoolRankRepository.findBySchoolIdAndDateTypeAndCreatedAtBetween( - schoolId, DateType.MONTH.toString(), monthCreatedAt, now - ); + LocalDate createAt = now.minusWeeks(1); + + return schoolRankRepository + .findBySchoolIdAndDateTypeAndCreatedAtBetween(schoolId, DateType.WEEK.toString(), createAt, now) + .flatMap( + weekSchoolRanks -> schoolRankRepository + .findBySchoolIdAndDateTypeAndCreatedAtBetween(schoolId, DateType.MONTH.toString(), createAt, now) + .map(monthSchoolRanks -> schoolDetailsInfoResponseBuilder(school, weekSchoolRanks, monthSchoolRanks)) + ) + .orElse(null); + } + private SchoolDetailsInfoResponse schoolDetailsInfoResponseBuilder(School school, SchoolRank weekSchoolRanks, SchoolRank monthSchoolRanks) { return SchoolDetailsInfoResponse.builder() - .userCount(school.getUserCount()) - .weekTotalWalkCount(weekSchoolRanks.getWalkCount()) - .monthTotalWalkCount(monthSchoolRanks.getWalkCount()) - .weekRanking(weekSchoolRanks.getRanking()) - .monthRanking(monthSchoolRanks.getRanking()) - .build(); + .userCount(school.getUserCount()) + .weekTotalWalkCount(weekSchoolRanks.getWalkCount()) + .monthTotalWalkCount(monthSchoolRanks.getWalkCount()) + .weekRanking(weekSchoolRanks.getRanking()) + .monthRanking(monthSchoolRanks.getRanking()) + .build(); } } From 5de0af8df6f4d6e8f37b0e5a81c1d5d274a55306 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Thu, 17 Feb 2022 10:13:23 +0900 Subject: [PATCH 357/522] =?UTF-8?q?=F0=9F=93=91=20::=20DefaultTitleBadgeNo?= =?UTF-8?q?tFound?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../user/exception/DefaultTitleBadgeNotFound.java | 14 ++++++++++++++ .../walkhub/global/error/exception/ErrorCode.java | 4 +++- 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/walkhub/walkhub/domain/user/exception/DefaultTitleBadgeNotFound.java diff --git a/src/main/java/com/walkhub/walkhub/domain/user/exception/DefaultTitleBadgeNotFound.java b/src/main/java/com/walkhub/walkhub/domain/user/exception/DefaultTitleBadgeNotFound.java new file mode 100644 index 000000000..cfa6d5a7d --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/user/exception/DefaultTitleBadgeNotFound.java @@ -0,0 +1,14 @@ +package com.walkhub.walkhub.domain.user.exception; + +import com.walkhub.walkhub.global.error.exception.ErrorCode; +import com.walkhub.walkhub.global.error.exception.WalkhubException; + +public class DefaultTitleBadgeNotFound extends WalkhubException { + + public static final WalkhubException EXCEPTION = + new DefaultTitleBadgeNotFound(); + + public DefaultTitleBadgeNotFound() { + super(ErrorCode.DEFAULT_TITLE_BADGE_NOT_FOUND); + } +} diff --git a/src/main/java/com/walkhub/walkhub/global/error/exception/ErrorCode.java b/src/main/java/com/walkhub/walkhub/global/error/exception/ErrorCode.java index 7a20c7050..6b207c5eb 100644 --- a/src/main/java/com/walkhub/walkhub/global/error/exception/ErrorCode.java +++ b/src/main/java/com/walkhub/walkhub/global/error/exception/ErrorCode.java @@ -53,7 +53,9 @@ public enum ErrorCode { ALREADY_EXERCISING(409, "EXERCISE-409-1", "Already Exercising"), REDIS_TRANSACTION_EXCEPTION(500, "REDIS-500-1", "Cannot Read Cache From Redis"), - INTERNAL_SERVER_ERROR(500, "SERVER-500-1", "Internal Server Error"); + INTERNAL_SERVER_ERROR(500, "SERVER-500-1", "Internal Server Error"), + + DEFAULT_TITLE_BADGE_NOT_FOUND(503, "SERVER-503-1", "Contact The Server Developer"); private final int status; private final String code; From 5c08875a1a2fd582a664bdeb1193e35b50178193 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Thu, 17 Feb 2022 10:13:40 +0900 Subject: [PATCH 358/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20mysql=20?= =?UTF-8?q?=EC=98=88=EC=95=BD=EC=96=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/walkhub/walkhub/domain/badge/domain/Badge.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/badge/domain/Badge.java b/src/main/java/com/walkhub/walkhub/domain/badge/domain/Badge.java index 80b314de1..a8770a0d2 100644 --- a/src/main/java/com/walkhub/walkhub/domain/badge/domain/Badge.java +++ b/src/main/java/com/walkhub/walkhub/domain/badge/domain/Badge.java @@ -35,16 +35,16 @@ public class Badge extends BaseTimeEntity { private String imageUrl; @NotNull - private String condition; + private String unlockCondition; @OneToMany(mappedBy = "badge", cascade = CascadeType.REMOVE) private List badgeCollections; @Builder public Badge(String name, String imageUrl, - String condition) { + String unlockCondition) { this.name = name; this.imageUrl = imageUrl; - this.condition = condition; + this.unlockCondition = unlockCondition; } } From 118b7b31a39761df250bf1b0cb186b087ff70e97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Thu, 17 Feb 2022 10:14:23 +0900 Subject: [PATCH 359/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20=ED=9A=8C?= =?UTF-8?q?=EC=9B=90=EA=B0=80=EC=9E=85=EC=8B=9C=20defaultTitleBadge?= =?UTF-8?q?=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../walkhub/domain/user/domain/User.java | 3 +- .../user/service/UserSignUpService.java | 30 ++++++++++++------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/user/domain/User.java b/src/main/java/com/walkhub/walkhub/domain/user/domain/User.java index 4c9b113d9..7895ef345 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/domain/User.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/domain/User.java @@ -116,7 +116,7 @@ public class User extends BaseTimeEntity { @Builder public User(String accountId, String password, String phoneNumber, String name, Authority authority, Section section, School school, boolean isMeasuring, - Integer weight, BigDecimal height, Sex sex) { + Integer weight, BigDecimal height, Sex sex, Badge badge) { this.accountId = accountId; this.password = password; this.phoneNumber = phoneNumber; @@ -128,6 +128,7 @@ public User(String accountId, String password, String phoneNumber, String name, this.healthInfo = new HealthInfo(weight, height); this.dailyWalkCountGoal = 10000; this.sex = sex; + this.badge = badge; } public void setDeviceToken(String deviceToken) { diff --git a/src/main/java/com/walkhub/walkhub/domain/user/service/UserSignUpService.java b/src/main/java/com/walkhub/walkhub/domain/user/service/UserSignUpService.java index 8e63d4298..499be72ca 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/service/UserSignUpService.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/service/UserSignUpService.java @@ -1,6 +1,8 @@ package com.walkhub.walkhub.domain.user.service; import com.walkhub.walkhub.domain.auth.presentation.dto.response.UserTokenResponse; +import com.walkhub.walkhub.domain.badge.domain.Badge; +import com.walkhub.walkhub.domain.badge.domain.repository.BadgeRepository; import com.walkhub.walkhub.domain.school.domain.School; import com.walkhub.walkhub.domain.school.domain.repository.SchoolRepository; import com.walkhub.walkhub.domain.user.domain.User; @@ -8,6 +10,7 @@ import com.walkhub.walkhub.domain.user.domain.repository.UserAuthCodeRepository; import com.walkhub.walkhub.domain.user.domain.repository.UserRepository; import com.walkhub.walkhub.domain.user.domain.type.HealthInfo; +import com.walkhub.walkhub.domain.user.exception.DefaultTitleBadgeNotFound; import com.walkhub.walkhub.domain.user.exception.SchoolNotFoundException; import com.walkhub.walkhub.domain.user.exception.UnauthorizedUserAuthCodeException; import com.walkhub.walkhub.domain.user.exception.UserAuthCodeNotFoundException; @@ -34,6 +37,7 @@ public class UserSignUpService { private final PasswordEncoder passwordEncoder; private final JwtTokenProvider jwtTokenProvider; private final JwtProperties jwtProperties; + private final BadgeRepository badgeRepository; @Transactional public UserTokenResponse execute(UserSignUpRequest request) { @@ -45,21 +49,25 @@ public UserTokenResponse execute(UserSignUpRequest request) { userFacade.checkUserExists(request.getAccountId()); + Badge defaultTitleBadge = badgeRepository.findById(1L) + .orElseThrow(() -> DefaultTitleBadgeNotFound.EXCEPTION); + School school = schoolRepository.findById(request.getSchoolId()) .orElseThrow(() -> SchoolNotFoundException.EXCEPTION); User user = User.builder() - .accountId(request.getAccountId()) - .password(passwordEncoder.encode(request.getPassword())) - .phoneNumber(request.getPhoneNumber()) - .authority(Authority.USER) - .name(request.getName()) - .school(school) - .height(request.getHeight()) - .weight(request.getWeight()) - .sex(request.getSex()) - .isMeasuring(false) - .build(); + .accountId(request.getAccountId()) + .password(passwordEncoder.encode(request.getPassword())) + .phoneNumber(request.getPhoneNumber()) + .authority(Authority.USER) + .name(request.getName()) + .school(school) + .height(request.getHeight()) + .weight(request.getWeight()) + .sex(request.getSex()) + .isMeasuring(false) + .badge(defaultTitleBadge) + .build(); userRepository.save(user); school.addUserCount(); From 9f1e81b663467c32238b0cd1e51a599dbaad35f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Thu, 17 Feb 2022 10:36:15 +0900 Subject: [PATCH 360/522] =?UTF-8?q?=F0=9F=90=9B=20::=20=EC=9D=B4=EB=A6=84?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../walkhub/domain/badge/service/QueryUserBadgeListService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/badge/service/QueryUserBadgeListService.java b/src/main/java/com/walkhub/walkhub/domain/badge/service/QueryUserBadgeListService.java index 35ad3b24c..8bff41404 100644 --- a/src/main/java/com/walkhub/walkhub/domain/badge/service/QueryUserBadgeListService.java +++ b/src/main/java/com/walkhub/walkhub/domain/badge/service/QueryUserBadgeListService.java @@ -24,7 +24,7 @@ public QueryUserBadgeListResponse execute(Long userId) { .map(badgeCollection -> DefaultBadgeResponse.builder() .name(badgeCollection.getBadge().getName()) .imageUrl(badgeCollection.getBadge().getImageUrl()) - .condition(badgeCollection.getBadge().getCondition()) + .condition(badgeCollection.getBadge().getUnlockCondition()) .build()) .collect(Collectors.toList()); From d4de6cfbdadbfcd5d0ca646185daa6e3d032f9bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Thu, 17 Feb 2022 10:38:56 +0900 Subject: [PATCH 361/522] =?UTF-8?q?=E2=9A=A1=20::=20=EC=95=88=EC=93=B0?= =?UTF-8?q?=EB=8A=94=20import=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../walkhub/domain/school/service/SchoolDetailsInfoService.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/school/service/SchoolDetailsInfoService.java b/src/main/java/com/walkhub/walkhub/domain/school/service/SchoolDetailsInfoService.java index a6202bf55..fbcc40032 100644 --- a/src/main/java/com/walkhub/walkhub/domain/school/service/SchoolDetailsInfoService.java +++ b/src/main/java/com/walkhub/walkhub/domain/school/service/SchoolDetailsInfoService.java @@ -6,7 +6,6 @@ import com.walkhub.walkhub.domain.school.facade.SchoolFacade; import com.walkhub.walkhub.domain.school.presentation.dto.response.SchoolDetailsInfoResponse; import com.walkhub.walkhub.global.enums.DateType; -import java.util.Optional; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; From 2327cf3fd25d697b195288813ffc2baf310a7206 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Thu, 17 Feb 2022 11:43:45 +0900 Subject: [PATCH 362/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20total=20dista?= =?UTF-8?q?nce,=20total=20walkcount,=20average=20distance,=20average=20wal?= =?UTF-8?q?kcount=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/response/QueryUserListResponse.java | 4 ++++ .../teacher/service/QueryUserListService.java | 4 ++++ .../walkhub/domain/teacher/vo/UserListInfoVO.java | 11 ++++++++++- .../domain/repository/UserRepositoryCustomImpl.java | 13 ++++++++++--- 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/QueryUserListResponse.java b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/QueryUserListResponse.java index 84eb32e93..bb7077edb 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/QueryUserListResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/QueryUserListResponse.java @@ -20,6 +20,10 @@ public static class UserListInfo { private final Integer grade; private final Integer classNum; private final Integer number; + private final Double averageWalkCount; + private final Integer totalWalkCount; + private final Double averageDistance; + private final Integer totalDistance; private final Boolean isTeacher; } } diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/service/QueryUserListService.java b/src/main/java/com/walkhub/walkhub/domain/teacher/service/QueryUserListService.java index 3743b1f02..911e6aaa5 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/service/QueryUserListService.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/service/QueryUserListService.java @@ -25,6 +25,10 @@ public QueryUserListResponse execute(QueryUserListRequest request) { .grade(users.getGrade()) .classNum(users.getClassNum()) .number(users.getNumber()) + .averageWalkCount(users.getAverageWalkCount()) + .totalWalkCount(users.getTotalWalkCount()) + .averageDistance(users.getAverageDistance()) + .totalDistance(users.getTotalDistance()) .isTeacher(users.getIsTeacher()) .build() ).collect(Collectors.toList()) diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/vo/UserListInfoVO.java b/src/main/java/com/walkhub/walkhub/domain/teacher/vo/UserListInfoVO.java index e1bd0a6e3..90c3d9ef6 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/vo/UserListInfoVO.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/vo/UserListInfoVO.java @@ -11,16 +11,25 @@ public class UserListInfoVO { private final Integer grade; private final Integer classNum; private final Integer number; + private final Double averageWalkCount; + private final Integer totalWalkCount; + private final Double averageDistance; + private final Integer totalDistance; private final Boolean isTeacher; @QueryProjection - public UserListInfoVO(Long userId, String name, String profileImageUrl, Integer grade, Integer classNum, Integer number, Boolean isTeacher) { + + public UserListInfoVO(Long userId, String name, String profileImageUrl, Integer grade, Integer classNum, Integer number, Double averageWalkCount, Integer totalWalkCount, Double averageDistance, Integer totalDistance, Boolean isTeacher) { this.userId = userId; this.name = name; this.profileImageUrl = profileImageUrl; this.grade = grade; this.classNum = classNum; this.number = number; + this.averageWalkCount = averageWalkCount; + this.totalWalkCount = totalWalkCount; + this.averageDistance = averageDistance; + this.totalDistance = totalDistance; this.isTeacher = isTeacher; } } diff --git a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java index 1c0cb5678..d0cf630a7 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java @@ -2,6 +2,7 @@ import com.querydsl.core.types.OrderSpecifier; import com.querydsl.core.types.dsl.BooleanExpression; +import com.querydsl.core.types.dsl.MathExpressions; import com.querydsl.jpa.impl.JPAQueryFactory; import com.walkhub.walkhub.domain.teacher.type.AuthorityScope; import com.walkhub.walkhub.domain.teacher.type.SortStandard; @@ -11,6 +12,7 @@ import com.walkhub.walkhub.global.enums.Authority; import lombok.RequiredArgsConstructor; +import java.time.LocalDate; import java.util.List; import static com.walkhub.walkhub.domain.exercise.domain.QExerciseAnalysis.exerciseAnalysis; @@ -31,6 +33,10 @@ public List queryUserList(Integer page, AuthorityScope scope, So user.section.grade, user.section.classNum, user.number, + MathExpressions.round(exerciseAnalysis.walkCount.avg(), 1).as("averageWalkCount"), + exerciseAnalysis.walkCount.sum().as("totalWalkCount"), + MathExpressions.round(exerciseAnalysis.distance.avg(), 1).as("averageDistance"), + exerciseAnalysis.distance.sum().as("totalDistance"), user.authority.eq(Authority.TEACHER).as("isTeacher") )) .from(user) @@ -39,9 +45,10 @@ public List queryUserList(Integer page, AuthorityScope scope, So user.school.eq(currentUser.getSchool()), buildFilteringCondition(scope), gradeEq(grade), - classNumEq(classNum) + classNumEq(classNum), + exerciseAnalysis.date.after(LocalDate.now().minusDays(7)) ) - .offset((long)page * size) + .offset((long) page * size) .limit(size) .orderBy(buildSortCondition(sort)) .groupBy(user.id) @@ -93,7 +100,7 @@ private OrderSpecifier[] buildSortCondition(SortStandard sort) { user.authority.asc() }; default: - return new OrderSpecifier[] {}; + return new OrderSpecifier[]{}; } } } From 7f35a12025b6542e151fe17a41feb81d2fd97acc Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Thu, 17 Feb 2022 12:31:01 +0900 Subject: [PATCH 363/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20leftjoin=20->?= =?UTF-8?q?=20join=EC=9C=BC=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 --- .../domain/user/domain/repository/UserRepositoryCustomImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java index d0cf630a7..c97d20666 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java @@ -40,7 +40,7 @@ public List queryUserList(Integer page, AuthorityScope scope, So user.authority.eq(Authority.TEACHER).as("isTeacher") )) .from(user) - .leftJoin(user.exerciseAnalyses, exerciseAnalysis) + .join(user.exerciseAnalyses, exerciseAnalysis) .where( user.school.eq(currentUser.getSchool()), buildFilteringCondition(scope), From 0a9aae1ee41926bf8d045efa24dd45c9d15a23c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Thu, 17 Feb 2022 13:13:14 +0900 Subject: [PATCH 364/522] =?UTF-8?q?=F0=9F=93=91=20::=20NoticeRepositoryCus?= =?UTF-8?q?tom?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/repository/NoticeRepositoryCustom.java | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 src/main/java/com/walkhub/walkhub/domain/notice/domain/repository/NoticeRepositoryCustom.java diff --git a/src/main/java/com/walkhub/walkhub/domain/notice/domain/repository/NoticeRepositoryCustom.java b/src/main/java/com/walkhub/walkhub/domain/notice/domain/repository/NoticeRepositoryCustom.java new file mode 100644 index 000000000..5899684f2 --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/notice/domain/repository/NoticeRepositoryCustom.java @@ -0,0 +1,10 @@ +package com.walkhub.walkhub.domain.notice.domain.repository; + +import com.walkhub.walkhub.domain.notice.domain.type.Scope; +import com.walkhub.walkhub.domain.notice.presentation.dto.response.QueryNoticeListResponse.NoticeResponse; +import com.walkhub.walkhub.domain.school.domain.School; +import java.util.List; + +public interface NoticeRepositoryCustom { + List queryNoticeByScopeAndPage(Scope scope, Integer page, School userSchool); +} From b3effae773b79fc030c4bbe95691c9f49c46a133 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Thu, 17 Feb 2022 13:13:28 +0900 Subject: [PATCH 365/522] =?UTF-8?q?=F0=9F=93=91=20::=20queryNoticeByScopeA?= =?UTF-8?q?ndPage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../NoticeRepositoryCustomImpl.java | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 src/main/java/com/walkhub/walkhub/domain/notice/domain/repository/NoticeRepositoryCustomImpl.java diff --git a/src/main/java/com/walkhub/walkhub/domain/notice/domain/repository/NoticeRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/notice/domain/repository/NoticeRepositoryCustomImpl.java new file mode 100644 index 000000000..11098eab7 --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/notice/domain/repository/NoticeRepositoryCustomImpl.java @@ -0,0 +1,52 @@ +package com.walkhub.walkhub.domain.notice.domain.repository; + +import com.querydsl.core.types.dsl.BooleanExpression; +import com.querydsl.jpa.impl.JPAQueryFactory; +import com.walkhub.walkhub.domain.notice.domain.type.Scope; +import com.walkhub.walkhub.domain.notice.presentation.dto.response.QQueryNoticeListResponse_NoticeResponse; +import com.walkhub.walkhub.domain.notice.presentation.dto.response.QQueryNoticeListResponse_Writer; +import com.walkhub.walkhub.domain.notice.presentation.dto.response.QueryNoticeListResponse.NoticeResponse; +import com.walkhub.walkhub.domain.school.domain.School; +import java.util.List; +import lombok.RequiredArgsConstructor; + +import static com.walkhub.walkhub.domain.notice.domain.QNotice.notice; +import static com.walkhub.walkhub.domain.user.domain.QUser.user; +import static com.walkhub.walkhub.domain.school.domain.QSchool.school; + +@RequiredArgsConstructor +public class NoticeRepositoryCustomImpl implements NoticeRepositoryCustom{ + private final JPAQueryFactory queryFactory; + + @Override + public List queryNoticeByScopeAndPage(Scope scope, Integer page, School userSchool) { + long size = 3; + return queryFactory + .select(new QQueryNoticeListResponse_NoticeResponse( + notice.id, + notice.title, + notice.content, + notice.createdAt, + new QQueryNoticeListResponse_Writer( + user.id, + user.name, + user.profileImageUrl + )) + ) + .from(notice) + .join(notice.user, user) + .join(user.school, school) + .where( + notice.scope.eq(scope), + scopeFilter(scope, userSchool) + ) + .offset((long) page * size) + .limit(size) + .orderBy(notice.createdAt.desc()) + .fetch(); + } + + private BooleanExpression scopeFilter(Scope scope, School userSchool) { + return scope.equals(Scope.SCHOOL) ? school.eq(userSchool) : null; + } +} From 012fc029d482f4ecda3334e2a891a736b6315755 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Thu, 17 Feb 2022 13:13:43 +0900 Subject: [PATCH 366/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20QueryDsl?= =?UTF-8?q?=EB=A1=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../notice/domain/repository/NoticeRepository.java | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/notice/domain/repository/NoticeRepository.java b/src/main/java/com/walkhub/walkhub/domain/notice/domain/repository/NoticeRepository.java index b39c9f4fe..cf2c810a9 100644 --- a/src/main/java/com/walkhub/walkhub/domain/notice/domain/repository/NoticeRepository.java +++ b/src/main/java/com/walkhub/walkhub/domain/notice/domain/repository/NoticeRepository.java @@ -1,18 +1,8 @@ package com.walkhub.walkhub.domain.notice.domain.repository; import com.walkhub.walkhub.domain.notice.domain.Notice; -import com.walkhub.walkhub.domain.notice.domain.type.Scope; -import com.walkhub.walkhub.domain.school.domain.School; -import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.CrudRepository; -import org.springframework.data.repository.query.Param; -import java.util.List; +public interface NoticeRepository extends CrudRepository, NoticeRepositoryCustom { -public interface NoticeRepository extends CrudRepository { - - @Query("select n from Notice n where n.user.school = :school and n.scope = :scope") - List findAllBySchoolAndScope(@Param("school") School school, @Param("scope") Scope scope); - - List findAllByScope(Scope scope); } From 3719ba40a4403832d5ce2e7b2bd7004c9f5ed04d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Thu, 17 Feb 2022 13:14:04 +0900 Subject: [PATCH 367/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20@QueryProject?= =?UTF-8?q?ion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/response/QueryNoticeListResponse.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/notice/presentation/dto/response/QueryNoticeListResponse.java b/src/main/java/com/walkhub/walkhub/domain/notice/presentation/dto/response/QueryNoticeListResponse.java index eb7f083c4..0291dad46 100644 --- a/src/main/java/com/walkhub/walkhub/domain/notice/presentation/dto/response/QueryNoticeListResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/notice/presentation/dto/response/QueryNoticeListResponse.java @@ -2,6 +2,7 @@ import com.fasterxml.jackson.annotation.JsonFormat; +import com.querydsl.core.annotations.QueryProjection; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; @@ -25,6 +26,16 @@ public static class NoticeResponse { @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'hh:mm:SS") private final LocalDateTime createdAt; private final Writer writer; + + @QueryProjection + public NoticeResponse(Long id, String title, String content, LocalDateTime createdAt, + Writer writer) { + this.id = id; + this.title = title; + this.content = content; + this.createdAt = createdAt; + this.writer = writer; + } } @Getter @@ -33,5 +44,12 @@ public static class Writer { private final Long id; private final String name; private final String profileImageUrl; + + @QueryProjection + public Writer(Long id, String name, String profileImageUrl) { + this.id = id; + this.name = name; + this.profileImageUrl = profileImageUrl; + } } } From 95352da1f88399924919243109da735732926e89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Thu, 17 Feb 2022 13:14:26 +0900 Subject: [PATCH 368/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20=ED=8E=98?= =?UTF-8?q?=EC=9D=B4=EC=A7=95=EA=B3=BC=20QueryDsl=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 --- .../notice/presentation/NoticeController.java | 4 +-- .../service/QueryNoticeListService.java | 36 +++---------------- 2 files changed, 6 insertions(+), 34 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/notice/presentation/NoticeController.java b/src/main/java/com/walkhub/walkhub/domain/notice/presentation/NoticeController.java index ca5dd52a8..03b192d79 100644 --- a/src/main/java/com/walkhub/walkhub/domain/notice/presentation/NoticeController.java +++ b/src/main/java/com/walkhub/walkhub/domain/notice/presentation/NoticeController.java @@ -30,8 +30,8 @@ public class NoticeController { private final DeleteNoticeService deleteNoticeService; @GetMapping("/list") - public QueryNoticeListResponse queryNoticeList(@RequestParam Scope scope) { - return queryNoticeListService.execute(scope); + public QueryNoticeListResponse queryNoticeList(@RequestParam Scope scope, @RequestParam Integer page) { + return queryNoticeListService.execute(scope, page); } @ResponseStatus(HttpStatus.CREATED) diff --git a/src/main/java/com/walkhub/walkhub/domain/notice/service/QueryNoticeListService.java b/src/main/java/com/walkhub/walkhub/domain/notice/service/QueryNoticeListService.java index 3d95a012c..1fd0a8932 100644 --- a/src/main/java/com/walkhub/walkhub/domain/notice/service/QueryNoticeListService.java +++ b/src/main/java/com/walkhub/walkhub/domain/notice/service/QueryNoticeListService.java @@ -1,11 +1,9 @@ package com.walkhub.walkhub.domain.notice.service; -import com.walkhub.walkhub.domain.notice.domain.Notice; import com.walkhub.walkhub.domain.notice.domain.repository.NoticeRepository; import com.walkhub.walkhub.domain.notice.domain.type.Scope; import com.walkhub.walkhub.domain.notice.presentation.dto.response.QueryNoticeListResponse; import com.walkhub.walkhub.domain.notice.presentation.dto.response.QueryNoticeListResponse.NoticeResponse; -import com.walkhub.walkhub.domain.notice.presentation.dto.response.QueryNoticeListResponse.Writer; import com.walkhub.walkhub.domain.user.domain.User; import com.walkhub.walkhub.domain.user.facade.UserFacade; import lombok.RequiredArgsConstructor; @@ -13,8 +11,6 @@ import org.springframework.transaction.annotation.Transactional; import java.util.List; -import java.util.stream.Collectors; - @RequiredArgsConstructor @Service public class QueryNoticeListService { @@ -23,36 +19,12 @@ public class QueryNoticeListService { private final UserFacade userFacade; @Transactional(readOnly = true) - public QueryNoticeListResponse execute(Scope scope) { + public QueryNoticeListResponse execute(Scope scope, Integer page) { User user = userFacade.getCurrentUser(); - List noticeList; - - if (scope.equals(Scope.ALL)) { - noticeList = noticeRepository.findAllByScope(scope); - } else { - noticeList = noticeRepository - .findAllBySchoolAndScope(user.getSection().getSchool(), scope); - } - return new QueryNoticeListResponse( - noticeList.stream() - .map(this::noticeResponseBuilder) - .collect(Collectors.toList()) - ); - } + List noticeResponseList = noticeRepository + .queryNoticeByScopeAndPage(scope, page, user.getSchool()); - private NoticeResponse noticeResponseBuilder(Notice notice) { - return NoticeResponse.builder() - .id(notice.getId()) - .title(notice.getTitle()) - .content(notice.getContent()) - .createdAt(notice.getCreatedAt()) - .writer(Writer.builder() - .id(notice.getUser().getId()) - .name(notice.getUser().getName()) - .profileImageUrl(notice.getUser().getProfileImageUrl()) - .build()) - .build(); + return new QueryNoticeListResponse(noticeResponseList); } - } From 7178f13eaea5bc830a975664016bf69af9286137 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Thu, 17 Feb 2022 13:33:50 +0900 Subject: [PATCH 369/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20chunk=20size?= =?UTF-8?q?=20100=EC=9C=BC=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/walkhub/walkhub/domain/rank/job/UserRankJob.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/job/UserRankJob.java b/src/main/java/com/walkhub/walkhub/domain/rank/job/UserRankJob.java index 386ace591..f9516c66a 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/job/UserRankJob.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/job/UserRankJob.java @@ -27,7 +27,7 @@ @RequiredArgsConstructor public class UserRankJob { - private static final Integer CHUNK_SIZE = 50000; + private static final Integer CHUNK_SIZE = 100; private final JobBuilderFactory jobBuilderFactory; private final StepBuilderFactory stepBuilderFactory; From 21f55e4c34dfe0bed92d066be6d5c332415632cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Thu, 17 Feb 2022 14:41:00 +0900 Subject: [PATCH 370/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20=EC=A4=84?= =?UTF-8?q?=EB=B0=94=EA=BF=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../NoticeRepositoryCustomImpl.java | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/notice/domain/repository/NoticeRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/notice/domain/repository/NoticeRepositoryCustomImpl.java index 11098eab7..6f3e8dcb3 100644 --- a/src/main/java/com/walkhub/walkhub/domain/notice/domain/repository/NoticeRepositoryCustomImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/notice/domain/repository/NoticeRepositoryCustomImpl.java @@ -15,7 +15,8 @@ import static com.walkhub.walkhub.domain.school.domain.QSchool.school; @RequiredArgsConstructor -public class NoticeRepositoryCustomImpl implements NoticeRepositoryCustom{ +public class NoticeRepositoryCustomImpl implements NoticeRepositoryCustom { + private final JPAQueryFactory queryFactory; @Override @@ -23,16 +24,16 @@ public List queryNoticeByScopeAndPage(Scope scope, Integer page, long size = 3; return queryFactory .select(new QQueryNoticeListResponse_NoticeResponse( - notice.id, - notice.title, - notice.content, - notice.createdAt, - new QQueryNoticeListResponse_Writer( - user.id, - user.name, - user.profileImageUrl - )) - ) + notice.id, + notice.title, + notice.content, + notice.createdAt, + new QQueryNoticeListResponse_Writer( + user.id, + user.name, + user.profileImageUrl + )) + ) .from(notice) .join(notice.user, user) .join(user.school, school) From 0c9eb2f58d01cb20bc0a2e5fdcd7382ffde877bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Thu, 17 Feb 2022 15:21:11 +0900 Subject: [PATCH 371/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20=ED=8E=98?= =?UTF-8?q?=EC=9D=B4=EC=A7=80=20size=2010?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../notice/domain/repository/NoticeRepositoryCustomImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/notice/domain/repository/NoticeRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/notice/domain/repository/NoticeRepositoryCustomImpl.java index 6f3e8dcb3..3caaa9270 100644 --- a/src/main/java/com/walkhub/walkhub/domain/notice/domain/repository/NoticeRepositoryCustomImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/notice/domain/repository/NoticeRepositoryCustomImpl.java @@ -21,7 +21,7 @@ public class NoticeRepositoryCustomImpl implements NoticeRepositoryCustom { @Override public List queryNoticeByScopeAndPage(Scope scope, Integer page, School userSchool) { - long size = 3; + long size = 10; return queryFactory .select(new QQueryNoticeListResponse_NoticeResponse( notice.id, From 04283af2de6479550983c2795c9207932ca810e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B2=94=EC=A7=84?= Date: Thu, 17 Feb 2022 20:52:09 +0900 Subject: [PATCH 372/522] =?UTF-8?q?=F0=9F=90=9B=20::=20(#403)=20delete=20s?= =?UTF-8?q?ubquery?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ChallengeStatusRepositoryCustomImpl.java | 54 ++++++++++--------- 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java index 7636468bf..ef6758231 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java @@ -98,12 +98,12 @@ public List queryChallengeParticipantsList(Challenge ch user.profileImageUrl, user.school.name.as("schoolName"), Expressions.asNumber(select(exerciseAnalysis.count()) - .from(exerciseAnalysis) - .where( - exerciseAnalysis.user.eq(user), - isChallengeSuccessFilter(challenge), - challengeDateFilter(challenge) - )) + .from(exerciseAnalysis) + .where( + exerciseAnalysis.user.eq(user), + isChallengeSuccessFilter(challenge), + challengeDateFilter(challenge) + )) .goe(challenge.getSuccessStandard()).as("isSuccess"), GroupBy.list(exerciseAnalysis.date)) ) @@ -114,16 +114,20 @@ public List queryChallengeParticipantsList(Challenge ch public void deleteNotOverChallengeStatusByUserId(Long userId) { queryFactory .delete(challengeStatus) - .where( - (challengeStatus.challenge.userScope.eq(UserScope.CLASS).or(challengeStatus.challenge.userScope.eq(UserScope.GRADE))) - .and(challengeStatus.challenge.endAt.after(LocalDate.now())) - .and(challengeStatus.user.id.eq(userId)) + .where(challengeStatus.user.id.eq(userId), + challengeStatus.challenge.id.in( + JPAExpressions + .select(challenge.id) + .from(challenge) + .where(challenge.userScope.eq(UserScope.CLASS).or(challenge.userScope.eq(UserScope.GRADE))) + .where(challenge.endAt.after(LocalDate.now()).and(challengeStatus.user.id.eq(userId))) + ) ) .execute(); - } + } - @Override - public List getAllChallengesByUser(User user1) { + @Override + public List getAllChallengesByUser(User user1) { return queryFactory .select(new QShowChallengeVO( challenge.id.as("challengeId"), @@ -150,22 +154,22 @@ private BooleanExpression successScopeFilter(Challenge challenge, SuccessScope s switch (successScope) { case TRUE: { return Expressions.asNumber(select(exerciseAnalysis.count()) - .from(exerciseAnalysis) - .where( - exerciseAnalysis.user.eq(user), - isChallengeSuccessFilter(challenge), - challengeDateFilter(challenge) - )) + .from(exerciseAnalysis) + .where( + exerciseAnalysis.user.eq(user), + isChallengeSuccessFilter(challenge), + challengeDateFilter(challenge) + )) .goe(challenge.getSuccessStandard()); } case FALSE: { return Expressions.asNumber(select(exerciseAnalysis.count()) - .from(exerciseAnalysis) - .where( - exerciseAnalysis.user.eq(user), - isChallengeSuccessFilter(challenge), - challengeDateFilter(challenge) - )) + .from(exerciseAnalysis) + .where( + exerciseAnalysis.user.eq(user), + isChallengeSuccessFilter(challenge), + challengeDateFilter(challenge) + )) .lt(challenge.getSuccessStandard()); } default: { From ec0d88e028e0b7c037c80509717a33f35bbcbf5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B2=94=EC=A7=84?= Date: Thu, 17 Feb 2022 20:52:44 +0900 Subject: [PATCH 373/522] =?UTF-8?q?=E2=99=BB=20::=20(#403)=20=EA=B3=B5?= =?UTF-8?q?=ED=86=B5=EB=90=9C=20=EA=B8=B0=EB=8A=A5=20=EB=AC=B6=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/repository/ChallengeStatusRepositoryCustom.java | 3 +-- .../walkhub/domain/user/service/UpdateSchoolInfoService.java | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustom.java b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustom.java index ad6ed7640..cd5d92501 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustom.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustom.java @@ -14,7 +14,6 @@ public interface ChallengeStatusRepositoryCustom { Integer getParticipantsCountByChallengeId(Long challengeId); List getRelatedChallengeParticipantsList(Long challengeId, School school, Integer grade, Integer classNum); List queryChallengeParticipantsList(Challenge challenge, SuccessScope successScope, Long page); - void deleteNotOverChallengeStatusByUserId(Long userId); - void resignParticipatedChallenge(User user); List getAllChallengesByUser(User user); + void deleteNotOverChallengeStatusByUserId(Long userId); } diff --git a/src/main/java/com/walkhub/walkhub/domain/user/service/UpdateSchoolInfoService.java b/src/main/java/com/walkhub/walkhub/domain/user/service/UpdateSchoolInfoService.java index 519a83b91..5e8b3f0f8 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/service/UpdateSchoolInfoService.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/service/UpdateSchoolInfoService.java @@ -29,6 +29,6 @@ public void execute(UpdateSchoolInfoRequest request) { school.addUserCount(); - challengeStatusRepository.resignParticipatedChallenge(user); + challengeStatusRepository.deleteNotOverChallengeStatusByUserId(user.getId()); } } From e64ee3c93a85b3eb068e7de67f5c20e31f5a9a2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B2=94=EC=A7=84?= Date: Thu, 17 Feb 2022 20:57:01 +0900 Subject: [PATCH 374/522] =?UTF-8?q?=E2=9A=B0=20::=20(#403)=20override=20me?= =?UTF-8?q?thod?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ChallengeStatusRepositoryCustomImpl.java | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java index ef6758231..735786f6a 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java @@ -217,15 +217,4 @@ private BooleanExpression challengeDateFilter(Challenge challenge) { .and(exerciseAnalysis.date.goe(challengeStatus.createdAt)) .and(exerciseAnalysis.date.loe(challenge.getEndAt())); } - - @Override - public void resignParticipatedChallenge(User user) { - queryFactory.delete(challengeStatus) - .where(challengeStatus.user.eq(user) - .and(isChallengeFinished().not())); - } - - private BooleanExpression isChallengeFinished() { - return challengeStatus.challenge.endAt.before(LocalDate.now()); - } } From b3780cbb602f1d3b127b2ad6972f6b3b89ef60e9 Mon Sep 17 00:00:00 2001 From: jhhong0509 Date: Fri, 18 Feb 2022 04:30:15 +0900 Subject: [PATCH 375/522] =?UTF-8?q?:bug:=20::=20(#405)=20DateFormat=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../auth/presentation/dto/response/UserAccessTokenResponse.java | 2 +- .../auth/presentation/dto/response/UserTokenResponse.java | 2 +- .../presentation/dto/response/ExerciseListResponse.java | 2 +- .../presentation/dto/response/QueryNoticeListResponse.java | 2 +- .../presentation/dto/response/QueryUserDetailsResponse.java | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/auth/presentation/dto/response/UserAccessTokenResponse.java b/src/main/java/com/walkhub/walkhub/domain/auth/presentation/dto/response/UserAccessTokenResponse.java index b113d1647..820f55176 100644 --- a/src/main/java/com/walkhub/walkhub/domain/auth/presentation/dto/response/UserAccessTokenResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/auth/presentation/dto/response/UserAccessTokenResponse.java @@ -12,6 +12,6 @@ public class UserAccessTokenResponse { private final String accessToken; - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'hh:mm:SS") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'hh:mm:ss") private final LocalDateTime expiredAt; } diff --git a/src/main/java/com/walkhub/walkhub/domain/auth/presentation/dto/response/UserTokenResponse.java b/src/main/java/com/walkhub/walkhub/domain/auth/presentation/dto/response/UserTokenResponse.java index 93e003cf7..e4cb6d3b9 100644 --- a/src/main/java/com/walkhub/walkhub/domain/auth/presentation/dto/response/UserTokenResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/auth/presentation/dto/response/UserTokenResponse.java @@ -14,7 +14,7 @@ public class UserTokenResponse { private final String accessToken; - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'hh:mm:SS") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'hh:mm:ss") private final LocalDateTime expiredAt; private final String refreshToken; private final Authority authority; diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/response/ExerciseListResponse.java b/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/response/ExerciseListResponse.java index 41ece0af2..384764d04 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/response/ExerciseListResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/response/ExerciseListResponse.java @@ -20,7 +20,7 @@ public class ExerciseListResponse { public static class ExerciseResponse { private final Long exerciseId; private final String imageUrl; - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'hh:mm:SS") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'hh:mm:ss") private final LocalDateTime startAt; private final BigDecimal latitude; private final BigDecimal longitude; diff --git a/src/main/java/com/walkhub/walkhub/domain/notice/presentation/dto/response/QueryNoticeListResponse.java b/src/main/java/com/walkhub/walkhub/domain/notice/presentation/dto/response/QueryNoticeListResponse.java index eb7f083c4..0c60adfa8 100644 --- a/src/main/java/com/walkhub/walkhub/domain/notice/presentation/dto/response/QueryNoticeListResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/notice/presentation/dto/response/QueryNoticeListResponse.java @@ -22,7 +22,7 @@ public static class NoticeResponse { private final String title; private final String content; - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'hh:mm:SS") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'hh:mm:ss") private final LocalDateTime createdAt; private final Writer writer; } diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/QueryUserDetailsResponse.java b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/QueryUserDetailsResponse.java index e4c20b4b5..334397c6d 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/QueryUserDetailsResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/QueryUserDetailsResponse.java @@ -24,7 +24,7 @@ public class QueryUserDetailsResponse { @Builder public static class ExerciseResponse { private final String imageUrl; - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'hh:mm:SS") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'hh:mm:ss") private final LocalDateTime startAt; private final BigDecimal latitude; private final BigDecimal longitude; From 8c7dc9cf1acc6fb95dd3e15c78ac524d98964141 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Fri, 18 Feb 2022 16:55:12 +0900 Subject: [PATCH 376/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20=EC=A0=95?= =?UTF-8?q?=EB=A0=AC=20=EC=A1=B0=EA=B1=B4=20=EC=9A=B0=EC=84=A0=EC=88=9C?= =?UTF-8?q?=EC=9C=84=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/UserRepositoryCustomImpl.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java index c97d20666..d9336bb9d 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java @@ -80,24 +80,24 @@ private OrderSpecifier[] buildSortCondition(SortStandard sort) { switch (sort) { case NAME: return new OrderSpecifier[]{ - user.name.asc(), user.authority.asc() + user.authority.asc(), user.name.asc() }; case GCN: return new OrderSpecifier[]{ + user.authority.asc(), user.section.grade.asc(), user.section.classNum.asc(), - user.number.asc(), - user.authority.asc() + user.number.asc() }; case WALK_COUNT: return new OrderSpecifier[]{ - exerciseAnalysis.walkCount.desc(), - user.authority.asc() + user.authority.asc(), + exerciseAnalysis.walkCount.desc() }; case DISTANCE: return new OrderSpecifier[]{ - exerciseAnalysis.distance.desc(), - user.authority.asc() + user.authority.asc(), + exerciseAnalysis.distance.desc() }; default: return new OrderSpecifier[]{}; From 35432d9e07f9ca5262ac77b34e79a0b07e895dd8 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Sat, 19 Feb 2022 22:08:35 +0900 Subject: [PATCH 377/522] =?UTF-8?q?:recycle:=20::=20authenticated()=20->?= =?UTF-8?q?=20hasAuthority("USER")=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/walkhub/walkhub/global/security/SecurityConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java b/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java index e59896f96..df4087330 100644 --- a/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java +++ b/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java @@ -52,7 +52,7 @@ protected void configure(HttpSecurity http) throws Exception { .antMatchers(HttpMethod.GET, "/users/{user-id}").authenticated() .antMatchers(HttpMethod.GET, "/users").authenticated() .antMatchers(HttpMethod.PATCH, "/users").authenticated() - .antMatchers(HttpMethod.POST, "/users/classes").authenticated() + .antMatchers(HttpMethod.POST, "/users/classes").hasAuthority("USER") .antMatchers(HttpMethod.DELETE, "/users/classes").hasAuthority("USER") .antMatchers(HttpMethod.GET, "/users/accounts/{phone-number}").permitAll() .antMatchers(HttpMethod.PATCH, "/users/health").authenticated() From 72927cfeccdff5fc1f1218d4a7f78644b7ed274f Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Sun, 20 Feb 2022 12:44:11 +0900 Subject: [PATCH 378/522] =?UTF-8?q?:bug:=20::=20levels/lists=20securityCon?= =?UTF-8?q?fig=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/walkhub/walkhub/global/security/SecurityConfig.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java b/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java index df4087330..252570634 100644 --- a/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java +++ b/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java @@ -58,8 +58,9 @@ protected void configure(HttpSecurity http) throws Exception { .antMatchers(HttpMethod.PATCH, "/users/health").authenticated() .antMatchers(HttpMethod.PATCH, "/users/goal").authenticated() .antMatchers(HttpMethod.PATCH, "/users/schools").authenticated() - .antMatchers(HttpMethod.GET, "/users/levels/lists").authenticated() + //levels + .antMatchers(HttpMethod.GET, "/levels/lists").authenticated() // badges .antMatchers(HttpMethod.GET, "/badges/{user-id}").authenticated() From 185ff0a71ccf50b28094b10e8db0c59d3b54e019 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Sun, 20 Feb 2022 12:44:28 +0900 Subject: [PATCH 379/522] =?UTF-8?q?:recycle:=20::=20static=20import=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../calorielevel/service/CalorieLevelListService.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/calorielevel/service/CalorieLevelListService.java b/src/main/java/com/walkhub/walkhub/domain/calorielevel/service/CalorieLevelListService.java index d8f172a81..420e0a86e 100644 --- a/src/main/java/com/walkhub/walkhub/domain/calorielevel/service/CalorieLevelListService.java +++ b/src/main/java/com/walkhub/walkhub/domain/calorielevel/service/CalorieLevelListService.java @@ -3,6 +3,7 @@ import com.walkhub.walkhub.domain.calorielevel.domain.CalorieLevel; import com.walkhub.walkhub.domain.calorielevel.domain.repository.CalorieLevelRepository; import com.walkhub.walkhub.domain.user.presentation.dto.response.CalorieLevelListResponse; +import com.walkhub.walkhub.domain.user.presentation.dto.response.CalorieLevelListResponse.CalorieLevelResponse; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -18,7 +19,7 @@ public class CalorieLevelListService { @Transactional(readOnly = true) public CalorieLevelListResponse execute() { - List results = + List results = calorieLevelRepository.findAllBy() .stream() .map(this::calorieLevelResponse) @@ -27,8 +28,8 @@ public CalorieLevelListResponse execute() { return new CalorieLevelListResponse(results); } - private CalorieLevelListResponse.CalorieLevelResponse calorieLevelResponse(CalorieLevel calorieLevel) { - return CalorieLevelListResponse.CalorieLevelResponse.builder() + private CalorieLevelResponse calorieLevelResponse(CalorieLevel calorieLevel) { + return CalorieLevelResponse.builder() .levelId(calorieLevel.getId()) .level(calorieLevel.getLevel()) .foodImageUrl(calorieLevel.getFoodImageUrl()) From fc8caabd4dd3c2b9b9118afa98b2ff5704f79939 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Sun, 20 Feb 2022 20:46:49 +0900 Subject: [PATCH 380/522] =?UTF-8?q?=F0=9F=93=91=20::=20searchUser=20?= =?UTF-8?q?=EB=9D=BC=EC=9A=B0=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 --- .../teacher/presentation/TeacherController.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/TeacherController.java b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/TeacherController.java index 3470cc9a3..3ae199a27 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/TeacherController.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/TeacherController.java @@ -1,9 +1,6 @@ package com.walkhub.walkhub.domain.teacher.presentation; -import com.walkhub.walkhub.domain.teacher.presentation.dto.request.CreateClassRequest; -import com.walkhub.walkhub.domain.teacher.presentation.dto.request.QueryUserListRequest; -import com.walkhub.walkhub.domain.teacher.presentation.dto.request.TeacherCodeRequest; -import com.walkhub.walkhub.domain.teacher.presentation.dto.request.UpdateTeacherSchoolRequest; +import com.walkhub.walkhub.domain.teacher.presentation.dto.request.*; import com.walkhub.walkhub.domain.teacher.presentation.dto.response.ClassListResponse; import com.walkhub.walkhub.domain.teacher.presentation.dto.response.CodeResponse; import com.walkhub.walkhub.domain.teacher.presentation.dto.response.QueryUserListResponse; @@ -51,6 +48,7 @@ public class TeacherController { private final ConfirmTeacherCodeService confirmTeacherCodeService; private final ClassListService classListService; private final UpdateTeacherSchoolService updateTeacherSchoolService; + private final UserSearchForTeacherService userSearchForTeacherService; @ResponseStatus(HttpStatus.CREATED) @PostMapping("/classes") @@ -102,4 +100,9 @@ public ClassListResponse classList() { public void updateTeacherSchool(@Valid @RequestBody UpdateTeacherSchoolRequest request) { updateTeacherSchoolService.execute(request); } + + @GetMapping("/users/search") + public QueryUserListResponse searchUser(UserSearchRequest request) { + return userSearchForTeacherService.execute(request); + } } From 1c6fe2363d84628c5e0e68a7e9cf13b246267595 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Sun, 20 Feb 2022 20:47:05 +0900 Subject: [PATCH 381/522] =?UTF-8?q?=F0=9F=93=91=20::=20UserSearchRequest?= =?UTF-8?q?=20DTO?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/request/UserSearchRequest.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/request/UserSearchRequest.java diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/request/UserSearchRequest.java b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/request/UserSearchRequest.java new file mode 100644 index 000000000..806d12494 --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/request/UserSearchRequest.java @@ -0,0 +1,14 @@ +package com.walkhub.walkhub.domain.teacher.presentation.dto.request; + +import com.walkhub.walkhub.domain.teacher.type.AuthorityScope; +import com.walkhub.walkhub.domain.teacher.type.SortStandard; +import lombok.Data; + +@Data +public class UserSearchRequest { + private AuthorityScope scope; + private SortStandard sort; + private Integer grade; + private Integer classNum; + private String name; +} From 705058817e9c1e34d8d8526718c699ed04b0ebe6 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Sun, 20 Feb 2022 20:47:18 +0900 Subject: [PATCH 382/522] =?UTF-8?q?=F0=9F=93=91=20::=20UserSearchForTeache?= =?UTF-8?q?rService?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/UserSearchForTeacherService.java | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/main/java/com/walkhub/walkhub/domain/teacher/service/UserSearchForTeacherService.java diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/service/UserSearchForTeacherService.java b/src/main/java/com/walkhub/walkhub/domain/teacher/service/UserSearchForTeacherService.java new file mode 100644 index 000000000..dd27c69d1 --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/service/UserSearchForTeacherService.java @@ -0,0 +1,39 @@ +package com.walkhub.walkhub.domain.teacher.service; + +import com.walkhub.walkhub.domain.rank.presentation.dto.response.UserListResponse; +import com.walkhub.walkhub.domain.teacher.presentation.dto.request.UserSearchRequest; +import com.walkhub.walkhub.domain.teacher.presentation.dto.response.QueryUserListResponse; +import com.walkhub.walkhub.domain.user.domain.repository.UserRepository; +import com.walkhub.walkhub.domain.user.facade.UserFacade; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +import java.util.stream.Collectors; + +@RequiredArgsConstructor +@Service +public class UserSearchForTeacherService { + private final UserRepository userRepository; + private final UserFacade userFacade; + + public QueryUserListResponse execute(UserSearchRequest request) { + return QueryUserListResponse.builder() + .userList(userRepository.searchUser(request.getScope(), request.getSort(), request.getGrade(), request.getClassNum(), userFacade.getCurrentUser(), request.getName()) + .stream().map(users -> QueryUserListResponse.UserListInfo.builder() + .userId(users.getUserId()) + .name(users.getName()) + .profileImageUrl(users.getProfileImageUrl()) + .grade(users.getGrade()) + .classNum(users.getClassNum()) + .number(users.getNumber()) + .averageWalkCount(users.getAverageWalkCount()) + .totalWalkCount(users.getTotalWalkCount()) + .averageDistance(users.getAverageDistance()) + .totalDistance(users.getTotalDistance()) + .isTeacher(users.getIsTeacher()) + .build() + ).collect(Collectors.toList()) + ) + .build(); + } +} From c93be9ece7cf9c799648c12700116280ec7c1dec Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Sun, 20 Feb 2022 20:47:34 +0900 Subject: [PATCH 383/522] =?UTF-8?q?=F0=9F=93=91=20::=20searchUser=20?= =?UTF-8?q?=EB=A9=94=EC=86=8C=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/user/domain/repository/UserRepositoryCustom.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustom.java b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustom.java index 5928ce3bb..a8d890cc5 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustom.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustom.java @@ -9,4 +9,5 @@ public interface UserRepositoryCustom { List queryUserList(Integer page, AuthorityScope scope, SortStandard sort, Integer grade, Integer classNum, User currentUser); + List searchUser(AuthorityScope scope, SortStandard sort, Integer grade, Integer classNum, User currentUser, String name); } From 8ac8cedecced96066c0081ef1dbccc54cadeff3b Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Sun, 20 Feb 2022 20:47:52 +0900 Subject: [PATCH 384/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20searchUser=20?= =?UTF-8?q?=EB=A9=94=EC=86=8C=EB=93=9C=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/UserRepositoryCustomImpl.java | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java index d9336bb9d..68976ad13 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java @@ -55,6 +55,38 @@ public List queryUserList(Integer page, AuthorityScope scope, So .fetch(); } + @Override + public List searchUser(AuthorityScope scope, SortStandard sort, Integer grade, Integer classNum, User currentUser, String name) { + return queryFactory + .select(new QUserListInfoVO( + user.id.as("userId"), + user.name, + user.profileImageUrl, + user.section.grade, + user.section.classNum, + user.number, + MathExpressions.round(exerciseAnalysis.walkCount.avg(), 1).as("averageWalkCount"), + exerciseAnalysis.walkCount.sum().as("totalWalkCount"), + MathExpressions.round(exerciseAnalysis.distance.avg(), 1).as("averageDistance"), + exerciseAnalysis.distance.sum().as("totalDistance"), + user.authority.eq(Authority.TEACHER).as("isTeacher") + )) + .from(user) + .join(user.exerciseAnalyses, exerciseAnalysis) + .where( + user.school.eq(currentUser.getSchool()), + buildFilteringCondition(scope), + gradeEq(grade), + classNumEq(classNum), + nameEq(name), + exerciseAnalysis.date.after(LocalDate.now().minusDays(7)) + ) + .orderBy(buildSortCondition(sort)) + .groupBy(user.id) + .fetch(); + + } + private BooleanExpression gradeEq(Integer grade) { return grade != null ? user.section.grade.eq(grade) : null; } @@ -63,6 +95,10 @@ private BooleanExpression classNumEq(Integer classNum) { return classNum != null ? user.section.classNum.eq(classNum) : null; } + private BooleanExpression nameEq(String name) { + return name.isEmpty() ? user.name.contains(name) : null; + } + private BooleanExpression buildFilteringCondition(AuthorityScope scope) { switch (scope) { case ALL: From 937efe8a9e9b20cee9a972cd1e7940324789bbb7 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Sun, 20 Feb 2022 20:56:10 +0900 Subject: [PATCH 385/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20codesmell=20?= =?UTF-8?q?=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/teacher/service/UserSearchForTeacherService.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/service/UserSearchForTeacherService.java b/src/main/java/com/walkhub/walkhub/domain/teacher/service/UserSearchForTeacherService.java index dd27c69d1..a2cbffb9a 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/service/UserSearchForTeacherService.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/service/UserSearchForTeacherService.java @@ -1,6 +1,5 @@ package com.walkhub.walkhub.domain.teacher.service; -import com.walkhub.walkhub.domain.rank.presentation.dto.response.UserListResponse; import com.walkhub.walkhub.domain.teacher.presentation.dto.request.UserSearchRequest; import com.walkhub.walkhub.domain.teacher.presentation.dto.response.QueryUserListResponse; import com.walkhub.walkhub.domain.user.domain.repository.UserRepository; From bedb3db18d059f13d947b14e5b758c8ac1131589 Mon Sep 17 00:00:00 2001 From: jhhong0509 Date: Sun, 20 Feb 2022 23:52:45 +0900 Subject: [PATCH 386/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20(#418)=20Cust?= =?UTF-8?q?omRepository=EC=97=90=20=EC=B1=8C=EB=A6=B0=EC=A7=80=20=EC=B0=B8?= =?UTF-8?q?=EC=97=AC=EC=9E=90=20=EB=AA=A9=EB=A1=9D=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ChallengeStatusRepositoryCustom.java | 4 + .../ChallengeStatusRepositoryCustomImpl.java | 92 ++++++++++++++++++- 2 files changed, 93 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustom.java b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustom.java index ad6ed7640..ce9df4773 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustom.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustom.java @@ -2,8 +2,11 @@ import com.walkhub.walkhub.domain.challenge.domain.Challenge; import com.walkhub.walkhub.domain.challenge.domain.repository.vo.ChallengeParticipantsVO; +import com.walkhub.walkhub.domain.challenge.domain.repository.vo.ChallengeProgressVO; import com.walkhub.walkhub.domain.challenge.domain.repository.vo.RelatedChallengeParticipantsVO; import com.walkhub.walkhub.domain.challenge.domain.repository.vo.ShowChallengeVO; +import com.walkhub.walkhub.domain.challenge.domain.type.ChallengeParticipantsOrder; +import com.walkhub.walkhub.domain.challenge.domain.type.ChallengeParticipantsScope; import com.walkhub.walkhub.domain.challenge.domain.type.SuccessScope; import com.walkhub.walkhub.domain.school.domain.School; import com.walkhub.walkhub.domain.user.domain.User; @@ -17,4 +20,5 @@ public interface ChallengeStatusRepositoryCustom { void deleteNotOverChallengeStatusByUserId(Long userId); void resignParticipatedChallenge(User user); List getAllChallengesByUser(User user); + List queryChallengeProgress(Challenge challenge, ChallengeParticipantsScope participantsScope, ChallengeParticipantsOrder participantsOrder, SuccessScope successScope, Long page); } diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java index 7636468bf..2d741fb0e 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java @@ -1,19 +1,25 @@ package com.walkhub.walkhub.domain.challenge.domain.repository; import com.querydsl.core.group.GroupBy; +import com.querydsl.core.types.Order; +import com.querydsl.core.types.OrderSpecifier; import com.querydsl.core.types.dsl.BooleanExpression; import com.querydsl.core.types.dsl.Expressions; +import com.querydsl.core.types.dsl.NumberExpression; import com.querydsl.core.types.dsl.NumberPath; import com.querydsl.jpa.JPAExpressions; import com.querydsl.jpa.impl.JPAQueryFactory; import com.walkhub.walkhub.domain.challenge.domain.Challenge; import com.walkhub.walkhub.domain.challenge.domain.ChallengeStatus; import com.walkhub.walkhub.domain.challenge.domain.repository.vo.*; +import com.walkhub.walkhub.domain.challenge.domain.type.ChallengeParticipantsOrder; +import com.walkhub.walkhub.domain.challenge.domain.type.ChallengeParticipantsScope; import com.walkhub.walkhub.domain.challenge.domain.type.GoalScope; import com.walkhub.walkhub.domain.challenge.domain.type.SuccessScope; import com.walkhub.walkhub.domain.exercise.domain.type.GoalType; import com.walkhub.walkhub.domain.school.domain.School; import com.walkhub.walkhub.domain.user.domain.User; +import com.walkhub.walkhub.global.enums.Authority; import com.walkhub.walkhub.global.enums.UserScope; import lombok.RequiredArgsConstructor; @@ -31,6 +37,8 @@ @RequiredArgsConstructor public class ChallengeStatusRepositoryCustomImpl implements ChallengeStatusRepositoryCustom { + private static final int PARTICIPANTS_SIZE = 9; + private final JPAQueryFactory queryFactory; @Override @@ -120,10 +128,10 @@ public void deleteNotOverChallengeStatusByUserId(Long userId) { .and(challengeStatus.user.id.eq(userId)) ) .execute(); - } + } - @Override - public List getAllChallengesByUser(User user1) { + @Override + public List getAllChallengesByUser(User user1) { return queryFactory .select(new QShowChallengeVO( challenge.id.as("challengeId"), @@ -224,4 +232,82 @@ public void resignParticipatedChallenge(User user) { private BooleanExpression isChallengeFinished() { return challengeStatus.challenge.endAt.before(LocalDate.now()); } + + + @Override + public List queryChallengeProgress( + Challenge challenge, + ChallengeParticipantsScope participantsScope, + ChallengeParticipantsOrder participantsOrder, + SuccessScope successScope, + Long page + ) { + return queryFactory.select(new QChallengeProgressVO( + user.id, + user.name, + section.grade, + section.classNum, + user.number, + school.name, + user.profileImageUrl, + Expressions.asNumber( + select(exerciseAnalysis.walkCount.sum()) + .from(exerciseAnalysis) + .where(exerciseAnalysis.user.eq(user), + challengeDateFilter(challenge)) + ).intValue(), + getChallengeProgress(challenge).multiply(100).round().longValue(), + exerciseAnalysis.date.count().goe(challenge.getSuccessStandard()), + exerciseAnalysis.date.max())) + .from(user) + .offset(page == null ? 0 : page * PARTICIPANTS_SIZE) + .limit(PARTICIPANTS_SIZE) + .leftJoin(user.section, section) + .join(user.school, school) + .join(user.exerciseAnalyses, exerciseAnalysis) + .join(user.challengeStatuses, challengeStatus) + .where(userScopeFilter(participantsScope), + isChallengeSuccessFilter(challenge), + challengeDateFilter(challenge)) + .orderBy(challengeParticipantsOrder(participantsOrder)) + .fetch(); + } + + private BooleanExpression userScopeFilter(ChallengeParticipantsScope challengeParticipantsScope) { + if (challengeParticipantsScope == ChallengeParticipantsScope.STUDENT) { + return user.authority.eq(Authority.USER); + } else if (challengeParticipantsScope == ChallengeParticipantsScope.TEACHER) { + return user.authority.eq(Authority.TEACHER); + } else { + return null; + } + } + + private NumberExpression getChallengeProgress(Challenge challenge) { + NumberExpression successProgress; + + if (challenge.getGoalScope() == GoalScope.ALL) { + if (challenge.getGoalType() == GoalType.DISTANCE) { + successProgress = exerciseAnalysis.distance.sum(); + } else { + successProgress = exerciseAnalysis.walkCount.sum(); + } + return successProgress.divide(challenge.getGoal()).longValue(); + } else { + return exerciseAnalysis.date.count().divide(challenge.getSuccessStandard()); + } + } + + private OrderSpecifier challengeParticipantsOrder(ChallengeParticipantsOrder challengeParticipantsOrder) { + if (challengeParticipantsOrder == ChallengeParticipantsOrder.USER_NAME || + challengeParticipantsOrder == null) { + return new OrderSpecifier<>(Order.ASC, user.name); + } else if (challengeParticipantsOrder == ChallengeParticipantsOrder.PROGRESS) { + return new OrderSpecifier<>(Order.DESC, exerciseAnalysis.walkCount.sum().divide(exerciseAnalysis.date.count())); + } else if (challengeParticipantsOrder == ChallengeParticipantsOrder.SCHOOL_NAME) { + return new OrderSpecifier<>(Order.ASC, school.name); + } else { + return new OrderSpecifier<>(Order.DESC, exerciseAnalysis.date.max()); + } + } } From 6a8c49054f34b778969128492f450bad6d608ea2 Mon Sep 17 00:00:00 2001 From: jhhong0509 Date: Sun, 20 Feb 2022 23:53:08 +0900 Subject: [PATCH 387/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20(#418)=20DTO?= =?UTF-8?q?=20=EA=B0=9D=EC=B2=B4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/vo/ChallengeProgressVO.java | 40 +++++++++++++++ .../QueryChallengeProgressRequest.java | 16 ++++++ .../QueryChallengeProgressResponse.java | 51 +++++++++++++++++++ 3 files changed, 107 insertions(+) create mode 100644 src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/vo/ChallengeProgressVO.java create mode 100644 src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/dto/request/QueryChallengeProgressRequest.java create mode 100644 src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/dto/response/QueryChallengeProgressResponse.java diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/vo/ChallengeProgressVO.java b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/vo/ChallengeProgressVO.java new file mode 100644 index 000000000..d80f2ff49 --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/vo/ChallengeProgressVO.java @@ -0,0 +1,40 @@ +package com.walkhub.walkhub.domain.challenge.domain.repository.vo; + +import com.querydsl.core.annotations.QueryProjection; +import lombok.Getter; + +import java.time.LocalDate; + +@Getter +public class ChallengeProgressVO { + private final Long userId; + private final String userName; + private final Integer grade; + private final Integer classNum; + private final Integer number; + private final String schoolName; + private final String profileImageUrl; + private final Integer totalWalkCount; + private final Long progress; + private final Boolean isSuccess; + private final LocalDate successDate; + + @QueryProjection + public ChallengeProgressVO(Long userId, String userName, Integer grade, + Integer classNum, Integer number, String schoolName, + String profileImageUrl, Integer totalWalkCount, Long progress, + Boolean isSuccess, LocalDate successDate) { + this.userId = userId; + this.userName = userName; + this.grade = grade; + this.classNum = classNum; + this.number = number; + this.schoolName = schoolName; + this.profileImageUrl = profileImageUrl; + this.totalWalkCount = totalWalkCount; + this.progress = progress; + this.isSuccess = isSuccess; + this.successDate = successDate; + } + +} diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/dto/request/QueryChallengeProgressRequest.java b/src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/dto/request/QueryChallengeProgressRequest.java new file mode 100644 index 000000000..cc0230b8a --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/dto/request/QueryChallengeProgressRequest.java @@ -0,0 +1,16 @@ +package com.walkhub.walkhub.domain.challenge.presenstation.dto.request; + +import com.walkhub.walkhub.domain.challenge.domain.type.ChallengeParticipantsOrder; +import com.walkhub.walkhub.domain.challenge.domain.type.ChallengeParticipantsScope; +import com.walkhub.walkhub.domain.challenge.domain.type.SuccessScope; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public class QueryChallengeProgressRequest { + private final ChallengeParticipantsScope participantsScope; + private final ChallengeParticipantsOrder participantsOrder; + private final SuccessScope successScope; + private final Long page; +} diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/dto/response/QueryChallengeProgressResponse.java b/src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/dto/response/QueryChallengeProgressResponse.java new file mode 100644 index 000000000..b92cf66d5 --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/dto/response/QueryChallengeProgressResponse.java @@ -0,0 +1,51 @@ +package com.walkhub.walkhub.domain.challenge.presenstation.dto.response; + +import com.walkhub.walkhub.domain.challenge.domain.type.GoalScope; +import com.walkhub.walkhub.domain.exercise.domain.type.GoalType; +import com.walkhub.walkhub.global.enums.UserScope; +import lombok.Builder; +import lombok.Getter; + +import java.time.LocalDate; +import java.util.List; + +@Getter +@Builder +public class QueryChallengeProgressResponse { + + private final String name; + private final Long userId; + private final String content; + private final String imageUrl; + private final String writerName; + private final String writerProfileImageUrl; + private final String award; + private final LocalDate startAt; + private final LocalDate endAt; + private final Integer goal; + private final GoalScope goalScope; + private final UserScope userScope; + private final GoalType goalType; + private final Integer classNum; + private final Integer grade; + private final Integer successStandard; + private final Long count; + private final List userResponse; + + @Getter + @Builder + public static class UserChallengeProgressResponse { + private final Long userId; + private final String userName; + private final Integer grade; + private final Integer classNum; + private final Integer number; + private final String schoolName; + private final String profileImageUrl; + private final Integer totalWalkCount; + private final Long progress; + private final Boolean isSuccess; + private final LocalDate successDate; + } + +} From 7ce4e5daea5098fcfda5e9b940bd62f9d4117f98 Mon Sep 17 00:00:00 2001 From: jhhong0509 Date: Sun, 20 Feb 2022 23:53:28 +0900 Subject: [PATCH 388/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20(#418)=20Enum?= =?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 --- .../challenge/domain/type/ChallengeParticipantsOrder.java | 8 ++++++++ .../challenge/domain/type/ChallengeParticipantsScope.java | 7 +++++++ 2 files changed, 15 insertions(+) create mode 100644 src/main/java/com/walkhub/walkhub/domain/challenge/domain/type/ChallengeParticipantsOrder.java create mode 100644 src/main/java/com/walkhub/walkhub/domain/challenge/domain/type/ChallengeParticipantsScope.java diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/type/ChallengeParticipantsOrder.java b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/type/ChallengeParticipantsOrder.java new file mode 100644 index 000000000..45a3dd8e6 --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/type/ChallengeParticipantsOrder.java @@ -0,0 +1,8 @@ +package com.walkhub.walkhub.domain.challenge.domain.type; + +public enum ChallengeParticipantsOrder { + SCHOOL_NAME, + USER_NAME, + SUCCESS_DATE, + PROGRESS +} diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/type/ChallengeParticipantsScope.java b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/type/ChallengeParticipantsScope.java new file mode 100644 index 000000000..fc49c1b3d --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/type/ChallengeParticipantsScope.java @@ -0,0 +1,7 @@ +package com.walkhub.walkhub.domain.challenge.domain.type; + +public enum ChallengeParticipantsScope { + ALL, + STUDENT, + TEACHER +} From 5df93d80e559b49cb78cd7f0924cf64b93695b16 Mon Sep 17 00:00:00 2001 From: jhhong0509 Date: Mon, 21 Feb 2022 00:06:48 +0900 Subject: [PATCH 389/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20(#418)=20null?= =?UTF-8?q?=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../auth/service/TokenRefreshService.java | 2 + .../QueryChallengeProgressService.java | 81 +++++++++++++++++++ 2 files changed, 83 insertions(+) create mode 100644 src/main/java/com/walkhub/walkhub/domain/challenge/service/QueryChallengeProgressService.java diff --git a/src/main/java/com/walkhub/walkhub/domain/auth/service/TokenRefreshService.java b/src/main/java/com/walkhub/walkhub/domain/auth/service/TokenRefreshService.java index f31fcb0d6..30c4cd9b8 100644 --- a/src/main/java/com/walkhub/walkhub/domain/auth/service/TokenRefreshService.java +++ b/src/main/java/com/walkhub/walkhub/domain/auth/service/TokenRefreshService.java @@ -27,6 +27,8 @@ public UserAccessTokenResponse execute(String refreshToken) { redisRefreshToken.updateExp(jwtProperties.getRefreshExp()); String accessToken = jwtTokenProvider.generateAccessToken(redisRefreshToken.getAccountId()); + System.out.println(LocalDateTime.now()); + System.out.println(LocalDateTime.now().plusSeconds(jwtProperties.getAccessExp())); return UserAccessTokenResponse.builder() .accessToken(accessToken) .expiredAt(LocalDateTime.now().plusSeconds(jwtProperties.getAccessExp())) diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/service/QueryChallengeProgressService.java b/src/main/java/com/walkhub/walkhub/domain/challenge/service/QueryChallengeProgressService.java new file mode 100644 index 000000000..cbec440c5 --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/service/QueryChallengeProgressService.java @@ -0,0 +1,81 @@ +package com.walkhub.walkhub.domain.challenge.service; + +import com.walkhub.walkhub.domain.challenge.domain.Challenge; +import com.walkhub.walkhub.domain.challenge.domain.repository.ChallengeStatusRepository; +import com.walkhub.walkhub.domain.challenge.domain.repository.vo.ChallengeProgressVO; +import com.walkhub.walkhub.domain.challenge.facade.ChallengeFacade; +import com.walkhub.walkhub.domain.challenge.presenstation.dto.request.QueryChallengeProgressRequest; +import com.walkhub.walkhub.domain.challenge.presenstation.dto.response.QueryChallengeProgressResponse; +import com.walkhub.walkhub.domain.user.domain.User; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.stream.Collectors; + +@RequiredArgsConstructor +@Service +public class QueryChallengeProgressService { + + private final ChallengeStatusRepository challengeStatusRepository; + private final ChallengeFacade challengeFacade; + + public QueryChallengeProgressResponse execute(Long challengeId, QueryChallengeProgressRequest request) { + Challenge challenge = challengeFacade.getChallengeById(challengeId); + + List challengeProgressVOS = challengeStatusRepository.queryChallengeProgress( + challenge, + request.getParticipantsScope(), + request.getParticipantsOrder(), + request.getSuccessScope(), + request.getPage() + ); + + List challengeProgressResponses = challengeProgressVOS.stream() + .map(this::buildUserChallengeProgressResponse) + .collect(Collectors.toList()); + + User challengeCreator = challenge.getUser(); + + return QueryChallengeProgressResponse.builder() + .userResponse(challengeProgressResponses) + .award(challenge.getAward()) + .classNum(challengeCreator.hasSection() ? challengeCreator.getSection().getClassNum() : null) + .content(challenge.getContent()) + .count((long) challenge.getChallengeStatuses().size()) + .endAt(challenge.getEndAt()) + .goal(challenge.getGoal()) + .goalScope(challenge.getGoalScope()) + .goalType(challenge.getGoalType()) + .grade(challengeCreator.hasSection() ? challengeCreator.getSection().getGrade() : null) + .imageUrl(challenge.getImageUrl()) + .name(challenge.getName()) + .startAt(challenge.getStartAt()) + .successStandard(challenge.getSuccessStandard()) + .userId(challengeCreator.getId()) + .userScope(challenge.getUserScope()) + .writerName(challengeCreator.getName()) + .writerProfileImageUrl(challengeCreator.getProfileImageUrl()) + .name(challenge.getName()) + .build(); + } + + private QueryChallengeProgressResponse.UserChallengeProgressResponse buildUserChallengeProgressResponse(ChallengeProgressVO vo) { + if (vo.getUserId() != null) { + return null; + } + return QueryChallengeProgressResponse.UserChallengeProgressResponse.builder() + .classNum(vo.getClassNum()) + .progress(vo.getProgress()) + .grade(vo.getGrade()) + .isSuccess(vo.getIsSuccess()) + .number(vo.getNumber()) + .profileImageUrl(vo.getProfileImageUrl()) + .schoolName(vo.getSchoolName()) + .successDate(vo.getSuccessDate()) + .totalWalkCount(vo.getTotalWalkCount()) + .userId(vo.getUserId()) + .userName(vo.getUserName()) + .build(); + } +} From da4560f21c1412691dce235b8a883be7aa6ff487 Mon Sep 17 00:00:00 2001 From: jhhong0509 Date: Mon, 21 Feb 2022 00:07:28 +0900 Subject: [PATCH 390/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20(#418)=20Secu?= =?UTF-8?q?rityConfig=EC=97=90=20progress=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/walkhub/walkhub/global/security/SecurityConfig.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java b/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java index e59896f96..05d767ba6 100644 --- a/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java +++ b/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java @@ -95,6 +95,7 @@ protected void configure(HttpSecurity http) throws Exception { .antMatchers(HttpMethod.POST, "/challenges").hasAnyAuthority("TEACHER", "ROOT", "SU") .antMatchers(HttpMethod.PATCH, "/challenges/{challenge-id}").hasAnyAuthority("TEACHER", "ROOT", "SU") .antMatchers(HttpMethod.DELETE, "/challenges/{challenge-id}").hasAnyAuthority("TEACHER", "ROOT", "SU") + .antMatchers(HttpMethod.GET, "/challenges/{challenge-id}/progress").hasAuthority("TEACHER") .antMatchers(HttpMethod.GET, "/challenges/{challenge-id}").authenticated() .antMatchers(HttpMethod.POST, "/challenges/{challenge-id}").authenticated() .antMatchers(HttpMethod.GET, "/challenges/{challenge-id}/participants/students").authenticated() From b6e423a5558db041a58266dd90c4b5a5825e54ca Mon Sep 17 00:00:00 2001 From: jhhong0509 Date: Mon, 21 Feb 2022 00:07:44 +0900 Subject: [PATCH 391/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20(#418)=20Cont?= =?UTF-8?q?roller=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presenstation/ChallengeController.java | 36 +++++++------------ 1 file changed, 12 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/ChallengeController.java b/src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/ChallengeController.java index 6a40ef544..3dc41e54d 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/ChallengeController.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/ChallengeController.java @@ -2,32 +2,13 @@ import com.walkhub.walkhub.domain.challenge.domain.type.SuccessScope; import com.walkhub.walkhub.domain.challenge.presenstation.dto.request.CreateChallengeRequest; +import com.walkhub.walkhub.domain.challenge.presenstation.dto.request.QueryChallengeProgressRequest; import com.walkhub.walkhub.domain.challenge.presenstation.dto.request.UpdateChallengeRequest; -import com.walkhub.walkhub.domain.challenge.presenstation.dto.response.QueryChallengeDetailsResponse; -import com.walkhub.walkhub.domain.challenge.presenstation.dto.response.QueryChallengeListResponse; -import com.walkhub.walkhub.domain.challenge.presenstation.dto.response.QueryChallengeParticipantsForStudentResponse; +import com.walkhub.walkhub.domain.challenge.presenstation.dto.response.*; import com.walkhub.walkhub.domain.challenge.service.*; -import com.walkhub.walkhub.domain.challenge.presenstation.dto.response.QueryChallengeParticipantsForTeacherResponse; -import com.walkhub.walkhub.domain.challenge.service.CreateChallengeService; -import com.walkhub.walkhub.domain.challenge.service.ParticipateChallengeService; -import com.walkhub.walkhub.domain.challenge.service.QueryChallengeDetailsService; -import com.walkhub.walkhub.domain.challenge.service.QueryChallengeListService; -import com.walkhub.walkhub.domain.challenge.service.QueryChallengeParticipantsForTeacherService; -import com.walkhub.walkhub.domain.challenge.service.QueryParticipatedChallengeListService; -import com.walkhub.walkhub.domain.challenge.service.RemoveChallengeService; -import com.walkhub.walkhub.domain.challenge.service.UpdateChallengeService; import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PatchMapping; -import org.springframework.web.bind.annotation.PathVariable; -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.RequestParam; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import javax.validation.Valid; @@ -46,6 +27,7 @@ public class ChallengeController { private final QueryParticipatedChallengeListService queryParticipatedChallengeListService; private final QueryChallengeParticipantsForStudentService queryChallengeParticipantsForStudentService; private final QueryChallengeParticipantsForTeacherService queryChallengeParticipantsForTeacherService; + private final QueryChallengeProgressService challengeProgressService; @ResponseStatus(HttpStatus.NO_CONTENT) @DeleteMapping("/{challenge-id}") @@ -86,7 +68,7 @@ public QueryChallengeDetailsResponse queryChallengeDetails(@PathVariable("challe public void participateChallenge(@PathVariable("challenge-id") Long challengeId) { participateChallengeService.execute(challengeId); } - + @GetMapping("/participated") public QueryChallengeListResponse queryParticipatedChallengeList() { return queryParticipatedChallengeListService.execute(); @@ -96,11 +78,17 @@ public QueryChallengeListResponse queryParticipatedChallengeList() { public QueryChallengeParticipantsForStudentResponse queryChallengeParticipantsForStudent(@PathVariable("challenge-id") Long challengeId) { return queryChallengeParticipantsForStudentService.execute(challengeId); } - + @GetMapping("/{challenge-id}/participants/teachers") public QueryChallengeParticipantsForTeacherResponse queryChallengeParticipantsForTeacher(@PathVariable("challenge-id") Long challengeId, @RequestParam SuccessScope successScope, @RequestParam Long page) { return queryChallengeParticipantsForTeacherService.execute(challengeId, successScope, page); } + + @GetMapping("/{challenge-id}/progress") + public QueryChallengeProgressResponse queryChallengeProgress(@PathVariable("challenge-id") Long challengeId, + QueryChallengeProgressRequest request) { + return challengeProgressService.execute(challengeId, request); + } } From f80c73cd858175a19afdce77b445c47f438a0ac6 Mon Sep 17 00:00:00 2001 From: jhhong0509 Date: Mon, 21 Feb 2022 00:13:37 +0900 Subject: [PATCH 392/522] =?UTF-8?q?:coffin:=20::=20(#418)=20=EA=B8=B0?= =?UTF-8?q?=EC=A1=B4=20API=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ChallengeStatusRepositoryCustom.java | 1 - .../ChallengeStatusRepositoryCustomImpl.java | 71 ------------------- .../presenstation/ChallengeController.java | 14 ++-- ...allengeParticipantsForTeacherResponse.java | 30 -------- ...hallengeParticipantsForTeacherService.java | 50 ------------- .../walkhub/global/error/ExceptionFilter.java | 1 + 6 files changed, 5 insertions(+), 162 deletions(-) delete mode 100644 src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/dto/response/QueryChallengeParticipantsForTeacherResponse.java delete mode 100644 src/main/java/com/walkhub/walkhub/domain/challenge/service/QueryChallengeParticipantsForTeacherService.java diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustom.java b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustom.java index ce9df4773..b73de34dd 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustom.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustom.java @@ -16,7 +16,6 @@ public interface ChallengeStatusRepositoryCustom { Integer getParticipantsCountByChallengeId(Long challengeId); List getRelatedChallengeParticipantsList(Long challengeId, School school, Integer grade, Integer classNum); - List queryChallengeParticipantsList(Challenge challenge, SuccessScope successScope, Long page); void deleteNotOverChallengeStatusByUserId(Long userId); void resignParticipatedChallenge(User user); List getAllChallengesByUser(User user); diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java index 2d741fb0e..a9bf0608d 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java @@ -1,6 +1,5 @@ package com.walkhub.walkhub.domain.challenge.domain.repository; -import com.querydsl.core.group.GroupBy; import com.querydsl.core.types.Order; import com.querydsl.core.types.OrderSpecifier; import com.querydsl.core.types.dsl.BooleanExpression; @@ -26,7 +25,6 @@ import java.time.LocalDate; import java.util.List; -import static com.querydsl.core.group.GroupBy.groupBy; import static com.querydsl.jpa.JPAExpressions.select; import static com.walkhub.walkhub.domain.challenge.domain.QChallenge.challenge; import static com.walkhub.walkhub.domain.challenge.domain.QChallengeStatus.challengeStatus; @@ -77,47 +75,6 @@ public List getRelatedChallengeParticipantsList( .fetch(); } - @Override - public List queryChallengeParticipantsList(Challenge challenge, SuccessScope successScope, Long page) { - final long size = 20L; - return queryFactory - .selectFrom(user) - .join(user.school, school) - .leftJoin(user.section, section) - .join(user.exerciseAnalyses, exerciseAnalysis) - .join(user.challengeStatuses, challengeStatus) - .join(challengeStatus.challenge) - .on(challengeStatus.challenge.eq(challenge)) - .where( - successScopeFilter(challenge, successScope), - isChallengeSuccessFilter(challenge), - challengeDateFilter(challenge) - ) - .offset(page * size) - .limit(size) - .orderBy(user.name.asc(), user.id.asc(), exerciseAnalysis.date.asc()) - .transform(groupBy(user.name, user.id) - .list(new QChallengeParticipantsVO( - user.id.as("userId"), - user.section.grade, - user.section.classNum, - user.number, - user.name, - user.profileImageUrl, - user.school.name.as("schoolName"), - Expressions.asNumber(select(exerciseAnalysis.count()) - .from(exerciseAnalysis) - .where( - exerciseAnalysis.user.eq(user), - isChallengeSuccessFilter(challenge), - challengeDateFilter(challenge) - )) - .goe(challenge.getSuccessStandard()).as("isSuccess"), - GroupBy.list(exerciseAnalysis.date)) - ) - ); - } - @Override public void deleteNotOverChallengeStatusByUserId(Long userId) { queryFactory @@ -154,34 +111,6 @@ public List getAllChallengesByUser(User user1) { .fetch(); } - private BooleanExpression successScopeFilter(Challenge challenge, SuccessScope successScope) { - switch (successScope) { - case TRUE: { - return Expressions.asNumber(select(exerciseAnalysis.count()) - .from(exerciseAnalysis) - .where( - exerciseAnalysis.user.eq(user), - isChallengeSuccessFilter(challenge), - challengeDateFilter(challenge) - )) - .goe(challenge.getSuccessStandard()); - } - case FALSE: { - return Expressions.asNumber(select(exerciseAnalysis.count()) - .from(exerciseAnalysis) - .where( - exerciseAnalysis.user.eq(user), - isChallengeSuccessFilter(challenge), - challengeDateFilter(challenge) - )) - .lt(challenge.getSuccessStandard()); - } - default: { - return null; - } - } - } - private BooleanExpression isChallengeSuccessFilter(Challenge challenge) { if (challenge.getGoalScope() == GoalScope.DAY) { return isChallengeSuccessInDayScope(challenge); diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/ChallengeController.java b/src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/ChallengeController.java index 3dc41e54d..ed644b3da 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/ChallengeController.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/ChallengeController.java @@ -1,10 +1,12 @@ package com.walkhub.walkhub.domain.challenge.presenstation; -import com.walkhub.walkhub.domain.challenge.domain.type.SuccessScope; import com.walkhub.walkhub.domain.challenge.presenstation.dto.request.CreateChallengeRequest; import com.walkhub.walkhub.domain.challenge.presenstation.dto.request.QueryChallengeProgressRequest; import com.walkhub.walkhub.domain.challenge.presenstation.dto.request.UpdateChallengeRequest; -import com.walkhub.walkhub.domain.challenge.presenstation.dto.response.*; +import com.walkhub.walkhub.domain.challenge.presenstation.dto.response.QueryChallengeDetailsResponse; +import com.walkhub.walkhub.domain.challenge.presenstation.dto.response.QueryChallengeListResponse; +import com.walkhub.walkhub.domain.challenge.presenstation.dto.response.QueryChallengeParticipantsForStudentResponse; +import com.walkhub.walkhub.domain.challenge.presenstation.dto.response.QueryChallengeProgressResponse; import com.walkhub.walkhub.domain.challenge.service.*; import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; @@ -26,7 +28,6 @@ public class ChallengeController { private final ParticipateChallengeService participateChallengeService; private final QueryParticipatedChallengeListService queryParticipatedChallengeListService; private final QueryChallengeParticipantsForStudentService queryChallengeParticipantsForStudentService; - private final QueryChallengeParticipantsForTeacherService queryChallengeParticipantsForTeacherService; private final QueryChallengeProgressService challengeProgressService; @ResponseStatus(HttpStatus.NO_CONTENT) @@ -79,13 +80,6 @@ public QueryChallengeParticipantsForStudentResponse queryChallengeParticipantsFo return queryChallengeParticipantsForStudentService.execute(challengeId); } - @GetMapping("/{challenge-id}/participants/teachers") - public QueryChallengeParticipantsForTeacherResponse queryChallengeParticipantsForTeacher(@PathVariable("challenge-id") Long challengeId, - @RequestParam SuccessScope successScope, - @RequestParam Long page) { - return queryChallengeParticipantsForTeacherService.execute(challengeId, successScope, page); - } - @GetMapping("/{challenge-id}/progress") public QueryChallengeProgressResponse queryChallengeProgress(@PathVariable("challenge-id") Long challengeId, QueryChallengeProgressRequest request) { diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/dto/response/QueryChallengeParticipantsForTeacherResponse.java b/src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/dto/response/QueryChallengeParticipantsForTeacherResponse.java deleted file mode 100644 index 60d0576df..000000000 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/dto/response/QueryChallengeParticipantsForTeacherResponse.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.walkhub.walkhub.domain.challenge.presenstation.dto.response; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; - -import java.time.LocalDate; -import java.util.List; - -@Getter -@AllArgsConstructor -public class QueryChallengeParticipantsForTeacherResponse { - - private final List challengeParticipantsList; - - @Getter - @Builder - public static class ChallengeParticipants { - private final Long userId; - private final Integer grade; - private final Integer classNum; - private final Integer number; - private final String name; - private final String profileImageUrl; - private final String schoolName; - private final List successDate; - private final Boolean isSuccess; - } - -} diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/service/QueryChallengeParticipantsForTeacherService.java b/src/main/java/com/walkhub/walkhub/domain/challenge/service/QueryChallengeParticipantsForTeacherService.java deleted file mode 100644 index a913a7059..000000000 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/service/QueryChallengeParticipantsForTeacherService.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.walkhub.walkhub.domain.challenge.service; - -import com.walkhub.walkhub.domain.challenge.domain.Challenge; -import com.walkhub.walkhub.domain.challenge.domain.repository.ChallengeStatusRepository; -import com.walkhub.walkhub.domain.challenge.domain.type.SuccessScope; -import com.walkhub.walkhub.domain.challenge.facade.ChallengeFacade; -import com.walkhub.walkhub.domain.challenge.presenstation.dto.response.QueryChallengeParticipantsForTeacherResponse; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import java.util.List; -import java.util.stream.Collectors; - -@RequiredArgsConstructor -@Service -public class QueryChallengeParticipantsForTeacherService { - private final ChallengeFacade challengeFacade; - private final ChallengeStatusRepository challengeStatusRepository; - - @Transactional(readOnly = true) - public QueryChallengeParticipantsForTeacherResponse execute(Long challengeId, SuccessScope successScope, Long page) { - Challenge challenge = challengeFacade.getChallengeById(challengeId); - - return new QueryChallengeParticipantsForTeacherResponse( - queryChallengeParticipantsForTeacherResponseBuilder(challenge, successScope, page) - ); - } - - private List queryChallengeParticipantsForTeacherResponseBuilder( - Challenge challenge, SuccessScope successScope, Long page - ) { - return challengeStatusRepository.queryChallengeParticipantsList(challenge, successScope, page) - .stream() - .map(vo -> QueryChallengeParticipantsForTeacherResponse.ChallengeParticipants.builder() - .userId(vo.getUserId()) - .grade(vo.getGrade()) - .classNum(vo.getClassNum()) - .number(vo.getNumber()) - .name(vo.getName()) - .profileImageUrl(vo.getProfileImageUrl()) - .schoolName(vo.getSchoolName()) - .successDate(vo.getExerciseAnalysesDates()) - .isSuccess(vo.getIsSuccess()) - .build() - ) - .collect(Collectors.toList()); - } - -} diff --git a/src/main/java/com/walkhub/walkhub/global/error/ExceptionFilter.java b/src/main/java/com/walkhub/walkhub/global/error/ExceptionFilter.java index a89661f34..7d6e746a5 100644 --- a/src/main/java/com/walkhub/walkhub/global/error/ExceptionFilter.java +++ b/src/main/java/com/walkhub/walkhub/global/error/ExceptionFilter.java @@ -26,6 +26,7 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse sendErrorMessage(response, e.getErrorCode()); } catch (Exception e) { logger.error(e); + e.printStackTrace(); sendErrorMessage(response, ErrorCode.INTERNAL_SERVER_ERROR); } } From c7020996c798dce76e2fb158a0fce229f462436f Mon Sep 17 00:00:00 2001 From: jhhong0509 Date: Mon, 21 Feb 2022 00:34:14 +0900 Subject: [PATCH 393/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20(#418)=20Code?= =?UTF-8?q?Smell=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../walkhub/domain/auth/service/TokenRefreshService.java | 2 -- .../domain/repository/ChallengeStatusRepositoryCustom.java | 1 - 2 files changed, 3 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/auth/service/TokenRefreshService.java b/src/main/java/com/walkhub/walkhub/domain/auth/service/TokenRefreshService.java index 30c4cd9b8..f31fcb0d6 100644 --- a/src/main/java/com/walkhub/walkhub/domain/auth/service/TokenRefreshService.java +++ b/src/main/java/com/walkhub/walkhub/domain/auth/service/TokenRefreshService.java @@ -27,8 +27,6 @@ public UserAccessTokenResponse execute(String refreshToken) { redisRefreshToken.updateExp(jwtProperties.getRefreshExp()); String accessToken = jwtTokenProvider.generateAccessToken(redisRefreshToken.getAccountId()); - System.out.println(LocalDateTime.now()); - System.out.println(LocalDateTime.now().plusSeconds(jwtProperties.getAccessExp())); return UserAccessTokenResponse.builder() .accessToken(accessToken) .expiredAt(LocalDateTime.now().plusSeconds(jwtProperties.getAccessExp())) diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustom.java b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustom.java index e688d732e..e71d0bdac 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustom.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustom.java @@ -1,7 +1,6 @@ package com.walkhub.walkhub.domain.challenge.domain.repository; import com.walkhub.walkhub.domain.challenge.domain.Challenge; -import com.walkhub.walkhub.domain.challenge.domain.repository.vo.ChallengeParticipantsVO; import com.walkhub.walkhub.domain.challenge.domain.repository.vo.ChallengeProgressVO; import com.walkhub.walkhub.domain.challenge.domain.repository.vo.RelatedChallengeParticipantsVO; import com.walkhub.walkhub.domain.challenge.domain.repository.vo.ShowChallengeVO; From f5c337d5a94c10aa812cf9aeed7c65ec4946959b Mon Sep 17 00:00:00 2001 From: jhhong0509 Date: Mon, 21 Feb 2022 00:39:29 +0900 Subject: [PATCH 394/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20(#418)=20prin?= =?UTF-8?q?t=EB=AC=B8=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/walkhub/walkhub/global/error/ExceptionFilter.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/global/error/ExceptionFilter.java b/src/main/java/com/walkhub/walkhub/global/error/ExceptionFilter.java index 7d6e746a5..a89661f34 100644 --- a/src/main/java/com/walkhub/walkhub/global/error/ExceptionFilter.java +++ b/src/main/java/com/walkhub/walkhub/global/error/ExceptionFilter.java @@ -26,7 +26,6 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse sendErrorMessage(response, e.getErrorCode()); } catch (Exception e) { logger.error(e); - e.printStackTrace(); sendErrorMessage(response, ErrorCode.INTERNAL_SERVER_ERROR); } } From 28dac97750f41d6917e45d7f2c4e225a86a8c8e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B2=94=EC=A7=84?= Date: Mon, 21 Feb 2022 20:22:59 +0900 Subject: [PATCH 395/522] =?UTF-8?q?=E2=9A=A1=20::=20(#420)=20=ED=95=B4?= =?UTF-8?q?=EB=8B=B9=20=EB=B0=98=EC=9D=B4=20=EC=9D=B4=EB=AF=B8=20=EC=A1=B4?= =?UTF-8?q?=EC=9E=AC=ED=95=98=EB=8A=94=EC=A7=80=20=EA=B2=80=EC=82=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../walkhub/domain/user/domain/repository/SectionRepository.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/SectionRepository.java b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/SectionRepository.java index 7498d3b8b..a753202bb 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/SectionRepository.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/SectionRepository.java @@ -8,4 +8,5 @@ public interface SectionRepository extends JpaRepository { Optional
findByClassCodeAndSchool(String classCode, School school); + Optional
findBySchoolAndGradeAndClassNum(School school, Integer grade, Integer classNum); } From f898017b0723986b547e0ccb52be9a4997a7b995 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B2=94=EC=A7=84?= Date: Mon, 21 Feb 2022 20:23:18 +0900 Subject: [PATCH 396/522] =?UTF-8?q?=E2=99=BB=20::=20(#420)=20=EB=B0=98=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1=20=EC=8B=9C=20409=20=EC=98=88=EC=99=B8=20?= =?UTF-8?q?=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/teacher/service/CreateClassService.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/service/CreateClassService.java b/src/main/java/com/walkhub/walkhub/domain/teacher/service/CreateClassService.java index 5ffbe73d2..6e171dae6 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/service/CreateClassService.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/service/CreateClassService.java @@ -35,13 +35,13 @@ public CodeResponse execute(CreateClassRequest request) { .classCode(classCode) .build(); - try { - Section savedSection = sectionRepository.save(section); - user.setSection(savedSection); - } catch (DataIntegrityViolationException e) { + if (user.hasSection() || sectionRepository.findBySchoolAndGradeAndClassNum(userSchool, grade, classNum).isPresent()) { throw AlreadyCreatedException.EXCEPTION; } + Section savedSection = sectionRepository.save(section); + user.setSection(savedSection); + return new CodeResponse(classCode); } From 02eb8bfec5e4d6b81ca0ea9fff1560c6a26b4336 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B2=94=EC=A7=84?= Date: Mon, 21 Feb 2022 20:29:22 +0900 Subject: [PATCH 397/522] =?UTF-8?q?=E2=99=BB=20::=20(#420)=20code=20smell?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../walkhub/domain/teacher/service/CreateClassService.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/service/CreateClassService.java b/src/main/java/com/walkhub/walkhub/domain/teacher/service/CreateClassService.java index 6e171dae6..10ab872d8 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/service/CreateClassService.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/service/CreateClassService.java @@ -10,7 +10,6 @@ import com.walkhub.walkhub.domain.user.facade.UserFacade; import com.walkhub.walkhub.global.utils.code.RandomCodeUtil; import lombok.RequiredArgsConstructor; -import org.springframework.dao.DataIntegrityViolationException; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; From 7e073ba37a9f917913398a7bc77625187017948e Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Mon, 21 Feb 2022 22:39:50 +0900 Subject: [PATCH 398/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20=EC=96=B4?= =?UTF-8?q?=EB=85=B8=ED=85=8C=EC=9D=B4=EC=85=98=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../teacher/presentation/dto/request/UserSearchRequest.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/request/UserSearchRequest.java b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/request/UserSearchRequest.java index 806d12494..62dc6269f 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/request/UserSearchRequest.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/request/UserSearchRequest.java @@ -2,9 +2,11 @@ import com.walkhub.walkhub.domain.teacher.type.AuthorityScope; import com.walkhub.walkhub.domain.teacher.type.SortStandard; -import lombok.Data; +import lombok.AllArgsConstructor; +import lombok.Getter; -@Data +@Getter +@AllArgsConstructor public class UserSearchRequest { private AuthorityScope scope; private SortStandard sort; From 3140e37b88586f37b970eaaf774bc302b2d8e4aa Mon Sep 17 00:00:00 2001 From: jhhong0509 Date: Tue, 22 Feb 2022 07:04:25 +0900 Subject: [PATCH 399/522] =?UTF-8?q?:recycle:=20::=20(#418)=20switch=20case?= =?UTF-8?q?=EB=AC=B8=EC=9C=BC=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 --- .../ChallengeStatusRepositoryCustomImpl.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java index 8bbd547a2..fc6632265 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java @@ -220,15 +220,16 @@ private NumberExpression getChallengeProgress(Challenge challenge) { } private OrderSpecifier challengeParticipantsOrder(ChallengeParticipantsOrder challengeParticipantsOrder) { - if (challengeParticipantsOrder == ChallengeParticipantsOrder.USER_NAME || - challengeParticipantsOrder == null) { - return new OrderSpecifier<>(Order.ASC, user.name); - } else if (challengeParticipantsOrder == ChallengeParticipantsOrder.PROGRESS) { - return new OrderSpecifier<>(Order.DESC, exerciseAnalysis.walkCount.sum().divide(exerciseAnalysis.date.count())); - } else if (challengeParticipantsOrder == ChallengeParticipantsOrder.SCHOOL_NAME) { - return new OrderSpecifier<>(Order.ASC, school.name); - } else { - return new OrderSpecifier<>(Order.DESC, exerciseAnalysis.date.max()); + switch (challengeParticipantsOrder) { + case SUCCESS_DATE: + return new OrderSpecifier<>(Order.DESC, exerciseAnalysis.date.max()); + case PROGRESS: + return new OrderSpecifier<>(Order.DESC, exerciseAnalysis.walkCount.sum().divide(exerciseAnalysis.date.count())); + case SCHOOL_NAME: + return new OrderSpecifier<>(Order.ASC, school.name); + default: + return new OrderSpecifier<>(Order.ASC, user.name); + } } } From 622b7d1cc196bc64761e0efe160c4795e6748a85 Mon Sep 17 00:00:00 2001 From: jhhong0509 Date: Tue, 22 Feb 2022 07:05:38 +0900 Subject: [PATCH 400/522] =?UTF-8?q?:recycle:=20::=20(#418)=20switch=20case?= =?UTF-8?q?=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 --- .../ChallengeStatusRepositoryCustomImpl.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java index fc6632265..bf4879d8f 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java @@ -195,12 +195,13 @@ public List queryChallengeProgress( } private BooleanExpression userScopeFilter(ChallengeParticipantsScope challengeParticipantsScope) { - if (challengeParticipantsScope == ChallengeParticipantsScope.STUDENT) { - return user.authority.eq(Authority.USER); - } else if (challengeParticipantsScope == ChallengeParticipantsScope.TEACHER) { - return user.authority.eq(Authority.TEACHER); - } else { - return null; + switch (challengeParticipantsScope) { + case STUDENT: + return user.authority.eq(Authority.USER); + case TEACHER: + return user.authority.eq(Authority.TEACHER); + default: + return null; } } From 68cd5560fce8390d62b998f5dbde6602cd36ae6a Mon Sep 17 00:00:00 2001 From: jhhong0509 Date: Tue, 22 Feb 2022 12:49:05 +0900 Subject: [PATCH 401/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20(#418)=20Succ?= =?UTF-8?q?essScope=20=ED=95=84=ED=84=B0=EB=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ChallengeStatusRepositoryCustomImpl.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java index bf4879d8f..6a4448b3c 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java @@ -189,7 +189,8 @@ public List queryChallengeProgress( .join(user.challengeStatuses, challengeStatus) .where(userScopeFilter(participantsScope), isChallengeSuccessFilter(challenge), - challengeDateFilter(challenge)) + challengeDateFilter(challenge), + challengeSuccessFilter(successScope, challenge)) .orderBy(challengeParticipantsOrder(participantsOrder)) .fetch(); } @@ -205,6 +206,17 @@ private BooleanExpression userScopeFilter(ChallengeParticipantsScope challengePa } } + private BooleanExpression challengeSuccessFilter(SuccessScope successScope, Challenge challenge) { + switch (successScope) { + case TRUE: + return exerciseAnalysis.date.count().goe(challenge.getSuccessStandard()); + case FALSE: + return exerciseAnalysis.date.count().lt(challenge.getSuccessStandard()); + default: + return null; + } + } + private NumberExpression getChallengeProgress(Challenge challenge) { NumberExpression successProgress; From 5edd97d03b2166fa8247d1325811769b9406dfa0 Mon Sep 17 00:00:00 2001 From: jhhong0509 Date: Tue, 22 Feb 2022 12:53:41 +0900 Subject: [PATCH 402/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20(#418)=20?= =?UTF-8?q?=EB=A7=8C=EC=95=BD=20=EC=B1=8C=EB=A6=B0=EC=A7=80=EB=A5=BC=20?= =?UTF-8?q?=EC=84=B1=EA=B3=B5=ED=95=98=EC=A7=80=20=EB=AA=BB=ED=96=88?= =?UTF-8?q?=EB=8B=A4=EB=A9=B4=20null=20=EB=B0=98=ED=99=98=ED=95=98?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ChallengeStatusRepositoryCustomImpl.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java index 6a4448b3c..865697e6c 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java @@ -2,10 +2,7 @@ import com.querydsl.core.types.Order; import com.querydsl.core.types.OrderSpecifier; -import com.querydsl.core.types.dsl.BooleanExpression; -import com.querydsl.core.types.dsl.Expressions; -import com.querydsl.core.types.dsl.NumberExpression; -import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.core.types.dsl.*; import com.querydsl.jpa.JPAExpressions; import com.querydsl.jpa.impl.JPAQueryFactory; import com.walkhub.walkhub.domain.challenge.domain.Challenge; @@ -179,7 +176,10 @@ public List queryChallengeProgress( ).intValue(), getChallengeProgress(challenge).multiply(100).round().longValue(), exerciseAnalysis.date.count().goe(challenge.getSuccessStandard()), - exerciseAnalysis.date.max())) + new CaseBuilder() + .when(exerciseAnalysis.date.count().goe(challenge.getSuccessStandard())) + .then(exerciseAnalysis.date.max()) + .otherwise(Expressions.nullExpression()))) .from(user) .offset(page == null ? 0 : page * PARTICIPANTS_SIZE) .limit(PARTICIPANTS_SIZE) From 88f1eafdd68f4681fd3ffef2b217e0de4e0d095f Mon Sep 17 00:00:00 2001 From: jhhong0509 Date: Tue, 22 Feb 2022 13:03:02 +0900 Subject: [PATCH 403/522] =?UTF-8?q?:bug:=20::=20(#418)=20NPE=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 --- .../ChallengeStatusRepositoryCustomImpl.java | 44 +++++++++---------- .../walkhub/global/error/ExceptionFilter.java | 1 + 2 files changed, 21 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java index 865697e6c..66ba6df2d 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java @@ -196,24 +196,22 @@ public List queryChallengeProgress( } private BooleanExpression userScopeFilter(ChallengeParticipantsScope challengeParticipantsScope) { - switch (challengeParticipantsScope) { - case STUDENT: - return user.authority.eq(Authority.USER); - case TEACHER: - return user.authority.eq(Authority.TEACHER); - default: - return null; + if (challengeParticipantsScope == ChallengeParticipantsScope.STUDENT) { + return user.authority.eq(Authority.USER); + } else if (challengeParticipantsScope == ChallengeParticipantsScope.TEACHER) { + return user.authority.eq(Authority.TEACHER); + } else { + return null; } } private BooleanExpression challengeSuccessFilter(SuccessScope successScope, Challenge challenge) { - switch (successScope) { - case TRUE: - return exerciseAnalysis.date.count().goe(challenge.getSuccessStandard()); - case FALSE: - return exerciseAnalysis.date.count().lt(challenge.getSuccessStandard()); - default: - return null; + if (successScope == SuccessScope.TRUE) { + return exerciseAnalysis.date.count().goe(challenge.getSuccessStandard()); + } else if (successScope == SuccessScope.FALSE) { + return exerciseAnalysis.date.count().lt(challenge.getSuccessStandard()); + } else { + return null; } } @@ -233,16 +231,14 @@ private NumberExpression getChallengeProgress(Challenge challenge) { } private OrderSpecifier challengeParticipantsOrder(ChallengeParticipantsOrder challengeParticipantsOrder) { - switch (challengeParticipantsOrder) { - case SUCCESS_DATE: - return new OrderSpecifier<>(Order.DESC, exerciseAnalysis.date.max()); - case PROGRESS: - return new OrderSpecifier<>(Order.DESC, exerciseAnalysis.walkCount.sum().divide(exerciseAnalysis.date.count())); - case SCHOOL_NAME: - return new OrderSpecifier<>(Order.ASC, school.name); - default: - return new OrderSpecifier<>(Order.ASC, user.name); - + if (challengeParticipantsOrder == ChallengeParticipantsOrder.SUCCESS_DATE) { + return new OrderSpecifier<>(Order.DESC, exerciseAnalysis.date.max()); + } else if (challengeParticipantsOrder == ChallengeParticipantsOrder.PROGRESS) { + return new OrderSpecifier<>(Order.DESC, exerciseAnalysis.walkCount.sum().divide(exerciseAnalysis.date.count())); + } else if (challengeParticipantsOrder == ChallengeParticipantsOrder.SCHOOL_NAME) { + return new OrderSpecifier<>(Order.ASC, school.name); + } else { + return new OrderSpecifier<>(Order.ASC, user.name); } } } diff --git a/src/main/java/com/walkhub/walkhub/global/error/ExceptionFilter.java b/src/main/java/com/walkhub/walkhub/global/error/ExceptionFilter.java index a89661f34..7d6e746a5 100644 --- a/src/main/java/com/walkhub/walkhub/global/error/ExceptionFilter.java +++ b/src/main/java/com/walkhub/walkhub/global/error/ExceptionFilter.java @@ -26,6 +26,7 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse sendErrorMessage(response, e.getErrorCode()); } catch (Exception e) { logger.error(e); + e.printStackTrace(); sendErrorMessage(response, ErrorCode.INTERNAL_SERVER_ERROR); } } From 9130eaff684b6dba217d40e8044bb51c41181b13 Mon Sep 17 00:00:00 2001 From: jhhong0509 Date: Tue, 22 Feb 2022 13:22:31 +0900 Subject: [PATCH 404/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20null=EC=B2=98?= =?UTF-8?q?=EB=A6=AC=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/challenge/service/QueryChallengeProgressService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/service/QueryChallengeProgressService.java b/src/main/java/com/walkhub/walkhub/domain/challenge/service/QueryChallengeProgressService.java index cbec440c5..be760fb4d 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/service/QueryChallengeProgressService.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/service/QueryChallengeProgressService.java @@ -61,7 +61,7 @@ public QueryChallengeProgressResponse execute(Long challengeId, QueryChallengePr } private QueryChallengeProgressResponse.UserChallengeProgressResponse buildUserChallengeProgressResponse(ChallengeProgressVO vo) { - if (vo.getUserId() != null) { + if (vo.getUserId() == null) { return null; } return QueryChallengeProgressResponse.UserChallengeProgressResponse.builder() From cff63c9e010a00e3826356e728e148ec269cb4f6 Mon Sep 17 00:00:00 2001 From: jhhong0509 Date: Tue, 22 Feb 2022 13:29:30 +0900 Subject: [PATCH 405/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20(#418)=20prin?= =?UTF-8?q?tStackTrace=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/walkhub/walkhub/global/error/ExceptionFilter.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/global/error/ExceptionFilter.java b/src/main/java/com/walkhub/walkhub/global/error/ExceptionFilter.java index 7d6e746a5..a89661f34 100644 --- a/src/main/java/com/walkhub/walkhub/global/error/ExceptionFilter.java +++ b/src/main/java/com/walkhub/walkhub/global/error/ExceptionFilter.java @@ -26,7 +26,6 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse sendErrorMessage(response, e.getErrorCode()); } catch (Exception e) { logger.error(e); - e.printStackTrace(); sendErrorMessage(response, ErrorCode.INTERNAL_SERVER_ERROR); } } From cb49a0bb62f1783cfb0b1adfd4088a3e1bfc4058 Mon Sep 17 00:00:00 2001 From: KIM JUNG BIN Date: Tue, 22 Feb 2022 14:17:58 +0900 Subject: [PATCH 406/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20(#422)=20Asyn?= =?UTF-8?q?cConfigurer=EB=A5=BC=20override=ED=95=98=EC=97=AC=20asyncExecut?= =?UTF-8?q?or=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../walkhub/global/async/AsyncConfig.java | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/global/async/AsyncConfig.java b/src/main/java/com/walkhub/walkhub/global/async/AsyncConfig.java index 53634241b..012d3c25d 100644 --- a/src/main/java/com/walkhub/walkhub/global/async/AsyncConfig.java +++ b/src/main/java/com/walkhub/walkhub/global/async/AsyncConfig.java @@ -1,8 +1,27 @@ package com.walkhub.walkhub.global.async; import org.springframework.context.annotation.Configuration; +import org.springframework.scheduling.annotation.AsyncConfigurer; import org.springframework.scheduling.annotation.EnableAsync; +import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; + +import java.util.concurrent.Executor; +import java.util.concurrent.ThreadPoolExecutor; @EnableAsync @Configuration -public class AsyncConfig { } \ No newline at end of file +public class AsyncConfig implements AsyncConfigurer { + + @Override + public Executor getAsyncExecutor() { + ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); + executor.setThreadNamePrefix("async-thread-"); + executor.setCorePoolSize(10); + executor.setMaxPoolSize(50); + executor.setQueueCapacity(100); + executor.setRejectedExecutionHandler(new ThreadPoolExecutor.AbortPolicy()); + executor.initialize(); + + return executor; + } +} \ No newline at end of file From fca3060f5aa895e82950a4b8a4d5c002247daa3b Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Tue, 22 Feb 2022 14:53:10 +0900 Subject: [PATCH 407/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20=EB=B9=8C?= =?UTF-8?q?=EB=8D=94=20=EB=B6=80=EB=B6=84=20=EB=A9=94=EC=86=8C=EB=93=9C?= =?UTF-8?q?=EB=A1=9C=20=EB=BA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/UserSearchForTeacherService.java | 33 +++++++++++-------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/service/UserSearchForTeacherService.java b/src/main/java/com/walkhub/walkhub/domain/teacher/service/UserSearchForTeacherService.java index a2cbffb9a..ac785b0fa 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/service/UserSearchForTeacherService.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/service/UserSearchForTeacherService.java @@ -2,6 +2,7 @@ import com.walkhub.walkhub.domain.teacher.presentation.dto.request.UserSearchRequest; import com.walkhub.walkhub.domain.teacher.presentation.dto.response.QueryUserListResponse; +import com.walkhub.walkhub.domain.teacher.vo.UserListInfoVO; import com.walkhub.walkhub.domain.user.domain.repository.UserRepository; import com.walkhub.walkhub.domain.user.facade.UserFacade; import lombok.RequiredArgsConstructor; @@ -18,21 +19,25 @@ public class UserSearchForTeacherService { public QueryUserListResponse execute(UserSearchRequest request) { return QueryUserListResponse.builder() .userList(userRepository.searchUser(request.getScope(), request.getSort(), request.getGrade(), request.getClassNum(), userFacade.getCurrentUser(), request.getName()) - .stream().map(users -> QueryUserListResponse.UserListInfo.builder() - .userId(users.getUserId()) - .name(users.getName()) - .profileImageUrl(users.getProfileImageUrl()) - .grade(users.getGrade()) - .classNum(users.getClassNum()) - .number(users.getNumber()) - .averageWalkCount(users.getAverageWalkCount()) - .totalWalkCount(users.getTotalWalkCount()) - .averageDistance(users.getAverageDistance()) - .totalDistance(users.getTotalDistance()) - .isTeacher(users.getIsTeacher()) - .build() - ).collect(Collectors.toList()) + .stream().map(this::buildUserListResponse) + .collect(Collectors.toList()) ) .build(); } + + private QueryUserListResponse.UserListInfo buildUserListResponse(UserListInfoVO users) { + return QueryUserListResponse.UserListInfo.builder() + .userId(users.getUserId()) + .name(users.getName()) + .profileImageUrl(users.getProfileImageUrl()) + .grade(users.getGrade()) + .classNum(users.getClassNum()) + .number(users.getNumber()) + .averageWalkCount(users.getAverageWalkCount()) + .totalWalkCount(users.getTotalWalkCount()) + .averageDistance(users.getAverageDistance()) + .totalDistance(users.getTotalDistance()) + .isTeacher(users.getIsTeacher()) + .build(); + } } From 5099a53ece75a5e3e305f3cc151a0349cb2500d9 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Tue, 22 Feb 2022 19:58:24 +0900 Subject: [PATCH 408/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20=EA=B6=8C?= =?UTF-8?q?=ED=95=9C=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/walkhub/walkhub/global/security/SecurityConfig.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java b/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java index 252570634..3005d09e4 100644 --- a/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java +++ b/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java @@ -121,6 +121,7 @@ protected void configure(HttpSecurity http) throws Exception { .antMatchers(HttpMethod.GET, "/teachers/classes").hasAuthority("TEACHER") .antMatchers(HttpMethod.GET, "/teachers/users/{user-id}").hasAnyAuthority("TEACHER") .antMatchers(HttpMethod.GET, "/teachers/users").hasAnyAuthority("TEACHER", "ROOT") + .antMatchers(HttpMethod.GET, "/teachers/users/search").hasAnyAuthority("TEACHER", "ROOT") .antMatchers(HttpMethod.PATCH, "/teachers/schools").hasAuthority("TEACHER") .antMatchers(HttpMethod.GET, "/teachers/students/verification-codes").hasAnyAuthority("TEACHER") .antMatchers(HttpMethod.PATCH, "/teachers/classes/verification-codes").hasAuthority("TEACHER") From 6b5fda5d3bdbfa18e2c7ee2184e2524bb7fb2387 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Tue, 22 Feb 2022 20:05:50 +0900 Subject: [PATCH 409/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20=EB=B0=98?= =?UTF-8?q?=EB=8C=80=EC=98=80=EB=84=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/user/domain/repository/UserRepositoryCustomImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java index 68976ad13..b01002b32 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepositoryCustomImpl.java @@ -96,7 +96,7 @@ private BooleanExpression classNumEq(Integer classNum) { } private BooleanExpression nameEq(String name) { - return name.isEmpty() ? user.name.contains(name) : null; + return name.isEmpty() ? null : user.name.contains(name); } private BooleanExpression buildFilteringCondition(AuthorityScope scope) { From dfb7b90b58df3a4f78f17bf15612b2c0049e75ee Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Tue, 22 Feb 2022 22:06:23 +0900 Subject: [PATCH 410/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EC=9C=84=EB=A1=9C=20=EC=98=AC=EB=A6=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/walkhub/walkhub/global/security/SecurityConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java b/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java index 3005d09e4..3991343d5 100644 --- a/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java +++ b/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java @@ -114,6 +114,7 @@ protected void configure(HttpSecurity http) throws Exception { // teachers .antMatchers(HttpMethod.POST, "/teachers/verification-codes").hasAuthority("ROOT") .antMatchers(HttpMethod.PATCH, "/teachers/verification-codes").hasAuthority("USER") + .antMatchers(HttpMethod.GET, "/teachers/users/search").hasAnyAuthority("TEACHER", "ROOT") .antMatchers(HttpMethod.GET,"/teachers/users").hasAnyAuthority("TEACHER", "ROOT") .antMatchers(HttpMethod.POST, "/teachers/classes").hasAnyAuthority("TEACHER", "ROOT") .antMatchers(HttpMethod.GET, "/teachers/classes/lists").hasAnyAuthority("TEACHER", "ROOT") @@ -121,7 +122,6 @@ protected void configure(HttpSecurity http) throws Exception { .antMatchers(HttpMethod.GET, "/teachers/classes").hasAuthority("TEACHER") .antMatchers(HttpMethod.GET, "/teachers/users/{user-id}").hasAnyAuthority("TEACHER") .antMatchers(HttpMethod.GET, "/teachers/users").hasAnyAuthority("TEACHER", "ROOT") - .antMatchers(HttpMethod.GET, "/teachers/users/search").hasAnyAuthority("TEACHER", "ROOT") .antMatchers(HttpMethod.PATCH, "/teachers/schools").hasAuthority("TEACHER") .antMatchers(HttpMethod.GET, "/teachers/students/verification-codes").hasAnyAuthority("TEACHER") .antMatchers(HttpMethod.PATCH, "/teachers/classes/verification-codes").hasAuthority("TEACHER") From 69744e8af32d4c7017bc6014e6513005bd28de9f Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Tue, 22 Feb 2022 23:50:22 +0900 Subject: [PATCH 411/522] =?UTF-8?q?:bug:=20::=20securityConfig=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/walkhub/walkhub/global/security/SecurityConfig.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java b/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java index 3991343d5..0949c4fe7 100644 --- a/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java +++ b/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java @@ -61,6 +61,7 @@ protected void configure(HttpSecurity http) throws Exception { //levels .antMatchers(HttpMethod.GET, "/levels/lists").authenticated() + .antMatchers(HttpMethod.PATCH, "/levels/{level-id}").authenticated() // badges .antMatchers(HttpMethod.GET, "/badges/{user-id}").authenticated() From 26252c8057b612ad1b55f08eb90c13b3b3c441c9 Mon Sep 17 00:00:00 2001 From: jhhong0509 Date: Tue, 22 Feb 2022 23:56:26 +0900 Subject: [PATCH 412/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20(#430)=20Time?= =?UTF-8?q?zone=20=EC=84=A4=EC=A0=95=ED=8C=8C=EC=9D=BC=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 --- .../global/date/DateTimeZoneConfiguration.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/main/java/com/walkhub/walkhub/global/date/DateTimeZoneConfiguration.java diff --git a/src/main/java/com/walkhub/walkhub/global/date/DateTimeZoneConfiguration.java b/src/main/java/com/walkhub/walkhub/global/date/DateTimeZoneConfiguration.java new file mode 100644 index 000000000..ddda9981b --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/global/date/DateTimeZoneConfiguration.java @@ -0,0 +1,14 @@ +package com.walkhub.walkhub.global.date; + +import org.springframework.context.annotation.Configuration; + +import javax.annotation.PostConstruct; +import java.util.TimeZone; + +@Configuration +public class DateTimeZoneConfiguration { + @PostConstruct + public void setup() { + TimeZone.setDefault(TimeZone.getTimeZone("Asia/Seoul")); + } +} From 5f86e3eea7bff8ac28d7d3bf99063ee44a16a0b0 Mon Sep 17 00:00:00 2001 From: jhhong0509 Date: Tue, 22 Feb 2022 23:56:37 +0900 Subject: [PATCH 413/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20(#430)=20?= =?UTF-8?q?=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=ED=95=A0=20=EB=95=8C=20=ED=95=9C?= =?UTF-8?q?=EA=B5=AD=20=EC=8B=9C=EA=B0=84=EC=9C=BC=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 --- .../dto/response/UserAccessTokenResponse.java | 4 +-- .../dto/response/UserTokenResponse.java | 4 +-- .../auth/service/TokenRefreshService.java | 4 +-- .../auth/service/UserSignInService.java | 5 ++-- .../user/service/UserSignUpService.java | 30 +++++++++---------- 5 files changed, 24 insertions(+), 23 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/auth/presentation/dto/response/UserAccessTokenResponse.java b/src/main/java/com/walkhub/walkhub/domain/auth/presentation/dto/response/UserAccessTokenResponse.java index 820f55176..e0bfac39f 100644 --- a/src/main/java/com/walkhub/walkhub/domain/auth/presentation/dto/response/UserAccessTokenResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/auth/presentation/dto/response/UserAccessTokenResponse.java @@ -4,7 +4,7 @@ import lombok.Builder; import lombok.Getter; -import java.time.LocalDateTime; +import java.time.ZonedDateTime; @Getter @Builder @@ -13,5 +13,5 @@ public class UserAccessTokenResponse { private final String accessToken; @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'hh:mm:ss") - private final LocalDateTime expiredAt; + private final ZonedDateTime expiredAt; } diff --git a/src/main/java/com/walkhub/walkhub/domain/auth/presentation/dto/response/UserTokenResponse.java b/src/main/java/com/walkhub/walkhub/domain/auth/presentation/dto/response/UserTokenResponse.java index e4cb6d3b9..89e0f2395 100644 --- a/src/main/java/com/walkhub/walkhub/domain/auth/presentation/dto/response/UserTokenResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/auth/presentation/dto/response/UserTokenResponse.java @@ -7,7 +7,7 @@ import lombok.Getter; import java.math.BigDecimal; -import java.time.LocalDateTime; +import java.time.ZonedDateTime; @Getter @Builder @@ -15,7 +15,7 @@ public class UserTokenResponse { private final String accessToken; @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'hh:mm:ss") - private final LocalDateTime expiredAt; + private final ZonedDateTime expiredAt; private final String refreshToken; private final Authority authority; private final BigDecimal height; diff --git a/src/main/java/com/walkhub/walkhub/domain/auth/service/TokenRefreshService.java b/src/main/java/com/walkhub/walkhub/domain/auth/service/TokenRefreshService.java index f31fcb0d6..101bf5fc8 100644 --- a/src/main/java/com/walkhub/walkhub/domain/auth/service/TokenRefreshService.java +++ b/src/main/java/com/walkhub/walkhub/domain/auth/service/TokenRefreshService.java @@ -10,7 +10,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.time.LocalDateTime; +import java.time.ZonedDateTime; @RequiredArgsConstructor @Service @@ -29,7 +29,7 @@ public UserAccessTokenResponse execute(String refreshToken) { String accessToken = jwtTokenProvider.generateAccessToken(redisRefreshToken.getAccountId()); return UserAccessTokenResponse.builder() .accessToken(accessToken) - .expiredAt(LocalDateTime.now().plusSeconds(jwtProperties.getAccessExp())) + .expiredAt(ZonedDateTime.now().plusSeconds(jwtProperties.getAccessExp())) .build(); } diff --git a/src/main/java/com/walkhub/walkhub/domain/auth/service/UserSignInService.java b/src/main/java/com/walkhub/walkhub/domain/auth/service/UserSignInService.java index cec6a7ee3..705cc59da 100644 --- a/src/main/java/com/walkhub/walkhub/domain/auth/service/UserSignInService.java +++ b/src/main/java/com/walkhub/walkhub/domain/auth/service/UserSignInService.java @@ -14,7 +14,8 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.time.LocalDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; @RequiredArgsConstructor @Service @@ -41,7 +42,7 @@ public UserTokenResponse execute(SignInRequest request) { return UserTokenResponse.builder() .accessToken(accessToken) - .expiredAt(LocalDateTime.now().plusSeconds(jwtProperties.getAccessExp())) + .expiredAt(ZonedDateTime.now().plusSeconds(jwtProperties.getAccessExp())) .refreshToken(refreshToken) .authority(user.getAuthority()) .height(healthInfo.getHeight()) diff --git a/src/main/java/com/walkhub/walkhub/domain/user/service/UserSignUpService.java b/src/main/java/com/walkhub/walkhub/domain/user/service/UserSignUpService.java index 499be72ca..3c52bd30a 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/service/UserSignUpService.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/service/UserSignUpService.java @@ -24,7 +24,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.time.LocalDateTime; +import java.time.ZonedDateTime; @RequiredArgsConstructor @Service @@ -50,24 +50,24 @@ public UserTokenResponse execute(UserSignUpRequest request) { userFacade.checkUserExists(request.getAccountId()); Badge defaultTitleBadge = badgeRepository.findById(1L) - .orElseThrow(() -> DefaultTitleBadgeNotFound.EXCEPTION); + .orElseThrow(() -> DefaultTitleBadgeNotFound.EXCEPTION); School school = schoolRepository.findById(request.getSchoolId()) .orElseThrow(() -> SchoolNotFoundException.EXCEPTION); User user = User.builder() - .accountId(request.getAccountId()) - .password(passwordEncoder.encode(request.getPassword())) - .phoneNumber(request.getPhoneNumber()) - .authority(Authority.USER) - .name(request.getName()) - .school(school) - .height(request.getHeight()) - .weight(request.getWeight()) - .sex(request.getSex()) - .isMeasuring(false) - .badge(defaultTitleBadge) - .build(); + .accountId(request.getAccountId()) + .password(passwordEncoder.encode(request.getPassword())) + .phoneNumber(request.getPhoneNumber()) + .authority(Authority.USER) + .name(request.getName()) + .school(school) + .height(request.getHeight()) + .weight(request.getWeight()) + .sex(request.getSex()) + .isMeasuring(false) + .badge(defaultTitleBadge) + .build(); userRepository.save(user); school.addUserCount(); @@ -78,7 +78,7 @@ public UserTokenResponse execute(UserSignUpRequest request) { return UserTokenResponse.builder() .accessToken(accessToken) - .expiredAt(LocalDateTime.now().plusSeconds(jwtProperties.getAccessExp())) + .expiredAt(ZonedDateTime.now().plusSeconds(jwtProperties.getAccessExp())) .refreshToken(refreshToken) .authority(user.getAuthority()) .height(healthInfo.getHeight()) From 68062c8e6f51c1b2201334734accddc3db90165f Mon Sep 17 00:00:00 2001 From: jhhong0509 Date: Tue, 22 Feb 2022 23:59:07 +0900 Subject: [PATCH 414/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20(#430)=20?= =?UTF-8?q?=EC=97=94=ED=8B=B0=ED=8B=B0,=20dto=EC=97=90=EC=84=9C=20zonedDat?= =?UTF-8?q?eTime=EC=9C=BC=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 --- .../domain/exercise/domain/Exercise.java | 17 ++++------------- .../dto/response/ExerciseListResponse.java | 4 ++-- .../dto/response/QueryNoticeListResponse.java | 8 ++++---- .../domain/rank/domain/SchoolRankId.java | 10 +++------- .../dto/response/QueryUserDetailsResponse.java | 4 ++-- .../walkhub/global/entity/BaseTimeEntity.java | 4 ++-- 6 files changed, 17 insertions(+), 30 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/Exercise.java b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/Exercise.java index 75eb65f00..bad1b3cbe 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/Exercise.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/Exercise.java @@ -10,18 +10,9 @@ import lombok.NoArgsConstructor; import org.hibernate.annotations.DynamicInsert; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.EnumType; -import javax.persistence.Enumerated; -import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; +import javax.persistence.*; import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; +import java.time.ZonedDateTime; @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) @@ -36,7 +27,7 @@ public class Exercise extends BaseTimeEntity { @Column(nullable = false, columnDefinition = "integer default 0") private Integer walkCount; - private LocalDateTime endAt; + private ZonedDateTime endAt; @Column(nullable = false, columnDefinition = "integer default 0") private Integer distance; @@ -76,7 +67,7 @@ public void closeExercise(Integer walkCount, Integer distance, Double calorie) { this.walkCount = walkCount; this.distance = distance; this.calorie = calorie; - this.endAt = LocalDateTime.now(); + this.endAt = ZonedDateTime.now(); this.isExercising = false; } diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/response/ExerciseListResponse.java b/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/response/ExerciseListResponse.java index 384764d04..c27338348 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/response/ExerciseListResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/response/ExerciseListResponse.java @@ -6,7 +6,7 @@ import lombok.Getter; import java.math.BigDecimal; -import java.time.LocalDateTime; +import java.time.ZonedDateTime; import java.util.List; @Getter @@ -21,7 +21,7 @@ public static class ExerciseResponse { private final Long exerciseId; private final String imageUrl; @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'hh:mm:ss") - private final LocalDateTime startAt; + private final ZonedDateTime startAt; private final BigDecimal latitude; private final BigDecimal longitude; } diff --git a/src/main/java/com/walkhub/walkhub/domain/notice/presentation/dto/response/QueryNoticeListResponse.java b/src/main/java/com/walkhub/walkhub/domain/notice/presentation/dto/response/QueryNoticeListResponse.java index d559378ef..cfbc77a28 100644 --- a/src/main/java/com/walkhub/walkhub/domain/notice/presentation/dto/response/QueryNoticeListResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/notice/presentation/dto/response/QueryNoticeListResponse.java @@ -7,7 +7,7 @@ import lombok.Builder; import lombok.Getter; -import java.time.LocalDateTime; +import java.time.ZonedDateTime; import java.util.List; @Getter @@ -24,12 +24,12 @@ public static class NoticeResponse { private final String content; @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'hh:mm:ss") - private final LocalDateTime createdAt; + private final ZonedDateTime createdAt; private final Writer writer; @QueryProjection - public NoticeResponse(Long id, String title, String content, LocalDateTime createdAt, - Writer writer) { + public NoticeResponse(Long id, String title, String content, ZonedDateTime createdAt, + Writer writer) { this.id = id; this.title = title; this.content = content; diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/domain/SchoolRankId.java b/src/main/java/com/walkhub/walkhub/domain/rank/domain/SchoolRankId.java index 08f4b5747..dbab6e83c 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/domain/SchoolRankId.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/domain/SchoolRankId.java @@ -1,13 +1,9 @@ package com.walkhub.walkhub.domain.rank.domain; -import lombok.AccessLevel; -import lombok.AllArgsConstructor; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.NoArgsConstructor; +import lombok.*; import java.io.Serializable; -import java.time.LocalDateTime; +import java.time.ZonedDateTime; @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) @@ -16,7 +12,7 @@ public class SchoolRankId implements Serializable { private Long schoolId; - private LocalDateTime createdAt; + private ZonedDateTime createdAt; private String dateType; } diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/QueryUserDetailsResponse.java b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/QueryUserDetailsResponse.java index 334397c6d..fa51337ab 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/QueryUserDetailsResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/QueryUserDetailsResponse.java @@ -5,7 +5,7 @@ import lombok.Getter; import java.math.BigDecimal; -import java.time.LocalDateTime; +import java.time.ZonedDateTime; import java.util.List; @Getter @@ -25,7 +25,7 @@ public class QueryUserDetailsResponse { public static class ExerciseResponse { private final String imageUrl; @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'hh:mm:ss") - private final LocalDateTime startAt; + private final ZonedDateTime startAt; private final BigDecimal latitude; private final BigDecimal longitude; } diff --git a/src/main/java/com/walkhub/walkhub/global/entity/BaseTimeEntity.java b/src/main/java/com/walkhub/walkhub/global/entity/BaseTimeEntity.java index c694b0afe..92cea1b82 100644 --- a/src/main/java/com/walkhub/walkhub/global/entity/BaseTimeEntity.java +++ b/src/main/java/com/walkhub/walkhub/global/entity/BaseTimeEntity.java @@ -7,7 +7,7 @@ import javax.persistence.Column; import javax.persistence.EntityListeners; import javax.persistence.MappedSuperclass; -import java.time.LocalDateTime; +import java.time.ZonedDateTime; @Getter @MappedSuperclass @@ -16,6 +16,6 @@ public abstract class BaseTimeEntity { @Column(nullable = false) @CreatedDate - private LocalDateTime createdAt; + private ZonedDateTime createdAt; } From 3c601716796fdce1dbef1af2f947bc32e4b27635 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Wed, 23 Feb 2022 00:14:17 +0900 Subject: [PATCH 415/522] =?UTF-8?q?:recycle:=20::=20=EC=9E=91=EC=84=B1?= =?UTF-8?q?=EC=9E=90=EB=A7=8C=20=EC=A7=80=EC=9A=B8=20=EC=88=98=20=EC=9E=88?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EB=A1=9C=EC=A7=81=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/notice/service/DeleteNoticeService.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/notice/service/DeleteNoticeService.java b/src/main/java/com/walkhub/walkhub/domain/notice/service/DeleteNoticeService.java index 4e6e91424..c2624fea8 100644 --- a/src/main/java/com/walkhub/walkhub/domain/notice/service/DeleteNoticeService.java +++ b/src/main/java/com/walkhub/walkhub/domain/notice/service/DeleteNoticeService.java @@ -3,6 +3,9 @@ import com.walkhub.walkhub.domain.notice.domain.Notice; import com.walkhub.walkhub.domain.notice.domain.repository.NoticeRepository; import com.walkhub.walkhub.domain.notice.exception.NoticeNotFoundException; +import com.walkhub.walkhub.domain.user.domain.User; +import com.walkhub.walkhub.domain.user.facade.UserFacade; +import com.walkhub.walkhub.global.exception.InvalidRoleException; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -11,13 +14,20 @@ @Service public class DeleteNoticeService { + private final UserFacade userFacade; private final NoticeRepository noticeRepository; @Transactional public void execute(Long noticeId) { + User user = userFacade.getCurrentUser(); + Notice notice = noticeRepository.findById(noticeId) .orElseThrow(() -> NoticeNotFoundException.EXCEPTION); + if (!notice.getUser().equals(user)) { + throw InvalidRoleException.EXCEPTION; + } + noticeRepository.delete(notice); } } From 846efed6950a3f343ff91b6a95e16a721c2eb4bb Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Wed, 23 Feb 2022 00:15:12 +0900 Subject: [PATCH 416/522] =?UTF-8?q?:bug:=20::=20notice=20securityconfig=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../walkhub/global/security/SecurityConfig.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java b/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java index 0949c4fe7..044fddfd9 100644 --- a/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java +++ b/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java @@ -79,8 +79,8 @@ protected void configure(HttpSecurity http) throws Exception { // notices .antMatchers(HttpMethod.GET, "/notices/list").authenticated() - .antMatchers(HttpMethod.POST, "/notices").hasAnyAuthority("TEACHER", "ROOT", "SU") - .antMatchers(HttpMethod.DELETE, "/notices/{notice-id}").hasAnyAuthority("TEACHER", "ROOT", "SU") + .antMatchers(HttpMethod.POST, "/notices").hasAnyAuthority("ROOT", "SU") + .antMatchers(HttpMethod.DELETE, "/notices/{notice-id}").hasAnyAuthority("ROOT", "SU") // notifications .antMatchers(HttpMethod.GET, "/notifications").authenticated() @@ -116,7 +116,7 @@ protected void configure(HttpSecurity http) throws Exception { .antMatchers(HttpMethod.POST, "/teachers/verification-codes").hasAuthority("ROOT") .antMatchers(HttpMethod.PATCH, "/teachers/verification-codes").hasAuthority("USER") .antMatchers(HttpMethod.GET, "/teachers/users/search").hasAnyAuthority("TEACHER", "ROOT") - .antMatchers(HttpMethod.GET,"/teachers/users").hasAnyAuthority("TEACHER", "ROOT") + .antMatchers(HttpMethod.GET, "/teachers/users").hasAnyAuthority("TEACHER", "ROOT") .antMatchers(HttpMethod.POST, "/teachers/classes").hasAnyAuthority("TEACHER", "ROOT") .antMatchers(HttpMethod.GET, "/teachers/classes/lists").hasAnyAuthority("TEACHER", "ROOT") .antMatchers(HttpMethod.DELETE, "/teachers/classes/{section-id}").hasAnyAuthority("TEACHER", "ROOT") @@ -128,8 +128,8 @@ protected void configure(HttpSecurity http) throws Exception { .antMatchers(HttpMethod.PATCH, "/teachers/classes/verification-codes").hasAuthority("TEACHER") // su - .antMatchers(HttpMethod.GET,"/su").hasAuthority("SU") - .antMatchers(HttpMethod.POST,"/su/accounts/{school-id}").hasAuthority("SU") + .antMatchers(HttpMethod.GET, "/su").hasAuthority("SU") + .antMatchers(HttpMethod.POST, "/su/accounts/{school-id}").hasAuthority("SU") //excel .antMatchers(HttpMethod.GET, "/excel").hasAnyAuthority("TEACHER", "ROOT") From 447be46f15c28036460e706721c9ed54b61cfbbd Mon Sep 17 00:00:00 2001 From: jhhong0509 Date: Wed, 23 Feb 2022 00:26:31 +0900 Subject: [PATCH 417/522] =?UTF-8?q?:recycle:=20::=20(#430)=20unused=20impo?= =?UTF-8?q?rt=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../walkhub/walkhub/domain/auth/service/UserSignInService.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/auth/service/UserSignInService.java b/src/main/java/com/walkhub/walkhub/domain/auth/service/UserSignInService.java index 705cc59da..8a52af71d 100644 --- a/src/main/java/com/walkhub/walkhub/domain/auth/service/UserSignInService.java +++ b/src/main/java/com/walkhub/walkhub/domain/auth/service/UserSignInService.java @@ -14,7 +14,6 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.time.ZoneId; import java.time.ZonedDateTime; @RequiredArgsConstructor From 1f38e59c519e524a1daf2a1396680878240d950b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B2=94=EC=A7=84?= Date: Wed, 23 Feb 2022 00:29:07 +0900 Subject: [PATCH 418/522] =?UTF-8?q?=E2=9A=A1=20::=20(#432)=20setSectionNul?= =?UTF-8?q?l?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/teacher/service/ConfirmTeacherCodeService.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/service/ConfirmTeacherCodeService.java b/src/main/java/com/walkhub/walkhub/domain/teacher/service/ConfirmTeacherCodeService.java index 5e727f92e..cc42ea00c 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/service/ConfirmTeacherCodeService.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/service/ConfirmTeacherCodeService.java @@ -25,6 +25,7 @@ public TokenResponse execute(TeacherCodeRequest request) { throw VerificationCodeNotFoundException.EXCEPTION; } user.setAuthorityTeacher(); + user.setSectionNull(); String accessToken = jwtTokenProvider.generateAccessToken(user.getAccountId()); String refreshToken = jwtTokenProvider.generateRefreshToken(user.getAccountId()); From 867e49d5ddb001c2ed89c64841cf52fbd4d0e77c Mon Sep 17 00:00:00 2001 From: jhhong0509 Date: Wed, 23 Feb 2022 09:52:50 +0900 Subject: [PATCH 419/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20(#434)=20Reps?= =?UTF-8?q?onse=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../teacher/presentation/dto/response/ClassListResponse.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/ClassListResponse.java b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/ClassListResponse.java index be2bf70a9..d756511a8 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/ClassListResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/ClassListResponse.java @@ -10,6 +10,7 @@ @AllArgsConstructor public class ClassListResponse { + private final String authCode; private final List classList; @Getter From 0dc691000fd4a9c9c25e786509cdd3f0ca3655e7 Mon Sep 17 00:00:00 2001 From: jhhong0509 Date: Wed, 23 Feb 2022 09:53:01 +0900 Subject: [PATCH 420/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20(#434)=20Serv?= =?UTF-8?q?ice=EC=97=90=20r=EC=83=9D=EC=84=B1=EC=9E=90=20=ED=98=B8?= =?UTF-8?q?=EC=B6=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../walkhub/domain/teacher/service/ClassListService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/service/ClassListService.java b/src/main/java/com/walkhub/walkhub/domain/teacher/service/ClassListService.java index fd9735117..f98a29be8 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/service/ClassListService.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/service/ClassListService.java @@ -40,7 +40,7 @@ public ClassListResponse execute() { .map(this::buildClassList) .collect(Collectors.toList()); - return new ClassListResponse(classList); + return new ClassListResponse(school.getAuthCode(), classList); } private ClassResponse buildClassList(Section section) { From b021132835a8cec6bfd093fda5ae36f9cff1f874 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Wed, 23 Feb 2022 10:47:43 +0900 Subject: [PATCH 421/522] :bookmark_tabs: :: QueryExerciseDetailsResponse --- .../QueryExerciseDetailsResponse.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/response/QueryExerciseDetailsResponse.java diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/response/QueryExerciseDetailsResponse.java b/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/response/QueryExerciseDetailsResponse.java new file mode 100644 index 000000000..f4bae390a --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/response/QueryExerciseDetailsResponse.java @@ -0,0 +1,24 @@ +package com.walkhub.walkhub.domain.exercise.presentation.dto.response; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; + +import java.math.BigDecimal; +import java.util.List; + +@Getter +@AllArgsConstructor +public class QueryExerciseDetailsResponse { + + private final String imageUrl; + private final List exerciseList; + + @Getter + @Builder + public static class ExerciseResponse { + private final Integer order; + private final BigDecimal latitude; + private final BigDecimal longitude; + } +} From 55c414baa314d4b57828d4c642c83ce1f3658d86 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Wed, 23 Feb 2022 10:47:58 +0900 Subject: [PATCH 422/522] :bookmark_tabs: :: QueryExerciseDetailsService --- .../service/QueryExerciseDetailsService.java | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/main/java/com/walkhub/walkhub/domain/exercise/service/QueryExerciseDetailsService.java diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/service/QueryExerciseDetailsService.java b/src/main/java/com/walkhub/walkhub/domain/exercise/service/QueryExerciseDetailsService.java new file mode 100644 index 000000000..3df9f2147 --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/service/QueryExerciseDetailsService.java @@ -0,0 +1,35 @@ +package com.walkhub.walkhub.domain.exercise.service; + +import com.walkhub.walkhub.domain.exercise.domain.Exercise; +import com.walkhub.walkhub.domain.exercise.domain.repository.LocationRepository; +import com.walkhub.walkhub.domain.exercise.facade.ExerciseFacade; +import com.walkhub.walkhub.domain.exercise.presentation.dto.response.QueryExerciseDetailsResponse; +import com.walkhub.walkhub.domain.exercise.presentation.dto.response.QueryExerciseDetailsResponse.ExerciseResponse; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.stream.Collectors; + +@RequiredArgsConstructor +@Service +public class QueryExerciseDetailsService { + + private final ExerciseFacade exerciseFacade; + private final LocationRepository locationRepository; + + public QueryExerciseDetailsResponse execute(Long exerciseId) { + Exercise exercise = exerciseFacade.getById(exerciseId); + + List locations = locationRepository.findAllByExerciseOrderBySequence(exercise) + .stream() + .map(location -> ExerciseResponse.builder() + .order(location.getSequence()) + .latitude(location.getLatitude()) + .longitude(location.getLongitude()) + .build()) + .collect(Collectors.toList()); + + return new QueryExerciseDetailsResponse(exercise.getImageUrl(), locations); + } +} From f8c504f0e0e4f64ea13d2b4f5b61aa4b5d2ae07e Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Wed, 23 Feb 2022 10:48:10 +0900 Subject: [PATCH 423/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20findAllByExer?= =?UTF-8?q?ciseOrderBySequence=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/exercise/domain/repository/LocationRepository.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/LocationRepository.java b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/LocationRepository.java index 7dd886238..33b208554 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/LocationRepository.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/LocationRepository.java @@ -5,6 +5,9 @@ import com.walkhub.walkhub.domain.exercise.domain.LocationId; import org.springframework.data.repository.CrudRepository; +import java.util.List; + public interface LocationRepository extends CrudRepository { Location findTop1ByExerciseOrderBySequenceDesc(Exercise exercise); + List findAllByExerciseOrderBySequence(Exercise exercise); } From b24cdeeb206d03f151da7b290b44ce32079acd01 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Wed, 23 Feb 2022 10:48:34 +0900 Subject: [PATCH 424/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20=EC=9A=B4?= =?UTF-8?q?=EB=8F=99=20=EC=83=81=EC=84=B8=EB=B3=B4=EA=B8=B0=20api=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 --- .../domain/exercise/presentation/ExerciseController.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/ExerciseController.java b/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/ExerciseController.java index 4d78a2062..333ae2da6 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/ExerciseController.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/ExerciseController.java @@ -6,6 +6,7 @@ import com.walkhub.walkhub.domain.exercise.presentation.dto.request.SaveLocationRequest; import com.walkhub.walkhub.domain.exercise.presentation.dto.response.CreateExerciseResponse; import com.walkhub.walkhub.domain.exercise.presentation.dto.response.QueryExerciseAnalysisResponse; +import com.walkhub.walkhub.domain.exercise.presentation.dto.response.QueryExerciseDetailsResponse; import com.walkhub.walkhub.domain.exercise.service.*; import com.walkhub.walkhub.domain.exercise.presentation.dto.response.ExerciseListResponse; import com.walkhub.walkhub.domain.exercise.service.CreateExerciseService; @@ -30,6 +31,7 @@ public class ExerciseController { private final QueryExerciseListService queryExerciseListService; private final SaveOrUpdateExerciseAnalysisService saveOrUpdateExerciseAnalysisService; private final QueryExerciseAnalysisService queryExerciseAnalysisService; + private final QueryExerciseDetailsService queryExerciseDetailsService; @ResponseStatus(HttpStatus.CREATED) @PostMapping @@ -66,4 +68,9 @@ public QueryExerciseAnalysisResponse queryExerciseAnalysis() { public ExerciseListResponse queryExerciseList() { return queryExerciseListService.execute(); } + + @GetMapping("{exercise-id}") + public QueryExerciseDetailsResponse queryExerciseDetails(@PathVariable("exercise-id") Long exerciseId) { + return queryExerciseDetailsService.execute(exerciseId); + } } From ba5f66c9cebff88f6a61638921fc9c09eb64d0a9 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Wed, 23 Feb 2022 10:49:38 +0900 Subject: [PATCH 425/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20securityConfi?= =?UTF-8?q?g=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/walkhub/walkhub/global/security/SecurityConfig.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java b/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java index 044fddfd9..9bf689376 100644 --- a/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java +++ b/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java @@ -76,6 +76,7 @@ protected void configure(HttpSecurity http) throws Exception { .antMatchers(HttpMethod.POST, "/exercises/locations/{exercise-id}").authenticated() .antMatchers(HttpMethod.GET, "/exercises/analysis").authenticated() .antMatchers(HttpMethod.GET, "/exercises/lists").authenticated() + .antMatchers(HttpMethod.GET, "/exercises/{exercise-id}}").hasAnyAuthority("TEACHER", "ROOT") // notices .antMatchers(HttpMethod.GET, "/notices/list").authenticated() From 2de72a38257865244a702bb3c514a9a21d63f362 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Wed, 23 Feb 2022 11:05:55 +0900 Subject: [PATCH 426/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20@Transactiona?= =?UTF-8?q?l(readOnly=20=3D=20true)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/exercise/service/QueryExerciseDetailsService.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/service/QueryExerciseDetailsService.java b/src/main/java/com/walkhub/walkhub/domain/exercise/service/QueryExerciseDetailsService.java index 3df9f2147..00dc3e04c 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/service/QueryExerciseDetailsService.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/service/QueryExerciseDetailsService.java @@ -7,6 +7,7 @@ import com.walkhub.walkhub.domain.exercise.presentation.dto.response.QueryExerciseDetailsResponse.ExerciseResponse; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.util.List; import java.util.stream.Collectors; @@ -18,6 +19,7 @@ public class QueryExerciseDetailsService { private final ExerciseFacade exerciseFacade; private final LocationRepository locationRepository; + @Transactional(readOnly = true) public QueryExerciseDetailsResponse execute(Long exerciseId) { Exercise exercise = exerciseFacade.getById(exerciseId); From e5560a253090416b4f388aed03b1be159b1d3e72 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Wed, 23 Feb 2022 11:06:43 +0900 Subject: [PATCH 427/522] =?UTF-8?q?:recycle:=20::=20image=5Furl=20->=20cer?= =?UTF-8?q?tifying=5Fshot=EC=9C=BC=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 --- .../presentation/dto/response/QueryExerciseDetailsResponse.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/response/QueryExerciseDetailsResponse.java b/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/response/QueryExerciseDetailsResponse.java index f4bae390a..a160948f1 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/response/QueryExerciseDetailsResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/response/QueryExerciseDetailsResponse.java @@ -11,7 +11,7 @@ @AllArgsConstructor public class QueryExerciseDetailsResponse { - private final String imageUrl; + private final String certifyingShot; private final List exerciseList; @Getter From 0f2dcc4ccb76e8aedd8c5110ccc29e140746428f Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Wed, 23 Feb 2022 11:06:55 +0900 Subject: [PATCH 428/522] =?UTF-8?q?:recycle:=20::=20=EC=A0=95=EB=A0=AC=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/exercise/domain/repository/LocationRepository.java | 2 +- .../domain/exercise/service/QueryExerciseDetailsService.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/LocationRepository.java b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/LocationRepository.java index 33b208554..f745ba1fa 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/LocationRepository.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/LocationRepository.java @@ -9,5 +9,5 @@ public interface LocationRepository extends CrudRepository { Location findTop1ByExerciseOrderBySequenceDesc(Exercise exercise); - List findAllByExerciseOrderBySequence(Exercise exercise); + List findAllByExercise(Exercise exercise); } diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/service/QueryExerciseDetailsService.java b/src/main/java/com/walkhub/walkhub/domain/exercise/service/QueryExerciseDetailsService.java index 00dc3e04c..fdefa2d0e 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/service/QueryExerciseDetailsService.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/service/QueryExerciseDetailsService.java @@ -23,7 +23,7 @@ public class QueryExerciseDetailsService { public QueryExerciseDetailsResponse execute(Long exerciseId) { Exercise exercise = exerciseFacade.getById(exerciseId); - List locations = locationRepository.findAllByExerciseOrderBySequence(exercise) + List locations = locationRepository.findAllByExercise(exercise) .stream() .map(location -> ExerciseResponse.builder() .order(location.getSequence()) From 4b27a02c059e73a2df8413761786b714162c2a6f Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Wed, 23 Feb 2022 14:41:36 +0900 Subject: [PATCH 429/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20weekly=20->?= =?UTF-8?q?=20week,=20monthly=20->=20month=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 --- .../walkhub/domain/rank/job/UserRankJob.java | 76 +++++++++---------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/job/UserRankJob.java b/src/main/java/com/walkhub/walkhub/domain/rank/job/UserRankJob.java index f9516c66a..b840e3e71 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/job/UserRankJob.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/job/UserRankJob.java @@ -23,101 +23,101 @@ import java.sql.Types; import java.time.LocalDate; +import static com.walkhub.walkhub.domain.rank.job.constant.RankJobConstant.*; + @Configuration @RequiredArgsConstructor public class UserRankJob { - private static final Integer CHUNK_SIZE = 100; - private final JobBuilderFactory jobBuilderFactory; private final StepBuilderFactory stepBuilderFactory; private final DataSource dataSource; @Bean public Job userJob() { - return jobBuilderFactory.get("userRankJob") - .start(weeklyUserSchoolRankStep(null)) - .next(monthlyUserSchoolRankStep(null)) - .next(weeklyUserClassRankStep(null)) - .next(monthlyUserClassRankStep(null)) + return jobBuilderFactory.get(USER_RANK_JOB) + .start(weekUserSchoolRankStep(null)) + .next(monthUserSchoolRankStep(null)) + .next(weekUserClassRankStep(null)) + .next(monthUserClassRankStep(null)) .build(); } @Bean @JobScope - public Step weeklyUserSchoolRankStep(@Value("#{jobParameters[jobKey]}") String jobKey) { - return stepBuilderFactory.get("weeklyUserSchoolRankStep") + public Step weekUserSchoolRankStep(@Value("#{jobParameters[jobKey]}") String jobKey) { + return stepBuilderFactory.get("weekUserSchoolRankStep") .chunk(CHUNK_SIZE) - .reader(weeklyUserSchoolRankReader(null)) - .processor(weeklyUserSchoolRankProcessor(null)) + .reader(weekUserSchoolRankReader(null)) + .processor(weekUserSchoolRankProcessor(null)) .writer(userRankWriter(null)) .build(); } @Bean @JobScope - public Step monthlyUserSchoolRankStep(@Value("#{jobParameters[jobKey]}") String jobKey) { - return stepBuilderFactory.get("monthlyUserSchoolRankStep") + public Step monthUserSchoolRankStep(@Value("#{jobParameters[jobKey]}") String jobKey) { + return stepBuilderFactory.get("monthUserSchoolRankStep") .chunk(CHUNK_SIZE) - .reader(monthlyUserSchoolRankReader(null)) - .processor(monthlyUserSchoolRankProcessor(null)) + .reader(monthUserSchoolRankReader(null)) + .processor(monthUserSchoolRankProcessor(null)) .writer(userRankWriter(null)) .build(); } @Bean @JobScope - public Step weeklyUserClassRankStep(@Value("#{jobParameters[jobKey]}") String jobKey) { + public Step weekUserClassRankStep(@Value("#{jobParameters[jobKey]}") String jobKey) { return stepBuilderFactory.get("weeklyUserClassRankStep") .chunk(CHUNK_SIZE) - .reader(weeklyUserClassRankReader(null)) - .processor(weeklyUserClassRankProcessor(null)) + .reader(weekUserClassRankReader(null)) + .processor(weekUserClassRankProcessor(null)) .writer(userRankWriter(null)) .build(); } @Bean @JobScope - public Step monthlyUserClassRankStep(@Value("#{jobParameters[jobKey]}") String jobKey) { - return stepBuilderFactory.get("monthlyUserClassRankStep") + public Step monthUserClassRankStep(@Value("#{jobParameters[jobKey]}") String jobKey) { + return stepBuilderFactory.get("monthUserClassRankStep") .chunk(CHUNK_SIZE) - .reader(monthlyUserClassRankReader(null)) - .processor(monthlyUserClassRankProcessor(null)) + .reader(monthUserClassRankReader(null)) + .processor(monthUserClassRankProcessor(null)) .writer(userRankWriter(null)) .build(); } @Bean @StepScope - public StoredProcedureItemReader weeklyUserSchoolRankReader(@Value("#{jobParameters[stepKey]}") Integer type) { - return callProcedure("weeklyUserSchoolRankReader", "SELECT_USER_RANK_BY_SCHOOL", 7); + public StoredProcedureItemReader weekUserSchoolRankReader(@Value("#{jobParameters[stepKey]}") Integer type) { + return callProcedure("weekUserSchoolRankReader", "SELECT_USER_RANK_BY_SCHOOL", 7); } @Bean @StepScope - public StoredProcedureItemReader monthlyUserSchoolRankReader(@Value("#{jobParameters[stepKey]}") Integer type) { - return callProcedure("monthlyUserSchoolRankReader", "SELECT_USER_RANK_BY_SCHOOL", 28); + public StoredProcedureItemReader monthUserSchoolRankReader(@Value("#{jobParameters[stepKey]}") Integer type) { + return callProcedure("monthUserSchoolRankReader", "SELECT_USER_RANK_BY_SCHOOL", 28); } @Bean @StepScope - public StoredProcedureItemReader weeklyUserClassRankReader(@Value("#{jobParameters[stepKey]}") Integer type) { - return callProcedure("weeklyUserClassRankReader", "SELECT_USER_RANK_BY_CLASS", 7); + public StoredProcedureItemReader weekUserClassRankReader(@Value("#{jobParameters[stepKey]}") Integer type) { + return callProcedure("weekUserClassRankReader", "SELECT_USER_RANK_BY_CLASS", 7); } @Bean @StepScope - public StoredProcedureItemReader monthlyUserClassRankReader(@Value("#{jobParameters[stepKey]}") Integer type) { - return callProcedure("monthlyUserClassRankReader", "SELECT_USER_RANK_BY_CLASS", 28); + public StoredProcedureItemReader monthUserClassRankReader(@Value("#{jobParameters[stepKey]}") Integer type) { + return callProcedure("monthUserClassRankReader", "SELECT_USER_RANK_BY_CLASS", 28); } @Bean @StepScope - public ItemProcessor weeklyUserSchoolRankProcessor(@Value("#{jobParameters[jobKey]}") String jobKey) { + public ItemProcessor weekUserSchoolRankProcessor(@Value("#{jobParameters[jobKey]}") String jobKey) { return rankInfo -> UserRank.builder() .userId(rankInfo.getUserId()) .createdAt(LocalDate.now()) - .dateType("WEEK") + .dateType(DATE_WEEK) .scopeType("SCHOOL") .schoolId(rankInfo.getSchoolId()) .name(rankInfo.getName()) @@ -131,11 +131,11 @@ public ItemProcessor weeklyUserSchoolRankProcessor(@Valu @Bean @StepScope - public ItemProcessor monthlyUserSchoolRankProcessor(@Value("#{jobParameters[jobKey]}") String jobKey) { + public ItemProcessor monthUserSchoolRankProcessor(@Value("#{jobParameters[jobKey]}") String jobKey) { return rankInfo -> UserRank.builder() .userId(rankInfo.getUserId()) .createdAt(LocalDate.now()) - .dateType("MONTH") + .dateType(DATE_MONTH) .scopeType("SCHOOL") .schoolId(rankInfo.getSchoolId()) .name(rankInfo.getName()) @@ -149,11 +149,11 @@ public ItemProcessor monthlyUserSchoolRankProcessor(@Val @Bean @StepScope - public ItemProcessor weeklyUserClassRankProcessor(@Value("#{jobParameters[jobKey]}") String jobKey) { + public ItemProcessor weekUserClassRankProcessor(@Value("#{jobParameters[jobKey]}") String jobKey) { return rankInfo -> UserRank.builder() .userId(rankInfo.getUserId()) .createdAt(LocalDate.now()) - .dateType("WEEK") + .dateType(DATE_WEEK) .scopeType("CLASS") .schoolId(rankInfo.getSchoolId()) .name(rankInfo.getName()) @@ -167,11 +167,11 @@ public ItemProcessor weeklyUserClassRankProcessor(@Value @Bean @StepScope - public ItemProcessor monthlyUserClassRankProcessor(@Value("#{jobParameters[jobKey]}") String jobKey) { + public ItemProcessor monthUserClassRankProcessor(@Value("#{jobParameters[jobKey]}") String jobKey) { return rankInfo -> UserRank.builder() .userId(rankInfo.getUserId()) .createdAt(LocalDate.now()) - .dateType("MONTH") + .dateType(DATE_MONTH) .scopeType("CLASS") .schoolId(rankInfo.getSchoolId()) .name(rankInfo.getName()) From 21d9cd5c0d227a20c3f73aa6909a6140c2168bb9 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Wed, 23 Feb 2022 14:50:21 +0900 Subject: [PATCH 430/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20constant=20?= =?UTF-8?q?=EC=84=A0=EC=96=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rank/job/constant/RankJobConstant.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/job/constant/RankJobConstant.java b/src/main/java/com/walkhub/walkhub/domain/rank/job/constant/RankJobConstant.java index 0d17bb332..e001cdc2d 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/job/constant/RankJobConstant.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/job/constant/RankJobConstant.java @@ -21,4 +21,20 @@ public final class RankJobConstant { public static final String SELECT_PROCEDURE_NAME = "SELECT_SCHOOL_RANK_BY_DATETYPE"; public static final String SQL_SAVE_SCHOOL_RANK = "CALL SAVE_SCHOOL_RANK(:schoolId, :createdAt, :dateType, :name, :logoImageUrl, :userCount,:walkCount, :ranking)"; + // user rank + public static final String USER_RANK_JOB = "userRankJob"; + public static final String WEEK_USER_SCHOOL_RANK_STEP = "weekUserSchoolRankStep"; + public static final String MONTH_USER_SCHOOL_RANK_STEP = "monthUserSchoolRankStep"; + public static final String WEEK_USER_CLASS_RANK_STEP = "weekUserClassRankStep"; + public static final String MONTH_USER_CLASS_RANK_STEP = "monthUserClassRankStep"; + + public static final String WEEK_USER_SCHOOL_RANK_READER = "weekUserSchoolRankReader"; + public static final String MONTH_USER_SCHOOL_RANK_READER = "monthUserSchoolRankReader"; + public static final String WEEK_USER_CLASS_RANK_READER = "weekUserClassRankReader"; + public static final String MONTH_USER_CLASS_RANK_READER = "monthUserClassRankReader"; + + public static final String SELECT_BY_SCHOOL_PROCEDURE = "SELECT_USER_RANK_BY_SCHOOL"; + public static final String SELECT_BY_CLASS_PROCEDURE = "SELECT_USER_RANK_BY_CLASS"; + public static final String CALL_SAVE_PROCEDURE = "CALL SAVE_USER_RANK(:userId, :createdAt, :dateType, :scopeType, :schoolId, :name, :grade, :classNum, :profileImageUrl, :ranking, :walkCount)"; + } From 275a7326ebeb98255f2d02e28e0726a4c72f8a3d Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Wed, 23 Feb 2022 14:50:32 +0900 Subject: [PATCH 431/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20=EC=83=81?= =?UTF-8?q?=EC=88=98=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 --- .../walkhub/domain/rank/job/UserRankJob.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/job/UserRankJob.java b/src/main/java/com/walkhub/walkhub/domain/rank/job/UserRankJob.java index b840e3e71..504d527e8 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/job/UserRankJob.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/job/UserRankJob.java @@ -46,7 +46,7 @@ public Job userJob() { @Bean @JobScope public Step weekUserSchoolRankStep(@Value("#{jobParameters[jobKey]}") String jobKey) { - return stepBuilderFactory.get("weekUserSchoolRankStep") + return stepBuilderFactory.get(WEEK_USER_SCHOOL_RANK_STEP) .chunk(CHUNK_SIZE) .reader(weekUserSchoolRankReader(null)) .processor(weekUserSchoolRankProcessor(null)) @@ -57,7 +57,7 @@ public Step weekUserSchoolRankStep(@Value("#{jobParameters[jobKey]}") String job @Bean @JobScope public Step monthUserSchoolRankStep(@Value("#{jobParameters[jobKey]}") String jobKey) { - return stepBuilderFactory.get("monthUserSchoolRankStep") + return stepBuilderFactory.get(MONTH_USER_SCHOOL_RANK_STEP) .chunk(CHUNK_SIZE) .reader(monthUserSchoolRankReader(null)) .processor(monthUserSchoolRankProcessor(null)) @@ -68,7 +68,7 @@ public Step monthUserSchoolRankStep(@Value("#{jobParameters[jobKey]}") String jo @Bean @JobScope public Step weekUserClassRankStep(@Value("#{jobParameters[jobKey]}") String jobKey) { - return stepBuilderFactory.get("weeklyUserClassRankStep") + return stepBuilderFactory.get(WEEK_USER_CLASS_RANK_STEP) .chunk(CHUNK_SIZE) .reader(weekUserClassRankReader(null)) .processor(weekUserClassRankProcessor(null)) @@ -79,7 +79,7 @@ public Step weekUserClassRankStep(@Value("#{jobParameters[jobKey]}") String jobK @Bean @JobScope public Step monthUserClassRankStep(@Value("#{jobParameters[jobKey]}") String jobKey) { - return stepBuilderFactory.get("monthUserClassRankStep") + return stepBuilderFactory.get(MONTH_USER_CLASS_RANK_STEP) .chunk(CHUNK_SIZE) .reader(monthUserClassRankReader(null)) .processor(monthUserClassRankProcessor(null)) @@ -90,25 +90,25 @@ public Step monthUserClassRankStep(@Value("#{jobParameters[jobKey]}") String job @Bean @StepScope public StoredProcedureItemReader weekUserSchoolRankReader(@Value("#{jobParameters[stepKey]}") Integer type) { - return callProcedure("weekUserSchoolRankReader", "SELECT_USER_RANK_BY_SCHOOL", 7); + return callProcedure(WEEK_USER_SCHOOL_RANK_READER, SELECT_BY_SCHOOL_PROCEDURE, 7); } @Bean @StepScope public StoredProcedureItemReader monthUserSchoolRankReader(@Value("#{jobParameters[stepKey]}") Integer type) { - return callProcedure("monthUserSchoolRankReader", "SELECT_USER_RANK_BY_SCHOOL", 28); + return callProcedure(MONTH_USER_SCHOOL_RANK_READER, SELECT_BY_SCHOOL_PROCEDURE, 28); } @Bean @StepScope public StoredProcedureItemReader weekUserClassRankReader(@Value("#{jobParameters[stepKey]}") Integer type) { - return callProcedure("weekUserClassRankReader", "SELECT_USER_RANK_BY_CLASS", 7); + return callProcedure(WEEK_USER_CLASS_RANK_READER, SELECT_BY_CLASS_PROCEDURE, 7); } @Bean @StepScope public StoredProcedureItemReader monthUserClassRankReader(@Value("#{jobParameters[stepKey]}") Integer type) { - return callProcedure("monthUserClassRankReader", "SELECT_USER_RANK_BY_CLASS", 28); + return callProcedure(MONTH_USER_CLASS_RANK_READER, SELECT_BY_CLASS_PROCEDURE, 28); } @Bean @@ -188,7 +188,7 @@ public ItemProcessor monthUserClassRankProcessor(@Value( public JdbcBatchItemWriter userRankWriter(@Value("#{jobParameters[jobKey]}") String jobKey) { JdbcBatchItemWriter writer = new JdbcBatchItemWriterBuilder() .dataSource(dataSource) - .sql("CALL SAVE_USER_RANK(:userId, :createdAt, :dateType, :scopeType, :schoolId, :name, :grade, :classNum, :profileImageUrl, :ranking, :walkCount)") + .sql(CALL_SAVE_PROCEDURE) .beanMapped() .build(); From 1d0fd84ac4a93c492aa4effa97b2c265fcb96257 Mon Sep 17 00:00:00 2001 From: jhhong0509 Date: Wed, 23 Feb 2022 16:07:50 +0900 Subject: [PATCH 432/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20(#439)=20Date?= =?UTF-8?q?TimeFormat=20=EB=B3=80=EA=B2=AF=E3=85=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../auth/presentation/dto/response/UserAccessTokenResponse.java | 2 +- .../auth/presentation/dto/response/UserTokenResponse.java | 2 +- .../presentation/dto/response/ExerciseListResponse.java | 2 +- .../presentation/dto/response/QueryNoticeListResponse.java | 2 +- .../presentation/dto/response/QueryUserDetailsResponse.java | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/auth/presentation/dto/response/UserAccessTokenResponse.java b/src/main/java/com/walkhub/walkhub/domain/auth/presentation/dto/response/UserAccessTokenResponse.java index e0bfac39f..6314d27ac 100644 --- a/src/main/java/com/walkhub/walkhub/domain/auth/presentation/dto/response/UserAccessTokenResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/auth/presentation/dto/response/UserAccessTokenResponse.java @@ -12,6 +12,6 @@ public class UserAccessTokenResponse { private final String accessToken; - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'hh:mm:ss") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss") private final ZonedDateTime expiredAt; } diff --git a/src/main/java/com/walkhub/walkhub/domain/auth/presentation/dto/response/UserTokenResponse.java b/src/main/java/com/walkhub/walkhub/domain/auth/presentation/dto/response/UserTokenResponse.java index 89e0f2395..af404783c 100644 --- a/src/main/java/com/walkhub/walkhub/domain/auth/presentation/dto/response/UserTokenResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/auth/presentation/dto/response/UserTokenResponse.java @@ -14,7 +14,7 @@ public class UserTokenResponse { private final String accessToken; - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'hh:mm:ss") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss") private final ZonedDateTime expiredAt; private final String refreshToken; private final Authority authority; diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/response/ExerciseListResponse.java b/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/response/ExerciseListResponse.java index c27338348..c82eb5c9f 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/response/ExerciseListResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/response/ExerciseListResponse.java @@ -20,7 +20,7 @@ public class ExerciseListResponse { public static class ExerciseResponse { private final Long exerciseId; private final String imageUrl; - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'hh:mm:ss") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss") private final ZonedDateTime startAt; private final BigDecimal latitude; private final BigDecimal longitude; diff --git a/src/main/java/com/walkhub/walkhub/domain/notice/presentation/dto/response/QueryNoticeListResponse.java b/src/main/java/com/walkhub/walkhub/domain/notice/presentation/dto/response/QueryNoticeListResponse.java index cfbc77a28..130e7cee9 100644 --- a/src/main/java/com/walkhub/walkhub/domain/notice/presentation/dto/response/QueryNoticeListResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/notice/presentation/dto/response/QueryNoticeListResponse.java @@ -23,7 +23,7 @@ public static class NoticeResponse { private final String title; private final String content; - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'hh:mm:ss") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss") private final ZonedDateTime createdAt; private final Writer writer; diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/QueryUserDetailsResponse.java b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/QueryUserDetailsResponse.java index fa51337ab..8ccdd23ca 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/QueryUserDetailsResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/QueryUserDetailsResponse.java @@ -24,7 +24,7 @@ public class QueryUserDetailsResponse { @Builder public static class ExerciseResponse { private final String imageUrl; - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'hh:mm:ss") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss") private final ZonedDateTime startAt; private final BigDecimal latitude; private final BigDecimal longitude; From a6737f7d862b6206d6e605e9051397885a0ceb4b Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Wed, 23 Feb 2022 18:58:40 +0900 Subject: [PATCH 433/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20static=20impo?= =?UTF-8?q?rt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/walkhub/walkhub/domain/rank/domain/UserRank.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/domain/UserRank.java b/src/main/java/com/walkhub/walkhub/domain/rank/domain/UserRank.java index cdc705c9b..484462cbe 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/domain/UserRank.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/domain/UserRank.java @@ -6,10 +6,7 @@ import lombok.Getter; import lombok.NoArgsConstructor; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.IdClass; +import javax.persistence.*; import java.time.LocalDate; @Getter From 4d085f1ee4435d689cf883707016c8139e87fc73 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Wed, 23 Feb 2022 20:55:01 +0900 Subject: [PATCH 434/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20=EA=B0=80?= =?UTF-8?q?=EB=8F=85=EC=84=B1=20=EC=97=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../QueryUserRankListByMySchoolService.java | 47 ++++++++++++------- 1 file changed, 30 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListByMySchoolService.java b/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListByMySchoolService.java index bfbf6d6bc..a68160eb1 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListByMySchoolService.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListByMySchoolService.java @@ -28,24 +28,25 @@ public class QueryUserRankListByMySchoolService { public UserRankListResponse execute(UserRankScope scope, DateType dateType) { User user = userFacade.getCurrentUser(); - School school = user.getSchool(); LocalDate date = LocalDate.now(); - UserRankListResponse.UserRankResponse myRank = null; - List userRankList = new ArrayList<>(); + UserRankListResponse userRankListResponse = null; if (dateType.equals(DateType.DAY)) { - myRank = buildDayMyRankResponse(user); - List usersDayRank = exerciseAnalysisCacheRepository.getUserIdsByRankTop100(school.getId()); - for (ExerciseAnalysisDto users : usersDayRank) { - userRankList.add(buildDayUsersRankResponse(users)); - } + userRankListResponse = buildDayRankResponse(user); } else if (scope.equals(UserRankScope.ALL)) { - myRank = buildWeekOrMonthMyRankResponse(user.getId(), null, null, dateType, date); - List usersWeekOrMonthRank = userRankRepository.getUserRankListBySchoolId(user.getSchool().getId(), user.getSection().getGrade(), null, dateType, date); - userRankList = userRankFacade.buildWeekOrMonthUsersRankResponse(usersWeekOrMonthRank); + userRankListResponse = buildWeekOrMonthRankResponse(user, null, null, dateType, date); } else if (scope.equals(UserRankScope.CLASS)) { - myRank = buildWeekOrMonthMyRankResponse(user.getId(), user.getSection().getGrade(), user.getSection().getClassNum(), dateType, date); - List usersWeekOrMonthRank = userRankRepository.getUserRankListBySchoolId(user.getSchool().getId(), user.getSection().getGrade(), user.getSection().getClassNum(), dateType, date); - userRankList = userRankFacade.buildWeekOrMonthUsersRankResponse(usersWeekOrMonthRank); + userRankListResponse = buildWeekOrMonthRankResponse(user, user.getSection().getGrade(), user.getSection().getClassNum(), dateType, date); + } + return userRankListResponse; + } + + private UserRankListResponse buildDayRankResponse(User user) { + UserRankListResponse.UserRankResponse myRank; + List userRankList = new ArrayList<>(); + myRank = buildDayMyRank(user); + List usersDayRank = exerciseAnalysisCacheRepository.getUserIdsByRankTop100(user.getSchool().getId()); + for (ExerciseAnalysisDto users : usersDayRank) { + userRankList.add(buildDayUsersRank(users)); } return UserRankListResponse.builder() .myRank(myRank) @@ -53,7 +54,19 @@ public UserRankListResponse execute(UserRankScope scope, DateType dateType) { .build(); } - private UserRankListResponse.UserRankResponse buildDayMyRankResponse(User user) { + private UserRankListResponse buildWeekOrMonthRankResponse(User user, Integer grade, Integer classNum, DateType dateType, LocalDate date) { + UserRankListResponse.UserRankResponse myRank; + List userRankList; + myRank = buildWeekOrMonthMyRank(user.getId(), grade, classNum, dateType, date); + List usersWeekOrMonthRank = userRankRepository.getUserRankListBySchoolId(user.getSchool().getId(), user.getSection().getGrade(), classNum, dateType, date); + userRankList = userRankFacade.buildWeekOrMonthUsersRankResponse(usersWeekOrMonthRank); + return UserRankListResponse.builder() + .myRank(myRank) + .rankList(userRankList) + .build(); + } + + private UserRankListResponse.UserRankResponse buildDayMyRank(User user) { ExerciseAnalysisDto exerciseAnalysisDto = exerciseAnalysisCacheRepository.getUserTodayRank(user.getSchool().getId(), user.getId()); if (exerciseAnalysisDto == null) { return null; @@ -69,7 +82,7 @@ private UserRankListResponse.UserRankResponse buildDayMyRankResponse(User user) .build(); } - private UserRankListResponse.UserRankResponse buildDayUsersRankResponse(ExerciseAnalysisDto dayRank) { + private UserRankListResponse.UserRankResponse buildDayUsersRank(ExerciseAnalysisDto dayRank) { User user = userFacade.getUserById(dayRank.getUserId()); return UserRankListResponse.UserRankResponse.builder() .userId(user.getId()) @@ -82,7 +95,7 @@ private UserRankListResponse.UserRankResponse buildDayUsersRankResponse(Exercise .build(); } - private UserRankListResponse.UserRankResponse buildWeekOrMonthMyRankResponse(Long userId, Integer grade, Integer classNum, DateType dateType, LocalDate date) { + private UserRankListResponse.UserRankResponse buildWeekOrMonthMyRank(Long userId, Integer grade, Integer classNum, DateType dateType, LocalDate date) { UserRankVO myRank = userRankRepository.getMyRankByUserId(userId, grade, classNum, dateType, date); if (myRank == null) { return null; From 454640ce287f1f2a621fb3039855cdcc97bdab7a Mon Sep 17 00:00:00 2001 From: jhhong0509 Date: Thu, 24 Feb 2022 01:13:14 +0900 Subject: [PATCH 435/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20(#444)=20Sect?= =?UTF-8?q?ion=20=EB=AA=A9=EB=A1=9D=EC=97=90=EC=84=9C=20=EB=B0=98=20?= =?UTF-8?q?=EC=97=86=EB=8A=94=20=EC=84=A0=EC=83=9D=EB=8B=98=EB=8F=84=20?= =?UTF-8?q?=EB=B3=B4=EC=97=AC=EC=A3=BC=EB=8F=84=EB=A1=9D=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 --- .../dto/response/ClassListResponse.java | 1 - .../teacher/service/ClassListService.java | 27 +++++++++---------- .../domain/repository/UserRepository.java | 7 ++--- 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/ClassListResponse.java b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/ClassListResponse.java index be2bf70a9..3fdcdaf83 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/ClassListResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/presentation/dto/response/ClassListResponse.java @@ -15,7 +15,6 @@ public class ClassListResponse { @Getter @Builder public static class ClassResponse { - private final Integer userCount; private final SectionResponse section; private final TeacherResponse teacher; } diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/service/ClassListService.java b/src/main/java/com/walkhub/walkhub/domain/teacher/service/ClassListService.java index fd9735117..d69b05a7d 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/service/ClassListService.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/service/ClassListService.java @@ -1,6 +1,5 @@ package com.walkhub.walkhub.domain.teacher.service; -import com.walkhub.walkhub.domain.school.domain.School; import com.walkhub.walkhub.domain.teacher.presentation.dto.response.ClassListResponse; import com.walkhub.walkhub.domain.teacher.presentation.dto.response.ClassListResponse.ClassResponse; import com.walkhub.walkhub.domain.teacher.presentation.dto.response.ClassListResponse.SectionResponse; @@ -8,7 +7,6 @@ import com.walkhub.walkhub.domain.user.domain.Section; import com.walkhub.walkhub.domain.user.domain.User; import com.walkhub.walkhub.domain.user.domain.repository.UserRepository; -import com.walkhub.walkhub.domain.user.exception.AlreadyJoinedException; import com.walkhub.walkhub.domain.user.facade.UserFacade; import com.walkhub.walkhub.global.enums.Authority; import lombok.RequiredArgsConstructor; @@ -28,26 +26,25 @@ public class ClassListService { @Transactional(readOnly = true) public ClassListResponse execute() { User user = userFacade.getCurrentUser(); + List teachers = userRepository.findAllBySchoolAndAuthority(user.getSchool(), Authority.TEACHER); - if (user.hasSection()) { - throw AlreadyJoinedException.EXCEPTION; - } - - School school = user.getSchool(); - - List classList = school.getSections() - .stream() - .map(this::buildClassList) + List classList = teachers.stream() + .map(this::buildClassResponse) .collect(Collectors.toList()); return new ClassListResponse(classList); } - private ClassResponse buildClassList(Section section) { - User teacher = userRepository.findBySectionAndAuthority(section, Authority.TEACHER); - Integer userCount = userRepository.findAllBySectionAndAuthority(section, Authority.USER).size(); + private ClassResponse buildClassResponse(User teacher) { + Section section; + + if (teacher.hasSection()) { + section = teacher.getSection(); + } else { + section = Section.builder().build(); + } + return ClassResponse.builder() - .userCount(userCount) .section(SectionResponse.builder() .sectionId(section.getId()) .grade(section.getGrade()) diff --git a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepository.java b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepository.java index a24f1d533..295422cb1 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepository.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepository.java @@ -1,12 +1,13 @@ package com.walkhub.walkhub.domain.user.domain.repository; +import com.walkhub.walkhub.domain.school.domain.School; import com.walkhub.walkhub.domain.user.domain.Section; import com.walkhub.walkhub.domain.user.domain.User; import com.walkhub.walkhub.global.enums.Authority; -import io.lettuce.core.dynamic.annotation.Param; import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.query.Param; import org.springframework.transaction.annotation.Transactional; import java.util.List; @@ -15,9 +16,9 @@ public interface UserRepository extends CrudRepository, UserRepositoryCustom { Optional findByAccountId(String accountId); Optional findByPhoneNumber(String phoneNumber); - User findBySectionAndAuthority(Section section, Authority authority); - List findAllBySectionAndAuthority(Section section, Authority authority); List findAllBySchoolIdAndNameContaining(Long id, String name); + @Query("select u from User u left join fetch u.section where u.school = :school and u.authority = :authority") + List findAllBySchoolAndAuthority(@Param("school") School school, @Param("authority") Authority authority); @Transactional @Modifying From d07f7d611328262619a713808c4e407599a92730 Mon Sep 17 00:00:00 2001 From: jhhong0509 Date: Thu, 24 Feb 2022 01:17:09 +0900 Subject: [PATCH 436/522] =?UTF-8?q?:recycle:=20::=20(#444)=20=EC=9D=B8?= =?UTF-8?q?=EB=8D=B4=ED=85=8C=EC=9D=B4=EC=85=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../walkhub/walkhub/domain/teacher/service/ClassListService.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/service/ClassListService.java b/src/main/java/com/walkhub/walkhub/domain/teacher/service/ClassListService.java index d69b05a7d..f50839da0 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/service/ClassListService.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/service/ClassListService.java @@ -56,6 +56,7 @@ private ClassResponse buildClassResponse(User teacher) { .profileImageUrl(teacher.getProfileImageUrl()) .build()) .build(); + } } From be3b6cf682646338cf11f859db426fc62ae63923 Mon Sep 17 00:00:00 2001 From: jhhong0509 Date: Thu, 24 Feb 2022 01:39:43 +0900 Subject: [PATCH 437/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20(#444)=20auth?= =?UTF-8?q?code=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../walkhub/domain/teacher/service/ClassListService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/service/ClassListService.java b/src/main/java/com/walkhub/walkhub/domain/teacher/service/ClassListService.java index c3df02363..e9309526d 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/service/ClassListService.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/service/ClassListService.java @@ -32,7 +32,7 @@ public ClassListResponse execute() { .map(this::buildClassResponse) .collect(Collectors.toList()); - return new ClassListResponse(school.getAuthCode(), classList); + return new ClassListResponse(user.getSchool().getAuthCode(), classList); } private ClassResponse buildClassResponse(User teacher) { From 79b8147043f613220c644232a7208037ca744dbc Mon Sep 17 00:00:00 2001 From: jhhong0509 Date: Thu, 24 Feb 2022 02:44:10 +0900 Subject: [PATCH 438/522] =?UTF-8?q?:bug:=20::=20(#446)=20BaseTimeEntity=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 --- .../com/walkhub/walkhub/global/entity/BaseTimeEntity.java | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/global/entity/BaseTimeEntity.java b/src/main/java/com/walkhub/walkhub/global/entity/BaseTimeEntity.java index 92cea1b82..fbb5f82cb 100644 --- a/src/main/java/com/walkhub/walkhub/global/entity/BaseTimeEntity.java +++ b/src/main/java/com/walkhub/walkhub/global/entity/BaseTimeEntity.java @@ -1,21 +1,16 @@ package com.walkhub.walkhub.global.entity; import lombok.Getter; -import org.springframework.data.annotation.CreatedDate; -import org.springframework.data.jpa.domain.support.AuditingEntityListener; import javax.persistence.Column; -import javax.persistence.EntityListeners; import javax.persistence.MappedSuperclass; import java.time.ZonedDateTime; @Getter @MappedSuperclass -@EntityListeners(AuditingEntityListener.class) public abstract class BaseTimeEntity { @Column(nullable = false) - @CreatedDate - private ZonedDateTime createdAt; + private ZonedDateTime createdAt = ZonedDateTime.now(); } From 581df8851dbe8f8cfb2a89d65e16592408c9fbcf Mon Sep 17 00:00:00 2001 From: jhhong0509 Date: Thu, 24 Feb 2022 03:17:42 +0900 Subject: [PATCH 439/522] =?UTF-8?q?:bug:=20::=20(#448)=20=EC=98=A4?= =?UTF-8?q?=ED=83=80=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/walkhub/walkhub/global/security/SecurityConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java b/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java index 9bf689376..da0c28a46 100644 --- a/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java +++ b/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java @@ -76,7 +76,7 @@ protected void configure(HttpSecurity http) throws Exception { .antMatchers(HttpMethod.POST, "/exercises/locations/{exercise-id}").authenticated() .antMatchers(HttpMethod.GET, "/exercises/analysis").authenticated() .antMatchers(HttpMethod.GET, "/exercises/lists").authenticated() - .antMatchers(HttpMethod.GET, "/exercises/{exercise-id}}").hasAnyAuthority("TEACHER", "ROOT") + .antMatchers(HttpMethod.GET, "/exercises/{exercise-id}").hasAnyAuthority("TEACHER", "ROOT") // notices .antMatchers(HttpMethod.GET, "/notices/list").authenticated() From 2d89f0e49236790dd5e919959cf4adf3c1561587 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B2=94=EC=A7=84?= Date: Thu, 24 Feb 2022 12:31:52 +0900 Subject: [PATCH 440/522] =?UTF-8?q?=E2=9A=A1=20::=20sex=20column=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/walkhub/walkhub/domain/user/domain/User.java | 1 - .../user/presentation/dto/request/UpdateUserInfoRequest.java | 5 ----- 2 files changed, 6 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/user/domain/User.java b/src/main/java/com/walkhub/walkhub/domain/user/domain/User.java index 7895ef345..19a426fe2 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/domain/User.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/domain/User.java @@ -138,7 +138,6 @@ public void setDeviceToken(String deviceToken) { public void updateUser(UpdateUserInfoRequest request) { this.name = request.getName(); this.profileImageUrl = request.getProfileImageUrl(); - this.sex = request.getSex(); } public void setBadge(Badge badge) { diff --git a/src/main/java/com/walkhub/walkhub/domain/user/presentation/dto/request/UpdateUserInfoRequest.java b/src/main/java/com/walkhub/walkhub/domain/user/presentation/dto/request/UpdateUserInfoRequest.java index ce8d37bdf..8952cf514 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/presentation/dto/request/UpdateUserInfoRequest.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/presentation/dto/request/UpdateUserInfoRequest.java @@ -1,7 +1,5 @@ package com.walkhub.walkhub.domain.user.presentation.dto.request; -import com.walkhub.walkhub.domain.user.domain.type.Sex; -import javax.validation.constraints.NotNull; import lombok.Getter; import lombok.NoArgsConstructor; @@ -19,7 +17,4 @@ public class UpdateUserInfoRequest { @NotBlank(message = "profile_image_url은 null, 공백, 띄어쓰기를 허용하지 않습니다.") private String profileImageUrl; - @NotNull(message = "sex는 null, 공백, 띄어쓰기를 허용하지 않습니다.") - private Sex sex; - } From cc83ce5258ddd36e678d41539532cd38dcdf4280 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Fri, 25 Feb 2022 16:15:40 +0900 Subject: [PATCH 441/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20=EC=A4=84?= =?UTF-8?q?=EB=B0=94=EA=BF=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/QueryUserRankListByMySchoolService.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListByMySchoolService.java b/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListByMySchoolService.java index a68160eb1..d019a6c2f 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListByMySchoolService.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListByMySchoolService.java @@ -30,6 +30,7 @@ public UserRankListResponse execute(UserRankScope scope, DateType dateType) { User user = userFacade.getCurrentUser(); LocalDate date = LocalDate.now(); UserRankListResponse userRankListResponse = null; + if (dateType.equals(DateType.DAY)) { userRankListResponse = buildDayRankResponse(user); } else if (scope.equals(UserRankScope.ALL)) { @@ -37,17 +38,21 @@ public UserRankListResponse execute(UserRankScope scope, DateType dateType) { } else if (scope.equals(UserRankScope.CLASS)) { userRankListResponse = buildWeekOrMonthRankResponse(user, user.getSection().getGrade(), user.getSection().getClassNum(), dateType, date); } + return userRankListResponse; } private UserRankListResponse buildDayRankResponse(User user) { UserRankListResponse.UserRankResponse myRank; List userRankList = new ArrayList<>(); + myRank = buildDayMyRank(user); + List usersDayRank = exerciseAnalysisCacheRepository.getUserIdsByRankTop100(user.getSchool().getId()); for (ExerciseAnalysisDto users : usersDayRank) { userRankList.add(buildDayUsersRank(users)); } + return UserRankListResponse.builder() .myRank(myRank) .rankList(userRankList) @@ -57,9 +62,12 @@ private UserRankListResponse buildDayRankResponse(User user) { private UserRankListResponse buildWeekOrMonthRankResponse(User user, Integer grade, Integer classNum, DateType dateType, LocalDate date) { UserRankListResponse.UserRankResponse myRank; List userRankList; + myRank = buildWeekOrMonthMyRank(user.getId(), grade, classNum, dateType, date); + List usersWeekOrMonthRank = userRankRepository.getUserRankListBySchoolId(user.getSchool().getId(), user.getSection().getGrade(), classNum, dateType, date); userRankList = userRankFacade.buildWeekOrMonthUsersRankResponse(usersWeekOrMonthRank); + return UserRankListResponse.builder() .myRank(myRank) .rankList(userRankList) @@ -71,6 +79,7 @@ private UserRankListResponse.UserRankResponse buildDayMyRank(User user) { if (exerciseAnalysisDto == null) { return null; } + return UserRankListResponse.UserRankResponse.builder() .userId(user.getId()) .name(user.getName()) @@ -84,6 +93,7 @@ private UserRankListResponse.UserRankResponse buildDayMyRank(User user) { private UserRankListResponse.UserRankResponse buildDayUsersRank(ExerciseAnalysisDto dayRank) { User user = userFacade.getUserById(dayRank.getUserId()); + return UserRankListResponse.UserRankResponse.builder() .userId(user.getId()) .name(user.getName()) @@ -100,6 +110,7 @@ private UserRankListResponse.UserRankResponse buildWeekOrMonthMyRank(Long userId if (myRank == null) { return null; } + return UserRankListResponse.UserRankResponse.builder() .userId(myRank.getUserId()) .name(myRank.getName()) From f4c8413aa40e41320114557c733e08acbbec6e56 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Fri, 25 Feb 2022 16:36:15 +0900 Subject: [PATCH 442/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20codesmell=20?= =?UTF-8?q?=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rank/service/QueryUserRankListByMySchoolService.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListByMySchoolService.java b/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListByMySchoolService.java index d019a6c2f..b39919db0 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListByMySchoolService.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListByMySchoolService.java @@ -7,7 +7,6 @@ import com.walkhub.walkhub.domain.rank.domain.type.UserRankScope; import com.walkhub.walkhub.domain.rank.facade.UserRankFacade; import com.walkhub.walkhub.domain.rank.presentation.dto.response.UserRankListResponse; -import com.walkhub.walkhub.domain.school.domain.School; import com.walkhub.walkhub.domain.user.domain.User; import com.walkhub.walkhub.domain.user.facade.UserFacade; import com.walkhub.walkhub.global.enums.DateType; @@ -110,7 +109,7 @@ private UserRankListResponse.UserRankResponse buildWeekOrMonthMyRank(Long userId if (myRank == null) { return null; } - + return UserRankListResponse.UserRankResponse.builder() .userId(myRank.getUserId()) .name(myRank.getName()) From 4f52b042af3938f1c918b03b6341666aa7e7fde1 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Fri, 25 Feb 2022 16:58:01 +0900 Subject: [PATCH 443/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20grade,=20clas?= =?UTF-8?q?sNum=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/repository/UserRankRepositoryCustomImpl.java | 4 ---- .../domain/rank/domain/repository/vo/UserRankVO.java | 6 +----- .../walkhub/walkhub/domain/rank/facade/UserRankFacade.java | 2 -- .../presentation/dto/response/UserRankListResponse.java | 2 -- .../rank/service/QueryUserRankListByMySchoolService.java | 6 ------ 5 files changed, 1 insertion(+), 19 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustomImpl.java index 5dac10207..57140485d 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustomImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustomImpl.java @@ -24,8 +24,6 @@ public UserRankVO getMyRankByUserId(Long userId, Integer grade, Integer classNum .select(new QUserRankVO( userRank.userId, userRank.name, - userRank.grade, - userRank.classNum, userRank.ranking, userRank.profileImageUrl, userRank.walkCount @@ -46,8 +44,6 @@ public List getUserRankListBySchoolId(Long schoolId, Integer grade, .select(new QUserRankVO( userRank.userId, userRank.name, - userRank.grade, - userRank.classNum, userRank.ranking, userRank.profileImageUrl, userRank.walkCount diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/vo/UserRankVO.java b/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/vo/UserRankVO.java index 28edcf7ef..d76d7dba7 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/vo/UserRankVO.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/vo/UserRankVO.java @@ -7,18 +7,14 @@ public class UserRankVO { private final Long userId; private final String name; - private final Integer grade; - private final Integer classNum; private final Integer ranking; private final String profileImageUrl; private final Integer walkCount; @QueryProjection - public UserRankVO(Long userId, String name, Integer grade, Integer classNum, Integer ranking, String profileImageUrl, Integer walkCount) { + public UserRankVO(Long userId, String name, Integer ranking, String profileImageUrl, Integer walkCount) { this.userId = userId; this.name = name; - this.grade = grade; - this.classNum = classNum; this.ranking = ranking; this.profileImageUrl = profileImageUrl; this.walkCount = walkCount; diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/facade/UserRankFacade.java b/src/main/java/com/walkhub/walkhub/domain/rank/facade/UserRankFacade.java index 38a66c214..a2c0042bc 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/facade/UserRankFacade.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/facade/UserRankFacade.java @@ -17,8 +17,6 @@ public List buildWeekOrMonthUsersRankResp .map(userRank -> UserRankListResponse.UserRankResponse.builder() .userId(userRank.getUserId()) .name(userRank.getName()) - .grade(userRank.getGrade()) - .classNum(userRank.getClassNum()) .ranking(userRank.getRanking()) .profileImageUrl(userRank.getProfileImageUrl()) .walkCount(userRank.getWalkCount()) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/presentation/dto/response/UserRankListResponse.java b/src/main/java/com/walkhub/walkhub/domain/rank/presentation/dto/response/UserRankListResponse.java index 4eff771d2..b4e12aa36 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/presentation/dto/response/UserRankListResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/presentation/dto/response/UserRankListResponse.java @@ -19,8 +19,6 @@ public class UserRankListResponse { public static class UserRankResponse { private final Long userId; private final String name; - private final Integer grade; - private final Integer classNum; private final Integer ranking; private final String profileImageUrl; private final Integer walkCount; diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListByMySchoolService.java b/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListByMySchoolService.java index b39919db0..4d9dc0aa6 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListByMySchoolService.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListByMySchoolService.java @@ -82,8 +82,6 @@ private UserRankListResponse.UserRankResponse buildDayMyRank(User user) { return UserRankListResponse.UserRankResponse.builder() .userId(user.getId()) .name(user.getName()) - .grade(user.getSection().getGrade()) - .classNum(user.getSection().getClassNum()) .ranking(exerciseAnalysisDto.getRanking()) .profileImageUrl(user.getProfileImageUrl()) .walkCount(exerciseAnalysisDto.getWalkCount()) @@ -96,8 +94,6 @@ private UserRankListResponse.UserRankResponse buildDayUsersRank(ExerciseAnalysis return UserRankListResponse.UserRankResponse.builder() .userId(user.getId()) .name(user.getName()) - .grade(user.getSection().getGrade()) - .classNum(user.getSection().getClassNum()) .ranking(dayRank.getRanking()) .profileImageUrl(user.getProfileImageUrl()) .walkCount(dayRank.getWalkCount()) @@ -113,8 +109,6 @@ private UserRankListResponse.UserRankResponse buildWeekOrMonthMyRank(Long userId return UserRankListResponse.UserRankResponse.builder() .userId(myRank.getUserId()) .name(myRank.getName()) - .grade(myRank.getGrade()) - .classNum(myRank.getClassNum()) .ranking(myRank.getRanking()) .profileImageUrl(myRank.getProfileImageUrl()) .walkCount(myRank.getWalkCount()) From 6f4435c283c1bdee2e7513991c37fdb96072dd3c Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Fri, 25 Feb 2022 17:38:01 +0900 Subject: [PATCH 444/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20Setter=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 --- src/main/java/com/walkhub/walkhub/domain/user/domain/User.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/user/domain/User.java b/src/main/java/com/walkhub/walkhub/domain/user/domain/User.java index 19a426fe2..91bfe019d 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/domain/User.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/domain/User.java @@ -83,6 +83,7 @@ public class User extends BaseTimeEntity { @NotNull @Enumerated(EnumType.STRING) + @Setter private Sex sex; @OneToOne(fetch = FetchType.LAZY) From 0e7024523e9790bf7b627dea9daff8c4cfa4526a Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Fri, 25 Feb 2022 17:38:22 +0900 Subject: [PATCH 445/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20Sex=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80,=20Notnull=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/request/InputHealthInformationRequest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/user/presentation/dto/request/InputHealthInformationRequest.java b/src/main/java/com/walkhub/walkhub/domain/user/presentation/dto/request/InputHealthInformationRequest.java index dc35a7e96..a0434ca65 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/presentation/dto/request/InputHealthInformationRequest.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/presentation/dto/request/InputHealthInformationRequest.java @@ -1,10 +1,10 @@ package com.walkhub.walkhub.domain.user.presentation.dto.request; +import com.walkhub.walkhub.domain.user.domain.type.Sex; import lombok.Getter; import lombok.NoArgsConstructor; import javax.validation.constraints.Digits; -import javax.validation.constraints.NotNull; import javax.validation.constraints.Positive; import java.math.BigDecimal; @@ -12,11 +12,11 @@ @NoArgsConstructor public class InputHealthInformationRequest { - @NotNull(message = "height는 null일 수 없습니다.") @Digits(integer = 3, fraction = 1) private BigDecimal height; - @NotNull(message = "weight는 null일 수 없습니다.") @Positive(message = "weight는 양수여야 합니다.") private Integer weight; + + private Sex sex; } \ No newline at end of file From 3bd54cd733ae65619d2e76ab4be2bbcd4a13797f Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Fri, 25 Feb 2022 17:38:37 +0900 Subject: [PATCH 446/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20null=20?= =?UTF-8?q?=EC=B2=B4=ED=81=AC=20=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/user/service/InputHealthInformationService.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/user/service/InputHealthInformationService.java b/src/main/java/com/walkhub/walkhub/domain/user/service/InputHealthInformationService.java index 282b233b3..d13d12446 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/service/InputHealthInformationService.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/service/InputHealthInformationService.java @@ -17,6 +17,11 @@ public class InputHealthInformationService { @Transactional public void execute(InputHealthInformationRequest request) { User user = userFacade.getCurrentUser(); - user.setHealthInfo(new HealthInfo(request.getWeight(), request.getHeight())); + if (request.getHeight() != null || request.getWeight() != null) { + user.setHealthInfo(new HealthInfo(request.getWeight(), request.getHeight())); + } + if (request.getSex() != null) { + user.setSex(request.getSex()); + } } } \ No newline at end of file From 9ef6de49ee8c337f78fb88d9f7d9c69d8c3b9ccb Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Fri, 25 Feb 2022 23:36:01 +0900 Subject: [PATCH 447/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20=EB=B0=98?= =?UTF-8?q?=ED=99=98=EA=B0=92=20null=EC=9D=B4=EB=A9=B4=20=EA=B7=B8?= =?UTF-8?q?=EB=8C=80=EB=A1=9C=20=EB=B0=98=ED=99=98=ED=95=98=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cache/ExerciseAnalysisCacheRepositoryImpl.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/cache/ExerciseAnalysisCacheRepositoryImpl.java b/src/main/java/com/walkhub/walkhub/domain/exercise/cache/ExerciseAnalysisCacheRepositoryImpl.java index 4110d2aad..e6092972a 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/cache/ExerciseAnalysisCacheRepositoryImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/cache/ExerciseAnalysisCacheRepositoryImpl.java @@ -25,8 +25,10 @@ public void saveExerciseCache(Long schoolId, Long userId, Double walkCount) { @Override public ExerciseAnalysisDto getUserTodayRank(Long schoolId, Long userId) { - Double doubleWalkCount = Optional.ofNullable(zSetOperations.score(getExerciseAnalysisKey(schoolId), userId)) - .orElseThrow(() -> RedisTransactionException.EXCEPTION); + Double doubleWalkCount = zSetOperations.score(getExerciseAnalysisKey(schoolId), userId); + if (doubleWalkCount == null) { + return null; + } Integer walkCount = doubleWalkCount.intValue(); Long ranking = zSetOperations.rank(getExerciseAnalysisKey(schoolId), userId); @@ -44,10 +46,11 @@ public ExerciseAnalysisDto getUserTodayRank(Long schoolId, Long userId) { @Override public List getUserIdsByRankTop100(Long schoolId) { - Set> rankUserIds = Optional.ofNullable( - zSetOperations.reverseRangeWithScores(getExerciseAnalysisKey(schoolId), 0, 99)) - .orElseThrow(() -> RedisTransactionException.EXCEPTION); + Set> rankUserIds = zSetOperations.reverseRangeWithScores(getExerciseAnalysisKey(schoolId), 0, 99); int rank = 1; + if (rankUserIds == null) { + return Collections.emptyList(); + } List exerciseAnalysisDtos = new ArrayList<>(rankUserIds.size()); From 64955204275dfdc561248fac361f74b12fe58f82 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Fri, 25 Feb 2022 23:36:16 +0900 Subject: [PATCH 448/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20=EC=BB=AC?= =?UTF-8?q?=EB=9F=BC=20=ED=83=80=EC=9E=85=20ENUM=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/walkhub/walkhub/domain/rank/domain/UserRank.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/domain/UserRank.java b/src/main/java/com/walkhub/walkhub/domain/rank/domain/UserRank.java index 484462cbe..73bdb7808 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/domain/UserRank.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/domain/UserRank.java @@ -1,5 +1,7 @@ package com.walkhub.walkhub.domain.rank.domain; +import com.walkhub.walkhub.domain.rank.domain.type.UserRankScope; +import com.walkhub.walkhub.global.enums.DateType; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Builder; @@ -23,10 +25,12 @@ public class UserRank { private LocalDate createdAt; @Id - private String dateType; + @Enumerated(EnumType.STRING) + private DateType dateType; @Id - private String scopeType; + @Enumerated(EnumType.STRING) + private UserRankScope scopeType; @Column(length = 20, nullable = false) private String name; From df98b72f6ef4cae8818fcaea634e6c87d699e010 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Fri, 25 Feb 2022 23:37:00 +0900 Subject: [PATCH 449/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20grade,=20clas?= =?UTF-8?q?snum=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/UserRankRepositoryCustomImpl.java | 11 ++++------- .../domain/rank/domain/repository/vo/UserRankVO.java | 6 +----- .../walkhub/domain/rank/facade/UserRankFacade.java | 2 -- 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustomImpl.java index 5dac10207..1b65f25ec 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustomImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/UserRankRepositoryCustomImpl.java @@ -4,6 +4,7 @@ import com.querydsl.jpa.impl.JPAQueryFactory; import com.walkhub.walkhub.domain.rank.domain.repository.vo.QUserRankVO; import com.walkhub.walkhub.domain.rank.domain.repository.vo.UserRankVO; +import com.walkhub.walkhub.domain.rank.domain.type.UserRankScope; import com.walkhub.walkhub.global.enums.DateType; import lombok.RequiredArgsConstructor; @@ -24,8 +25,6 @@ public UserRankVO getMyRankByUserId(Long userId, Integer grade, Integer classNum .select(new QUserRankVO( userRank.userId, userRank.name, - userRank.grade, - userRank.classNum, userRank.ranking, userRank.profileImageUrl, userRank.walkCount @@ -46,8 +45,6 @@ public List getUserRankListBySchoolId(Long schoolId, Integer grade, .select(new QUserRankVO( userRank.userId, userRank.name, - userRank.grade, - userRank.classNum, userRank.ranking, userRank.profileImageUrl, userRank.walkCount @@ -78,15 +75,15 @@ private BooleanExpression gradeEq(Integer grade) { } private BooleanExpression classNumEq(Integer classNum) { - return classNum != null ? userRank.scopeType.eq("CLASS").and(userRank.classNum.eq(classNum)) : userRank.scopeType.eq("SCHOOL"); + return classNum != null ? userRank.scopeType.eq(UserRankScope.CLASS).and(userRank.classNum.eq(classNum)) : userRank.scopeType.eq(UserRankScope.SCHOOL); } private BooleanExpression dateTypeEq(DateType dateType) { switch (dateType) { case WEEK: - return userRank.dateType.eq("WEEK"); + return userRank.dateType.eq(DateType.WEEK); case MONTH: - return userRank.dateType.eq("MONTH"); + return userRank.dateType.eq(DateType.MONTH); default: return null; } diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/vo/UserRankVO.java b/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/vo/UserRankVO.java index 28edcf7ef..d76d7dba7 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/vo/UserRankVO.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/vo/UserRankVO.java @@ -7,18 +7,14 @@ public class UserRankVO { private final Long userId; private final String name; - private final Integer grade; - private final Integer classNum; private final Integer ranking; private final String profileImageUrl; private final Integer walkCount; @QueryProjection - public UserRankVO(Long userId, String name, Integer grade, Integer classNum, Integer ranking, String profileImageUrl, Integer walkCount) { + public UserRankVO(Long userId, String name, Integer ranking, String profileImageUrl, Integer walkCount) { this.userId = userId; this.name = name; - this.grade = grade; - this.classNum = classNum; this.ranking = ranking; this.profileImageUrl = profileImageUrl; this.walkCount = walkCount; diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/facade/UserRankFacade.java b/src/main/java/com/walkhub/walkhub/domain/rank/facade/UserRankFacade.java index 38a66c214..a2c0042bc 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/facade/UserRankFacade.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/facade/UserRankFacade.java @@ -17,8 +17,6 @@ public List buildWeekOrMonthUsersRankResp .map(userRank -> UserRankListResponse.UserRankResponse.builder() .userId(userRank.getUserId()) .name(userRank.getName()) - .grade(userRank.getGrade()) - .classNum(userRank.getClassNum()) .ranking(userRank.getRanking()) .profileImageUrl(userRank.getProfileImageUrl()) .walkCount(userRank.getWalkCount()) From 372babcceda332a4decc7335757b3f071ad47e69 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Fri, 25 Feb 2022 23:37:52 +0900 Subject: [PATCH 450/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20=ED=94=84?= =?UTF-8?q?=EB=A1=9C=EC=8B=9C=EC=A0=80=EC=97=90=20ENUM=EC=9D=84=20STRING?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20=EC=A0=84=EB=8B=AC=ED=95=98=EA=B8=B0=20?= =?UTF-8?q?=EC=9C=84=ED=95=9C=20VO?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/vo/UserRankWriterVO.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/vo/UserRankWriterVO.java diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/vo/UserRankWriterVO.java b/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/vo/UserRankWriterVO.java new file mode 100644 index 000000000..3e0dab68b --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/vo/UserRankWriterVO.java @@ -0,0 +1,24 @@ +package com.walkhub.walkhub.domain.rank.domain.repository.vo; + +import com.walkhub.walkhub.domain.rank.domain.type.UserRankScope; +import com.walkhub.walkhub.global.enums.DateType; +import lombok.Builder; +import lombok.Getter; + +import java.time.LocalDate; + +@Getter +@Builder +public class UserRankWriterVO { + private Long userId; + private LocalDate createdAt; + private String dateType; + private String scopeType; + private String name; + private Integer grade; + private Integer classNum; + private String profileImageUrl; + private Integer walkCount; + private Integer ranking; + private Long schoolId; +} From b04a1351a5158923d2b8cb716764363507aa9fbb Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Fri, 25 Feb 2022 23:38:04 +0900 Subject: [PATCH 451/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20ALL=20->=20SC?= =?UTF-8?q?HOOL?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../walkhub/walkhub/domain/rank/domain/type/UserRankScope.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/domain/type/UserRankScope.java b/src/main/java/com/walkhub/walkhub/domain/rank/domain/type/UserRankScope.java index 5e4878172..57a05ed1c 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/domain/type/UserRankScope.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/domain/type/UserRankScope.java @@ -1,6 +1,6 @@ package com.walkhub.walkhub.domain.rank.domain.type; public enum UserRankScope { - ALL, + SCHOOL, CLASS } From 05d610a2a3c3fccd6ddfb4f4abcc9b13ec2f20b2 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Fri, 25 Feb 2022 23:38:21 +0900 Subject: [PATCH 452/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20=EB=B0=98?= =?UTF-8?q?=ED=99=98=20=ED=83=80=EC=9E=85=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../walkhub/domain/rank/job/UserRankJob.java | 47 ++++++++++--------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/job/UserRankJob.java b/src/main/java/com/walkhub/walkhub/domain/rank/job/UserRankJob.java index 504d527e8..fcc063d41 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/job/UserRankJob.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/job/UserRankJob.java @@ -1,7 +1,10 @@ package com.walkhub.walkhub.domain.rank.job; import com.walkhub.walkhub.domain.rank.domain.*; +import com.walkhub.walkhub.domain.rank.domain.repository.vo.UserRankWriterVO; +import com.walkhub.walkhub.domain.rank.domain.type.UserRankScope; import com.walkhub.walkhub.domain.rank.presentation.dto.response.UserRankInfo; +import com.walkhub.walkhub.global.enums.DateType; import lombok.RequiredArgsConstructor; import org.springframework.batch.core.Job; import org.springframework.batch.core.Step; @@ -47,7 +50,7 @@ public Job userJob() { @JobScope public Step weekUserSchoolRankStep(@Value("#{jobParameters[jobKey]}") String jobKey) { return stepBuilderFactory.get(WEEK_USER_SCHOOL_RANK_STEP) - .chunk(CHUNK_SIZE) + .chunk(CHUNK_SIZE) .reader(weekUserSchoolRankReader(null)) .processor(weekUserSchoolRankProcessor(null)) .writer(userRankWriter(null)) @@ -58,7 +61,7 @@ public Step weekUserSchoolRankStep(@Value("#{jobParameters[jobKey]}") String job @JobScope public Step monthUserSchoolRankStep(@Value("#{jobParameters[jobKey]}") String jobKey) { return stepBuilderFactory.get(MONTH_USER_SCHOOL_RANK_STEP) - .chunk(CHUNK_SIZE) + .chunk(CHUNK_SIZE) .reader(monthUserSchoolRankReader(null)) .processor(monthUserSchoolRankProcessor(null)) .writer(userRankWriter(null)) @@ -69,7 +72,7 @@ public Step monthUserSchoolRankStep(@Value("#{jobParameters[jobKey]}") String jo @JobScope public Step weekUserClassRankStep(@Value("#{jobParameters[jobKey]}") String jobKey) { return stepBuilderFactory.get(WEEK_USER_CLASS_RANK_STEP) - .chunk(CHUNK_SIZE) + .chunk(CHUNK_SIZE) .reader(weekUserClassRankReader(null)) .processor(weekUserClassRankProcessor(null)) .writer(userRankWriter(null)) @@ -80,7 +83,7 @@ public Step weekUserClassRankStep(@Value("#{jobParameters[jobKey]}") String jobK @JobScope public Step monthUserClassRankStep(@Value("#{jobParameters[jobKey]}") String jobKey) { return stepBuilderFactory.get(MONTH_USER_CLASS_RANK_STEP) - .chunk(CHUNK_SIZE) + .chunk(CHUNK_SIZE) .reader(monthUserClassRankReader(null)) .processor(monthUserClassRankProcessor(null)) .writer(userRankWriter(null)) @@ -113,12 +116,12 @@ public StoredProcedureItemReader monthUserClassRankReader(@Value(" @Bean @StepScope - public ItemProcessor weekUserSchoolRankProcessor(@Value("#{jobParameters[jobKey]}") String jobKey) { - return rankInfo -> UserRank.builder() + public ItemProcessor weekUserSchoolRankProcessor(@Value("#{jobParameters[jobKey]}") String jobKey) { + return rankInfo -> UserRankWriterVO.builder() .userId(rankInfo.getUserId()) .createdAt(LocalDate.now()) - .dateType(DATE_WEEK) - .scopeType("SCHOOL") + .dateType(DateType.WEEK.name()) + .scopeType(UserRankScope.SCHOOL.name()) .schoolId(rankInfo.getSchoolId()) .name(rankInfo.getName()) .grade(rankInfo.getGrade()) @@ -131,12 +134,12 @@ public ItemProcessor weekUserSchoolRankProcessor(@Value( @Bean @StepScope - public ItemProcessor monthUserSchoolRankProcessor(@Value("#{jobParameters[jobKey]}") String jobKey) { - return rankInfo -> UserRank.builder() + public ItemProcessor monthUserSchoolRankProcessor(@Value("#{jobParameters[jobKey]}") String jobKey) { + return rankInfo -> UserRankWriterVO.builder() .userId(rankInfo.getUserId()) .createdAt(LocalDate.now()) - .dateType(DATE_MONTH) - .scopeType("SCHOOL") + .dateType(DateType.MONTH.name()) + .scopeType(UserRankScope.SCHOOL.name()) .schoolId(rankInfo.getSchoolId()) .name(rankInfo.getName()) .grade(rankInfo.getGrade()) @@ -149,12 +152,12 @@ public ItemProcessor monthUserSchoolRankProcessor(@Value @Bean @StepScope - public ItemProcessor weekUserClassRankProcessor(@Value("#{jobParameters[jobKey]}") String jobKey) { - return rankInfo -> UserRank.builder() + public ItemProcessor weekUserClassRankProcessor(@Value("#{jobParameters[jobKey]}") String jobKey) { + return rankInfo -> UserRankWriterVO.builder() .userId(rankInfo.getUserId()) .createdAt(LocalDate.now()) - .dateType(DATE_WEEK) - .scopeType("CLASS") + .dateType(DateType.WEEK.name()) + .scopeType(UserRankScope.CLASS.name()) .schoolId(rankInfo.getSchoolId()) .name(rankInfo.getName()) .grade(rankInfo.getGrade()) @@ -167,12 +170,12 @@ public ItemProcessor weekUserClassRankProcessor(@Value(" @Bean @StepScope - public ItemProcessor monthUserClassRankProcessor(@Value("#{jobParameters[jobKey]}") String jobKey) { - return rankInfo -> UserRank.builder() + public ItemProcessor monthUserClassRankProcessor(@Value("#{jobParameters[jobKey]}") String jobKey) { + return rankInfo -> UserRankWriterVO.builder() .userId(rankInfo.getUserId()) .createdAt(LocalDate.now()) - .dateType(DATE_MONTH) - .scopeType("CLASS") + .dateType(DateType.MONTH.name()) + .scopeType(UserRankScope.CLASS.name()) .schoolId(rankInfo.getSchoolId()) .name(rankInfo.getName()) .grade(rankInfo.getGrade()) @@ -185,8 +188,8 @@ public ItemProcessor monthUserClassRankProcessor(@Value( @Bean @StepScope - public JdbcBatchItemWriter userRankWriter(@Value("#{jobParameters[jobKey]}") String jobKey) { - JdbcBatchItemWriter writer = new JdbcBatchItemWriterBuilder() + public JdbcBatchItemWriter userRankWriter(@Value("#{jobParameters[jobKey]}") String jobKey) { + JdbcBatchItemWriter writer = new JdbcBatchItemWriterBuilder() .dataSource(dataSource) .sql(CALL_SAVE_PROCEDURE) .beanMapped() From 93c6273ac15b11720fa6df8875232ead44aaa9af Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Fri, 25 Feb 2022 23:38:38 +0900 Subject: [PATCH 453/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20@JsonInclude?= =?UTF-8?q?=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rank/presentation/dto/response/UserRankListResponse.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/presentation/dto/response/UserRankListResponse.java b/src/main/java/com/walkhub/walkhub/domain/rank/presentation/dto/response/UserRankListResponse.java index 4eff771d2..d2d74d55d 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/presentation/dto/response/UserRankListResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/presentation/dto/response/UserRankListResponse.java @@ -1,6 +1,5 @@ package com.walkhub.walkhub.domain.rank.presentation.dto.response; -import com.fasterxml.jackson.annotation.JsonInclude; import lombok.Builder; import lombok.Getter; @@ -8,7 +7,6 @@ @Getter @Builder -@JsonInclude(JsonInclude.Include.NON_NULL) public class UserRankListResponse { private final UserRankResponse myRank; @@ -19,8 +17,6 @@ public class UserRankListResponse { public static class UserRankResponse { private final Long userId; private final String name; - private final Integer grade; - private final Integer classNum; private final Integer ranking; private final String profileImageUrl; private final Integer walkCount; From 147a40b5e158f5a6cb5b9350a520c7db0952eed3 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Fri, 25 Feb 2022 23:38:53 +0900 Subject: [PATCH 454/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20ALL=20->=20SC?= =?UTF-8?q?HOOL?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rank/service/QueryUserRankListByMySchoolService.java | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListByMySchoolService.java b/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListByMySchoolService.java index b39919db0..c8b5aac85 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListByMySchoolService.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListByMySchoolService.java @@ -32,7 +32,7 @@ public UserRankListResponse execute(UserRankScope scope, DateType dateType) { if (dateType.equals(DateType.DAY)) { userRankListResponse = buildDayRankResponse(user); - } else if (scope.equals(UserRankScope.ALL)) { + } else if (scope.equals(UserRankScope.SCHOOL)) { userRankListResponse = buildWeekOrMonthRankResponse(user, null, null, dateType, date); } else if (scope.equals(UserRankScope.CLASS)) { userRankListResponse = buildWeekOrMonthRankResponse(user, user.getSection().getGrade(), user.getSection().getClassNum(), dateType, date); @@ -82,8 +82,6 @@ private UserRankListResponse.UserRankResponse buildDayMyRank(User user) { return UserRankListResponse.UserRankResponse.builder() .userId(user.getId()) .name(user.getName()) - .grade(user.getSection().getGrade()) - .classNum(user.getSection().getClassNum()) .ranking(exerciseAnalysisDto.getRanking()) .profileImageUrl(user.getProfileImageUrl()) .walkCount(exerciseAnalysisDto.getWalkCount()) @@ -96,8 +94,6 @@ private UserRankListResponse.UserRankResponse buildDayUsersRank(ExerciseAnalysis return UserRankListResponse.UserRankResponse.builder() .userId(user.getId()) .name(user.getName()) - .grade(user.getSection().getGrade()) - .classNum(user.getSection().getClassNum()) .ranking(dayRank.getRanking()) .profileImageUrl(user.getProfileImageUrl()) .walkCount(dayRank.getWalkCount()) @@ -113,8 +109,6 @@ private UserRankListResponse.UserRankResponse buildWeekOrMonthMyRank(Long userId return UserRankListResponse.UserRankResponse.builder() .userId(myRank.getUserId()) .name(myRank.getName()) - .grade(myRank.getGrade()) - .classNum(myRank.getClassNum()) .ranking(myRank.getRanking()) .profileImageUrl(myRank.getProfileImageUrl()) .walkCount(myRank.getWalkCount()) From 548922831a6c2c78191a84a39eba1ddfece60d5c Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Fri, 25 Feb 2022 23:43:05 +0900 Subject: [PATCH 455/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20@Notnull=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 --- .../presentation/dto/request/InputHealthInformationRequest.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/user/presentation/dto/request/InputHealthInformationRequest.java b/src/main/java/com/walkhub/walkhub/domain/user/presentation/dto/request/InputHealthInformationRequest.java index a0434ca65..82c8958ba 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/presentation/dto/request/InputHealthInformationRequest.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/presentation/dto/request/InputHealthInformationRequest.java @@ -5,6 +5,7 @@ import lombok.NoArgsConstructor; import javax.validation.constraints.Digits; +import javax.validation.constraints.NotNull; import javax.validation.constraints.Positive; import java.math.BigDecimal; @@ -18,5 +19,6 @@ public class InputHealthInformationRequest { @Positive(message = "weight는 양수여야 합니다.") private Integer weight; + @NotNull private Sex sex; } \ No newline at end of file From 5c818706ff6cac4394584f771a09a35f08363ce0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Sat, 26 Feb 2022 03:21:18 +0900 Subject: [PATCH 456/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20=EC=84=B1?= =?UTF-8?q?=EA=B3=B5=ED=9A=9F=EC=88=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/response/QueryChallengeDetailsResponse.java | 1 + .../domain/challenge/service/QueryChallengeDetailsService.java | 1 + 2 files changed, 2 insertions(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/dto/response/QueryChallengeDetailsResponse.java b/src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/dto/response/QueryChallengeDetailsResponse.java index 1f1f5766d..c8ccde236 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/dto/response/QueryChallengeDetailsResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/dto/response/QueryChallengeDetailsResponse.java @@ -26,6 +26,7 @@ public class QueryChallengeDetailsResponse { private final Boolean isMine; private final Boolean isParticipated; private final Writer writer; + private final Integer successStandard; @Getter @Builder diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/service/QueryChallengeDetailsService.java b/src/main/java/com/walkhub/walkhub/domain/challenge/service/QueryChallengeDetailsService.java index b839149db..7b7931393 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/service/QueryChallengeDetailsService.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/service/QueryChallengeDetailsService.java @@ -48,6 +48,7 @@ public QueryChallengeDetailsResponse execute(Long challengeId) { .participantCount((long) challenge.getChallengeStatuses().size()) .isMine(isMine) .isParticipated(user.equals(writer)) + .successStandard(challenge.getSuccessStandard()) .writer(Writer.builder() .userId(writer.getId()) .name(writer.getName()) From 779fcb4bb5e4207d1dd5be3ce068385762ab76c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Sat, 26 Feb 2022 11:36:41 +0900 Subject: [PATCH 457/522] =?UTF-8?q?=F0=9F=90=9B=20::=20=EC=B9=BC=EB=A1=9C?= =?UTF-8?q?=EB=A6=AC=EB=A0=88=EB=B2=A8=20npe?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../walkhub/domain/user/service/UserSignUpService.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/user/service/UserSignUpService.java b/src/main/java/com/walkhub/walkhub/domain/user/service/UserSignUpService.java index 3c52bd30a..c37926877 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/service/UserSignUpService.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/service/UserSignUpService.java @@ -3,6 +3,9 @@ import com.walkhub.walkhub.domain.auth.presentation.dto.response.UserTokenResponse; import com.walkhub.walkhub.domain.badge.domain.Badge; import com.walkhub.walkhub.domain.badge.domain.repository.BadgeRepository; +import com.walkhub.walkhub.domain.calorielevel.domain.CalorieLevel; +import com.walkhub.walkhub.domain.calorielevel.domain.repository.CalorieLevelRepository; +import com.walkhub.walkhub.domain.calorielevel.exception.CalorieLevelNotFoundException; import com.walkhub.walkhub.domain.school.domain.School; import com.walkhub.walkhub.domain.school.domain.repository.SchoolRepository; import com.walkhub.walkhub.domain.user.domain.User; @@ -38,6 +41,7 @@ public class UserSignUpService { private final JwtTokenProvider jwtTokenProvider; private final JwtProperties jwtProperties; private final BadgeRepository badgeRepository; + private final CalorieLevelRepository calorieLevelRepository; @Transactional public UserTokenResponse execute(UserSignUpRequest request) { @@ -55,6 +59,9 @@ public UserTokenResponse execute(UserSignUpRequest request) { School school = schoolRepository.findById(request.getSchoolId()) .orElseThrow(() -> SchoolNotFoundException.EXCEPTION); + CalorieLevel calorieLevel = calorieLevelRepository.findByLevel(1) + .orElseThrow(() -> CalorieLevelNotFoundException.EXCEPTION); + User user = User.builder() .accountId(request.getAccountId()) .password(passwordEncoder.encode(request.getPassword())) @@ -67,6 +74,7 @@ public UserTokenResponse execute(UserSignUpRequest request) { .sex(request.getSex()) .isMeasuring(false) .badge(defaultTitleBadge) + .calorieLevel(calorieLevel) .build(); userRepository.save(user); From a077038c6e6362ae08950628306aeac167d6870a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Sat, 26 Feb 2022 11:37:37 +0900 Subject: [PATCH 458/522] =?UTF-8?q?=F0=9F=90=9B=20::=20section=20npe?= =?UTF-8?q?=EC=9A=B0=ED=9A=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/response/QueryUserProfileResponse.java | 10 ++++++++-- .../domain/user/service/QueryMyPageService.java | 9 ++++++--- .../domain/user/service/QueryUserProfileService.java | 8 +++++--- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/user/presentation/dto/response/QueryUserProfileResponse.java b/src/main/java/com/walkhub/walkhub/domain/user/presentation/dto/response/QueryUserProfileResponse.java index 79206973d..bf623f9bb 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/presentation/dto/response/QueryUserProfileResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/presentation/dto/response/QueryUserProfileResponse.java @@ -1,5 +1,6 @@ package com.walkhub.walkhub.domain.user.presentation.dto.response; +import com.walkhub.walkhub.domain.user.domain.Section; import lombok.Builder; import lombok.Getter; @@ -11,8 +12,8 @@ public class QueryUserProfileResponse { private final String name; private final String profileImageUrl; private final String schoolName; - private final Integer grade; - private final Integer classNum; + private Integer grade; + private Integer classNum; private final TitleBadge titleBadge; private final Level level; @@ -30,4 +31,9 @@ public static class Level { private final String name; private final String imageUrl; } + + public void setSection(Section section) { + this.grade = section.getGrade(); + this.classNum=section.getClassNum(); + } } diff --git a/src/main/java/com/walkhub/walkhub/domain/user/service/QueryMyPageService.java b/src/main/java/com/walkhub/walkhub/domain/user/service/QueryMyPageService.java index d9111dd4f..48ad15833 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/service/QueryMyPageService.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/service/QueryMyPageService.java @@ -2,6 +2,7 @@ import com.walkhub.walkhub.domain.badge.domain.Badge; import com.walkhub.walkhub.domain.calorielevel.domain.CalorieLevel; +import com.walkhub.walkhub.domain.user.domain.Section; import com.walkhub.walkhub.domain.user.domain.User; import com.walkhub.walkhub.domain.user.facade.UserFacade; import com.walkhub.walkhub.domain.user.presentation.dto.response.QueryUserProfileResponse; @@ -22,13 +23,11 @@ public QueryUserProfileResponse execute() { Badge titleBadge = user.getBadge(); CalorieLevel level = user.getMaxLevel(); - return QueryUserProfileResponse.builder() + QueryUserProfileResponse response = QueryUserProfileResponse.builder() .userId(user.getId()) .name(user.getName()) .profileImageUrl(user.getProfileImageUrl()) .schoolName(user.getSchool().getName()) - .grade(user.getSection().getGrade()) - .classNum(user.getSection().getClassNum()) .titleBadge(TitleBadge.builder() .id(titleBadge.getId()) .name(titleBadge.getName()) @@ -39,5 +38,9 @@ public QueryUserProfileResponse execute() { .name(level.getFoodName()) .build()) .build(); + + if (user.hasSection()) response.setSection(user.getSection()); + + return response; } } diff --git a/src/main/java/com/walkhub/walkhub/domain/user/service/QueryUserProfileService.java b/src/main/java/com/walkhub/walkhub/domain/user/service/QueryUserProfileService.java index 04c46a959..608b5cd53 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/service/QueryUserProfileService.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/service/QueryUserProfileService.java @@ -22,13 +22,11 @@ public QueryUserProfileResponse execute(Long userId) { Badge titleBadge = user.getBadge(); CalorieLevel level = user.getMaxLevel(); - return QueryUserProfileResponse.builder() + QueryUserProfileResponse response = QueryUserProfileResponse.builder() .userId(user.getId()) .name(user.getName()) .profileImageUrl(user.getProfileImageUrl()) .schoolName(user.getSchool().getName()) - .grade(user.getSection().getGrade()) - .classNum(user.getSection().getClassNum()) .titleBadge(TitleBadge.builder() .id(titleBadge.getId()) .name(titleBadge.getName()) @@ -39,5 +37,9 @@ public QueryUserProfileResponse execute(Long userId) { .name(level.getFoodName()) .build()) .build(); + + if (user.hasSection()) response.setSection(user.getSection()); + + return response; } } From 32c86e12c37b46cabf9332f5850dbf29660083d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Sat, 26 Feb 2022 11:37:58 +0900 Subject: [PATCH 459/522] =?UTF-8?q?=F0=9F=90=9B=20::=20=EB=AA=A9=ED=91=9C?= =?UTF-8?q?=20default=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../calorielevel/domain/repository/CalorieLevelRepository.java | 3 +++ .../com/walkhub/walkhub/domain/exercise/domain/Exercise.java | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/calorielevel/domain/repository/CalorieLevelRepository.java b/src/main/java/com/walkhub/walkhub/domain/calorielevel/domain/repository/CalorieLevelRepository.java index a3e3e37dd..d849707a4 100644 --- a/src/main/java/com/walkhub/walkhub/domain/calorielevel/domain/repository/CalorieLevelRepository.java +++ b/src/main/java/com/walkhub/walkhub/domain/calorielevel/domain/repository/CalorieLevelRepository.java @@ -1,10 +1,13 @@ package com.walkhub.walkhub.domain.calorielevel.domain.repository; import com.walkhub.walkhub.domain.calorielevel.domain.CalorieLevel; +import java.util.Optional; import org.springframework.data.repository.CrudRepository; import java.util.List; public interface CalorieLevelRepository extends CrudRepository { List findAllBy(); + + Optional findByLevel(Integer level); } diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/Exercise.java b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/Exercise.java index bad1b3cbe..575a4a35a 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/Exercise.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/Exercise.java @@ -59,7 +59,7 @@ public class Exercise extends BaseTimeEntity { public Exercise(User user, Integer goal, GoalType goalType) { this.user = user; this.goalType = goalType; - this.goal = goal; + if(goal != null) this.goal = goal; this.isExercising = true; } From f6626d650c0d6332bf41983c67c0ef1805034350 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Sat, 26 Feb 2022 11:38:23 +0900 Subject: [PATCH 460/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20goalType=20no?= =?UTF-8?q?tnull?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/dto/request/CreateExerciseRequest.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/request/CreateExerciseRequest.java b/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/request/CreateExerciseRequest.java index 5d06a6209..c72e2530e 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/request/CreateExerciseRequest.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/request/CreateExerciseRequest.java @@ -1,6 +1,7 @@ package com.walkhub.walkhub.domain.exercise.presentation.dto.request; import com.walkhub.walkhub.domain.exercise.domain.type.GoalType; +import javax.validation.constraints.NotNull; import lombok.Getter; import lombok.NoArgsConstructor; @@ -10,6 +11,7 @@ public class CreateExerciseRequest { private Integer goal; + @NotNull(message = "goal_type은 null, 공백을 허용하지 않습니다.") private GoalType goalType; } From dd1fbae45b642eb0e2b974f6d8e741453276c227 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Sat, 26 Feb 2022 11:38:58 +0900 Subject: [PATCH 461/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20order=20to=20?= =?UTF-8?q?sequence=20/=20sex=20default?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/response/QueryExerciseDetailsResponse.java | 2 +- .../exercise/service/QueryExerciseDetailsService.java | 2 +- .../java/com/walkhub/walkhub/domain/user/domain/User.java | 6 ++++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/response/QueryExerciseDetailsResponse.java b/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/response/QueryExerciseDetailsResponse.java index a160948f1..d4b5860af 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/response/QueryExerciseDetailsResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/response/QueryExerciseDetailsResponse.java @@ -17,7 +17,7 @@ public class QueryExerciseDetailsResponse { @Getter @Builder public static class ExerciseResponse { - private final Integer order; + private final Integer sequence; private final BigDecimal latitude; private final BigDecimal longitude; } diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/service/QueryExerciseDetailsService.java b/src/main/java/com/walkhub/walkhub/domain/exercise/service/QueryExerciseDetailsService.java index fdefa2d0e..4aef27940 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/service/QueryExerciseDetailsService.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/service/QueryExerciseDetailsService.java @@ -26,7 +26,7 @@ public QueryExerciseDetailsResponse execute(Long exerciseId) { List locations = locationRepository.findAllByExercise(exercise) .stream() .map(location -> ExerciseResponse.builder() - .order(location.getSequence()) + .sequence(location.getSequence()) .latitude(location.getLatitude()) .longitude(location.getLongitude()) .build()) diff --git a/src/main/java/com/walkhub/walkhub/domain/user/domain/User.java b/src/main/java/com/walkhub/walkhub/domain/user/domain/User.java index 19a426fe2..56cfb3cf6 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/domain/User.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/domain/User.java @@ -82,6 +82,7 @@ public class User extends BaseTimeEntity { private HealthInfo healthInfo; @NotNull + @ColumnDefault("X") @Enumerated(EnumType.STRING) private Sex sex; @@ -116,7 +117,7 @@ public class User extends BaseTimeEntity { @Builder public User(String accountId, String password, String phoneNumber, String name, Authority authority, Section section, School school, boolean isMeasuring, - Integer weight, BigDecimal height, Sex sex, Badge badge) { + Integer weight, BigDecimal height, Sex sex, Badge badge, CalorieLevel calorieLevel) { this.accountId = accountId; this.password = password; this.phoneNumber = phoneNumber; @@ -127,8 +128,9 @@ public User(String accountId, String password, String phoneNumber, String name, this.isMeasuring = isMeasuring; this.healthInfo = new HealthInfo(weight, height); this.dailyWalkCountGoal = 10000; - this.sex = sex; + if(sex != null) this.sex = sex; this.badge = badge; + this.maxLevel = calorieLevel; } public void setDeviceToken(String deviceToken) { From a422a67b21639a193abd9c6a5b711c023e7b3662 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Sat, 26 Feb 2022 11:42:55 +0900 Subject: [PATCH 462/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20=EB=B6=88?= =?UTF-8?q?=ED=8E=B8=ED=95=9C=20=EC=9C=84=EC=B9=98=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/response/QueryChallengeDetailsResponse.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/dto/response/QueryChallengeDetailsResponse.java b/src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/dto/response/QueryChallengeDetailsResponse.java index c8ccde236..f692db46d 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/dto/response/QueryChallengeDetailsResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/dto/response/QueryChallengeDetailsResponse.java @@ -25,8 +25,8 @@ public class QueryChallengeDetailsResponse { private final Long participantCount; private final Boolean isMine; private final Boolean isParticipated; - private final Writer writer; private final Integer successStandard; + private final Writer writer; @Getter @Builder From 0023da7f8843275ea6fa0892e7d0f0a3015553f3 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Sat, 26 Feb 2022 14:43:20 +0900 Subject: [PATCH 463/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20codesmell=20?= =?UTF-8?q?=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/rank/domain/repository/vo/UserRankWriterVO.java | 2 -- .../java/com/walkhub/walkhub/domain/rank/job/UserRankJob.java | 1 - 2 files changed, 3 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/vo/UserRankWriterVO.java b/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/vo/UserRankWriterVO.java index 3e0dab68b..00f48e924 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/vo/UserRankWriterVO.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/domain/repository/vo/UserRankWriterVO.java @@ -1,7 +1,5 @@ package com.walkhub.walkhub.domain.rank.domain.repository.vo; -import com.walkhub.walkhub.domain.rank.domain.type.UserRankScope; -import com.walkhub.walkhub.global.enums.DateType; import lombok.Builder; import lombok.Getter; diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/job/UserRankJob.java b/src/main/java/com/walkhub/walkhub/domain/rank/job/UserRankJob.java index fcc063d41..73f2938bc 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/job/UserRankJob.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/job/UserRankJob.java @@ -1,6 +1,5 @@ package com.walkhub.walkhub.domain.rank.job; -import com.walkhub.walkhub.domain.rank.domain.*; import com.walkhub.walkhub.domain.rank.domain.repository.vo.UserRankWriterVO; import com.walkhub.walkhub.domain.rank.domain.type.UserRankScope; import com.walkhub.walkhub.domain.rank.presentation.dto.response.UserRankInfo; From f6f95d511e37a8cf5b4687de25cc01ede4b7ff59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Sat, 26 Feb 2022 17:20:48 +0900 Subject: [PATCH 464/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EB=8B=A4=EB=93=AC=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/response/QueryUserProfileResponse.java | 9 ++------- .../domain/user/service/QueryMyPageService.java | 9 ++++----- .../domain/user/service/QueryUserProfileService.java | 11 ++++++----- 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/user/presentation/dto/response/QueryUserProfileResponse.java b/src/main/java/com/walkhub/walkhub/domain/user/presentation/dto/response/QueryUserProfileResponse.java index bf623f9bb..00bdb86fd 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/presentation/dto/response/QueryUserProfileResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/presentation/dto/response/QueryUserProfileResponse.java @@ -12,8 +12,8 @@ public class QueryUserProfileResponse { private final String name; private final String profileImageUrl; private final String schoolName; - private Integer grade; - private Integer classNum; + private final Integer grade; + private final Integer classNum; private final TitleBadge titleBadge; private final Level level; @@ -31,9 +31,4 @@ public static class Level { private final String name; private final String imageUrl; } - - public void setSection(Section section) { - this.grade = section.getGrade(); - this.classNum=section.getClassNum(); - } } diff --git a/src/main/java/com/walkhub/walkhub/domain/user/service/QueryMyPageService.java b/src/main/java/com/walkhub/walkhub/domain/user/service/QueryMyPageService.java index 48ad15833..bf0b411b2 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/service/QueryMyPageService.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/service/QueryMyPageService.java @@ -22,12 +22,15 @@ public QueryUserProfileResponse execute() { User user = userFacade.getCurrentUser(); Badge titleBadge = user.getBadge(); CalorieLevel level = user.getMaxLevel(); + Section section = user.hasSection() ? user.getSection() : Section.builder().build(); - QueryUserProfileResponse response = QueryUserProfileResponse.builder() + return QueryUserProfileResponse.builder() .userId(user.getId()) .name(user.getName()) .profileImageUrl(user.getProfileImageUrl()) .schoolName(user.getSchool().getName()) + .classNum(section.getClassNum()) + .grade(section.getGrade()) .titleBadge(TitleBadge.builder() .id(titleBadge.getId()) .name(titleBadge.getName()) @@ -38,9 +41,5 @@ public QueryUserProfileResponse execute() { .name(level.getFoodName()) .build()) .build(); - - if (user.hasSection()) response.setSection(user.getSection()); - - return response; } } diff --git a/src/main/java/com/walkhub/walkhub/domain/user/service/QueryUserProfileService.java b/src/main/java/com/walkhub/walkhub/domain/user/service/QueryUserProfileService.java index 608b5cd53..d68d984c0 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/service/QueryUserProfileService.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/service/QueryUserProfileService.java @@ -2,6 +2,7 @@ import com.walkhub.walkhub.domain.badge.domain.Badge; import com.walkhub.walkhub.domain.calorielevel.domain.CalorieLevel; +import com.walkhub.walkhub.domain.user.domain.Section; import com.walkhub.walkhub.domain.user.domain.User; import com.walkhub.walkhub.domain.user.facade.UserFacade; import com.walkhub.walkhub.domain.user.presentation.dto.response.QueryUserProfileResponse; @@ -19,14 +20,17 @@ public class QueryUserProfileService { public QueryUserProfileResponse execute(Long userId) { User user = userFacade.getUserById(userId); - Badge titleBadge = user.getBadge(); + Badge titleBadge = user.getBadge(); CalorieLevel level = user.getMaxLevel(); + Section section = user.hasSection() ? user.getSection() : Section.builder().build(); - QueryUserProfileResponse response = QueryUserProfileResponse.builder() + return QueryUserProfileResponse.builder() .userId(user.getId()) .name(user.getName()) .profileImageUrl(user.getProfileImageUrl()) .schoolName(user.getSchool().getName()) + .classNum(section.getClassNum()) + .grade(section.getGrade()) .titleBadge(TitleBadge.builder() .id(titleBadge.getId()) .name(titleBadge.getName()) @@ -38,8 +42,5 @@ public QueryUserProfileResponse execute(Long userId) { .build()) .build(); - if (user.hasSection()) response.setSection(user.getSection()); - - return response; } } From d5957538da887b0d5a59659345a526fb7ff21a79 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Sat, 26 Feb 2022 18:40:39 +0900 Subject: [PATCH 465/522] =?UTF-8?q?:bug:=20::=20{school-id}=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 --- .../com/walkhub/walkhub/global/security/SecurityConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java b/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java index 21f4c711e..663a99ace 100644 --- a/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java +++ b/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java @@ -92,7 +92,7 @@ protected void configure(HttpSecurity http) throws Exception { .antMatchers(HttpMethod.GET, "/ranks/schools/search").authenticated() .antMatchers(HttpMethod.GET, "/ranks/users/{school-id}").authenticated() .antMatchers(HttpMethod.GET, "/ranks/users/my-school").authenticated() - .antMatchers(HttpMethod.GET, "/ranks/users/search").authenticated() + .antMatchers(HttpMethod.GET, "/ranks/users/search/{school-id}").authenticated() // challenges .antMatchers(HttpMethod.POST, "/challenges").hasAnyAuthority("TEACHER", "ROOT", "SU") From bcf506ae016e26c04370626e6faa08c191fad940 Mon Sep 17 00:00:00 2001 From: jhhong0509 Date: Sat, 26 Feb 2022 18:51:02 +0900 Subject: [PATCH 466/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20(#463)=20?= =?UTF-8?q?=EA=B6=8C=ED=95=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/walkhub/walkhub/global/security/SecurityConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java b/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java index 21f4c711e..97688f02d 100644 --- a/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java +++ b/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java @@ -98,7 +98,7 @@ protected void configure(HttpSecurity http) throws Exception { .antMatchers(HttpMethod.POST, "/challenges").hasAnyAuthority("TEACHER", "ROOT", "SU") .antMatchers(HttpMethod.PATCH, "/challenges/{challenge-id}").hasAnyAuthority("TEACHER", "ROOT", "SU") .antMatchers(HttpMethod.DELETE, "/challenges/{challenge-id}").hasAnyAuthority("TEACHER", "ROOT", "SU") - .antMatchers(HttpMethod.GET, "/challenges/{challenge-id}/progress").hasAuthority("TEACHER") + .antMatchers(HttpMethod.GET, "/challenges/{challenge-id}/progress").hasAnyAuthority("TEACHER", "ROOT") .antMatchers(HttpMethod.GET, "/challenges/{challenge-id}").authenticated() .antMatchers(HttpMethod.POST, "/challenges/{challenge-id}").authenticated() .antMatchers(HttpMethod.GET, "/challenges/{challenge-id}/participants/students").authenticated() From 94d5d3a533bc1572f7d0e150877ee41a84d3f54e Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Sat, 26 Feb 2022 19:08:35 +0900 Subject: [PATCH 467/522] =?UTF-8?q?:bug:=20::=20npe=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rank/service/UserSearchService.java | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/service/UserSearchService.java b/src/main/java/com/walkhub/walkhub/domain/rank/service/UserSearchService.java index 63ece06be..4e03a47b9 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/service/UserSearchService.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/service/UserSearchService.java @@ -5,6 +5,7 @@ import com.walkhub.walkhub.domain.rank.domain.UserRank; import com.walkhub.walkhub.domain.rank.domain.repository.UserRankRepository; import com.walkhub.walkhub.domain.rank.presentation.dto.response.UserListResponse; +import com.walkhub.walkhub.domain.rank.presentation.dto.response.UserListResponse.UserSearchResponse; import com.walkhub.walkhub.domain.user.domain.User; import com.walkhub.walkhub.domain.user.domain.repository.UserRepository; import com.walkhub.walkhub.global.enums.DateType; @@ -25,7 +26,7 @@ public class UserSearchService { @Transactional(readOnly = true) public UserListResponse execute(Long schoolId, String name, DateType dateType) { - List result; + List result; if (DateType.DAY.equals(dateType)) { result = userRepository.findAllBySchoolIdAndNameContaining(schoolId, name) @@ -42,22 +43,25 @@ public UserListResponse execute(Long schoolId, String name, DateType dateType) { return new UserListResponse(result); } - private UserListResponse.UserSearchResponse buildDayUserSearchResponse(User user) { - ExerciseAnalysisDto exerciseAnalysisDto = exerciseAnalysisCacheRepository.getUserTodayRank(user.getSchool().getId(), user.getId()); + private UserSearchResponse buildDayUserSearchResponse(User user) { + ExerciseAnalysisDto exerciseAnalysisDto = + exerciseAnalysisCacheRepository.getUserTodayRank(user.getSchool().getId(), user.getId()); - return UserListResponse.UserSearchResponse.builder() + ExerciseAnalysisDto exerciseAnalysis = exerciseAnalysisDto == null ? ExerciseAnalysisDto.builder().build() : exerciseAnalysisDto; + + return UserSearchResponse.builder() .userId(user.getId()) .name(user.getName()) - .ranking(exerciseAnalysisDto.getRanking()) + .ranking(exerciseAnalysis.getRanking()) .grade(user.getSection().getGrade()) .classNum(user.getSection().getClassNum()) .profileImageUrl(user.getProfileImageUrl()) - .walkCount(exerciseAnalysisDto.getWalkCount()) + .walkCount(exerciseAnalysis.getWalkCount()) .build(); } - private UserListResponse.UserSearchResponse buildWeekOrMonthUserSearchResponse(UserRank userRank) { - return UserListResponse.UserSearchResponse.builder() + private UserSearchResponse buildWeekOrMonthUserSearchResponse(UserRank userRank) { + return UserSearchResponse.builder() .userId(userRank.getUserId()) .name(userRank.getName()) .ranking(userRank.getRanking()) From cfe7be03c0fd4ca43e977f08452e780cc9f88f47 Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Sat, 26 Feb 2022 19:14:39 +0900 Subject: [PATCH 468/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20myRank=20->?= =?UTF-8?q?=20myRanking=EC=9C=BC=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rank/presentation/dto/response/UserRankListResponse.java | 2 +- .../rank/service/QueryUserRankListByMySchoolService.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/presentation/dto/response/UserRankListResponse.java b/src/main/java/com/walkhub/walkhub/domain/rank/presentation/dto/response/UserRankListResponse.java index d2d74d55d..d743f1151 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/presentation/dto/response/UserRankListResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/presentation/dto/response/UserRankListResponse.java @@ -9,7 +9,7 @@ @Builder public class UserRankListResponse { - private final UserRankResponse myRank; + private final UserRankResponse myRanking; private final List rankList; @Getter diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListByMySchoolService.java b/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListByMySchoolService.java index c8b5aac85..6331b6c5c 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListByMySchoolService.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListByMySchoolService.java @@ -53,7 +53,7 @@ private UserRankListResponse buildDayRankResponse(User user) { } return UserRankListResponse.builder() - .myRank(myRank) + .myRanking(myRank) .rankList(userRankList) .build(); } @@ -68,7 +68,7 @@ private UserRankListResponse buildWeekOrMonthRankResponse(User user, Integer gra userRankList = userRankFacade.buildWeekOrMonthUsersRankResponse(usersWeekOrMonthRank); return UserRankListResponse.builder() - .myRank(myRank) + .myRanking(myRank) .rankList(userRankList) .build(); } From 49ef9dfb565cc3651b25a53af345a0f02db77199 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Sat, 26 Feb 2022 23:47:25 +0900 Subject: [PATCH 469/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20=EC=9E=84?= =?UTF-8?q?=EC=8B=9C=20=EB=A1=9C=EA=B7=B8=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../global/websocket/connect/WebSocketJwtHandler.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/com/walkhub/walkhub/global/websocket/connect/WebSocketJwtHandler.java b/src/main/java/com/walkhub/walkhub/global/websocket/connect/WebSocketJwtHandler.java index 7671d86e2..d46295e10 100644 --- a/src/main/java/com/walkhub/walkhub/global/websocket/connect/WebSocketJwtHandler.java +++ b/src/main/java/com/walkhub/walkhub/global/websocket/connect/WebSocketJwtHandler.java @@ -6,6 +6,8 @@ import com.walkhub.walkhub.global.security.jwt.JwtTokenProvider; import com.walkhub.walkhub.global.websocket.property.ClientProperty; import lombok.RequiredArgsConstructor; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.security.core.Authentication; import org.springframework.web.bind.annotation.RestController; @@ -16,6 +18,8 @@ @RestController public class WebSocketJwtHandler { + private final Logger logger = LoggerFactory.getLogger(this.getClass().getSimpleName()); + private final JwtTokenProvider jwtTokenProvider; public static final ConcurrentMap socketIOClientMap = new ConcurrentHashMap<>(); @@ -26,11 +30,13 @@ public void onConnect(SocketIOClient client) { Authentication authentication = jwtTokenProvider.authentication(token); socketIOClientMap.put(authentication.getName(), client); client.set(ClientProperty.USER_KEY, authentication.getName()); + logger.info("Connected : " + client.getSessionId() + ", " + authentication.getName()); } @OnDisconnect public void onDisconnect(SocketIOClient client) { socketIOClientMap.remove(client.get(ClientProperty.USER_KEY).toString()); + logger.info("DisConnected : " + client.getSessionId()); } } From 52f09f0c5dc20e360c586df9067d6c42bbf99b7f Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Sun, 27 Feb 2022 00:21:03 +0900 Subject: [PATCH 470/522] =?UTF-8?q?:recycle:=20::=20Code=20Smell=20?= =?UTF-8?q?=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../walkhub/global/websocket/connect/WebSocketJwtHandler.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/global/websocket/connect/WebSocketJwtHandler.java b/src/main/java/com/walkhub/walkhub/global/websocket/connect/WebSocketJwtHandler.java index d46295e10..05b54d463 100644 --- a/src/main/java/com/walkhub/walkhub/global/websocket/connect/WebSocketJwtHandler.java +++ b/src/main/java/com/walkhub/walkhub/global/websocket/connect/WebSocketJwtHandler.java @@ -30,13 +30,13 @@ public void onConnect(SocketIOClient client) { Authentication authentication = jwtTokenProvider.authentication(token); socketIOClientMap.put(authentication.getName(), client); client.set(ClientProperty.USER_KEY, authentication.getName()); - logger.info("Connected : " + client.getSessionId() + ", " + authentication.getName()); + logger.info(String.format("Connected : %s", client.getSessionId())); } @OnDisconnect public void onDisconnect(SocketIOClient client) { socketIOClientMap.remove(client.get(ClientProperty.USER_KEY).toString()); - logger.info("DisConnected : " + client.getSessionId()); + logger.info(String.format("DisConnected : %s", client.getSessionId())); } } From a2225d981bd7653413fdb36f0a34f49a07ff88c6 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Sun, 27 Feb 2022 13:32:04 +0900 Subject: [PATCH 471/522] =?UTF-8?q?:recycle:=20::=20@Slf4j=EB=A1=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=20&=20name=EB=A1=9C=EA=B9=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 --- .../global/websocket/connect/WebSocketJwtHandler.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/global/websocket/connect/WebSocketJwtHandler.java b/src/main/java/com/walkhub/walkhub/global/websocket/connect/WebSocketJwtHandler.java index 05b54d463..9494eb3f1 100644 --- a/src/main/java/com/walkhub/walkhub/global/websocket/connect/WebSocketJwtHandler.java +++ b/src/main/java/com/walkhub/walkhub/global/websocket/connect/WebSocketJwtHandler.java @@ -6,6 +6,7 @@ import com.walkhub.walkhub.global.security.jwt.JwtTokenProvider; import com.walkhub.walkhub.global.websocket.property.ClientProperty; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.security.core.Authentication; @@ -14,12 +15,11 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; +@Slf4j @RequiredArgsConstructor @RestController public class WebSocketJwtHandler { - private final Logger logger = LoggerFactory.getLogger(this.getClass().getSimpleName()); - private final JwtTokenProvider jwtTokenProvider; public static final ConcurrentMap socketIOClientMap = new ConcurrentHashMap<>(); @@ -30,13 +30,13 @@ public void onConnect(SocketIOClient client) { Authentication authentication = jwtTokenProvider.authentication(token); socketIOClientMap.put(authentication.getName(), client); client.set(ClientProperty.USER_KEY, authentication.getName()); - logger.info(String.format("Connected : %s", client.getSessionId())); + log.info("Connected : " + client.getSessionId() + ", " + authentication.getName()); } @OnDisconnect public void onDisconnect(SocketIOClient client) { socketIOClientMap.remove(client.get(ClientProperty.USER_KEY).toString()); - logger.info(String.format("DisConnected : %s", client.getSessionId())); + log.info("DisConnected : " + client.getSessionId()); } } From 762376c276d72183414b8a9ed3ee6d3619493fdd Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Sun, 27 Feb 2022 13:38:37 +0900 Subject: [PATCH 472/522] =?UTF-8?q?:recycle:=20::=20import=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../walkhub/global/websocket/connect/WebSocketJwtHandler.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/global/websocket/connect/WebSocketJwtHandler.java b/src/main/java/com/walkhub/walkhub/global/websocket/connect/WebSocketJwtHandler.java index 9494eb3f1..a4ecf7a7e 100644 --- a/src/main/java/com/walkhub/walkhub/global/websocket/connect/WebSocketJwtHandler.java +++ b/src/main/java/com/walkhub/walkhub/global/websocket/connect/WebSocketJwtHandler.java @@ -7,8 +7,6 @@ import com.walkhub.walkhub.global.websocket.property.ClientProperty; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.security.core.Authentication; import org.springframework.web.bind.annotation.RestController; From 14c5183482b9b1354f464b2b9e93925ee919fc01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Sun, 27 Feb 2022 18:14:54 +0900 Subject: [PATCH 473/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20=EC=95=88?= =?UTF-8?q?=EC=93=B0=EB=8A=94=20import=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../user/presentation/dto/response/QueryUserProfileResponse.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/user/presentation/dto/response/QueryUserProfileResponse.java b/src/main/java/com/walkhub/walkhub/domain/user/presentation/dto/response/QueryUserProfileResponse.java index 00bdb86fd..79206973d 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/presentation/dto/response/QueryUserProfileResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/presentation/dto/response/QueryUserProfileResponse.java @@ -1,6 +1,5 @@ package com.walkhub.walkhub.domain.user.presentation.dto.response; -import com.walkhub.walkhub.domain.user.domain.Section; import lombok.Builder; import lombok.Getter; From 26be68a5dda97e04a234577ae78f6e3181240dd0 Mon Sep 17 00:00:00 2001 From: jhhong0509 Date: Sun, 27 Feb 2022 18:29:55 +0900 Subject: [PATCH 474/522] =?UTF-8?q?:bug:=20::=20(#469)=20=EC=BF=BC?= =?UTF-8?q?=EB=A6=AC=20=EB=B2=84=EA=B7=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ChallengeStatusRepositoryCustomImpl.java | 44 +++---------------- 1 file changed, 5 insertions(+), 39 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java index 66ba6df2d..255d91789 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java @@ -112,40 +112,6 @@ public List getAllChallengesByUser(User user1) { .fetch(); } - private BooleanExpression isChallengeSuccessFilter(Challenge challenge) { - if (challenge.getGoalScope() == GoalScope.DAY) { - return isChallengeSuccessInDayScope(challenge); - } - - return isChallengeSuccessInAllScope(challenge); - } - - private BooleanExpression isChallengeSuccessInDayScope(Challenge challenge) { - NumberPath exerciseAmount = exerciseAnalysis.distance; - - if (challenge.getGoalType() == GoalType.WALK) { - exerciseAmount = exerciseAnalysis.walkCount; - } - - return exerciseAmount.goe(challenge.getGoal()); - } - - private BooleanExpression isChallengeSuccessInAllScope(Challenge challenge) { - NumberPath exerciseAmount = exerciseAnalysis.distance; - - if (challenge.getGoalType() == GoalType.WALK) { - exerciseAmount = exerciseAnalysis.walkCount; - } - - return JPAExpressions.select(exerciseAmount.sum()) - .from(exerciseAnalysis) - .where( - exerciseAnalysis.user.eq(user), - challengeDateFilter(challenge) - ) - .goe(challenge.getGoal()); - } - private BooleanExpression challengeDateFilter(Challenge challenge) { return exerciseAnalysis.date.goe(challenge.getStartAt()) .and(exerciseAnalysis.date.goe(challengeStatus.createdAt)) @@ -185,13 +151,13 @@ public List queryChallengeProgress( .limit(PARTICIPANTS_SIZE) .leftJoin(user.section, section) .join(user.school, school) - .join(user.exerciseAnalyses, exerciseAnalysis) .join(user.challengeStatuses, challengeStatus) - .where(userScopeFilter(participantsScope), - isChallengeSuccessFilter(challenge), - challengeDateFilter(challenge), - challengeSuccessFilter(successScope, challenge)) + .leftJoin(user.exerciseAnalyses, exerciseAnalysis) + .on(challengeDateFilter(challenge)) + .where(userScopeFilter(participantsScope)) .orderBy(challengeParticipantsOrder(participantsOrder)) + .having(challengeSuccessFilter(successScope, challenge)) + .groupBy(user.id) .fetch(); } From 26517dd4b2b4dfe5a06b53bd160fb39fdbf46234 Mon Sep 17 00:00:00 2001 From: jhhong0509 Date: Mon, 28 Feb 2022 05:41:53 +0900 Subject: [PATCH 475/522] =?UTF-8?q?:bug:=20::=20(#472)=20where=EB=AC=B8=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 --- .../ChallengeStatusRepositoryCustomImpl.java | 37 ++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java index 255d91789..22d261278 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java @@ -154,13 +154,48 @@ public List queryChallengeProgress( .join(user.challengeStatuses, challengeStatus) .leftJoin(user.exerciseAnalyses, exerciseAnalysis) .on(challengeDateFilter(challenge)) - .where(userScopeFilter(participantsScope)) + .where(userScopeFilter(participantsScope), + isChallengeSuccessFilter(challenge)) .orderBy(challengeParticipantsOrder(participantsOrder)) .having(challengeSuccessFilter(successScope, challenge)) .groupBy(user.id) .fetch(); } + private BooleanExpression isChallengeSuccessFilter(Challenge challenge) { + if (challenge.getGoalScope() == GoalScope.DAY) { + return isChallengeSuccessInDayScope(challenge); + } + + return isChallengeSuccessInAllScope(challenge); + } + + private BooleanExpression isChallengeSuccessInDayScope(Challenge challenge) { + NumberPath exerciseAmount = exerciseAnalysis.distance; + + if (challenge.getGoalType() == GoalType.WALK) { + exerciseAmount = exerciseAnalysis.walkCount; + } + + return exerciseAmount.goe(challenge.getGoal()); + } + + private BooleanExpression isChallengeSuccessInAllScope(Challenge challenge) { + NumberPath exerciseAmount = exerciseAnalysis.distance; + + if (challenge.getGoalType() == GoalType.WALK) { + exerciseAmount = exerciseAnalysis.walkCount; + } + + return JPAExpressions.select(exerciseAmount.sum()) + .from(exerciseAnalysis) + .where( + exerciseAnalysis.user.eq(user), + challengeDateFilter(challenge) + ) + .goe(challenge.getGoal()); + } + private BooleanExpression userScopeFilter(ChallengeParticipantsScope challengeParticipantsScope) { if (challengeParticipantsScope == ChallengeParticipantsScope.STUDENT) { return user.authority.eq(Authority.USER); From 2054d185e970a09d9f0cd67968a8062b74de0054 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B2=94=EC=A7=84?= Date: Mon, 28 Feb 2022 13:31:42 +0900 Subject: [PATCH 476/522] =?UTF-8?q?=E2=99=BB=20::=20our=20<->=20other=20sc?= =?UTF-8?q?hool=20user=20rank=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/rank/facade/UserRankFacade.java | 6 +-- .../rank/presentation/RankController.java | 9 ++-- .../OtherSchoolUserRankListResponse.java | 16 +++++++ ...ava => OurSchoolUserRankListResponse.java} | 2 +- .../QueryUserRankListByMySchoolService.java | 42 +++++++++---------- .../service/QueryUserRankListService.java | 11 +++-- 6 files changed, 51 insertions(+), 35 deletions(-) create mode 100644 src/main/java/com/walkhub/walkhub/domain/rank/presentation/dto/response/OtherSchoolUserRankListResponse.java rename src/main/java/com/walkhub/walkhub/domain/rank/presentation/dto/response/{UserRankListResponse.java => OurSchoolUserRankListResponse.java} (92%) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/facade/UserRankFacade.java b/src/main/java/com/walkhub/walkhub/domain/rank/facade/UserRankFacade.java index a2c0042bc..33c20059c 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/facade/UserRankFacade.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/facade/UserRankFacade.java @@ -1,7 +1,7 @@ package com.walkhub.walkhub.domain.rank.facade; import com.walkhub.walkhub.domain.rank.domain.repository.vo.UserRankVO; -import com.walkhub.walkhub.domain.rank.presentation.dto.response.UserRankListResponse; +import com.walkhub.walkhub.domain.rank.presentation.dto.response.OurSchoolUserRankListResponse; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; @@ -12,9 +12,9 @@ @Component public class UserRankFacade { - public List buildWeekOrMonthUsersRankResponse(List userRanks) { + public List buildWeekOrMonthUsersRankResponse(List userRanks) { return userRanks.stream() - .map(userRank -> UserRankListResponse.UserRankResponse.builder() + .map(userRank -> OurSchoolUserRankListResponse.UserRankResponse.builder() .userId(userRank.getUserId()) .name(userRank.getName()) .ranking(userRank.getRanking()) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/presentation/RankController.java b/src/main/java/com/walkhub/walkhub/domain/rank/presentation/RankController.java index c4cee281f..322de5482 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/presentation/RankController.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/presentation/RankController.java @@ -1,11 +1,12 @@ package com.walkhub.walkhub.domain.rank.presentation; import com.walkhub.walkhub.domain.rank.domain.type.SchoolDateType; +import com.walkhub.walkhub.domain.rank.presentation.dto.response.OtherSchoolUserRankListResponse; import com.walkhub.walkhub.domain.rank.presentation.dto.response.SchoolListResponse; import com.walkhub.walkhub.domain.rank.domain.type.UserRankScope; import com.walkhub.walkhub.domain.rank.presentation.dto.response.SchoolRankResponse; import com.walkhub.walkhub.domain.rank.presentation.dto.response.UserListResponse; -import com.walkhub.walkhub.domain.rank.presentation.dto.response.UserRankListResponse; +import com.walkhub.walkhub.domain.rank.presentation.dto.response.OurSchoolUserRankListResponse; import com.walkhub.walkhub.domain.rank.service.QueryUserRankListByMySchoolService; import com.walkhub.walkhub.domain.rank.service.QuerySchoolRankService; import com.walkhub.walkhub.domain.rank.service.SchoolSearchService; @@ -51,13 +52,13 @@ public SchoolListResponse schoolSearch(@RequestParam("name") @NotNull @Size(max } @GetMapping("/users/my-school") - public UserRankListResponse queryUserRankListByMySchool(@RequestParam UserRankScope scope, @RequestParam DateType dateType) { + public OurSchoolUserRankListResponse queryUserRankListByMySchool(@RequestParam UserRankScope scope, @RequestParam DateType dateType) { return queryUserRankListByMySchoolService.execute(scope, dateType); } @GetMapping("/users/{school-id}") - public UserRankListResponse queryUserRankList(@RequestParam DateType dateType, - @PathVariable("school-id") Long schoolId) { + public OtherSchoolUserRankListResponse queryUserRankList(@RequestParam DateType dateType, + @PathVariable("school-id") Long schoolId) { return queryUserRankListService.execute(schoolId, dateType); } } diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/presentation/dto/response/OtherSchoolUserRankListResponse.java b/src/main/java/com/walkhub/walkhub/domain/rank/presentation/dto/response/OtherSchoolUserRankListResponse.java new file mode 100644 index 000000000..9e67ca2a9 --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/rank/presentation/dto/response/OtherSchoolUserRankListResponse.java @@ -0,0 +1,16 @@ +package com.walkhub.walkhub.domain.rank.presentation.dto.response; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.List; + +import static com.walkhub.walkhub.domain.rank.presentation.dto.response.OurSchoolUserRankListResponse.UserRankResponse; + +@Getter +@AllArgsConstructor +public class OtherSchoolUserRankListResponse { + + private final List rankList; + +} diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/presentation/dto/response/UserRankListResponse.java b/src/main/java/com/walkhub/walkhub/domain/rank/presentation/dto/response/OurSchoolUserRankListResponse.java similarity index 92% rename from src/main/java/com/walkhub/walkhub/domain/rank/presentation/dto/response/UserRankListResponse.java rename to src/main/java/com/walkhub/walkhub/domain/rank/presentation/dto/response/OurSchoolUserRankListResponse.java index d743f1151..eeff62da4 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/presentation/dto/response/UserRankListResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/presentation/dto/response/OurSchoolUserRankListResponse.java @@ -7,7 +7,7 @@ @Getter @Builder -public class UserRankListResponse { +public class OurSchoolUserRankListResponse { private final UserRankResponse myRanking; private final List rankList; diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListByMySchoolService.java b/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListByMySchoolService.java index 6331b6c5c..e046103ea 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListByMySchoolService.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListByMySchoolService.java @@ -6,7 +6,7 @@ import com.walkhub.walkhub.domain.rank.domain.repository.vo.UserRankVO; import com.walkhub.walkhub.domain.rank.domain.type.UserRankScope; import com.walkhub.walkhub.domain.rank.facade.UserRankFacade; -import com.walkhub.walkhub.domain.rank.presentation.dto.response.UserRankListResponse; +import com.walkhub.walkhub.domain.rank.presentation.dto.response.OurSchoolUserRankListResponse; import com.walkhub.walkhub.domain.user.domain.User; import com.walkhub.walkhub.domain.user.facade.UserFacade; import com.walkhub.walkhub.global.enums.DateType; @@ -25,25 +25,25 @@ public class QueryUserRankListByMySchoolService { private final UserFacade userFacade; private final UserRankFacade userRankFacade; - public UserRankListResponse execute(UserRankScope scope, DateType dateType) { + public OurSchoolUserRankListResponse execute(UserRankScope scope, DateType dateType) { User user = userFacade.getCurrentUser(); LocalDate date = LocalDate.now(); - UserRankListResponse userRankListResponse = null; + OurSchoolUserRankListResponse ourSchoolUserRankListResponse = null; if (dateType.equals(DateType.DAY)) { - userRankListResponse = buildDayRankResponse(user); + ourSchoolUserRankListResponse = buildDayRankResponse(user); } else if (scope.equals(UserRankScope.SCHOOL)) { - userRankListResponse = buildWeekOrMonthRankResponse(user, null, null, dateType, date); + ourSchoolUserRankListResponse = buildWeekOrMonthRankResponse(user, null, null, dateType, date); } else if (scope.equals(UserRankScope.CLASS)) { - userRankListResponse = buildWeekOrMonthRankResponse(user, user.getSection().getGrade(), user.getSection().getClassNum(), dateType, date); + ourSchoolUserRankListResponse = buildWeekOrMonthRankResponse(user, user.getSection().getGrade(), user.getSection().getClassNum(), dateType, date); } - return userRankListResponse; + return ourSchoolUserRankListResponse; } - private UserRankListResponse buildDayRankResponse(User user) { - UserRankListResponse.UserRankResponse myRank; - List userRankList = new ArrayList<>(); + private OurSchoolUserRankListResponse buildDayRankResponse(User user) { + OurSchoolUserRankListResponse.UserRankResponse myRank; + List userRankList = new ArrayList<>(); myRank = buildDayMyRank(user); @@ -52,34 +52,34 @@ private UserRankListResponse buildDayRankResponse(User user) { userRankList.add(buildDayUsersRank(users)); } - return UserRankListResponse.builder() + return OurSchoolUserRankListResponse.builder() .myRanking(myRank) .rankList(userRankList) .build(); } - private UserRankListResponse buildWeekOrMonthRankResponse(User user, Integer grade, Integer classNum, DateType dateType, LocalDate date) { - UserRankListResponse.UserRankResponse myRank; - List userRankList; + private OurSchoolUserRankListResponse buildWeekOrMonthRankResponse(User user, Integer grade, Integer classNum, DateType dateType, LocalDate date) { + OurSchoolUserRankListResponse.UserRankResponse myRank; + List userRankList; myRank = buildWeekOrMonthMyRank(user.getId(), grade, classNum, dateType, date); List usersWeekOrMonthRank = userRankRepository.getUserRankListBySchoolId(user.getSchool().getId(), user.getSection().getGrade(), classNum, dateType, date); userRankList = userRankFacade.buildWeekOrMonthUsersRankResponse(usersWeekOrMonthRank); - return UserRankListResponse.builder() + return OurSchoolUserRankListResponse.builder() .myRanking(myRank) .rankList(userRankList) .build(); } - private UserRankListResponse.UserRankResponse buildDayMyRank(User user) { + private OurSchoolUserRankListResponse.UserRankResponse buildDayMyRank(User user) { ExerciseAnalysisDto exerciseAnalysisDto = exerciseAnalysisCacheRepository.getUserTodayRank(user.getSchool().getId(), user.getId()); if (exerciseAnalysisDto == null) { return null; } - return UserRankListResponse.UserRankResponse.builder() + return OurSchoolUserRankListResponse.UserRankResponse.builder() .userId(user.getId()) .name(user.getName()) .ranking(exerciseAnalysisDto.getRanking()) @@ -88,10 +88,10 @@ private UserRankListResponse.UserRankResponse buildDayMyRank(User user) { .build(); } - private UserRankListResponse.UserRankResponse buildDayUsersRank(ExerciseAnalysisDto dayRank) { + private OurSchoolUserRankListResponse.UserRankResponse buildDayUsersRank(ExerciseAnalysisDto dayRank) { User user = userFacade.getUserById(dayRank.getUserId()); - return UserRankListResponse.UserRankResponse.builder() + return OurSchoolUserRankListResponse.UserRankResponse.builder() .userId(user.getId()) .name(user.getName()) .ranking(dayRank.getRanking()) @@ -100,13 +100,13 @@ private UserRankListResponse.UserRankResponse buildDayUsersRank(ExerciseAnalysis .build(); } - private UserRankListResponse.UserRankResponse buildWeekOrMonthMyRank(Long userId, Integer grade, Integer classNum, DateType dateType, LocalDate date) { + private OurSchoolUserRankListResponse.UserRankResponse buildWeekOrMonthMyRank(Long userId, Integer grade, Integer classNum, DateType dateType, LocalDate date) { UserRankVO myRank = userRankRepository.getMyRankByUserId(userId, grade, classNum, dateType, date); if (myRank == null) { return null; } - return UserRankListResponse.UserRankResponse.builder() + return OurSchoolUserRankListResponse.UserRankResponse.builder() .userId(myRank.getUserId()) .name(myRank.getName()) .ranking(myRank.getRanking()) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListService.java b/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListService.java index be72a1d79..2b1dc768b 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListService.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListService.java @@ -3,7 +3,8 @@ import com.walkhub.walkhub.domain.rank.domain.repository.UserRankRepository; import com.walkhub.walkhub.domain.rank.domain.repository.vo.UserRankVO; import com.walkhub.walkhub.domain.rank.facade.UserRankFacade; -import com.walkhub.walkhub.domain.rank.presentation.dto.response.UserRankListResponse; +import com.walkhub.walkhub.domain.rank.presentation.dto.response.OtherSchoolUserRankListResponse; +import com.walkhub.walkhub.domain.rank.presentation.dto.response.OurSchoolUserRankListResponse; import com.walkhub.walkhub.global.enums.DateType; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -20,14 +21,12 @@ public class QueryUserRankListService { private final UserRankFacade userRankFacade; @Transactional(readOnly = true) - public UserRankListResponse execute(Long schoolId, DateType dateType) { + public OtherSchoolUserRankListResponse execute(Long schoolId, DateType dateType) { LocalDate now = LocalDate.now(); List usersWeekOrMonthRank = userRankRepository.getUserRankListBySchoolId(schoolId, null, null, dateType, now); - List rankList = userRankFacade.buildWeekOrMonthUsersRankResponse(usersWeekOrMonthRank); + List rankList = userRankFacade.buildWeekOrMonthUsersRankResponse(usersWeekOrMonthRank); - return UserRankListResponse.builder() - .rankList(rankList) - .build(); + return new OtherSchoolUserRankListResponse(rankList); } } From d9237a2b86d9e00f1c82e10c7e33de34c3ab140a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Mon, 28 Feb 2022 13:45:29 +0900 Subject: [PATCH 477/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20hasSchool?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/walkhub/walkhub/domain/user/domain/User.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/user/domain/User.java b/src/main/java/com/walkhub/walkhub/domain/user/domain/User.java index 91bfe019d..cedde18ad 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/domain/User.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/domain/User.java @@ -180,6 +180,10 @@ public boolean hasSection() { return this.section != null; } + public boolean hasSchool() { + return this.school != null; + } + public void setMaxLevel(CalorieLevel calorieLevel) { this.maxLevel = calorieLevel; } From 9b5438df92ee6198416877d30ed7398ccbdb5dab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Mon, 28 Feb 2022 13:45:36 +0900 Subject: [PATCH 478/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20response?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/response/QueryChallengeDetailsResponse.java | 5 +++++ .../challenge/service/QueryChallengeDetailsService.java | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/dto/response/QueryChallengeDetailsResponse.java b/src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/dto/response/QueryChallengeDetailsResponse.java index f692db46d..af4285a89 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/dto/response/QueryChallengeDetailsResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/dto/response/QueryChallengeDetailsResponse.java @@ -2,6 +2,7 @@ import com.walkhub.walkhub.domain.challenge.domain.type.GoalScope; import com.walkhub.walkhub.domain.exercise.domain.type.GoalType; +import com.walkhub.walkhub.global.enums.Authority; import com.walkhub.walkhub.global.enums.UserScope; import lombok.Builder; import lombok.Getter; @@ -34,5 +35,9 @@ public static class Writer{ private final Long userId; private final String name; private final String profileImageUrl; + private final Authority authority; + private final String schoolName; + private final Integer grade; + private final Integer classNum; } } diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/service/QueryChallengeDetailsService.java b/src/main/java/com/walkhub/walkhub/domain/challenge/service/QueryChallengeDetailsService.java index 7b7931393..09cb7aed1 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/service/QueryChallengeDetailsService.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/service/QueryChallengeDetailsService.java @@ -4,6 +4,8 @@ import com.walkhub.walkhub.domain.challenge.facade.ChallengeFacade; import com.walkhub.walkhub.domain.challenge.presenstation.dto.response.QueryChallengeDetailsResponse; import com.walkhub.walkhub.domain.challenge.presenstation.dto.response.QueryChallengeDetailsResponse.Writer; +import com.walkhub.walkhub.domain.school.domain.School; +import com.walkhub.walkhub.domain.user.domain.Section; import com.walkhub.walkhub.domain.user.domain.User; import com.walkhub.walkhub.domain.user.facade.UserFacade; import com.walkhub.walkhub.global.enums.UserScope; @@ -30,6 +32,9 @@ public QueryChallengeDetailsResponse execute(Long challengeId) { throw InvalidRoleException.EXCEPTION; } + School writerSchool = writer.hasSchool() ? writer.getSchool() : School.builder().build(); + Section writerSection = writer.hasSection() ? writer.getSection() : Section.builder().build(); + Boolean isMine = challenge.getChallengeStatuses() .stream() .anyMatch(challengeStatus -> challengeStatus.getUser().equals(user)); @@ -53,6 +58,10 @@ public QueryChallengeDetailsResponse execute(Long challengeId) { .userId(writer.getId()) .name(writer.getName()) .profileImageUrl(writer.getProfileImageUrl()) + .authority(writer.getAuthority()) + .schoolName(writerSchool.getName()) + .classNum(writerSection.getClassNum()) + .grade(writerSection.getGrade()) .build()) .build(); } From 32dce6ab6de3f04dcca39173ddb52ecc49f00452 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B2=94=EC=A7=84?= Date: Mon, 28 Feb 2022 13:50:51 +0900 Subject: [PATCH 479/522] =?UTF-8?q?=E2=9A=A1=20::=20(#476)=20=EB=A7=A4?= =?UTF-8?q?=EC=A3=BC=20=EC=9B=94=EC=9A=94=EC=9D=BC=2002=EC=8B=9C=20?= =?UTF-8?q?=EB=B0=98=EB=B3=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../walkhub/domain/rank/scheduler/SchoolRankScheduler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/scheduler/SchoolRankScheduler.java b/src/main/java/com/walkhub/walkhub/domain/rank/scheduler/SchoolRankScheduler.java index c67f0ae42..85af9bf9a 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/scheduler/SchoolRankScheduler.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/scheduler/SchoolRankScheduler.java @@ -18,7 +18,7 @@ public class SchoolRankScheduler { private final JobLauncher jobLauncher; private final UniqueIdGenerator uniqueIdGenerator; - @Scheduled(cron = "0 0 * * 1 *", zone = "Asia/Seoul") + @Scheduled(cron = "0 0 2 * * 1", zone = "Asia/Seoul") public void saveSchoolRank() throws JobInstanceAlreadyCompleteException, JobExecutionAlreadyRunningException, From 7b1246bdd5a8b1bfcabc7b52a2e5a6980e7a38ef Mon Sep 17 00:00:00 2001 From: parksangwoo Date: Mon, 28 Feb 2022 15:19:55 +0900 Subject: [PATCH 480/522] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20=ED=8C=8C?= =?UTF-8?q?=EB=9D=BC=EB=AF=B8=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 --- .../domain/rank/service/QueryUserRankListByMySchoolService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListByMySchoolService.java b/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListByMySchoolService.java index 6331b6c5c..f390ff68d 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListByMySchoolService.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/service/QueryUserRankListByMySchoolService.java @@ -64,7 +64,7 @@ private UserRankListResponse buildWeekOrMonthRankResponse(User user, Integer gra myRank = buildWeekOrMonthMyRank(user.getId(), grade, classNum, dateType, date); - List usersWeekOrMonthRank = userRankRepository.getUserRankListBySchoolId(user.getSchool().getId(), user.getSection().getGrade(), classNum, dateType, date); + List usersWeekOrMonthRank = userRankRepository.getUserRankListBySchoolId(user.getSchool().getId(), grade, classNum, dateType, date); userRankList = userRankFacade.buildWeekOrMonthUsersRankResponse(usersWeekOrMonthRank); return UserRankListResponse.builder() From 8f7bc03a93b7a9d34f6beabe87327235b98e896d Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Mon, 28 Feb 2022 16:40:12 +0900 Subject: [PATCH 481/522] :bookmark_tabs: :: QueryExercisingUserListService --- .../QueryExercisingUserListService.java | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/main/java/com/walkhub/walkhub/domain/exercise/service/QueryExercisingUserListService.java diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/service/QueryExercisingUserListService.java b/src/main/java/com/walkhub/walkhub/domain/exercise/service/QueryExercisingUserListService.java new file mode 100644 index 000000000..85f845635 --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/service/QueryExercisingUserListService.java @@ -0,0 +1,42 @@ +package com.walkhub.walkhub.domain.exercise.service; + +import com.walkhub.walkhub.domain.exercise.domain.Exercise; +import com.walkhub.walkhub.domain.exercise.domain.repository.ExerciseRepository; +import com.walkhub.walkhub.domain.exercise.presentation.dto.response.QueryExercisingUserListResponse; +import com.walkhub.walkhub.domain.exercise.presentation.dto.response.QueryExercisingUserListResponse.ExercisingUserListResponse; +import com.walkhub.walkhub.domain.user.domain.User; +import com.walkhub.walkhub.domain.user.facade.UserFacade; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.stream.Collectors; + +@RequiredArgsConstructor +@Service +public class QueryExercisingUserListService { + + private final UserFacade userFacade; + private final ExerciseRepository exerciseRepository; + + public QueryExercisingUserListResponse execute() { + User user = userFacade.getCurrentUser(); + + List exercisingList = + exerciseRepository.findAllByUserSectionAndUserIsMeasuring(user.getSection()) + .stream() + .map(this::buildExercisingUserList) + .collect(Collectors.toList()); + + return new QueryExercisingUserListResponse(exercisingList); + + } + + private ExercisingUserListResponse buildExercisingUserList(Exercise exercise) { + return ExercisingUserListResponse.builder() + .userId(exercise.getUser().getId()) + .name(exercise.getUser().getName()) + .profileImageUrl(exercise.getUser().getProfileImageUrl()) + .build(); + } +} From 14d4a02cc46ebf2e8386e80e77e4b809cdc41027 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Mon, 28 Feb 2022 16:40:26 +0900 Subject: [PATCH 482/522] :bookmark_tabs: :: QueryExercisingUserListRespons --- .../QueryExercisingUserListResponse.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/response/QueryExercisingUserListResponse.java diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/response/QueryExercisingUserListResponse.java b/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/response/QueryExercisingUserListResponse.java new file mode 100644 index 000000000..924b5f9d8 --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/response/QueryExercisingUserListResponse.java @@ -0,0 +1,22 @@ +package com.walkhub.walkhub.domain.exercise.presentation.dto.response; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; + +import java.util.List; + +@Getter +@AllArgsConstructor +public class QueryExercisingUserListResponse { + + private final List userList; + + @Getter + @Builder + public static class ExercisingUserListResponse { + private final Long userId; + private final String name; + private final String profileImageUrl; + } +} From 0551e6f0fa1e0f49269fcc3c43f615b1c8a1e1e7 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Mon, 28 Feb 2022 16:40:44 +0900 Subject: [PATCH 483/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20updateIsMeasu?= =?UTF-8?q?ring=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/walkhub/walkhub/domain/user/domain/User.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/user/domain/User.java b/src/main/java/com/walkhub/walkhub/domain/user/domain/User.java index 91bfe019d..a603d06aa 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/domain/User.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/domain/User.java @@ -188,4 +188,8 @@ public void setSectionNull() { this.section = null; } + public void updateIsMeasuring(Boolean isMeasuring) { + this.isMeasuring = isMeasuring; + } + } From 517ed9d95fdfbeebce02f3895481d508a20c1961 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Mon, 28 Feb 2022 16:41:02 +0900 Subject: [PATCH 484/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20findAllByUser?= =?UTF-8?q?SectionAndUserIsMeasuring=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/exercise/domain/repository/ExerciseRepository.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseRepository.java b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseRepository.java index dc2463285..a3efb606e 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseRepository.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseRepository.java @@ -1,6 +1,7 @@ package com.walkhub.walkhub.domain.exercise.domain.repository; import com.walkhub.walkhub.domain.exercise.domain.Exercise; +import com.walkhub.walkhub.domain.user.domain.Section; import com.walkhub.walkhub.domain.user.domain.User; import java.util.List; import org.springframework.data.repository.CrudRepository; @@ -10,4 +11,5 @@ public interface ExerciseRepository extends CrudRepository { Optional findByIsExercisingTrueAndUser(User user); List findAllByUser(User user); + List findAllByUserSectionAndUserIsMeasuring(Section section); } From 6974dbeb2239446d6ec3e1eb1bd000a62206cbf8 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Mon, 28 Feb 2022 16:41:24 +0900 Subject: [PATCH 485/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20=EC=9A=B4?= =?UTF-8?q?=EB=8F=99=20=EC=A4=91=EC=9D=B8=20=EC=9C=A0=EC=A0=80=20=EB=A6=AC?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=EB=B3=B4=EA=B8=B0=20api=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 --- .../domain/exercise/presentation/ExerciseController.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/ExerciseController.java b/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/ExerciseController.java index 333ae2da6..b93b0a3cc 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/ExerciseController.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/ExerciseController.java @@ -7,6 +7,7 @@ import com.walkhub.walkhub.domain.exercise.presentation.dto.response.CreateExerciseResponse; import com.walkhub.walkhub.domain.exercise.presentation.dto.response.QueryExerciseAnalysisResponse; import com.walkhub.walkhub.domain.exercise.presentation.dto.response.QueryExerciseDetailsResponse; +import com.walkhub.walkhub.domain.exercise.presentation.dto.response.QueryExercisingUserListResponse; import com.walkhub.walkhub.domain.exercise.service.*; import com.walkhub.walkhub.domain.exercise.presentation.dto.response.ExerciseListResponse; import com.walkhub.walkhub.domain.exercise.service.CreateExerciseService; @@ -32,6 +33,7 @@ public class ExerciseController { private final SaveOrUpdateExerciseAnalysisService saveOrUpdateExerciseAnalysisService; private final QueryExerciseAnalysisService queryExerciseAnalysisService; private final QueryExerciseDetailsService queryExerciseDetailsService; + private final QueryExercisingUserListService queryExercisingUserListService; @ResponseStatus(HttpStatus.CREATED) @PostMapping @@ -73,4 +75,9 @@ public ExerciseListResponse queryExerciseList() { public QueryExerciseDetailsResponse queryExerciseDetails(@PathVariable("exercise-id") Long exerciseId) { return queryExerciseDetailsService.execute(exerciseId); } + + @GetMapping("users/lists") + public QueryExercisingUserListResponse queryExercisingUserList() { + return queryExercisingUserListService.execute(); + } } From 2d0101b758a9cf74dee58e9d24795eb8226c35a2 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Mon, 28 Feb 2022 16:41:39 +0900 Subject: [PATCH 486/522] =?UTF-8?q?:recycle:=20::=20=EC=9A=B4=EB=8F=99?= =?UTF-8?q?=EC=A4=91=20=EC=97=AC=EB=B6=80=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/exercise/service/CreateExerciseService.java | 2 ++ .../domain/exercise/service/FinishExerciseService.java | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/service/CreateExerciseService.java b/src/main/java/com/walkhub/walkhub/domain/exercise/service/CreateExerciseService.java index e8059ed56..acdcf32eb 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/service/CreateExerciseService.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/service/CreateExerciseService.java @@ -33,6 +33,8 @@ public CreateExerciseResponse execute(CreateExerciseRequest request) { .build() ); + user.updateIsMeasuring(true); + return new CreateExerciseResponse(exercise.getId()); } } diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/service/FinishExerciseService.java b/src/main/java/com/walkhub/walkhub/domain/exercise/service/FinishExerciseService.java index 35ec15d78..294c24409 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/service/FinishExerciseService.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/service/FinishExerciseService.java @@ -5,6 +5,8 @@ import com.walkhub.walkhub.domain.exercise.domain.repository.CertifyingShotRepository; import com.walkhub.walkhub.domain.exercise.facade.ExerciseFacade; import com.walkhub.walkhub.domain.exercise.presentation.dto.request.FinishExerciseRequest; +import com.walkhub.walkhub.domain.user.domain.User; +import com.walkhub.walkhub.domain.user.facade.UserFacade; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -16,11 +18,14 @@ @Service public class FinishExerciseService { + private final UserFacade userFacade; private final ExerciseFacade exerciseFacade; private final CertifyingShotRepository certifyingShotRepository; @Transactional public void execute(Long exerciseId, FinishExerciseRequest request) { + User user = userFacade.getCurrentUser(); + Exercise exercise = exerciseFacade.getById(exerciseId); exercise.closeExercise(request.getWalkCount(), request.getDistance(), request.getCalorie()); @@ -31,6 +36,8 @@ public void execute(Long exerciseId, FinishExerciseRequest request) { .collect(Collectors.toList()); certifyingShotRepository.saveAll(certifyingShotList); + + user.updateIsMeasuring(false); } private CertifyingShot buildCertifyingShot(Exercise exercise, String image) { From 0f6e3839fde07630e89b2871175c50d74ae132cf Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Mon, 28 Feb 2022 16:43:14 +0900 Subject: [PATCH 487/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20securityConfi?= =?UTF-8?q?g=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/walkhub/walkhub/global/security/SecurityConfig.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java b/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java index a0122030b..18f136061 100644 --- a/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java +++ b/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java @@ -77,6 +77,7 @@ protected void configure(HttpSecurity http) throws Exception { .antMatchers(HttpMethod.GET, "/exercises/analysis").authenticated() .antMatchers(HttpMethod.GET, "/exercises/lists").authenticated() .antMatchers(HttpMethod.GET, "/exercises/{exercise-id}").hasAnyAuthority("TEACHER", "ROOT") + .antMatchers(HttpMethod.GET, "/exercises/users/lists").authenticated() // notices .antMatchers(HttpMethod.GET, "/notices/list").authenticated() From aaed8a88fada9621e267d6760c26d1358aca9d49 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Mon, 28 Feb 2022 19:27:30 +0900 Subject: [PATCH 488/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20@Transactiona?= =?UTF-8?q?l?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/CreateExerciseService.java | 36 ++++++++++--------- .../QueryExercisingUserListService.java | 2 ++ 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/service/CreateExerciseService.java b/src/main/java/com/walkhub/walkhub/domain/exercise/service/CreateExerciseService.java index acdcf32eb..008a7f525 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/service/CreateExerciseService.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/service/CreateExerciseService.java @@ -9,32 +9,34 @@ import com.walkhub.walkhub.domain.user.facade.UserFacade; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; @RequiredArgsConstructor @Service public class CreateExerciseService { - private final UserFacade userFacade; - private final ExerciseRepository exerciseRepository; + private final UserFacade userFacade; + private final ExerciseRepository exerciseRepository; - public CreateExerciseResponse execute(CreateExerciseRequest request) { + @Transactional + public CreateExerciseResponse execute(CreateExerciseRequest request) { - User user = userFacade.getCurrentUser(); + User user = userFacade.getCurrentUser(); - if (exerciseRepository.findByIsExercisingTrueAndUser(user).isPresent()) { - throw AlreadyExercisingException.EXCEPTION; - } + if (exerciseRepository.findByIsExercisingTrueAndUser(user).isPresent()) { + throw AlreadyExercisingException.EXCEPTION; + } - Exercise exercise = exerciseRepository.save( - Exercise.builder() - .user(user) - .goalType(request.getGoalType()) - .goal(request.getGoal()) - .build() - ); + Exercise exercise = exerciseRepository.save( + Exercise.builder() + .user(user) + .goalType(request.getGoalType()) + .goal(request.getGoal()) + .build() + ); - user.updateIsMeasuring(true); + user.updateIsMeasuring(true); - return new CreateExerciseResponse(exercise.getId()); - } + return new CreateExerciseResponse(exercise.getId()); + } } diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/service/QueryExercisingUserListService.java b/src/main/java/com/walkhub/walkhub/domain/exercise/service/QueryExercisingUserListService.java index 85f845635..64a3d8a04 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/service/QueryExercisingUserListService.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/service/QueryExercisingUserListService.java @@ -8,6 +8,7 @@ import com.walkhub.walkhub.domain.user.facade.UserFacade; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.util.List; import java.util.stream.Collectors; @@ -19,6 +20,7 @@ public class QueryExercisingUserListService { private final UserFacade userFacade; private final ExerciseRepository exerciseRepository; + @Transactional(readOnly = true) public QueryExercisingUserListResponse execute() { User user = userFacade.getCurrentUser(); From 6e2f523758f96eb29d3548244ddfbc371bd6b14f Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Mon, 28 Feb 2022 19:28:30 +0900 Subject: [PATCH 489/522] =?UTF-8?q?:recycle:=20::=20/=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/exercise/presentation/ExerciseController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/ExerciseController.java b/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/ExerciseController.java index b93b0a3cc..5ecaa5d29 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/ExerciseController.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/ExerciseController.java @@ -76,7 +76,7 @@ public QueryExerciseDetailsResponse queryExerciseDetails(@PathVariable("exercise return queryExerciseDetailsService.execute(exerciseId); } - @GetMapping("users/lists") + @GetMapping("/users/lists") public QueryExercisingUserListResponse queryExercisingUserList() { return queryExercisingUserListService.execute(); } From 68f845d46c1cbe93eaa97505976a0fd8bab66328 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Mon, 28 Feb 2022 20:04:24 +0900 Subject: [PATCH 490/522] =?UTF-8?q?:recycle:=20::=20=EC=A0=95=EB=A0=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/ExerciseController.java | 108 ++++++++++-------- 1 file changed, 59 insertions(+), 49 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/ExerciseController.java b/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/ExerciseController.java index 5ecaa5d29..b96db2622 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/ExerciseController.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/ExerciseController.java @@ -5,19 +5,29 @@ import com.walkhub.walkhub.domain.exercise.presentation.dto.request.SaveExerciseAnalysisRequest; import com.walkhub.walkhub.domain.exercise.presentation.dto.request.SaveLocationRequest; import com.walkhub.walkhub.domain.exercise.presentation.dto.response.CreateExerciseResponse; +import com.walkhub.walkhub.domain.exercise.presentation.dto.response.ExerciseListResponse; import com.walkhub.walkhub.domain.exercise.presentation.dto.response.QueryExerciseAnalysisResponse; import com.walkhub.walkhub.domain.exercise.presentation.dto.response.QueryExerciseDetailsResponse; import com.walkhub.walkhub.domain.exercise.presentation.dto.response.QueryExercisingUserListResponse; -import com.walkhub.walkhub.domain.exercise.service.*; -import com.walkhub.walkhub.domain.exercise.presentation.dto.response.ExerciseListResponse; import com.walkhub.walkhub.domain.exercise.service.CreateExerciseService; import com.walkhub.walkhub.domain.exercise.service.FinishExerciseService; +import com.walkhub.walkhub.domain.exercise.service.QueryExerciseAnalysisService; +import com.walkhub.walkhub.domain.exercise.service.QueryExerciseDetailsService; import com.walkhub.walkhub.domain.exercise.service.QueryExerciseListService; +import com.walkhub.walkhub.domain.exercise.service.QueryExercisingUserListService; import com.walkhub.walkhub.domain.exercise.service.SaveLocationService; import com.walkhub.walkhub.domain.exercise.service.SaveOrUpdateExerciseAnalysisService; import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PatchMapping; +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.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; import javax.validation.Valid; @@ -26,58 +36,58 @@ @RestController public class ExerciseController { - private final CreateExerciseService createExerciseService; - private final FinishExerciseService finishExerciseService; - private final SaveLocationService saveLocationService; - private final QueryExerciseListService queryExerciseListService; - private final SaveOrUpdateExerciseAnalysisService saveOrUpdateExerciseAnalysisService; - private final QueryExerciseAnalysisService queryExerciseAnalysisService; - private final QueryExerciseDetailsService queryExerciseDetailsService; - private final QueryExercisingUserListService queryExercisingUserListService; + private final CreateExerciseService createExerciseService; + private final FinishExerciseService finishExerciseService; + private final SaveLocationService saveLocationService; + private final QueryExerciseListService queryExerciseListService; + private final SaveOrUpdateExerciseAnalysisService saveOrUpdateExerciseAnalysisService; + private final QueryExerciseAnalysisService queryExerciseAnalysisService; + private final QueryExerciseDetailsService queryExerciseDetailsService; + private final QueryExercisingUserListService queryExercisingUserListService; - @ResponseStatus(HttpStatus.CREATED) - @PostMapping - public CreateExerciseResponse createExercise(@RequestBody CreateExerciseRequest request) { - return createExerciseService.execute(request); - } + @ResponseStatus(HttpStatus.CREATED) + @PostMapping + public CreateExerciseResponse createExercise(@RequestBody CreateExerciseRequest request) { + return createExerciseService.execute(request); + } - @ResponseStatus(HttpStatus.NO_CONTENT) - @PatchMapping("/{exercise-id}") - public void finishExercise(@PathVariable(name = "exercise-id") Long exerciseId, - @RequestBody @Valid FinishExerciseRequest request) { - finishExerciseService.execute(exerciseId, request); - } + @ResponseStatus(HttpStatus.NO_CONTENT) + @PatchMapping("/{exercise-id}") + public void finishExercise(@PathVariable(name = "exercise-id") Long exerciseId, + @RequestBody @Valid FinishExerciseRequest request) { + finishExerciseService.execute(exerciseId, request); + } - @ResponseStatus(HttpStatus.CREATED) - @PostMapping("/locations/{exercise-id}") - public void saveLocation(@PathVariable(name = "exercise-id") Long exerciseId, - @RequestBody @Valid SaveLocationRequest request) { - saveLocationService.execute(exerciseId, request); - } + @ResponseStatus(HttpStatus.CREATED) + @PostMapping("/locations/{exercise-id}") + public void saveLocation(@PathVariable(name = "exercise-id") Long exerciseId, + @RequestBody @Valid SaveLocationRequest request) { + saveLocationService.execute(exerciseId, request); + } - @ResponseStatus(HttpStatus.NO_CONTENT) - @PutMapping - public void saveOrUpdateTodayExercise(@RequestBody @Valid SaveExerciseAnalysisRequest request) { - saveOrUpdateExerciseAnalysisService.execute(request); - } + @ResponseStatus(HttpStatus.NO_CONTENT) + @PutMapping + public void saveOrUpdateTodayExercise(@RequestBody @Valid SaveExerciseAnalysisRequest request) { + saveOrUpdateExerciseAnalysisService.execute(request); + } - @GetMapping("/analysis") - public QueryExerciseAnalysisResponse queryExerciseAnalysis() { - return queryExerciseAnalysisService.execute(); - } + @GetMapping("/analysis") + public QueryExerciseAnalysisResponse queryExerciseAnalysis() { + return queryExerciseAnalysisService.execute(); + } - @GetMapping("/lists") - public ExerciseListResponse queryExerciseList() { - return queryExerciseListService.execute(); - } + @GetMapping("/lists") + public ExerciseListResponse queryExerciseList() { + return queryExerciseListService.execute(); + } - @GetMapping("{exercise-id}") - public QueryExerciseDetailsResponse queryExerciseDetails(@PathVariable("exercise-id") Long exerciseId) { - return queryExerciseDetailsService.execute(exerciseId); - } + @GetMapping("{exercise-id}") + public QueryExerciseDetailsResponse queryExerciseDetails(@PathVariable("exercise-id") Long exerciseId) { + return queryExerciseDetailsService.execute(exerciseId); + } - @GetMapping("/users/lists") - public QueryExercisingUserListResponse queryExercisingUserList() { - return queryExercisingUserListService.execute(); - } + @GetMapping("/users/lists") + public QueryExercisingUserListResponse queryExercisingUserList() { + return queryExercisingUserListService.execute(); + } } From f3f5fde94f2ce60881fdca65b4c07665f2218080 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Mon, 28 Feb 2022 20:05:06 +0900 Subject: [PATCH 491/522] =?UTF-8?q?:recycle:=20::=20=EC=9A=B4=EB=8F=99?= =?UTF-8?q?=EC=A4=91=EC=9D=B8=20=EC=9C=A0=EC=A0=80=20=EA=B0=80=EC=A0=B8?= =?UTF-8?q?=EC=98=A4=EA=B8=B0=20=EC=A1=B0=ED=9A=8C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/repository/ExerciseRepository.java | 5 ++--- .../service/QueryExercisingUserListService.java | 15 +++++++-------- .../user/domain/repository/UserRepository.java | 5 +++++ 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseRepository.java b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseRepository.java index a3efb606e..93ea46336 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseRepository.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/ExerciseRepository.java @@ -1,15 +1,14 @@ package com.walkhub.walkhub.domain.exercise.domain.repository; import com.walkhub.walkhub.domain.exercise.domain.Exercise; -import com.walkhub.walkhub.domain.user.domain.Section; import com.walkhub.walkhub.domain.user.domain.User; -import java.util.List; import org.springframework.data.repository.CrudRepository; +import java.util.List; import java.util.Optional; public interface ExerciseRepository extends CrudRepository { Optional findByIsExercisingTrueAndUser(User user); + List findAllByUser(User user); - List findAllByUserSectionAndUserIsMeasuring(Section section); } diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/service/QueryExercisingUserListService.java b/src/main/java/com/walkhub/walkhub/domain/exercise/service/QueryExercisingUserListService.java index 64a3d8a04..ca9227274 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/service/QueryExercisingUserListService.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/service/QueryExercisingUserListService.java @@ -1,10 +1,9 @@ package com.walkhub.walkhub.domain.exercise.service; -import com.walkhub.walkhub.domain.exercise.domain.Exercise; -import com.walkhub.walkhub.domain.exercise.domain.repository.ExerciseRepository; import com.walkhub.walkhub.domain.exercise.presentation.dto.response.QueryExercisingUserListResponse; import com.walkhub.walkhub.domain.exercise.presentation.dto.response.QueryExercisingUserListResponse.ExercisingUserListResponse; import com.walkhub.walkhub.domain.user.domain.User; +import com.walkhub.walkhub.domain.user.domain.repository.UserRepository; import com.walkhub.walkhub.domain.user.facade.UserFacade; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -18,14 +17,14 @@ public class QueryExercisingUserListService { private final UserFacade userFacade; - private final ExerciseRepository exerciseRepository; + private final UserRepository userRepository; @Transactional(readOnly = true) public QueryExercisingUserListResponse execute() { User user = userFacade.getCurrentUser(); List exercisingList = - exerciseRepository.findAllByUserSectionAndUserIsMeasuring(user.getSection()) + userRepository.findAllBySectionAndIsMeasuringTrue(user.getSection()) .stream() .map(this::buildExercisingUserList) .collect(Collectors.toList()); @@ -34,11 +33,11 @@ public QueryExercisingUserListResponse execute() { } - private ExercisingUserListResponse buildExercisingUserList(Exercise exercise) { + private ExercisingUserListResponse buildExercisingUserList(User user) { return ExercisingUserListResponse.builder() - .userId(exercise.getUser().getId()) - .name(exercise.getUser().getName()) - .profileImageUrl(exercise.getUser().getProfileImageUrl()) + .userId(user.getId()) + .name(user.getName()) + .profileImageUrl(user.getProfileImageUrl()) .build(); } } diff --git a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepository.java b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepository.java index 295422cb1..c842e0e13 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepository.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepository.java @@ -15,8 +15,11 @@ public interface UserRepository extends CrudRepository, UserRepositoryCustom { Optional findByAccountId(String accountId); + Optional findByPhoneNumber(String phoneNumber); + List findAllBySchoolIdAndNameContaining(Long id, String name); + @Query("select u from User u left join fetch u.section where u.school = :school and u.authority = :authority") List findAllBySchoolAndAuthority(@Param("school") School school, @Param("authority") Authority authority); @@ -24,4 +27,6 @@ public interface UserRepository extends CrudRepository, UserReposito @Modifying @Query("update User u set u.section = null where u.section = :section") void setUserSectionNull(@Param("section") Section section); + + List findAllBySectionAndIsMeasuringTrue(Section section); } From 3430e78b1aa78a59b225cea0a1c423d66dd4955d Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Mon, 28 Feb 2022 20:29:52 +0900 Subject: [PATCH 492/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20log=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../walkhub/domain/cheering/service/CheeringService.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/cheering/service/CheeringService.java b/src/main/java/com/walkhub/walkhub/domain/cheering/service/CheeringService.java index 335e11a3b..2d4d9f312 100644 --- a/src/main/java/com/walkhub/walkhub/domain/cheering/service/CheeringService.java +++ b/src/main/java/com/walkhub/walkhub/domain/cheering/service/CheeringService.java @@ -14,11 +14,13 @@ import com.walkhub.walkhub.global.websocket.property.ClientProperty; import com.walkhub.walkhub.global.websocket.property.SocketProperty; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.Optional; +@Slf4j @RequiredArgsConstructor @Service public class CheeringService { @@ -51,5 +53,7 @@ public void execute(SocketIOClient socketIOClient, CheerRequest request) { clientToSend.sendEvent(SocketProperty.NEW_CHEERING, message); + log.info(user.getName() + ", " + request.getUserId()); + } } From 771f45298ea8aac0ab8a6055ccf482ce07b4759a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B2=94=EC=A7=84?= Date: Mon, 28 Feb 2022 21:42:02 +0900 Subject: [PATCH 493/522] =?UTF-8?q?=E2=9A=B0=20::=20(#485)=20Certifying=20?= =?UTF-8?q?Shot?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exercise/domain/CertifyingShot.java | 32 ------------------- .../repository/CertifyingShotRepository.java | 7 ---- 2 files changed, 39 deletions(-) delete mode 100644 src/main/java/com/walkhub/walkhub/domain/exercise/domain/CertifyingShot.java delete mode 100644 src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/CertifyingShotRepository.java diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/CertifyingShot.java b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/CertifyingShot.java deleted file mode 100644 index 8d5d86703..000000000 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/CertifyingShot.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.walkhub.walkhub.domain.exercise.domain; - -import lombok.AccessLevel; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; - -import javax.persistence.*; - -@Getter -@NoArgsConstructor(access = AccessLevel.PROTECTED) -@Entity -public class CertifyingShot { - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - - @Column(nullable = false) - private String photo; - - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "exercise_id", nullable = false) - private Exercise exercise; - - @Builder - public CertifyingShot(String photo, Exercise exercise) { - this.photo = photo; - this.exercise = exercise; - } - -} diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/CertifyingShotRepository.java b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/CertifyingShotRepository.java deleted file mode 100644 index eada5a57d..000000000 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/repository/CertifyingShotRepository.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.walkhub.walkhub.domain.exercise.domain.repository; - -import com.walkhub.walkhub.domain.exercise.domain.CertifyingShot; -import org.springframework.data.repository.CrudRepository; - -public interface CertifyingShotRepository extends CrudRepository { -} From 382b60eeb5259e862de71a1164a4044fe578571b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B2=94=EC=A7=84?= Date: Mon, 28 Feb 2022 21:44:02 +0900 Subject: [PATCH 494/522] =?UTF-8?q?=E2=9A=A1::=20(#485)=20=EC=82=AC?= =?UTF-8?q?=EC=A7=84=20=ED=95=9C=20=EC=9E=A5=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 --- .../domain/exercise/domain/Exercise.java | 14 ++++++++-- .../dto/request/FinishExerciseRequest.java | 3 +-- .../service/FinishExerciseService.java | 27 +++++-------------- 3 files changed, 19 insertions(+), 25 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/Exercise.java b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/Exercise.java index bad1b3cbe..1fb73ea76 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/Exercise.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/Exercise.java @@ -10,7 +10,16 @@ import lombok.NoArgsConstructor; import org.hibernate.annotations.DynamicInsert; -import javax.persistence.*; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.EnumType; +import javax.persistence.Enumerated; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; import javax.validation.constraints.NotNull; import java.time.ZonedDateTime; @@ -63,11 +72,12 @@ public Exercise(User user, Integer goal, GoalType goalType) { this.isExercising = true; } - public void closeExercise(Integer walkCount, Integer distance, Double calorie) { + public void closeExercise(Integer walkCount, Integer distance, Double calorie, String imageUrl) { this.walkCount = walkCount; this.distance = distance; this.calorie = calorie; this.endAt = ZonedDateTime.now(); + this.imageUrl = imageUrl; this.isExercising = false; } diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/request/FinishExerciseRequest.java b/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/request/FinishExerciseRequest.java index 0ea97332a..d665cdb27 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/request/FinishExerciseRequest.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/request/FinishExerciseRequest.java @@ -6,7 +6,6 @@ import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; import javax.validation.constraints.PositiveOrZero; -import java.util.List; @Getter @NoArgsConstructor @@ -23,6 +22,6 @@ public class FinishExerciseRequest { private Double calorie; @NotEmpty(message = "image_url은 공백을 허용하지 않습니다.") - private List imageUrl; + private String imageUrl; } diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/service/FinishExerciseService.java b/src/main/java/com/walkhub/walkhub/domain/exercise/service/FinishExerciseService.java index 35ec15d78..d249356dd 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/service/FinishExerciseService.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/service/FinishExerciseService.java @@ -1,43 +1,28 @@ package com.walkhub.walkhub.domain.exercise.service; -import com.walkhub.walkhub.domain.exercise.domain.CertifyingShot; import com.walkhub.walkhub.domain.exercise.domain.Exercise; -import com.walkhub.walkhub.domain.exercise.domain.repository.CertifyingShotRepository; import com.walkhub.walkhub.domain.exercise.facade.ExerciseFacade; import com.walkhub.walkhub.domain.exercise.presentation.dto.request.FinishExerciseRequest; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.util.List; -import java.util.stream.Collectors; - @RequiredArgsConstructor @Service public class FinishExerciseService { private final ExerciseFacade exerciseFacade; - private final CertifyingShotRepository certifyingShotRepository; @Transactional public void execute(Long exerciseId, FinishExerciseRequest request) { Exercise exercise = exerciseFacade.getById(exerciseId); - exercise.closeExercise(request.getWalkCount(), request.getDistance(), request.getCalorie()); - - List certifyingShotList = request.getImageUrl() - .stream() - .map(image -> buildCertifyingShot(exercise, image)) - .collect(Collectors.toList()); - - certifyingShotRepository.saveAll(certifyingShotList); - } - - private CertifyingShot buildCertifyingShot(Exercise exercise, String image) { - return CertifyingShot.builder() - .exercise(exercise) - .photo(image) - .build(); + exercise.closeExercise( + request.getWalkCount(), + request.getDistance(), + request.getCalorie(), + request.getImageUrl() + ); } } From 0977f1d5ed6fa81f80b68fb7ccad5d51551cad47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B2=94=EC=A7=84?= Date: Mon, 28 Feb 2022 21:49:22 +0900 Subject: [PATCH 495/522] =?UTF-8?q?=E2=9A=A1=20::=20(#485)=20imageurl=20op?= =?UTF-8?q?tional?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/dto/request/FinishExerciseRequest.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/request/FinishExerciseRequest.java b/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/request/FinishExerciseRequest.java index d665cdb27..33c3a293d 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/request/FinishExerciseRequest.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/request/FinishExerciseRequest.java @@ -3,7 +3,6 @@ import lombok.Getter; import lombok.NoArgsConstructor; -import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; import javax.validation.constraints.PositiveOrZero; @@ -21,7 +20,6 @@ public class FinishExerciseRequest { @NotNull(message = "calorie는 null, 공백을 허용하지 않습니다.") private Double calorie; - @NotEmpty(message = "image_url은 공백을 허용하지 않습니다.") private String imageUrl; } From c4ad4aa9d59e711f416f5fb5458c2b47fed36948 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B2=94=EC=A7=84?= Date: Mon, 28 Feb 2022 21:53:36 +0900 Subject: [PATCH 496/522] =?UTF-8?q?=E2=9A=A1=20::=20(#486)=20npe=20?= =?UTF-8?q?=EB=B0=A9=EC=A7=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/challenge/service/ParticipateChallengeService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/service/ParticipateChallengeService.java b/src/main/java/com/walkhub/walkhub/domain/challenge/service/ParticipateChallengeService.java index b184178b0..be39029f9 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/service/ParticipateChallengeService.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/service/ParticipateChallengeService.java @@ -42,8 +42,8 @@ public void execute(Long challengeId) { } private boolean verifyScope(User user, User writer, Challenge challenge) { - Section userSection = user.getSection(); - Section writerSection = writer.getSection(); + Section userSection = user.getSection() != null ? user.getSection() : Section.builder().grade(0).classNum(0).build(); + Section writerSection = writer.getSection() != null ? writer.getSection() : Section.builder().grade(0).classNum(0).build(); switch (challenge.getUserScope()) { case SCHOOL: { From 7a6deacda925cfcba10c7ae76d110ee4b3990561 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B2=94=EC=A7=84?= Date: Mon, 28 Feb 2022 21:56:32 +0900 Subject: [PATCH 497/522] =?UTF-8?q?=E2=9A=A1=20::=20(#487)=20TEACHER=20?= =?UTF-8?q?=EA=B6=8C=ED=95=9C=EB=A7=8C=20=ED=97=88=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/walkhub/walkhub/global/security/SecurityConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java b/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java index a0122030b..b01f446da 100644 --- a/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java +++ b/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java @@ -121,7 +121,7 @@ protected void configure(HttpSecurity http) throws Exception { .antMatchers(HttpMethod.GET, "/teachers/users").hasAnyAuthority("TEACHER", "ROOT") .antMatchers(HttpMethod.POST, "/teachers/classes").hasAnyAuthority("TEACHER", "ROOT") .antMatchers(HttpMethod.GET, "/teachers/classes/lists").hasAnyAuthority("TEACHER", "ROOT") - .antMatchers(HttpMethod.DELETE, "/teachers/classes/{section-id}").hasAnyAuthority("TEACHER", "ROOT") + .antMatchers(HttpMethod.DELETE, "/teachers/classes/{section-id}").hasAuthority("TEACHER") .antMatchers(HttpMethod.GET, "/teachers/classes").hasAuthority("TEACHER") .antMatchers(HttpMethod.GET, "/teachers/users/{user-id}").hasAnyAuthority("TEACHER") .antMatchers(HttpMethod.GET, "/teachers/users").hasAnyAuthority("TEACHER", "ROOT") From e18f52bb02c281960d5484a831a703ecf1374333 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B2=94=EC=A7=84?= Date: Mon, 28 Feb 2022 21:59:35 +0900 Subject: [PATCH 498/522] =?UTF-8?q?=E2=9A=A1=20::=20(#487)=20=ED=95=84?= =?UTF-8?q?=EC=9A=94=EC=97=86=EB=8A=94=20=EB=A1=9C=EC=A7=81=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 --- .../walkhub/domain/teacher/service/DeleteClassService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/service/DeleteClassService.java b/src/main/java/com/walkhub/walkhub/domain/teacher/service/DeleteClassService.java index ff967cf23..5d0a5eddb 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/service/DeleteClassService.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/service/DeleteClassService.java @@ -27,7 +27,7 @@ public void execute(Long sectionId) { User user = userFacade.getCurrentUser(); - if (user.getAuthority() != Authority.TEACHER || !user.getSection().equals(section)) { + if (!user.getSection().equals(section)) { throw InvalidRoleException.EXCEPTION; } From 28adedfcb17f1caa5b9feacbe66dd4e853fe5fb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B2=94=EC=A7=84?= Date: Mon, 28 Feb 2022 23:24:02 +0900 Subject: [PATCH 499/522] =?UTF-8?q?=E2=99=BB=20::=20(#487)=20=EC=95=88?= =?UTF-8?q?=EC=93=B0=EB=8A=94=20import=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../walkhub/domain/teacher/service/DeleteClassService.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/teacher/service/DeleteClassService.java b/src/main/java/com/walkhub/walkhub/domain/teacher/service/DeleteClassService.java index 5d0a5eddb..7117d0338 100644 --- a/src/main/java/com/walkhub/walkhub/domain/teacher/service/DeleteClassService.java +++ b/src/main/java/com/walkhub/walkhub/domain/teacher/service/DeleteClassService.java @@ -6,7 +6,6 @@ import com.walkhub.walkhub.domain.user.domain.repository.UserRepository; import com.walkhub.walkhub.domain.user.facade.SectionFacade; import com.walkhub.walkhub.domain.user.facade.UserFacade; -import com.walkhub.walkhub.global.enums.Authority; import com.walkhub.walkhub.global.exception.InvalidRoleException; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; From 25417366809d26278724eb53dae79d76f9b6038b Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Tue, 1 Mar 2022 20:12:30 +0900 Subject: [PATCH 500/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20school=5Fimag?= =?UTF-8?q?e=5Furl=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../response/QueryUserProfileResponse.java | 1 + .../user/service/QueryMyPageService.java | 33 ++++++++++--------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/user/presentation/dto/response/QueryUserProfileResponse.java b/src/main/java/com/walkhub/walkhub/domain/user/presentation/dto/response/QueryUserProfileResponse.java index 79206973d..9fa6f3ba6 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/presentation/dto/response/QueryUserProfileResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/presentation/dto/response/QueryUserProfileResponse.java @@ -11,6 +11,7 @@ public class QueryUserProfileResponse { private final String name; private final String profileImageUrl; private final String schoolName; + private final String schoolImageUrl; private final Integer grade; private final Integer classNum; private final TitleBadge titleBadge; diff --git a/src/main/java/com/walkhub/walkhub/domain/user/service/QueryMyPageService.java b/src/main/java/com/walkhub/walkhub/domain/user/service/QueryMyPageService.java index bf0b411b2..41d4b49e6 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/service/QueryMyPageService.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/service/QueryMyPageService.java @@ -25,21 +25,22 @@ public QueryUserProfileResponse execute() { Section section = user.hasSection() ? user.getSection() : Section.builder().build(); return QueryUserProfileResponse.builder() - .userId(user.getId()) - .name(user.getName()) - .profileImageUrl(user.getProfileImageUrl()) - .schoolName(user.getSchool().getName()) - .classNum(section.getClassNum()) - .grade(section.getGrade()) - .titleBadge(TitleBadge.builder() - .id(titleBadge.getId()) - .name(titleBadge.getName()) - .imageUrl(titleBadge.getImageUrl()) - .build()) - .level(Level.builder() - .imageUrl(level.getFoodImageUrl()) - .name(level.getFoodName()) - .build()) - .build(); + .userId(user.getId()) + .name(user.getName()) + .profileImageUrl(user.getProfileImageUrl()) + .schoolName(user.getSchool().getName()) + .schoolImageUrl(user.getSchool().getLogoImageUrl()) + .classNum(section.getClassNum()) + .grade(section.getGrade()) + .titleBadge(TitleBadge.builder() + .id(titleBadge.getId()) + .name(titleBadge.getName()) + .imageUrl(titleBadge.getImageUrl()) + .build()) + .level(Level.builder() + .imageUrl(level.getFoodImageUrl()) + .name(level.getFoodName()) + .build()) + .build(); } } From 00b348fed4af537da54497204fe1c46ad97287e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B2=94=EC=A7=84?= Date: Wed, 2 Mar 2022 08:39:18 +0900 Subject: [PATCH 501/522] =?UTF-8?q?=F0=9F=90=9B=20::=20(#486)=20gecSection?= =?UTF-8?q?=20->=20hasSection?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/challenge/service/ParticipateChallengeService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/service/ParticipateChallengeService.java b/src/main/java/com/walkhub/walkhub/domain/challenge/service/ParticipateChallengeService.java index be39029f9..9e6c3fd61 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/service/ParticipateChallengeService.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/service/ParticipateChallengeService.java @@ -42,8 +42,8 @@ public void execute(Long challengeId) { } private boolean verifyScope(User user, User writer, Challenge challenge) { - Section userSection = user.getSection() != null ? user.getSection() : Section.builder().grade(0).classNum(0).build(); - Section writerSection = writer.getSection() != null ? writer.getSection() : Section.builder().grade(0).classNum(0).build(); + Section userSection = user.hasSection() ? user.getSection() : Section.builder().grade(0).classNum(0).build(); + Section writerSection = writer.hasSection() ? writer.getSection() : Section.builder().grade(0).classNum(0).build(); switch (challenge.getUserScope()) { case SCHOOL: { From 59bceddaec604f4f769ca32c48d76f373c72da6c Mon Sep 17 00:00:00 2001 From: jhhong0509 Date: Wed, 2 Mar 2022 09:49:54 +0900 Subject: [PATCH 502/522] =?UTF-8?q?:bug:=20::=20(#495)=20Where=20=EB=B2=84?= =?UTF-8?q?=EA=B7=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/ChallengeStatusRepositoryCustomImpl.java | 4 ++-- .../challenge/service/QueryChallengeProgressService.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java index 22d261278..0f676206d 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java @@ -153,9 +153,9 @@ public List queryChallengeProgress( .join(user.school, school) .join(user.challengeStatuses, challengeStatus) .leftJoin(user.exerciseAnalyses, exerciseAnalysis) - .on(challengeDateFilter(challenge)) - .where(userScopeFilter(participantsScope), + .on(challengeDateFilter(challenge), isChallengeSuccessFilter(challenge)) + .where(userScopeFilter(participantsScope)) .orderBy(challengeParticipantsOrder(participantsOrder)) .having(challengeSuccessFilter(successScope, challenge)) .groupBy(user.id) diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/service/QueryChallengeProgressService.java b/src/main/java/com/walkhub/walkhub/domain/challenge/service/QueryChallengeProgressService.java index be760fb4d..1d7b04473 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/service/QueryChallengeProgressService.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/service/QueryChallengeProgressService.java @@ -66,7 +66,7 @@ private QueryChallengeProgressResponse.UserChallengeProgressResponse buildUserCh } return QueryChallengeProgressResponse.UserChallengeProgressResponse.builder() .classNum(vo.getClassNum()) - .progress(vo.getProgress()) + .progress(vo.getProgress() == null ? 0 : vo.getProgress()) .grade(vo.getGrade()) .isSuccess(vo.getIsSuccess()) .number(vo.getNumber()) From c7a4206e819ecc587e3523eb8908b51120dc43c5 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Wed, 2 Mar 2022 12:22:36 +0900 Subject: [PATCH 503/522] =?UTF-8?q?:bug:=20::=20Conflict=20=ED=95=B4?= =?UTF-8?q?=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/dto/request/FinishExerciseRequest.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/request/FinishExerciseRequest.java b/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/request/FinishExerciseRequest.java index 0ea97332a..c11462f93 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/request/FinishExerciseRequest.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/request/FinishExerciseRequest.java @@ -3,10 +3,8 @@ import lombok.Getter; import lombok.NoArgsConstructor; -import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; import javax.validation.constraints.PositiveOrZero; -import java.util.List; @Getter @NoArgsConstructor @@ -22,7 +20,6 @@ public class FinishExerciseRequest { @NotNull(message = "calorie는 null, 공백을 허용하지 않습니다.") private Double calorie; - @NotEmpty(message = "image_url은 공백을 허용하지 않습니다.") - private List imageUrl; + private String imageUrl; -} +} \ No newline at end of file From b67aaebd08d288f672eaf5dc84101004ad1432db Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Wed, 2 Mar 2022 13:48:45 +0900 Subject: [PATCH 504/522] =?UTF-8?q?:bug:=20::=20Conflict=20=ED=95=B4?= =?UTF-8?q?=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../walkhub/domain/exercise/domain/Exercise.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/Exercise.java b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/Exercise.java index bad1b3cbe..4c1b95aca 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/Exercise.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/Exercise.java @@ -10,7 +10,16 @@ import lombok.NoArgsConstructor; import org.hibernate.annotations.DynamicInsert; -import javax.persistence.*; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.EnumType; +import javax.persistence.Enumerated; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; import javax.validation.constraints.NotNull; import java.time.ZonedDateTime; @@ -59,15 +68,16 @@ public class Exercise extends BaseTimeEntity { public Exercise(User user, Integer goal, GoalType goalType) { this.user = user; this.goalType = goalType; - this.goal = goal; + if(goal != null) this.goal = goal; this.isExercising = true; } - public void closeExercise(Integer walkCount, Integer distance, Double calorie) { + public void closeExercise(Integer walkCount, Integer distance, Double calorie, String imageUrl) { this.walkCount = walkCount; this.distance = distance; this.calorie = calorie; this.endAt = ZonedDateTime.now(); + this.imageUrl = imageUrl; this.isExercising = false; } From 1b3ff7c97a8adf6518652bda42f02582a2539738 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Wed, 2 Mar 2022 13:56:22 +0900 Subject: [PATCH 505/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20scope?= =?UTF-8?q?=EB=A5=BC=20section=20->=20school=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/exercise/service/QueryExercisingUserListService.java | 2 +- .../walkhub/domain/user/domain/repository/UserRepository.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/service/QueryExercisingUserListService.java b/src/main/java/com/walkhub/walkhub/domain/exercise/service/QueryExercisingUserListService.java index ca9227274..6ce6748bb 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/service/QueryExercisingUserListService.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/service/QueryExercisingUserListService.java @@ -24,7 +24,7 @@ public QueryExercisingUserListResponse execute() { User user = userFacade.getCurrentUser(); List exercisingList = - userRepository.findAllBySectionAndIsMeasuringTrue(user.getSection()) + userRepository.findAllBySchoolAndIsMeasuringTrue(user.getSchool()) .stream() .map(this::buildExercisingUserList) .collect(Collectors.toList()); diff --git a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepository.java b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepository.java index c842e0e13..5cf96fde7 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepository.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepository.java @@ -28,5 +28,5 @@ public interface UserRepository extends CrudRepository, UserReposito @Query("update User u set u.section = null where u.section = :section") void setUserSectionNull(@Param("section") Section section); - List findAllBySectionAndIsMeasuringTrue(Section section); + List findAllBySchoolAndIsMeasuringTrue(School school); } From 57a6e95b9cd81397e8fe745b161ce472c363cae7 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Wed, 2 Mar 2022 13:57:26 +0900 Subject: [PATCH 506/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20security=20Co?= =?UTF-8?q?nfig=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/walkhub/walkhub/global/security/SecurityConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java b/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java index 18f136061..2a155cd7e 100644 --- a/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java +++ b/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java @@ -77,7 +77,7 @@ protected void configure(HttpSecurity http) throws Exception { .antMatchers(HttpMethod.GET, "/exercises/analysis").authenticated() .antMatchers(HttpMethod.GET, "/exercises/lists").authenticated() .antMatchers(HttpMethod.GET, "/exercises/{exercise-id}").hasAnyAuthority("TEACHER", "ROOT") - .antMatchers(HttpMethod.GET, "/exercises/users/lists").authenticated() + .antMatchers(HttpMethod.GET, "/exercises/users/lists").hasAnyAuthority("USER", "TEACHER") // notices .antMatchers(HttpMethod.GET, "/notices/list").authenticated() From 9585bc8a89c5af66703d5a6700f6a2ee884b9ee8 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Wed, 2 Mar 2022 13:59:32 +0900 Subject: [PATCH 507/522] =?UTF-8?q?:recycle:=20::=20limit=203=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 --- .../domain/exercise/service/QueryExercisingUserListService.java | 2 +- .../walkhub/domain/user/domain/repository/UserRepository.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/service/QueryExercisingUserListService.java b/src/main/java/com/walkhub/walkhub/domain/exercise/service/QueryExercisingUserListService.java index 6ce6748bb..f6dcb21c7 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/service/QueryExercisingUserListService.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/service/QueryExercisingUserListService.java @@ -24,7 +24,7 @@ public QueryExercisingUserListResponse execute() { User user = userFacade.getCurrentUser(); List exercisingList = - userRepository.findAllBySchoolAndIsMeasuringTrue(user.getSchool()) + userRepository.findTop3BySchoolAndIsMeasuringTrue(user.getSchool()) .stream() .map(this::buildExercisingUserList) .collect(Collectors.toList()); diff --git a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepository.java b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepository.java index 5cf96fde7..3f7b3745f 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepository.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepository.java @@ -28,5 +28,5 @@ public interface UserRepository extends CrudRepository, UserReposito @Query("update User u set u.section = null where u.section = :section") void setUserSectionNull(@Param("section") Section section); - List findAllBySchoolAndIsMeasuringTrue(School school); + List findTop3BySchoolAndIsMeasuringTrue(School school); } From 06c6441b79198aa61a66e8fe06007547eafc5f2d Mon Sep 17 00:00:00 2001 From: Lee SeoJune Date: Wed, 2 Mar 2022 14:19:06 +0900 Subject: [PATCH 508/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20Reqeust=20dto?= =?UTF-8?q?=20paused=5Ftime?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/dto/request/FinishExerciseRequest.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/request/FinishExerciseRequest.java b/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/request/FinishExerciseRequest.java index 33c3a293d..ec09cc0e0 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/request/FinishExerciseRequest.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/request/FinishExerciseRequest.java @@ -22,4 +22,7 @@ public class FinishExerciseRequest { private String imageUrl; + @NotNull(message = "paused_time는 null, 공백을 허용하지 않습니다.") + private Integer pausedTime; + } From a593366967aa1eed6e48e20129038165b0f0c9c6 Mon Sep 17 00:00:00 2001 From: Lee SeoJune Date: Wed, 2 Mar 2022 14:19:23 +0900 Subject: [PATCH 509/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20paused=5Ftime?= =?UTF-8?q?=20column?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../walkhub/walkhub/domain/exercise/domain/Exercise.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/Exercise.java b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/Exercise.java index 4c1b95aca..ba96d0d99 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/domain/Exercise.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/domain/Exercise.java @@ -64,6 +64,9 @@ public class Exercise extends BaseTimeEntity { @Column(nullable = false, columnDefinition = "varchar(255) default " + DefaultImage.EXERCISE_IMAGE) private String imageUrl; + @Column(nullable = false, columnDefinition = "integer default 0") + private Integer pausedTime; + @Builder public Exercise(User user, Integer goal, GoalType goalType) { this.user = user; @@ -72,13 +75,14 @@ public Exercise(User user, Integer goal, GoalType goalType) { this.isExercising = true; } - public void closeExercise(Integer walkCount, Integer distance, Double calorie, String imageUrl) { + public void closeExercise(Integer walkCount, Integer distance, Double calorie, String imageUrl, Integer pausedTime) { this.walkCount = walkCount; this.distance = distance; this.calorie = calorie; this.endAt = ZonedDateTime.now(); this.imageUrl = imageUrl; this.isExercising = false; + this.pausedTime = pausedTime; } public void addCheeringCount() { From 452e0c1d4de05e6c0f46624731edb433f29823b1 Mon Sep 17 00:00:00 2001 From: Lee SeoJune Date: Wed, 2 Mar 2022 14:19:35 +0900 Subject: [PATCH 510/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20close=20exerc?= =?UTF-8?q?ise?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../walkhub/domain/exercise/service/FinishExerciseService.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/service/FinishExerciseService.java b/src/main/java/com/walkhub/walkhub/domain/exercise/service/FinishExerciseService.java index d249356dd..16e261381 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/service/FinishExerciseService.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/service/FinishExerciseService.java @@ -21,7 +21,8 @@ public void execute(Long exerciseId, FinishExerciseRequest request) { request.getWalkCount(), request.getDistance(), request.getCalorie(), - request.getImageUrl() + request.getImageUrl(), + request.getPausedTime() ); } From bec45a5eb0b87dc05cae8583fdc12a0f59f1fbbd Mon Sep 17 00:00:00 2001 From: jhhong0509 Date: Wed, 2 Mar 2022 14:41:32 +0900 Subject: [PATCH 511/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20(#499)=20User?= =?UTF-8?q?=20=EB=B9=84=EB=B0=80=EB=B2=88=ED=98=B8=20=EB=B3=80=EA=B2=BD=20?= =?UTF-8?q?API=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/walkhub/walkhub/domain/user/domain/User.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/user/domain/User.java b/src/main/java/com/walkhub/walkhub/domain/user/domain/User.java index d18e25ddf..f81ef18b3 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/domain/User.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/domain/User.java @@ -12,6 +12,8 @@ import com.walkhub.walkhub.domain.user.presentation.dto.request.UpdateUserInfoRequest; import com.walkhub.walkhub.global.entity.BaseTimeEntity; import com.walkhub.walkhub.global.enums.Authority; +import com.walkhub.walkhub.global.exception.InvalidRoleException; +import com.walkhub.walkhub.global.utils.code.RandomCodeUtil; import com.walkhub.walkhub.infrastructure.image.DefaultImage; import lombok.AccessLevel; import lombok.Builder; @@ -194,4 +196,13 @@ public void setSectionNull() { this.section = null; } + public String updateRootUserPassword() { + if (this.authority != Authority.ROOT) { + throw InvalidRoleException.EXCEPTION; + } + + this.password = RandomCodeUtil.make(8); + return this.password; + } + } From a0295a4060b6d00709b5b48f6daae992bd67529e Mon Sep 17 00:00:00 2001 From: jhhong0509 Date: Wed, 2 Mar 2022 14:42:00 +0900 Subject: [PATCH 512/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20(#499)=20Secu?= =?UTF-8?q?rityConfig=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/walkhub/walkhub/global/security/SecurityConfig.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java b/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java index b01f446da..84a509c31 100644 --- a/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java +++ b/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java @@ -132,6 +132,7 @@ protected void configure(HttpSecurity http) throws Exception { // su .antMatchers(HttpMethod.GET, "/su").hasAuthority("SU") .antMatchers(HttpMethod.POST, "/su/accounts/{school-id}").hasAuthority("SU") + .antMatchers(HttpMethod.PATCH, "/su/accounts/{school-id}").hasAuthority("SU") //excel .antMatchers(HttpMethod.GET, "/excel").hasAnyAuthority("TEACHER", "ROOT") From d2d6edb5fe38c20e96f32660f22a0a95e39810d5 Mon Sep 17 00:00:00 2001 From: jhhong0509 Date: Wed, 2 Mar 2022 14:42:23 +0900 Subject: [PATCH 513/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20(#499)=20DTO?= =?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 --- .../dto/response/UpdateSchoolPasswordResponse.java | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 src/main/java/com/walkhub/walkhub/domain/su/presentation/dto/response/UpdateSchoolPasswordResponse.java diff --git a/src/main/java/com/walkhub/walkhub/domain/su/presentation/dto/response/UpdateSchoolPasswordResponse.java b/src/main/java/com/walkhub/walkhub/domain/su/presentation/dto/response/UpdateSchoolPasswordResponse.java new file mode 100644 index 000000000..3266e3e5c --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/su/presentation/dto/response/UpdateSchoolPasswordResponse.java @@ -0,0 +1,10 @@ +package com.walkhub.walkhub.domain.su.presentation.dto.response; + +import lombok.Builder; +import lombok.Getter; + +@Getter +@Builder +public class UpdateSchoolPasswordResponse { + private final String password; +} From e51c9d7d3f08e0a1bf8d06463036d71a8cf03487 Mon Sep 17 00:00:00 2001 From: jhhong0509 Date: Wed, 2 Mar 2022 14:42:45 +0900 Subject: [PATCH 514/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20(#499)=20Exce?= =?UTF-8?q?ption=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exception/SchoolRootUserNotFoundException.java | 14 ++++++++++++++ .../walkhub/global/error/exception/ErrorCode.java | 1 + 2 files changed, 15 insertions(+) create mode 100644 src/main/java/com/walkhub/walkhub/domain/su/exception/SchoolRootUserNotFoundException.java diff --git a/src/main/java/com/walkhub/walkhub/domain/su/exception/SchoolRootUserNotFoundException.java b/src/main/java/com/walkhub/walkhub/domain/su/exception/SchoolRootUserNotFoundException.java new file mode 100644 index 000000000..0e979bdd8 --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/su/exception/SchoolRootUserNotFoundException.java @@ -0,0 +1,14 @@ +package com.walkhub.walkhub.domain.su.exception; + +import com.walkhub.walkhub.global.error.exception.ErrorCode; +import com.walkhub.walkhub.global.error.exception.WalkhubException; + +public class SchoolRootUserNotFoundException extends WalkhubException { + + public static final WalkhubException EXCEPTION = + new SchoolRootUserNotFoundException(); + + private SchoolRootUserNotFoundException() { + super(ErrorCode.ROOT_USER_NOT_FOUND); + } +} diff --git a/src/main/java/com/walkhub/walkhub/global/error/exception/ErrorCode.java b/src/main/java/com/walkhub/walkhub/global/error/exception/ErrorCode.java index 6b207c5eb..6645f6060 100644 --- a/src/main/java/com/walkhub/walkhub/global/error/exception/ErrorCode.java +++ b/src/main/java/com/walkhub/walkhub/global/error/exception/ErrorCode.java @@ -33,6 +33,7 @@ public enum ErrorCode { PHONE_NUMBER_NOT_FOUND(404, "USER-404-5", "PhoneNumber Not Found"), VERIFICATION_CODE_NOT_FOUND(404, "TEACHER-404-1", "Verification Code Not Found"), CHALLENGE_NOT_FOUND(404, "CHALLENGE-404-1", "Challenge Not Found"), + ROOT_USER_NOT_FOUND(404, "USER-404-6", "Root User Not Found."), EXERCISE_NOT_FOUND(404, "EXERCISE-404-1", "Exercise Not Found"), EXERCISE_ANALYSIS_NOT_FOUND(404, "EXERCISE-404-2", "Exercise Analysis Not Found"), From fa22b7b1258e6bc8ced9da99b5057964776ae0e6 Mon Sep 17 00:00:00 2001 From: jhhong0509 Date: Wed, 2 Mar 2022 14:43:08 +0900 Subject: [PATCH 515/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20(#499)=20Serv?= =?UTF-8?q?ice=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/UpdateSchoolPasswordService.java | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/main/java/com/walkhub/walkhub/domain/su/service/UpdateSchoolPasswordService.java diff --git a/src/main/java/com/walkhub/walkhub/domain/su/service/UpdateSchoolPasswordService.java b/src/main/java/com/walkhub/walkhub/domain/su/service/UpdateSchoolPasswordService.java new file mode 100644 index 000000000..a20670293 --- /dev/null +++ b/src/main/java/com/walkhub/walkhub/domain/su/service/UpdateSchoolPasswordService.java @@ -0,0 +1,33 @@ +package com.walkhub.walkhub.domain.su.service; + +import com.walkhub.walkhub.domain.school.domain.School; +import com.walkhub.walkhub.domain.school.facade.SchoolFacade; +import com.walkhub.walkhub.domain.su.exception.SchoolRootUserNotFoundException; +import com.walkhub.walkhub.domain.su.presentation.dto.response.UpdateSchoolPasswordResponse; +import com.walkhub.walkhub.domain.user.domain.User; +import com.walkhub.walkhub.domain.user.domain.repository.UserRepository; +import com.walkhub.walkhub.global.enums.Authority; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@RequiredArgsConstructor +@Service +public class UpdateSchoolPasswordService { + private final UserRepository userRepository; + private final SchoolFacade schoolFacade; + + @Transactional + public UpdateSchoolPasswordResponse execute(Long schoolId) { + School school = schoolFacade.getSchoolById(schoolId); + + User user = userRepository.findBySchoolAndAuthority(school, Authority.TEACHER) + .orElseThrow(() -> SchoolRootUserNotFoundException.EXCEPTION); + + String updatedPassword = user.updateRootUserPassword(); + + return UpdateSchoolPasswordResponse.builder() + .password(updatedPassword) + .build(); + } +} From 4b3cc63b071f0d253b0bb8063ea67312e53c76f9 Mon Sep 17 00:00:00 2001 From: jhhong0509 Date: Wed, 2 Mar 2022 14:43:24 +0900 Subject: [PATCH 516/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20(#499)=20Repo?= =?UTF-8?q?sitory=EC=97=90=20=ED=95=99=EA=B5=90=20=EB=B0=8F=20=EA=B6=8C?= =?UTF-8?q?=ED=95=9C=EC=9C=BC=EB=A1=9C=20=EC=A1=B0=ED=9A=8C=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 --- .../walkhub/domain/user/domain/repository/UserRepository.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepository.java b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepository.java index 295422cb1..0eeaff86e 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepository.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/domain/repository/UserRepository.java @@ -20,6 +20,8 @@ public interface UserRepository extends CrudRepository, UserReposito @Query("select u from User u left join fetch u.section where u.school = :school and u.authority = :authority") List findAllBySchoolAndAuthority(@Param("school") School school, @Param("authority") Authority authority); + Optional findBySchoolAndAuthority(School school, Authority authority); + @Transactional @Modifying @Query("update User u set u.section = null where u.section = :section") From aada8fd63ef7c16104463375183001da451e38d7 Mon Sep 17 00:00:00 2001 From: jhhong0509 Date: Wed, 2 Mar 2022 14:43:32 +0900 Subject: [PATCH 517/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20(#499)=20Cont?= =?UTF-8?q?roller=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/su/presentation/SuController.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/su/presentation/SuController.java b/src/main/java/com/walkhub/walkhub/domain/su/presentation/SuController.java index 35c1931da..90ecec7cb 100644 --- a/src/main/java/com/walkhub/walkhub/domain/su/presentation/SuController.java +++ b/src/main/java/com/walkhub/walkhub/domain/su/presentation/SuController.java @@ -2,17 +2,14 @@ import com.walkhub.walkhub.domain.su.presentation.dto.response.CreateRootAccountResponse; import com.walkhub.walkhub.domain.su.presentation.dto.response.SchoolListResponse; +import com.walkhub.walkhub.domain.su.presentation.dto.response.UpdateSchoolPasswordResponse; import com.walkhub.walkhub.domain.su.service.CreateRootAccountService; import com.walkhub.walkhub.domain.su.service.ShowSchoolService; +import com.walkhub.walkhub.domain.su.service.UpdateSchoolPasswordService; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Pageable; import org.springframework.http.HttpStatus; -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.RequestMapping; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; @RequiredArgsConstructor @@ -22,6 +19,7 @@ public class SuController { private final ShowSchoolService showSchoolService; private final CreateRootAccountService createRootAccountService; + private final UpdateSchoolPasswordService updateSchoolPasswordService; @GetMapping public SchoolListResponse showSchool(Pageable page) { @@ -33,4 +31,9 @@ public SchoolListResponse showSchool(Pageable page) { public CreateRootAccountResponse rootAccount(@PathVariable("school-id") Long schoolId) { return createRootAccountService.execute(schoolId); } + + @PatchMapping("/accounts/{school-id}") + public UpdateSchoolPasswordResponse updateRootPassword(@PathVariable("school-id") Long schoolId) { + return updateSchoolPasswordService.execute(schoolId); + } } From 188e2305bcbc5decbf170233aa3f12a00e42eb8a Mon Sep 17 00:00:00 2001 From: jhhong0509 Date: Wed, 2 Mar 2022 14:43:57 +0900 Subject: [PATCH 518/522] =?UTF-8?q?:bug:=20::=20(#499)=20=EA=B6=8C?= =?UTF-8?q?=ED=95=9C=20=EC=A1=B0=ED=9A=8C=ED=95=A0=20=EB=95=8C=20TEACHER?= =?UTF-8?q?=EC=97=90=EC=84=9C=20ROOT=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 --- .../walkhub/domain/su/service/UpdateSchoolPasswordService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/su/service/UpdateSchoolPasswordService.java b/src/main/java/com/walkhub/walkhub/domain/su/service/UpdateSchoolPasswordService.java index a20670293..6744c86e0 100644 --- a/src/main/java/com/walkhub/walkhub/domain/su/service/UpdateSchoolPasswordService.java +++ b/src/main/java/com/walkhub/walkhub/domain/su/service/UpdateSchoolPasswordService.java @@ -21,7 +21,7 @@ public class UpdateSchoolPasswordService { public UpdateSchoolPasswordResponse execute(Long schoolId) { School school = schoolFacade.getSchoolById(schoolId); - User user = userRepository.findBySchoolAndAuthority(school, Authority.TEACHER) + User user = userRepository.findBySchoolAndAuthority(school, Authority.ROOT) .orElseThrow(() -> SchoolRootUserNotFoundException.EXCEPTION); String updatedPassword = user.updateRootUserPassword(); From cc6e991b1d917423f6a62da83d736a91b6815506 Mon Sep 17 00:00:00 2001 From: Jiwoo <63524088+jeongjiwoo0522@users.noreply.github.com> Date: Wed, 2 Mar 2022 19:17:36 +0900 Subject: [PATCH 519/522] =?UTF-8?q?=F0=9F=90=9B=20::=20/challenges/lists/c?= =?UTF-8?q?losed=20URI=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/walkhub/walkhub/global/security/SecurityConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java b/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java index f64417c9f..4bffcf413 100644 --- a/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java +++ b/src/main/java/com/walkhub/walkhub/global/security/SecurityConfig.java @@ -105,7 +105,7 @@ protected void configure(HttpSecurity http) throws Exception { .antMatchers(HttpMethod.GET, "/challenges/{challenge-id}/participants/students").authenticated() .antMatchers(HttpMethod.GET, "/challenges/{challenge-id}/participants/teachers").hasAnyAuthority("TEACHER", "ROOT", "SU") .antMatchers(HttpMethod.GET, "/challenges/list").authenticated() - .antMatchers(HttpMethod.GET, "/challenges/list/closed").authenticated() + .antMatchers(HttpMethod.GET, "/challenges/lists/closed").authenticated() .antMatchers(HttpMethod.GET, "/challenges/participated").authenticated() // images From d311d92b5c4a9ba7fa6016987a5b7e0cadedae28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Wed, 2 Mar 2022 20:05:27 +0900 Subject: [PATCH 520/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20=EA=B9=83?= =?UTF-8?q?=EA=BC=AC=EC=9E=84=EC=9C=BC=EB=A1=9C=20=EC=9D=B8=ED=95=9C=20?= =?UTF-8?q?=EB=82=A0=EB=9D=BC=EA=B0=84=20=EC=BD=94=EB=93=9C=EB=93=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/repository/CalorieLevelRepository.java | 3 +++ .../dto/response/QueryChallengeDetailsResponse.java | 5 +++++ .../service/QueryChallengeDetailsService.java | 9 +++++++++ .../dto/request/CreateExerciseRequest.java | 2 ++ .../dto/response/QueryExerciseDetailsResponse.java | 2 +- .../exercise/service/QueryExerciseDetailsService.java | 2 +- .../com/walkhub/walkhub/domain/user/domain/User.java | 10 ++++++++-- .../domain/user/service/QueryUserProfileService.java | 6 ++++-- .../walkhub/domain/user/service/UserSignUpService.java | 8 ++++++++ 9 files changed, 41 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/calorielevel/domain/repository/CalorieLevelRepository.java b/src/main/java/com/walkhub/walkhub/domain/calorielevel/domain/repository/CalorieLevelRepository.java index a3e3e37dd..d849707a4 100644 --- a/src/main/java/com/walkhub/walkhub/domain/calorielevel/domain/repository/CalorieLevelRepository.java +++ b/src/main/java/com/walkhub/walkhub/domain/calorielevel/domain/repository/CalorieLevelRepository.java @@ -1,10 +1,13 @@ package com.walkhub.walkhub.domain.calorielevel.domain.repository; import com.walkhub.walkhub.domain.calorielevel.domain.CalorieLevel; +import java.util.Optional; import org.springframework.data.repository.CrudRepository; import java.util.List; public interface CalorieLevelRepository extends CrudRepository { List findAllBy(); + + Optional findByLevel(Integer level); } diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/dto/response/QueryChallengeDetailsResponse.java b/src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/dto/response/QueryChallengeDetailsResponse.java index f692db46d..af4285a89 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/dto/response/QueryChallengeDetailsResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/presenstation/dto/response/QueryChallengeDetailsResponse.java @@ -2,6 +2,7 @@ import com.walkhub.walkhub.domain.challenge.domain.type.GoalScope; import com.walkhub.walkhub.domain.exercise.domain.type.GoalType; +import com.walkhub.walkhub.global.enums.Authority; import com.walkhub.walkhub.global.enums.UserScope; import lombok.Builder; import lombok.Getter; @@ -34,5 +35,9 @@ public static class Writer{ private final Long userId; private final String name; private final String profileImageUrl; + private final Authority authority; + private final String schoolName; + private final Integer grade; + private final Integer classNum; } } diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/service/QueryChallengeDetailsService.java b/src/main/java/com/walkhub/walkhub/domain/challenge/service/QueryChallengeDetailsService.java index 7b7931393..a4cf1bcda 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/service/QueryChallengeDetailsService.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/service/QueryChallengeDetailsService.java @@ -4,6 +4,8 @@ import com.walkhub.walkhub.domain.challenge.facade.ChallengeFacade; import com.walkhub.walkhub.domain.challenge.presenstation.dto.response.QueryChallengeDetailsResponse; import com.walkhub.walkhub.domain.challenge.presenstation.dto.response.QueryChallengeDetailsResponse.Writer; +import com.walkhub.walkhub.domain.school.domain.School; +import com.walkhub.walkhub.domain.user.domain.Section; import com.walkhub.walkhub.domain.user.domain.User; import com.walkhub.walkhub.domain.user.facade.UserFacade; import com.walkhub.walkhub.global.enums.UserScope; @@ -30,6 +32,9 @@ public QueryChallengeDetailsResponse execute(Long challengeId) { throw InvalidRoleException.EXCEPTION; } + School writerSchool = writer.hasSchool() ? writer.getSchool() : School.builder().build(); + Section wrtierSection = writer.hasSection() ? writer.getSection() : Section.builder().build(); + Boolean isMine = challenge.getChallengeStatuses() .stream() .anyMatch(challengeStatus -> challengeStatus.getUser().equals(user)); @@ -53,6 +58,10 @@ public QueryChallengeDetailsResponse execute(Long challengeId) { .userId(writer.getId()) .name(writer.getName()) .profileImageUrl(writer.getProfileImageUrl()) + .authority(writer.getAuthority()) + .schoolName(writerSchool.getName()) + .classNum(wrtierSection.getClassNum()) + .grade(wrtierSection.getGrade()) .build()) .build(); } diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/request/CreateExerciseRequest.java b/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/request/CreateExerciseRequest.java index 5d06a6209..3120b00e4 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/request/CreateExerciseRequest.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/request/CreateExerciseRequest.java @@ -1,6 +1,7 @@ package com.walkhub.walkhub.domain.exercise.presentation.dto.request; import com.walkhub.walkhub.domain.exercise.domain.type.GoalType; +import javax.validation.constraints.NotNull; import lombok.Getter; import lombok.NoArgsConstructor; @@ -10,6 +11,7 @@ public class CreateExerciseRequest { private Integer goal; + @NotNull(message = "goal_type은 null, 공백을 허용x") private GoalType goalType; } diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/response/QueryExerciseDetailsResponse.java b/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/response/QueryExerciseDetailsResponse.java index a160948f1..d4b5860af 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/response/QueryExerciseDetailsResponse.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/presentation/dto/response/QueryExerciseDetailsResponse.java @@ -17,7 +17,7 @@ public class QueryExerciseDetailsResponse { @Getter @Builder public static class ExerciseResponse { - private final Integer order; + private final Integer sequence; private final BigDecimal latitude; private final BigDecimal longitude; } diff --git a/src/main/java/com/walkhub/walkhub/domain/exercise/service/QueryExerciseDetailsService.java b/src/main/java/com/walkhub/walkhub/domain/exercise/service/QueryExerciseDetailsService.java index fdefa2d0e..4aef27940 100644 --- a/src/main/java/com/walkhub/walkhub/domain/exercise/service/QueryExerciseDetailsService.java +++ b/src/main/java/com/walkhub/walkhub/domain/exercise/service/QueryExerciseDetailsService.java @@ -26,7 +26,7 @@ public QueryExerciseDetailsResponse execute(Long exerciseId) { List locations = locationRepository.findAllByExercise(exercise) .stream() .map(location -> ExerciseResponse.builder() - .order(location.getSequence()) + .sequence(location.getSequence()) .latitude(location.getLatitude()) .longitude(location.getLongitude()) .build()) diff --git a/src/main/java/com/walkhub/walkhub/domain/user/domain/User.java b/src/main/java/com/walkhub/walkhub/domain/user/domain/User.java index 28320c2ec..bbe0a74a6 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/domain/User.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/domain/User.java @@ -84,6 +84,7 @@ public class User extends BaseTimeEntity { private HealthInfo healthInfo; @NotNull + @ColumnDefault("X") @Enumerated(EnumType.STRING) @Setter private Sex sex; @@ -119,7 +120,7 @@ public class User extends BaseTimeEntity { @Builder public User(String accountId, String password, String phoneNumber, String name, Authority authority, Section section, School school, boolean isMeasuring, - Integer weight, BigDecimal height, Sex sex, Badge badge) { + Integer weight, BigDecimal height, Sex sex, Badge badge, CalorieLevel calorieLevel) { this.accountId = accountId; this.password = password; this.phoneNumber = phoneNumber; @@ -130,8 +131,9 @@ public User(String accountId, String password, String phoneNumber, String name, this.isMeasuring = isMeasuring; this.healthInfo = new HealthInfo(weight, height); this.dailyWalkCountGoal = 10000; - this.sex = sex; + if(sex != null) this.sex = sex; this.badge = badge; + this.maxLevel = calorieLevel; } public void setDeviceToken(String deviceToken) { @@ -182,6 +184,10 @@ public boolean hasSection() { return this.section != null; } + public boolean hasSchool() { + return this.school != null; + } + public void setMaxLevel(CalorieLevel calorieLevel) { this.maxLevel = calorieLevel; } diff --git a/src/main/java/com/walkhub/walkhub/domain/user/service/QueryUserProfileService.java b/src/main/java/com/walkhub/walkhub/domain/user/service/QueryUserProfileService.java index 04c46a959..2c6c6f657 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/service/QueryUserProfileService.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/service/QueryUserProfileService.java @@ -2,6 +2,7 @@ import com.walkhub.walkhub.domain.badge.domain.Badge; import com.walkhub.walkhub.domain.calorielevel.domain.CalorieLevel; +import com.walkhub.walkhub.domain.user.domain.Section; import com.walkhub.walkhub.domain.user.domain.User; import com.walkhub.walkhub.domain.user.facade.UserFacade; import com.walkhub.walkhub.domain.user.presentation.dto.response.QueryUserProfileResponse; @@ -21,14 +22,15 @@ public QueryUserProfileResponse execute(Long userId) { User user = userFacade.getUserById(userId); Badge titleBadge = user.getBadge(); CalorieLevel level = user.getMaxLevel(); + Section section = user.hasSection() ? user.getSection() : Section.builder().build(); return QueryUserProfileResponse.builder() .userId(user.getId()) .name(user.getName()) .profileImageUrl(user.getProfileImageUrl()) .schoolName(user.getSchool().getName()) - .grade(user.getSection().getGrade()) - .classNum(user.getSection().getClassNum()) + .classNum(section.getClassNum()) + .grade(section.getGrade()) .titleBadge(TitleBadge.builder() .id(titleBadge.getId()) .name(titleBadge.getName()) diff --git a/src/main/java/com/walkhub/walkhub/domain/user/service/UserSignUpService.java b/src/main/java/com/walkhub/walkhub/domain/user/service/UserSignUpService.java index 3c52bd30a..e3ba1a590 100644 --- a/src/main/java/com/walkhub/walkhub/domain/user/service/UserSignUpService.java +++ b/src/main/java/com/walkhub/walkhub/domain/user/service/UserSignUpService.java @@ -3,6 +3,9 @@ import com.walkhub.walkhub.domain.auth.presentation.dto.response.UserTokenResponse; import com.walkhub.walkhub.domain.badge.domain.Badge; import com.walkhub.walkhub.domain.badge.domain.repository.BadgeRepository; +import com.walkhub.walkhub.domain.calorielevel.domain.CalorieLevel; +import com.walkhub.walkhub.domain.calorielevel.domain.repository.CalorieLevelRepository; +import com.walkhub.walkhub.domain.calorielevel.exception.CalorieLevelNotFoundException; import com.walkhub.walkhub.domain.school.domain.School; import com.walkhub.walkhub.domain.school.domain.repository.SchoolRepository; import com.walkhub.walkhub.domain.user.domain.User; @@ -38,6 +41,7 @@ public class UserSignUpService { private final JwtTokenProvider jwtTokenProvider; private final JwtProperties jwtProperties; private final BadgeRepository badgeRepository; + private final CalorieLevelRepository calorieLevelRepository; @Transactional public UserTokenResponse execute(UserSignUpRequest request) { @@ -55,6 +59,9 @@ public UserTokenResponse execute(UserSignUpRequest request) { School school = schoolRepository.findById(request.getSchoolId()) .orElseThrow(() -> SchoolNotFoundException.EXCEPTION); + CalorieLevel calorieLevel = calorieLevelRepository.findByLevel(1) + .orElseThrow(() -> CalorieLevelNotFoundException.EXCEPTION); + User user = User.builder() .accountId(request.getAccountId()) .password(passwordEncoder.encode(request.getPassword())) @@ -67,6 +74,7 @@ public UserTokenResponse execute(UserSignUpRequest request) { .sex(request.getSex()) .isMeasuring(false) .badge(defaultTitleBadge) + .calorieLevel(calorieLevel) .build(); userRepository.save(user); From 8a7e3636b6479fb149d07beb5da237f9d187e96e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EC=84=9C?= Date: Wed, 2 Mar 2022 20:05:58 +0900 Subject: [PATCH 521/522] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20Zoned=20date?= =?UTF-8?q?=20time=20->=20local=20date?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/walkhub/walkhub/domain/rank/domain/SchoolRankId.java | 4 ++-- .../walkhub/domain/rank/presentation/RankController.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/domain/SchoolRankId.java b/src/main/java/com/walkhub/walkhub/domain/rank/domain/SchoolRankId.java index dbab6e83c..d42677c31 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/domain/SchoolRankId.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/domain/SchoolRankId.java @@ -1,9 +1,9 @@ package com.walkhub.walkhub.domain.rank.domain; +import java.time.LocalDate; import lombok.*; import java.io.Serializable; -import java.time.ZonedDateTime; @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) @@ -12,7 +12,7 @@ public class SchoolRankId implements Serializable { private Long schoolId; - private ZonedDateTime createdAt; + private LocalDate createdAt; private String dateType; } diff --git a/src/main/java/com/walkhub/walkhub/domain/rank/presentation/RankController.java b/src/main/java/com/walkhub/walkhub/domain/rank/presentation/RankController.java index c4cee281f..538347ad4 100644 --- a/src/main/java/com/walkhub/walkhub/domain/rank/presentation/RankController.java +++ b/src/main/java/com/walkhub/walkhub/domain/rank/presentation/RankController.java @@ -40,7 +40,7 @@ public UserListResponse userSearch(@PathVariable("school-id") Long schoolId, } @GetMapping("/schools") - public SchoolRankResponse querySchoolRank(@RequestParam SchoolDateType dateType) { + public SchoolRankResponse querySchoolRank(@RequestParam("schoolDateType") SchoolDateType dateType) { return querySchoolRankService.execute(dateType); } From 5d014b8c961c962fdf8f4834f1c1fb5ad4c348a0 Mon Sep 17 00:00:00 2001 From: JeongDaeHyun Date: Wed, 2 Mar 2022 20:25:40 +0900 Subject: [PATCH 522/522] =?UTF-8?q?:bug:=20::=20(#495)=20=EC=82=AC?= =?UTF-8?q?=EB=9D=BC=EC=A7=84=20=EB=A9=94=EC=86=8C=EB=93=9C=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 --- .../ChallengeStatusRepositoryCustomImpl.java | 47 ++++++++++++++++++- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java index c433ab187..e1252ed19 100644 --- a/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java +++ b/src/main/java/com/walkhub/walkhub/domain/challenge/domain/repository/ChallengeStatusRepositoryCustomImpl.java @@ -2,12 +2,21 @@ import com.querydsl.core.types.Order; import com.querydsl.core.types.OrderSpecifier; -import com.querydsl.core.types.dsl.*; +import com.querydsl.core.types.dsl.BooleanExpression; +import com.querydsl.core.types.dsl.CaseBuilder; +import com.querydsl.core.types.dsl.Expressions; +import com.querydsl.core.types.dsl.NumberExpression; +import com.querydsl.core.types.dsl.NumberPath; import com.querydsl.jpa.JPAExpressions; import com.querydsl.jpa.impl.JPAQueryFactory; import com.walkhub.walkhub.domain.challenge.domain.Challenge; import com.walkhub.walkhub.domain.challenge.domain.ChallengeStatus; -import com.walkhub.walkhub.domain.challenge.domain.repository.vo.*; +import com.walkhub.walkhub.domain.challenge.domain.repository.vo.ChallengeProgressVO; +import com.walkhub.walkhub.domain.challenge.domain.repository.vo.QChallengeProgressVO; +import com.walkhub.walkhub.domain.challenge.domain.repository.vo.QRelatedChallengeParticipantsVO; +import com.walkhub.walkhub.domain.challenge.domain.repository.vo.QShowChallengeVO; +import com.walkhub.walkhub.domain.challenge.domain.repository.vo.RelatedChallengeParticipantsVO; +import com.walkhub.walkhub.domain.challenge.domain.repository.vo.ShowChallengeVO; import com.walkhub.walkhub.domain.challenge.domain.type.ChallengeParticipantsOrder; import com.walkhub.walkhub.domain.challenge.domain.type.ChallengeParticipantsScope; import com.walkhub.walkhub.domain.challenge.domain.type.GoalScope; @@ -162,6 +171,40 @@ public List queryChallengeProgress( .fetch(); } + private BooleanExpression isChallengeSuccessFilter(Challenge challenge) { + if (challenge.getGoalScope() == GoalScope.DAY) { + return isChallengeSuccessInDayScope(challenge); + } + + return isChallengeSuccessInAllScope(challenge); + } + + private BooleanExpression isChallengeSuccessInDayScope(Challenge challenge) { + NumberPath exerciseAmount = exerciseAnalysis.distance; + + if (challenge.getGoalType() == GoalType.WALK) { + exerciseAmount = exerciseAnalysis.walkCount; + } + + return exerciseAmount.goe(challenge.getGoal()); + } + + private BooleanExpression isChallengeSuccessInAllScope(Challenge challenge) { + NumberPath exerciseAmount = exerciseAnalysis.distance; + + if (challenge.getGoalType() == GoalType.WALK) { + exerciseAmount = exerciseAnalysis.walkCount; + } + + return JPAExpressions.select(exerciseAmount.sum()) + .from(exerciseAnalysis) + .where( + exerciseAnalysis.user.eq(user), + challengeDateFilter(challenge) + ) + .goe(challenge.getGoal()); + } + private BooleanExpression userScopeFilter(ChallengeParticipantsScope challengeParticipantsScope) { if (challengeParticipantsScope == ChallengeParticipantsScope.STUDENT) { return user.authority.eq(Authority.USER);