Skip to content

Commit

Permalink
YEL-163 [deploy] v1.198
Browse files Browse the repository at this point in the history
YEL-163 [deploy] v1.198
  • Loading branch information
euije authored Sep 29, 2023
2 parents f0d6991 + 2375fb9 commit f61da95
Show file tree
Hide file tree
Showing 73 changed files with 9,995 additions and 2,570 deletions.
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 @@ -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
@@ -1,24 +1,27 @@
package com.yello.server.domain.authorization.controller;

import static com.yello.server.global.common.SuccessCode.CLASS_NAME_SEARCH_BY_SCHOOL_NAME_SCHOOL_SUCCESS;
import static com.yello.server.global.common.SuccessCode.DEPARTMENT_NAME_SEARCH_BY_SCHOOL_NAME_SCHOOL_SUCCESS;
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;

import com.yello.server.domain.authorization.dto.ServiceTokenVO;
import com.yello.server.domain.authorization.dto.request.OAuthRequest;
import com.yello.server.domain.authorization.dto.request.OnBoardingFriendRequest;
import com.yello.server.domain.authorization.dto.request.SignUpRequest;
import com.yello.server.domain.authorization.dto.response.ClassNameSearchResponse;
import com.yello.server.domain.authorization.dto.response.DepartmentSearchResponse;
import com.yello.server.domain.authorization.dto.response.GroupNameSearchResponse;
import com.yello.server.domain.authorization.dto.response.OAuthResponse;
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 @@ -54,7 +57,8 @@ public BaseResponse<Boolean> getYelloIdValidation(@RequestParam("yelloId") Strin

@PostMapping("/signup")
@SlackSignUpNotification
public BaseResponse<SignUpResponse> postSignUp(@Valid @RequestBody SignUpRequest signUpRequest) {
public BaseResponse<SignUpResponse> postSignUp(
@Valid @RequestBody SignUpRequest signUpRequest) {
val data = authService.signUp(signUpRequest);
return BaseResponse.success(SIGN_UP_SUCCESS, data);
}
Expand All @@ -68,22 +72,23 @@ public BaseResponse<OnBoardingFriendResponse> postFriendList(
return BaseResponse.success(ONBOARDING_FRIENDS_SUCCESS, data);
}

@GetMapping("/school")
public BaseResponse<GroupNameSearchResponse> getSchoolList(
@GetMapping("/group/univ/name")
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("/school/department")
@GetMapping("/group/univ/department")
public BaseResponse<DepartmentSearchResponse> getDepartmentList(
@NotNull @RequestParam("school") String schoolName,
@NotNull @RequestParam("name") String schoolName,
@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 @@ -92,4 +97,22 @@ public BaseResponse<ServiceTokenVO> postReIssueToken(@ServiceToken ServiceTokenV
val data = authService.reIssueToken(tokens);
return BaseResponse.success(RE_ISSUE_TOKEN_AUTH_SUCCESS, data);
}

@GetMapping("/group/high/name")
public BaseResponse<GroupNameSearchResponse> getHighSchoolList(
@NotNull @RequestParam("keyword") String keyword,
@NotNull @RequestParam("page") Integer page
) {
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
) {
val data = authService.getHighSchoolClassName(schoolName, keyword);
return BaseResponse.success(CLASS_NAME_SEARCH_BY_SCHOOL_NAME_SCHOOL_SUCCESS, data);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.yello.server.domain.authorization.dto.response;

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

@Builder
public record ClassNameSearchResponse(
Long groupId
) {

public static ClassNameSearchResponse of(UserGroup userGroup) {
return ClassNameSearchResponse.builder()
.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,12 +3,14 @@
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;
import com.yello.server.domain.authorization.dto.request.OAuthRequest;
import com.yello.server.domain.authorization.dto.request.OnBoardingFriendRequest;
import com.yello.server.domain.authorization.dto.request.SignUpRequest;
import com.yello.server.domain.authorization.dto.response.ClassNameSearchResponse;
import com.yello.server.domain.authorization.dto.response.DepartmentSearchResponse;
import com.yello.server.domain.authorization.dto.response.GroupNameSearchResponse;
import com.yello.server.domain.authorization.dto.response.OAuthResponse;
Expand All @@ -21,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 @@ -49,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 @@ -86,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 @@ -107,9 +110,9 @@ public void recommendUser(String recommendYelloId, String userYelloId) {
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 All @@ -129,7 +132,7 @@ public void makeFriend(User user, List<Long> friendIds) {
Friend savedFriend =
friendRepository.save(Friend.createFriend(user, friend.get()));
friendRepository.save(Friend.createFriend(friend.get(), user));

notificationService.sendFriendNotification(savedFriend);
}
});
Expand All @@ -147,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 @@ -179,4 +187,10 @@ public ServiceTokenVO reIssueToken(@NotNull ServiceTokenVO tokens) {

throw new NotExpiredTokenForbiddenException(TOKEN_NOT_EXPIRED_AUTH_EXCEPTION);
}

public ClassNameSearchResponse getHighSchoolClassName(String schoolName, String className) {
UserGroup userGroup =
userGroupRepository.getByGroupNameAndSubGroupName(schoolName, className, UserGroupType.HIGH_SCHOOL);
return ClassNameSearchResponse.of(userGroup);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static FriendResponse of(User user) {
return FriendResponse.builder()
.id(user.getId())
.name(user.getName())
.group(user.groupString())
.group(user.toGroupString())
.profileImage(user.getProfileImage())
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static SearchFriendVO of(User user, Boolean isFriend) {
return SearchFriendVO.builder()
.id(user.getId())
.name(user.getName())
.group(user.groupString())
.group(user.toGroupString())
.profileImage(user.getProfileImage())
.yelloId(user.getYelloId())
.isFriend(isFriend)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public RecommendFriendResponse findAllRecommendSchoolFriends(Pageable pageable,
final User user = userRepository.getById(userId);

List<User> recommendFriends =
userRepository.findAllByGroupId(user.getGroup().getSchoolName())
userRepository.findAllByGroupId(user.getGroup().getId())
.stream()
.filter(target -> !userId.equals(target.getId()))
.filter(target -> !friendRepository.existsByUserAndTarget(userId, target.getId()))
Expand Down Expand Up @@ -131,12 +131,12 @@ public RecommendFriendResponse findAllRecommendKakaoFriends(Pageable pageable, L
public SearchFriendResponse searchFriend(Long userId, Pageable pageable,
String keyword) {
final User user = userRepository.getById(userId);
final String groupName = user.getGroup().getSchoolName();
final String groupName = user.getGroup().getGroupName();
List<String> uuidList = Arrays.asList(YELLO_FEMALE, YELLO_MALE);

List<User> friendList = new ArrayList<>();

if (keyword==null || keyword.trim().isEmpty()) {
if (keyword == null || keyword.trim().isEmpty()) {
return SearchFriendResponse.of(0, Collections.emptyList());
}

Expand Down Expand Up @@ -165,7 +165,7 @@ public SearchFriendResponse searchFriend(Long userId, Pageable pageable,

public boolean isEnglish(String keyword) {
for (char c : keyword.toCharArray()) {
if (Character.UnicodeBlock.of(c)!=UnicodeBlock.BASIC_LATIN) {
if (Character.UnicodeBlock.of(c) != UnicodeBlock.BASIC_LATIN) {
return false;
}
}
Expand Down
56 changes: 0 additions & 56 deletions src/main/java/com/yello/server/domain/group/entity/School.java

This file was deleted.

Loading

0 comments on commit f61da95

Please sign in to comment.