Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/team-yello/YELLO-Server
Browse files Browse the repository at this point in the history
…into develop
  • Loading branch information
hyeonjeongs committed Mar 9, 2024
2 parents cb1a87b + 9af8a39 commit 066142b
Show file tree
Hide file tree
Showing 22 changed files with 580 additions and 176 deletions.
9 changes: 8 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,11 @@ dependencies {
// Repositories
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.amqp:spring-rabbit:3.1.1'
implementation 'org.hibernate:hibernate-core:6.4.4.Final'
implementation 'mysql:mysql-connector-java:8.0.33'

runtimeOnly 'com.h2database:h2'
runtimeOnly 'com.mysql:mysql-connector-j:8.0.31'
runtimeOnly 'com.mysql:mysql-connector-j:8.2.0'

// Validations
implementation 'org.springframework.boot:spring-boot-starter-validation'
Expand Down Expand Up @@ -88,6 +90,7 @@ dependencies {
testImplementation 'org.springframework.restdocs:spring-restdocs-mockmvc'
testImplementation 'org.springframework.security:spring-security-test'
testImplementation 'org.mockito:mockito-inline:5.2.0'
testImplementation 'org.springframework.batch:spring-batch-test'

// jwt decode
implementation 'org.bouncycastle:bcprov-jdk15on:1.69'
Expand All @@ -109,6 +112,10 @@ dependencies {
// tink
implementation 'com.google.crypto.tink:tink-android:1.4.0-rc1'
implementation 'com.google.crypto.tink:apps-rewardedads:1.10.0'

// spring batch
implementation 'org.springframework.boot:spring-boot-starter-batch'

}

asciidoctor {
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/yello/server/ServerApplication.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package com.yello.server;

import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;
import org.springframework.batch.core.configuration.support.DefaultBatchConfiguration;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;


@SpringBootApplication
@ConditionalOnMissingBean(value = DefaultBatchConfiguration.class, annotation = EnableBatchProcessing.class)
public class ServerApplication {

public static void main(String[] args) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,30 +110,34 @@ 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);
final Optional<UserData> recommended = userDataRepository.findByUserIdAndTag(recommendedUser.getId(),
UserDataType.RECOMMENDED);
final Optional<UserData> recommended =
userDataRepository.findByUserIdAndTag(recommendedUser.getId(),
UserDataType.RECOMMENDED);

recommendedUser.addRecommendCount(1L);
recommendedUser.addPointBySubscribe(RECOMMEND_POINT);
user.addPointBySubscribe(RECOMMEND_POINT);

final Optional<Cooldown> cooldown =
cooldownRepository.findByUserId(recommendedUser.getId());
cooldown.ifPresent(cooldownRepository::delete);

if (recommended.isEmpty()) {
recommendedUser.addTicketCount(1);
notificationService.sendRecommendSignupAndGetTicketNotification(recommendedUser,
user);

userDataRepository.save(UserData.of(
UserDataType.RECOMMENDED,
ZonedDateTime.now(GlobalZoneId).format(ISO_OFFSET_DATE_TIME),
recommendedUser
));
return;
}

notificationService.sendRecommendNotification(user, recommendedUser);

final Optional<Cooldown> cooldown =
cooldownRepository.findByUserId(recommendedUser.getId());
cooldown.ifPresent(cooldownRepository::delete);
}
}

Expand Down Expand Up @@ -165,22 +169,28 @@ public OnBoardingFriendResponse findOnBoardingFriends(OnBoardingFriendRequest fr
return OnBoardingFriendResponse.of(kakaoFriends.size(), pageList);
}

public GroupNameSearchResponse findGroupNameContaining(String keyword, UserGroupType userGroupType,
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();
int totalCount =
userGroupRepository.countDistinctGroupNameContaining(keyword, userGroupType);
final List<String> nameList =
userGroupRepository.findDistinctGroupNameContaining(keyword, userGroupType,
pageable)
.stream()
.toList();

return GroupNameSearchResponse.of(totalCount, nameList);
}

public DepartmentSearchResponse findGroupDepartmentBySchoolNameContaining(String schoolName, String keyword,
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);
int totalCount =
userGroupRepository.countAllByGroupNameContaining(schoolName, keyword, userGroupType);
final List<UserGroup> userGroupResult =
userGroupRepository.findAllByGroupNameContaining(schoolName, keyword,
userGroupType, pageable);

return DepartmentSearchResponse.of(totalCount, userGroupResult);
}
Expand All @@ -205,7 +215,8 @@ public ServiceTokenVO reIssueToken(@NotNull ServiceTokenVO tokens) {

public ClassNameSearchResponse getHighSchoolClassName(String schoolName, String className) {
UserGroup userGroup =
userGroupRepository.getByGroupNameAndSubGroupName(schoolName, className, UserGroupType.HIGH_SCHOOL);
userGroupRepository.getByGroupNameAndSubGroupName(schoolName, className,
UserGroupType.HIGH_SCHOOL);
return ClassNameSearchResponse.of(userGroup);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ public class EventService {

private final EventRepository eventRepository;
private final ObjectMapper objectMapper;
private final UserRepository userRepository;
private final UserDataRepository userDataRepository;
private final UserRepository userRepository;

public List<EventResponse> getEvents(Long userId) throws JsonProcessingException {
// exception
Expand Down Expand Up @@ -99,17 +99,18 @@ public List<EventResponse> getEvents(Long userId) throws JsonProcessingException
if (!eventTimeList.isEmpty()) {
final EventTime eventTime = eventTimeList.get(0);

// 현재 시각이 이벤트 시간에 유효하고, 남은 보상 카운트가 0인 이력
// 현재 시각이 이벤트 시간에 유효하고, 날짜별 기준, 남은 보상 카운트가 0인 이력
eventInstanceList.addAll(
eventRepository.findInstanceAllByEventTimeAndUser(
eventTime, user)
.stream()
.filter(eventInstance ->
eventInstance.getInstanceDate().isAfter(event.getStartDate())
&& eventInstance.getInstanceDate().isBefore(event.getEndDate())
&& eventInstance.getInstanceDate().toLocalDate().isEqual(now.toLocalDate())
&& nowTime.isAfter(eventInstance.getEventTime().getStartTime())
&& nowTime.isBefore(eventInstance.getEventTime().getEndTime())
&& eventInstance.getRemainEventCount()==0
&& eventInstance.getRemainEventCount() == 0
)
.toList()
);
Expand Down Expand Up @@ -278,7 +279,7 @@ public EventRewardResponse rewardAdmob(Long userId, AdmobRewardRequest request)
}

// history 있으면 userId로 세팅
if (eventHistory.get().getUser()!=null) {
if (eventHistory.get().getUser() != null) {
throw new EventForbiddenException(DUPLICATE_ADMOB_REWARD_EXCEPTION);
}
eventHistory.get().update(user);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,5 @@ List<User> findAllByOtherGroupContainingYelloId(@Param("groupName") String group
@Query("select u from User u "
+ "where LOWER(u.name) like LOWER(CONCAT('%', :name, '%'))")
Page<User> findAllByNameContaining(Pageable pageable, @Param("name") String name);

}
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,5 @@ List<User> findAllByOtherGroupContainingYelloId(String groupName, String keyword
Page<User> findAllByNameContaining(Pageable pageable, String name);

void delete(User user);

}
Original file line number Diff line number Diff line change
Expand Up @@ -192,4 +192,6 @@ public Page<User> findAllByNameContaining(Pageable pageable, String name) {
public void delete(User user) {
userJpaRepository.delete(user);
}


}
Loading

0 comments on commit 066142b

Please sign in to comment.