Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YEL-167 [deploy] School -> UserGroup 변경 #349

Merged
merged 25 commits into from
Sep 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
7dcd429
YEL-158 [deploy] v1.1.92
euije Sep 9, 2023
eba4961
YEL-159 [deploy] v1.193
euije Sep 9, 2023
c46e4ea
YEL-161 [deploy] v1.194
euije Sep 10, 2023
7c0bfcf
YEL-154, 153 [deploy] v1.195
euije Sep 12, 2023
9756f2e
YEL-162 [deploy] v1.196
hyeonjeongs Sep 12, 2023
a1f8a51
Revert "v1.195" of main
euije Sep 12, 2023
8890aea
YEL-162 [deploy] v1.196
euije Sep 15, 2023
64977b8
YEL-163 [deploy] v1.197
euije Sep 17, 2023
dfa76d9
YEL-163 [feat] custom
hyeonjeongs Sep 19, 2023
82c733c
YEL-163 [feat] notification
hyeonjeongs Sep 19, 2023
b4632d2
YEL-163 [feat] custom
hyeonjeongs Sep 19, 2023
6b724b5
YEL-163 [feat] push alarm 수정
hyeonjeongs Sep 21, 2023
4956b0a
YEL-163 [feat] service 변경
Sep 21, 2023
ee92854
YEL-163 [deploy] v1.198 hotfix!!!
euije Sep 21, 2023
be392a1
YEL-166 [fix] 내림차순 정렬
hyeonjeongs Sep 22, 2023
f0d6991
YEL-166 [fix] 내림차순 정렬
hyeonjeongs Sep 22, 2023
4d6e394
YEL-167 [feat] main -> feat/YEL-167 merge
Sep 23, 2023
87c8132
YEL-169 [merge] Merge branch 'main' of https://github.com/team-yello/…
hyeonjeongs Sep 24, 2023
dc99e24
YEL-167 [feat] 예시 그룹 추가
Sep 24, 2023
fd7a660
YEL-169 [fix] notification 오류 수정
hyeonjeongs Sep 24, 2023
9dc8a40
YEL-169 [fix] notification 수정
hyeonjeongs Sep 24, 2023
fbf6365
YEL-167 [feat] School -> UserGroup 변경
Sep 24, 2023
5b5f799
YEL-167 [feat] develop merge
Sep 24, 2023
1e34a55
YEL-167 [feat] School -> UserGroup 변경
euije Sep 24, 2023
0d6046d
YEL-167 [feat] staging -> develop
Sep 24, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/docs/asciidoc/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

* link:find-onboarding-friends.html[가입한 친구 목록 불러오기]

* link:search-school.html[대학교 검색하기]
* link:search-userGroup.html[대학교 검색하기]

* link:search-department.html[대학교 학과 검색하기]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import static com.yello.server.global.common.SuccessCode.READ_USER_DETAIL_ADMIN_SUCCESS;
import static com.yello.server.global.common.SuccessCode.UPDATE_USER_DETAIL_ADMIN_SUCCESS;
import static com.yello.server.global.common.factory.PaginationFactory.createPageable;
import static com.yello.server.global.common.factory.PaginationFactory.createPageableByNameSortDescLimitTen;
import static com.yello.server.global.common.factory.PaginationFactory.createPageableLimitTen;

import com.yello.server.domain.admin.dto.request.AdminLoginRequest;
Expand All @@ -28,6 +29,7 @@
import com.yello.server.global.common.annotation.AccessTokenUser;
import com.yello.server.global.common.dto.BaseResponse;
import com.yello.server.global.common.dto.EmptyObject;
import com.yello.server.infrastructure.firebase.dto.request.NotificationCustomMessage;
import com.yello.server.infrastructure.firebase.service.NotificationService;
import javax.annotation.Nullable;
import lombok.RequiredArgsConstructor;
Expand Down Expand Up @@ -56,18 +58,21 @@ public BaseResponse<AdminLoginResponse> postAdminLogin(@RequestBody AdminLoginRe
}

@GetMapping("/user")
public BaseResponse<AdminUserResponse> getUserAdmin(@AccessTokenUser User user, @RequestParam Integer page,
public BaseResponse<AdminUserResponse> getUserAdmin(@AccessTokenUser User user,
@RequestParam Integer page,
@Nullable @RequestParam String field,
@Nullable @RequestParam String value) {
val data = (field == null && value == null)
? adminService.findUser(user.getId(), createPageableLimitTen(page))
: adminService.findUserContaining(user.getId(), createPageableLimitTen(page),
val data = (field==null && value==null)
? adminService.findUser(user.getId(), createPageableByNameSortDescLimitTen(page))
: adminService.findUserContaining(user.getId(),
createPageableByNameSortDescLimitTen(page),
field, value);
return BaseResponse.success(READ_USER_ADMIN_SUCCESS, data);
}

@GetMapping("/user/{id}")
public BaseResponse<AdminUserDetailResponse> getUserDetailAdmin(@AccessTokenUser User user, @PathVariable Long id) {
public BaseResponse<AdminUserDetailResponse> getUserDetailAdmin(@AccessTokenUser User user,
@PathVariable Long id) {
val data = adminService.findUserDetail(user.getId(), id);
return BaseResponse.success(READ_USER_DETAIL_ADMIN_SUCCESS, data);
}
Expand All @@ -86,9 +91,10 @@ public BaseResponse deleteUser(@AccessTokenUser User user, @RequestParam Long us
}

@GetMapping("/cooldown")
public BaseResponse<AdminCooldownResponse> getCooldownAdmin(@AccessTokenUser User user, @RequestParam Integer page,
public BaseResponse<AdminCooldownResponse> getCooldownAdmin(@AccessTokenUser User user,
@RequestParam Integer page,
@Nullable @RequestParam String yelloId) {
val data = yelloId == null
val data = yelloId==null
? adminService.findCooldown(user.getId(), createPageableLimitTen(page))
: adminService.findCooldownContaining(user.getId(), createPageableLimitTen(page),
yelloId);
Expand All @@ -109,7 +115,8 @@ public BaseResponse<AdminQuestionResponse> getQuestionAdmin(@AccessTokenUser Use
}

@GetMapping("/question/{id}")
public BaseResponse<AdminQuestionDetailResponse> getQuestionDetailAdmin(@AccessTokenUser User user,
public BaseResponse<AdminQuestionDetailResponse> getQuestionDetailAdmin(
@AccessTokenUser User user,
@PathVariable Long id) {
val data = adminService.findQuestionDetail(user.getId(), id);
return BaseResponse.success(READ_QUESTION_DETAIL_ADMIN_SUCCESS, data);
Expand All @@ -129,4 +136,12 @@ public BaseResponse deleteQuestion(@AccessTokenUser User user, @RequestParam Lon
adminService.deleteQuestion(user.getId(), questionId);
return BaseResponse.success(DELETE_QUESTION_ADMIN_SUCCESS);
}

@PostMapping("/notification")
public BaseResponse<EmptyObject> postCustomNotificationSendAdmin(@AccessTokenUser User user,
@RequestBody NotificationCustomMessage request) {
val data = notificationService.adminSendCustomNotification(user.getId(), request);

return BaseResponse.success(CREATE_VOTE_SUCCESS, data);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import static com.yello.server.global.common.factory.TimeFactory.toDateFormattedString;

import com.yello.server.domain.group.entity.School;
import com.yello.server.domain.group.entity.UserGroup;
import com.yello.server.domain.user.entity.User;
import lombok.Builder;

Expand All @@ -18,7 +18,7 @@ public record AdminUserContentVO(
) {

public static AdminUserContentVO of(User user) {
final School userGroup = user.getGroup();
final UserGroup userGroup = user.getGroup();

return AdminUserContentVO.builder()
.id(user.getId())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ public AdminUserResponse findUser(Long adminId, Pageable page) {
return AdminUserResponse.of(totalCount, list);
}

public AdminUserResponse findUserContaining(Long adminId, Pageable page, String field, String value) {
public AdminUserResponse findUserContaining(Long adminId, Pageable page, String field,
String value) {
// exception
final User admin = userRepository.getById(adminId);
userAdminRepository.getByUser(admin);
Expand Down Expand Up @@ -185,16 +186,18 @@ public AdminCooldownResponse findCooldown(Long adminId, Pageable page) {
return AdminCooldownResponse.of(totalCount, list);
}

public AdminCooldownResponse findCooldownContaining(Long adminId, Pageable page, String yelloId) {
public AdminCooldownResponse findCooldownContaining(Long adminId, Pageable page,
String yelloId) {
// exception
final User admin = userRepository.getById(adminId);
userAdminRepository.getByUser(admin);

// logic
final Long totalCount = cooldownRepository.countAllByYelloIdContaining(yelloId);
final List<AdminCooldownContentVO> list = cooldownRepository.findAllContaining(page, yelloId).stream()
.map(AdminCooldownContentVO::of)
.toList();
final List<AdminCooldownContentVO> list =
cooldownRepository.findAllContaining(page, yelloId).stream()
.map(AdminCooldownContentVO::of)
.toList();

return AdminCooldownResponse.of(totalCount, list);
}
Expand Down Expand Up @@ -245,8 +248,10 @@ public List<Vote> createVote(Long adminId, Long questionId, AdminQuestionVoteReq
// logic
final List<Vote> result = new ArrayList<>();
request.voteContentList().forEach((voteContent -> {
final Optional<User> sender = userRepository.findByIdNotFiltered(voteContent.senderId());
final Optional<User> receiver = userRepository.findByIdNotFiltered(voteContent.receiverId());
final Optional<User> sender =
userRepository.findByIdNotFiltered(voteContent.senderId());
final Optional<User> receiver =
userRepository.findByIdNotFiltered(voteContent.receiverId());

if (sender.isPresent() && receiver.isPresent()) {
final Vote vote = Vote.createVote(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import static com.yello.server.global.common.SuccessCode.LOGIN_SUCCESS;
import static com.yello.server.global.common.SuccessCode.ONBOARDING_FRIENDS_SUCCESS;
import static com.yello.server.global.common.SuccessCode.RE_ISSUE_TOKEN_AUTH_SUCCESS;
import static com.yello.server.global.common.SuccessCode.SCHOOL_NAME_SEARCH_SCHOOL_SUCCESS;
import static com.yello.server.global.common.SuccessCode.SIGN_UP_SUCCESS;
import static com.yello.server.global.common.SuccessCode.UNIVERSITY_NAME_SEARCH_USER_GROUP_SUCCESS;
import static com.yello.server.global.common.SuccessCode.YELLOID_VALIDATION_SUCCESS;
import static com.yello.server.global.common.factory.PaginationFactory.createPageable;

Expand All @@ -21,6 +21,7 @@
import com.yello.server.domain.authorization.dto.response.OnBoardingFriendResponse;
import com.yello.server.domain.authorization.dto.response.SignUpResponse;
import com.yello.server.domain.authorization.service.AuthService;
import com.yello.server.domain.group.entity.UserGroupType;
import com.yello.server.global.common.annotation.ServiceToken;
import com.yello.server.global.common.dto.BaseResponse;
import com.yello.server.infrastructure.slack.annotation.SlackSignUpNotification;
Expand Down Expand Up @@ -72,12 +73,12 @@ public BaseResponse<OnBoardingFriendResponse> postFriendList(
}

@GetMapping("/group/univ/name")
public BaseResponse<GroupNameSearchResponse> getSchoolList(
public BaseResponse<GroupNameSearchResponse> getUniversityList(
@NotNull @RequestParam("keyword") String keyword,
@NotNull @RequestParam("page") Integer page
) {
val data = authService.findSchoolsByKeyword(keyword, createPageable(page));
return BaseResponse.success(SCHOOL_NAME_SEARCH_SCHOOL_SUCCESS, data);
val data = authService.findGroupNameContaining(keyword, UserGroupType.UNIVERSITY, createPageable(page));
return BaseResponse.success(UNIVERSITY_NAME_SEARCH_USER_GROUP_SUCCESS, data);
}

@GetMapping("/group/univ/department")
Expand All @@ -86,7 +87,8 @@ public BaseResponse<DepartmentSearchResponse> getDepartmentList(
@NotNull @RequestParam("keyword") String keyword,
@NotNull @RequestParam("page") Integer page
) {
val data = authService.findDepartmentsByKeyword(schoolName, keyword, createPageable(page));
val data = authService.findGroupDepartmentBySchoolNameContaining(schoolName, keyword, UserGroupType.UNIVERSITY,
createPageable(page));
return BaseResponse.success(DEPARTMENT_NAME_SEARCH_BY_SCHOOL_NAME_SCHOOL_SUCCESS, data);
}

Expand All @@ -101,16 +103,15 @@ public BaseResponse<GroupNameSearchResponse> getHighSchoolList(
@NotNull @RequestParam("keyword") String keyword,
@NotNull @RequestParam("page") Integer page
) {
val data = authService.getHighSchoolList(keyword, createPageable(page));
return BaseResponse.success(SCHOOL_NAME_SEARCH_SCHOOL_SUCCESS, data);
val data = authService.findGroupNameContaining(keyword, UserGroupType.HIGH_SCHOOL, createPageable(page));
return BaseResponse.success(UNIVERSITY_NAME_SEARCH_USER_GROUP_SUCCESS, data);
}

@GetMapping("/group/high/class")
public BaseResponse<ClassNameSearchResponse> getHighSchoolClassName(
@NotNull @RequestParam("name") String schoolName,
@NotNull @RequestParam("keyword") String keyword
) {
System.out.println("sfsdfsdfs");
val data = authService.getHighSchoolClassName(schoolName, keyword);
return BaseResponse.success(CLASS_NAME_SEARCH_BY_SCHOOL_NAME_SCHOOL_SUCCESS, data);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package com.yello.server.domain.authorization.dto.response;

import com.yello.server.domain.group.entity.School;
import com.yello.server.domain.group.entity.UserGroup;
import lombok.Builder;

@Builder
public record ClassNameSearchResponse(
Long groupId
) {

public static ClassNameSearchResponse of(School school) {
public static ClassNameSearchResponse of(UserGroup userGroup) {
return ClassNameSearchResponse.builder()
.groupId(school.getId())
.groupId(userGroup.getId())
.build();
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.yello.server.domain.authorization.dto.response;

import com.yello.server.domain.group.entity.School;
import com.yello.server.domain.group.entity.UserGroup;
import lombok.Builder;

@Builder
Expand All @@ -9,10 +9,10 @@ public record DepartmentInfo(
String departmentName
) {

public static DepartmentInfo of(School school) {
public static DepartmentInfo of(UserGroup userGroup) {
return DepartmentInfo.builder()
.groupId(school.getId())
.departmentName(school.getDepartmentName())
.groupId(userGroup.getId())
.departmentName(userGroup.getSubGroupName())
.build();
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.yello.server.domain.authorization.dto.response;

import com.yello.server.domain.group.entity.School;
import com.yello.server.domain.group.entity.UserGroup;
import java.util.List;
import lombok.Builder;

Expand All @@ -10,8 +10,8 @@ public record DepartmentSearchResponse(
List<DepartmentInfo> groupList
) {

public static DepartmentSearchResponse of(int totalCount, List<School> schoolList) {
List<DepartmentInfo> departmentInfoList = schoolList.stream()
public static DepartmentSearchResponse of(int totalCount, List<UserGroup> userGroupList) {
List<DepartmentInfo> departmentInfoList = userGroupList.stream()
.map(DepartmentInfo::of)
.toList();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static com.yello.server.global.common.ErrorCode.TOKEN_ALL_EXPIRED_AUTH_EXCEPTION;
import static com.yello.server.global.common.ErrorCode.TOKEN_NOT_EXPIRED_AUTH_EXCEPTION;
import static com.yello.server.global.common.ErrorCode.YELLOID_REQUIRED_EXCEPTION;
import static com.yello.server.global.common.util.ConstantUtil.RECOMMEND_POINT;

import com.yello.server.domain.authorization.dto.ServiceTokenVO;
import com.yello.server.domain.authorization.dto.kakao.KakaoTokenInfo;
Expand All @@ -22,8 +23,9 @@
import com.yello.server.domain.friend.entity.Friend;
import com.yello.server.domain.friend.repository.FriendRepository;
import com.yello.server.domain.friend.service.FriendManager;
import com.yello.server.domain.group.entity.School;
import com.yello.server.domain.group.repository.SchoolRepository;
import com.yello.server.domain.group.entity.UserGroup;
import com.yello.server.domain.group.entity.UserGroupType;
import com.yello.server.domain.group.repository.UserGroupRepository;
import com.yello.server.domain.user.entity.User;
import com.yello.server.domain.user.repository.UserRepository;
import com.yello.server.domain.vote.service.VoteManager;
Expand All @@ -50,7 +52,7 @@
public class AuthService {

private final UserRepository userRepository;
private final SchoolRepository schoolRepository;
private final UserGroupRepository userGroupRepository;
private final FriendRepository friendRepository;
private final CooldownRepository cooldownRepository;
private final MessageQueueRepository messageQueueRepository;
Expand Down Expand Up @@ -87,7 +89,7 @@ public Boolean isYelloIdDuplicated(String yelloId) {
@Transactional
public SignUpResponse signUp(SignUpRequest signUpRequest) {
authManager.validateSignupRequest(signUpRequest);
final School group = schoolRepository.getById(signUpRequest.groupId());
final UserGroup group = userGroupRepository.getById(signUpRequest.groupId());

final User newUser = userRepository.save(User.of(signUpRequest, group));
newUser.setDeviceToken(signUpRequest.deviceToken());
Expand All @@ -104,13 +106,13 @@ public SignUpResponse signUp(SignUpRequest signUpRequest) {

@Transactional
public void recommendUser(String recommendYelloId, String userYelloId) {
if (recommendYelloId!=null && !recommendYelloId.isEmpty()) {
if (recommendYelloId != null && !recommendYelloId.isEmpty()) {
User recommendedUser = userRepository.getByYelloId(recommendYelloId);
User user = userRepository.getByYelloId(userYelloId);

recommendedUser.increaseRecommendCount();
recommendedUser.increaseRecommendPoint();
user.increaseRecommendPoint();
recommendedUser.addRecommendCount(1L);
recommendedUser.addPoint(RECOMMEND_POINT);
user.addPoint(RECOMMEND_POINT);

notificationService.sendRecommendNotification(user, recommendedUser);

Expand Down Expand Up @@ -148,19 +150,24 @@ public OnBoardingFriendResponse findOnBoardingFriends(OnBoardingFriendRequest fr
return OnBoardingFriendResponse.of(kakaoFriends.size(), pageList);
}

public GroupNameSearchResponse findSchoolsByKeyword(String keyword, Pageable pageable) {
int totalCount = schoolRepository.countDistinctSchoolNameContaining(keyword);
final List<String> nameList = schoolRepository.findDistinctSchoolNameContaining(keyword,
pageable);
public GroupNameSearchResponse findGroupNameContaining(String keyword, UserGroupType userGroupType,
Pageable pageable) {
int totalCount = userGroupRepository.countDistinctGroupNameContaining(keyword, userGroupType);
final List<String> nameList = userGroupRepository.findDistinctGroupNameContaining(keyword, userGroupType,
pageable)
.stream()
.toList();

return GroupNameSearchResponse.of(totalCount, nameList);
}

public DepartmentSearchResponse findDepartmentsByKeyword(String schoolName, String keyword,
Pageable pageable) {
int totalCount = schoolRepository.countAllBySchoolNameContaining(schoolName, keyword);
final List<School> schoolResult = schoolRepository.findAllBySchoolNameContaining(schoolName,
keyword, pageable);
return DepartmentSearchResponse.of(totalCount, schoolResult);
public DepartmentSearchResponse findGroupDepartmentBySchoolNameContaining(String schoolName, String keyword,
UserGroupType userGroupType, Pageable pageable) {
int totalCount = userGroupRepository.countAllByGroupNameContaining(schoolName, keyword, userGroupType);
final List<UserGroup> userGroupResult = userGroupRepository.findAllByGroupNameContaining(schoolName, keyword,
userGroupType, pageable);

return DepartmentSearchResponse.of(totalCount, userGroupResult);
}

@Transactional
Expand All @@ -181,16 +188,9 @@ public ServiceTokenVO reIssueToken(@NotNull ServiceTokenVO tokens) {
throw new NotExpiredTokenForbiddenException(TOKEN_NOT_EXPIRED_AUTH_EXCEPTION);
}

public GroupNameSearchResponse getHighSchoolList(String keyword, Pageable pageable) {
int totalCount = schoolRepository.countDistinctHighSchoolNameContaining(keyword);
final List<String> nameList = schoolRepository.findDistinctHighSchoolNameContaining(keyword,
pageable);
return GroupNameSearchResponse.of(totalCount, nameList);
}

public ClassNameSearchResponse getHighSchoolClassName(String schoolName, String keyword) {
School school =
schoolRepository.findHighSchoolIdBySchoolNameAndClassName(schoolName, keyword);
return ClassNameSearchResponse.of(school);
public ClassNameSearchResponse getHighSchoolClassName(String schoolName, String className) {
UserGroup userGroup =
userGroupRepository.getByGroupNameAndSubGroupName(schoolName, className, UserGroupType.HIGH_SCHOOL);
return ClassNameSearchResponse.of(userGroup);
}
}
Loading