Skip to content

Commit

Permalink
Merge pull request #241 from EveryUniv/dev
Browse files Browse the repository at this point in the history
Release dev_deploy
  • Loading branch information
gutanbug authored Oct 24, 2024
2 parents 1433a9d + 883fbfa commit f8bd64b
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,4 @@ api.pdf

### Firebase ###
**/src/main/resources/**/**.json
**/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
import com.dku.council.domain.user.model.dto.response.ResponseScrappedStudentInfoDto;
import com.dku.council.domain.user.model.dto.response.ResponseVerifyStudentDto;
import com.dku.council.domain.user.service.DKUAuthService;
import com.dku.council.domain.user.service.UserService;
import com.dku.council.global.auth.jwt.AppAuthentication;
import com.dku.council.global.auth.role.UserAuth;
import com.dku.council.global.model.dto.ResponseBooleanDto;
import com.dku.council.infra.dku.service.DkuAuthBatchService;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
Expand All @@ -23,6 +25,17 @@ public class DKUController {
private final DKUAuthService service;
private final DkuAuthBatchService renewingAccountService;

/**
* 단국대학교 인증 확인
* <p>단국대학교 학생 인증이 되어 있는지 확인하기 위한 API 입니다.</p>
*/
@GetMapping("/check")
@UserAuth
public ResponseBooleanDto checkDKUAuth(AppAuthentication auth) {
boolean result = service.checkDkuAuth(auth.getUserId());
return new ResponseBooleanDto(result);
}

/**
* 단국대학교 학생 인증
* <p>학생 인증을 진행합니다. 성공시 반환되는 토큰은 회원가입에 사용됩니다.</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,10 @@ private Major retrieveMajor(String majorName, String departmentName) {
return entity;
});
}

public boolean checkDkuAuth(Long userId) {
return userRepository.findById(userId)
.orElseThrow(UserNotFoundException::new)
.isDkuChecked();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.dku.council.domain.with_dankook.exception;

import com.dku.council.global.error.exception.LocalizedMessageException;
import org.springframework.http.HttpStatus;

public class InvalidTimeException extends LocalizedMessageException {
public InvalidTimeException() {
super(HttpStatus.FORBIDDEN, "invalid.time");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.dku.council.domain.post.repository.PostTimeMemoryRepository;
import com.dku.council.domain.user.model.entity.User;
import com.dku.council.domain.user.repository.UserRepository;
import com.dku.council.domain.with_dankook.exception.InvalidTimeException;
import com.dku.council.domain.with_dankook.exception.WithDankookNotFoundException;
import com.dku.council.domain.with_dankook.model.dto.list.SummarizedBearEatsDto;
import com.dku.council.domain.with_dankook.model.dto.list.SummarizedBearEatsPossibleReviewDto;
Expand Down Expand Up @@ -35,6 +36,7 @@
import java.time.Clock;
import java.time.Duration;
import java.time.Instant;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
Expand Down Expand Up @@ -71,6 +73,7 @@ public Long create(Long userId, RequestCreateBearEatsDto dto) {
throw new PostCooltimeException("bear-eats");
}

checkTime(dto.getDeliveryTime());
Long result = withDankookService.create(bearEatsRepository, userId, dto);

WithDankookUser withDankookuser = WithDankookUser.builder()
Expand All @@ -88,6 +91,12 @@ public Long create(Long userId, RequestCreateBearEatsDto dto) {
return result;
}

private void checkTime(LocalDateTime deliveryTime) {
if (deliveryTime.isBefore(LocalDateTime.now(clock))) {
throw new InvalidTimeException();
}
}

public Page<SummarizedBearEatsDto> list(String keyword, Pageable pageable, int bodySize) {
Specification<BearEats> spec = WithDankookSpec.withTitleOrBody(keyword);
spec = spec.and(WithDankookSpec.withActive());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.dku.council.domain.user.model.entity.User;
import com.dku.council.domain.user.repository.UserRepository;
import com.dku.council.domain.with_dankook.exception.InvalidMinStudentIdException;
import com.dku.council.domain.with_dankook.exception.InvalidTimeException;
import com.dku.council.domain.with_dankook.exception.StudyCooltimeException;
import com.dku.council.domain.with_dankook.exception.WithDankookNotFoundException;
import com.dku.council.domain.with_dankook.model.dto.list.SummarizedStudyDto;
Expand Down Expand Up @@ -37,6 +38,7 @@
import java.time.Clock;
import java.time.Duration;
import java.time.Instant;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
Expand Down Expand Up @@ -73,6 +75,8 @@ public Long create(Long userId, RequestCreateStudyDto dto) {
throw new StudyCooltimeException("study");
}

checkTime(dto.getStartTime(), dto.getEndTime());

// 게시글에 작성한 태그 등록
StudyTag studyTag = retrieveStudyTag(dto.getTag());

Expand All @@ -83,6 +87,7 @@ public Long create(Long userId, RequestCreateStudyDto dto) {
.startTime(dto.getStartTime())
.endTime(dto.getEndTime())
.tag(studyTag)
.kakaoOpenChatLink(dto.getKakaoOpenChatLink())
.content(dto.getBody())
.build();

Expand All @@ -101,6 +106,15 @@ public Long create(Long userId, RequestCreateStudyDto dto) {
return result;
}

private void checkTime(LocalDateTime startTime, LocalDateTime endTime) {
if (startTime.isBefore(LocalDateTime.now())) {
throw new InvalidTimeException();
}
if (endTime.isBefore(startTime)) {
throw new InvalidTimeException();
}
}

private StudyTag retrieveStudyTag (String tagName) {
return studyTagRepository.findByName(tagName)
.orElseGet(() -> {
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/errors.properties
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ invalid.create-review-to-myself=\uC790\uC2E0\uC5D0\uAC8C\uB294 \uB9AC\uBDF0 \uC7
invalid.mbti=MBTI\uAC00 \uC62C\uBC14\uB974\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4.
invalid.chat-room-user=\uD574\uB2F9 \uCC44\uD305\uBC29\uC5D0\uC11C \uCC38\uC5EC\uC911\uC778 \uC720\uC800\uAC00 \uC544\uB2D9\uB2C8\uB2E4.
invalid.banner-type=\uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 \uBC30\uB108 \uD0C0\uC785\uC785\uB2C8\uB2E4: {0}
invalid.time=\uC62C\uBC14\uB978 \uC2DC\uAC04\uC744 \uC785\uB825\uD574\uC8FC\uC138\uC694.

notfound.user=\uC720\uC800\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4.
notfound.post=\uD574\uB2F9 \uAC8C\uC2DC\uAE00\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4.
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/errors_en_US.properties
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ invalid.create-review-to-myself=You can't write a review to yourself.
invalid.mbti=Invalid MBTI.
invalid.chat-room-user=You are not a participating user in this chat room.
invalid.banner-type=Unsupported banner type: {0}
invalid.time=Invalid time.

notfound.user=Cannot find that user.
notfound.post=No such post was found.
Expand Down

0 comments on commit f8bd64b

Please sign in to comment.