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

Feature/#430 야구게임 베팅금액, 획득금액을 변경한다. #440

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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 .github/workflows/deploy_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Deploy Keeper Development Server

on:
push:
branches: [develop]
branches: [ develop ]

jobs:
deploy_development:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy_prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Deploy Keeper Production Server

on:
push:
branches: [master]
branches: [ master ]

jobs:
deploy_production:
Expand Down
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ KEEPER 홈페이지 백엔드 서버입니다.

# 📝 링크

| 이름 | 링크 |
|----------------------|------------------------------------------------------------------------------------------------------------------|
| 운영 홈페이지 | [keeper.or.kr](https://keeper.or.kr) |
| 개발 홈페이지 | [dev.keeper.or.kr](https://dev.keeper.or.kr) |
| API 문서 | [api.keeper.or.kr/docs/keeper.html](https://api.keeper.or.kr/docs/keeper.html) |
| Notion | [Notion Link](https://chip-force-ed0.notion.site/KEEPER-0dbccc3c2374465b8be715cd9d872103?pvs=4) |
| 프론트 Repository | [Homepage-Front-R2](https://github.com/KEEPER31337/Homepage-Front-R2) |
| 인프라 코드 Repository | [Homepage-Infrastructure](https://github.com/KEEPER31337/Homepage-Infrastructure) |
| 데이터베이스 코드 Repository | [Homepage-Database](https://github.com/KEEPER31337/Homepage-Database) |
| 이름 | 링크 |
|----------------------|-------------------------------------------------------------------------------------------------|
| 운영 홈페이지 | [keeper.or.kr](https://keeper.or.kr) |
| 개발 홈페이지 | [dev.keeper.or.kr](https://dev.keeper.or.kr) |
| API 문서 | [api.keeper.or.kr/docs/keeper.html](https://api.keeper.or.kr/docs/keeper.html) |
| Notion | [Notion Link](https://chip-force-ed0.notion.site/KEEPER-0dbccc3c2374465b8be715cd9d872103?pvs=4) |
| 프론트 Repository | [Homepage-Front-R2](https://github.com/KEEPER31337/Homepage-Front-R2) |
| 인프라 코드 Repository | [Homepage-Infrastructure](https://github.com/KEEPER31337/Homepage-Infrastructure) |
| 데이터베이스 코드 Repository | [Homepage-Database](https://github.com/KEEPER31337/Homepage-Database) |

# ✨ 도메인

Expand Down
67 changes: 34 additions & 33 deletions images/logo_neon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
430 changes: 215 additions & 215 deletions intellij-java-google-style.xml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ public ResponseEntity<StaticWriteTitleTypeResponse> getAllTypes() {
}

@GetMapping("/titles/types/{type}")
public ResponseEntity<StaticWriteTitleResponse> getTitleByType(@PathVariable @NotNull String type) {
public ResponseEntity<StaticWriteTitleResponse> getTitleByType(
@PathVariable @NotNull String type) {
StaticWriteTitleResponse response = staticWriteService.getTitleByType(type);
return ResponseEntity.status(HttpStatus.OK)
.body(response);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ public StaticWriteTitleTypeResponse getAllTypes() {
}

public StaticWriteTitleResponse getTitleByType(String type) {
StaticWriteTitle staticWriteTitle = staticWriteTitleRepository.findByStaticWriteTitleType(StaticWriteTitleType.fromCode(type))
StaticWriteTitle staticWriteTitle = staticWriteTitleRepository.findByStaticWriteTitleType(
StaticWriteTitleType.fromCode(type))
.orElseThrow(() -> new BusinessException(type, "type", TITLE_TYPE_NOT_FOUND));
return StaticWriteTitleResponse.from(staticWriteTitle);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ public static StaticWriteSubTitleImageResponse from(StaticWriteSubtitleImage sub
return StaticWriteSubTitleImageResponse.builder()
.id(subtitleImage.getId())
.subtitle(subtitleImage.getSubtitle())
.thumbnailPath(subtitleImage.getThumbnail() != null ? subtitleImage.getThumbnail().getPath() : null)
.thumbnailPath(
subtitleImage.getThumbnail() != null ? subtitleImage.getThumbnail().getPath() : null)
.displayOrder(subtitleImage.getDisplayOrder())
.staticWriteContents(subtitleImage.getStaticWriteContents().stream()
.map(StaticWriteContentResponse::from)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ private int getRankPoint(int rank) {
}

private int getContinuousDay(Member member, LocalDate now) {
Attendance yesterdayAttendance = attendanceRepository.findByMemberAndDate(member, now.minusDays(1))
Attendance yesterdayAttendance = attendanceRepository.findByMemberAndDate(member,
now.minusDays(1))
.orElse(null);
if (yesterdayAttendance == null) {
return 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public interface AttendanceRepository extends JpaRepository<Attendance, Long> {
@Query("SELECT a FROM Attendance a "
+ "WHERE a.member = :member "
+ "AND a.date >= :localDate")
List<Attendance> findAllRecent(@Param("member") Member member, @Param("localDate") LocalDate localDate);
List<Attendance> findAllRecent(@Param("member") Member member,
@Param("localDate") LocalDate localDate);

}
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,26 @@ public ResponseEntity<Void> findLoginId(@RequestBody @Email FindLoginIdRequest r
@PostMapping("/send-password-change-auth-code")
public ResponseEntity<EmailAuthResponse> sendPasswordChangeAuthCode(
@RequestBody @Valid MemberIdAndEmailRequest request) {
int expiredSeconds = signInService.sendPasswordChangeAuthCode(EmailAddress.from(request.getEmail()),
int expiredSeconds = signInService.sendPasswordChangeAuthCode(
EmailAddress.from(request.getEmail()),
LoginId.from(request.getLoginId()));
return ResponseEntity.ok(EmailAuthResponse.from(expiredSeconds));
}

@GetMapping("/check-auth-code")
public ResponseEntity<CheckAuthCodeResponse> checkAuthCode(String email, String loginId, String authCode) {
boolean isAuth = signInService.isAuthenticated(EmailAddress.from(email), LoginId.from(loginId), authCode);
public ResponseEntity<CheckAuthCodeResponse> checkAuthCode(String email, String loginId,
String authCode) {
boolean isAuth = signInService.isAuthenticated(EmailAddress.from(email), LoginId.from(loginId),
authCode);
return ResponseEntity.ok(CheckAuthCodeResponse.from(isAuth));
}

@PatchMapping("/change-password-for-missing")
public ResponseEntity<Void> changePassword(
@RequestBody @Valid ChangePasswordForMissingRequest request) {
signInService.changePassword(request.getAuthCode(),
LoginId.from(request.getLoginId()), EmailAddress.from(request.getEmail()), request.getRawPassword());
LoginId.from(request.getLoginId()), EmailAddress.from(request.getEmail()),
request.getRawPassword());
return ResponseEntity.noContent().build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,20 @@ public class AuthCookieService {
private final JwtTokenProvider jwtTokenProvider;
private final RedisUtil redisUtil;

public void setNewCookieInResponse(String authId, String[] roles, String userAgent, HttpServletResponse response) {
public void setNewCookieInResponse(String authId, String[] roles, String userAgent,
HttpServletResponse response) {
String newRefreshToken = jwtTokenProvider.createAccessToken(REFRESH_TOKEN, authId, roles);
setTokenInCookie(response, newRefreshToken, (int) REFRESH_TOKEN.getExpiredMillis() / 1000,
REFRESH_TOKEN.getTokenName());
String newAccessToken = jwtTokenProvider.createAccessToken(ACCESS_TOKEN, authId, roles);
setTokenInCookie(response, newAccessToken, (int) REFRESH_TOKEN.getExpiredMillis() / 1000,
ACCESS_TOKEN.getTokenName());
redisUtil.setDataExpire(JwtTokenProvider.getRefreshTokenKeyForRedis(authId, userAgent), newRefreshToken, REFRESH_TOKEN.getExpiredMillis());
redisUtil.setDataExpire(JwtTokenProvider.getRefreshTokenKeyForRedis(authId, userAgent),
newRefreshToken, REFRESH_TOKEN.getExpiredMillis());
}

private void setTokenInCookie(HttpServletResponse httpResponse, String token, int expiredSeconds, String cookieName) {
private void setTokenInCookie(HttpServletResponse httpResponse, String token, int expiredSeconds,
String cookieName) {
ResponseCookie cookie = ResponseCookie.from(cookieName, token)
.path("/")
.sameSite("None")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,10 @@ public int sendPasswordChangeAuthCode(EmailAddress email, LoginId loginId) {
.orElseThrow(() -> new BusinessException(email.get(), "email", ErrorCode.MEMBER_NOT_FOUND));

String authCode = generateRandomAuthCode();
redisUtil.setDataExpire(PASSWORD_AUTH_CODE_KEY + member.getId(), authCode, AUTH_CODE_EXPIRE_MILLIS);
mailUtil.sendMail(List.of(email.get()), "KEEPER 비밀번호 변경 인증 코드입니다.", "회원님의 비밀번호 변경 인증 코드: " + authCode);
redisUtil.setDataExpire(PASSWORD_AUTH_CODE_KEY + member.getId(), authCode,
AUTH_CODE_EXPIRE_MILLIS);
mailUtil.sendMail(List.of(email.get()), "KEEPER 비밀번호 변경 인증 코드입니다.",
"회원님의 비밀번호 변경 인증 코드: " + authCode);

return AUTH_CODE_EXPIRE_MILLIS / 1000;
}
Expand All @@ -94,12 +96,14 @@ public boolean isAuthenticated(EmailAddress email, LoginId loginId, String reque
Member member = memberRepository.findByProfileEmailAddressAndProfileLoginId(email, loginId)
.orElseThrow(() -> new BusinessException(email.get(), "email", ErrorCode.MEMBER_NOT_FOUND));

Optional<String> data = redisUtil.getData(PASSWORD_AUTH_CODE_KEY + member.getId(), String.class);
Optional<String> data = redisUtil.getData(PASSWORD_AUTH_CODE_KEY + member.getId(),
String.class);
return data.map(correctAuthCode -> correctAuthCode.equals(requestAuthCode)).orElse(false);
}

@Transactional
public void changePassword(String authCode, LoginId loginId, EmailAddress email, String rawPassword) {
public void changePassword(String authCode, LoginId loginId, EmailAddress email,
String rawPassword) {
if (!isAuthenticated(email, loginId, authCode)) {
throw new BusinessException(authCode, "authCode", ErrorCode.AUTH_CODE_MISMATCH);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ public CommentListResponse getComments(Member member, Long postId) {
List<CommentResponse> commentResponses = comments.stream()
.map(comment -> {
if (post.isCategory(익명게시판)) {
return CommentResponse.of(comment, ANONYMOUS_NAME, null, member.isLike(comment), member.isDislike(comment));
return CommentResponse.of(comment, ANONYMOUS_NAME, null, member.isLike(comment),
member.isDislike(comment));
}
return CommentResponse.from(comment, member.isLike(comment), member.isDislike(comment));
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ public interface CommentRepository extends JpaRepository<Comment, Long> {
@Query("UPDATE Comment c "
+ "SET c.member = :virtualMember "
+ "WHERE c.member = :member")
void updateVirtualMember(@Param("member") Member member, @Param("virtualMember") Member virtualMember);
void updateVirtualMember(@Param("member") Member member,
@Param("virtualMember") Member virtualMember);
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ public static CommentResponse from(Comment comment, boolean isLike, boolean isDi
.build();
}

public static CommentResponse of(Comment comment, String writerName, String writerThumbnailPath, boolean isLike,
public static CommentResponse of(Comment comment, String writerName, String writerThumbnailPath,
boolean isLike,
boolean isDislike) {
return CommentResponse.builder()
.commentId(comment.getId())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ public ResponseEntity<Void> updateContest(
@PathVariable long contestId,
@RequestBody @Valid UpdateContestRequest request
) {
ctfContestService.updateContest(contestId, request.getName(), request.getDescription(), request.isJoinable());
ctfContestService.updateContest(contestId, request.getName(), request.getDescription(),
request.isJoinable());
return ResponseEntity.status(HttpStatus.CREATED)
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ public ResponseEntity<Void> createTeam(
@LoginMember Member member,
@RequestBody @Valid CreateTeamRequest request
) {
ctfTeamService.createTeam(member, request.getName(), request.getDescription(), request.getContestId());
ctfTeamService.createTeam(member, request.getName(), request.getDescription(),
request.getContestId());
return ResponseEntity.status(HttpStatus.CREATED)
.build();
}
Expand Down Expand Up @@ -69,7 +70,8 @@ public ResponseEntity<Page<CtfTeamResponse>> getTeams(
@RequestParam(defaultValue = "0") @PositiveOrZero int page,
@RequestParam(defaultValue = "10") @PositiveOrZero int size
) {
return ResponseEntity.ok(ctfTeamService.getTeams(contestId, search, PageRequest.of(page, size)));
return ResponseEntity.ok(
ctfTeamService.getTeams(contestId, search, PageRequest.of(page, size)));
}

@PostMapping("/{teamId}/members/{memberId}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ public CtfTeamDetailResponse getTeam(long teamId) {

public Page<CtfTeamResponse> getTeams(long contestId, String search, Pageable pageable) {
CtfContest contest = ctfContestFindService.findJoinableById(contestId);
return ctfTeamRepository.findAllByCtfContestAndNameIgnoreCaseContaining(contest, search, pageable)
return ctfTeamRepository.findAllByCtfContestAndNameIgnoreCaseContaining(contest, search,
pageable)
.map(CtfTeamResponse::from);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

@Converter
@Slf4j
public class CtfChallengeCategoryTypeConverter implements AttributeConverter<CtfChallengeCategoryType, String> {
public class CtfChallengeCategoryTypeConverter implements
AttributeConverter<CtfChallengeCategoryType, String> {

@Override
public String convertToDatabaseColumn(CtfChallengeCategoryType type) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public interface CtfContestRepository extends JpaRepository<CtfContest, Long> {
@Query("UPDATE CtfContest c "
+ "SET c.creator = :virtualMember "
+ "WHERE c.creator = :member")
void updateVirtualMember(@Param("member") Member member, @Param("virtualMember") Member virtualMember);
void updateVirtualMember(@Param("member") Member member,
@Param("virtualMember") Member virtualMember);

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.keeper.homepage.domain.ctf.entity.challenge.CtfChallengeHasCtfChallengeCategory;
import org.springframework.data.jpa.repository.JpaRepository;

public interface CtfChallengeHasCtfChallengeCategoryRepository extends JpaRepository<CtfChallengeHasCtfChallengeCategory, Long> {
public interface CtfChallengeHasCtfChallengeCategoryRepository extends
JpaRepository<CtfChallengeHasCtfChallengeCategory, Long> {

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.keeper.homepage.domain.ctf.entity.challenge.CtfChallengeHasFilePK;
import org.springframework.data.jpa.repository.JpaRepository;

public interface CtfChallengeHasFileRepository extends JpaRepository<CtfChallengeHasFile, CtfChallengeHasFilePK> {
public interface CtfChallengeHasFileRepository extends
JpaRepository<CtfChallengeHasFile, CtfChallengeHasFilePK> {

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public interface CtfChallengeRepository extends JpaRepository<CtfChallenge, Long
@Query("UPDATE CtfChallenge c "
+ "SET c.creator = :virtualMember "
+ "WHERE c.creator = :member")
void updateVirtualMember(@Param("member") Member member, @Param("virtualMember") Member virtualMember);
void updateVirtualMember(@Param("member") Member member,
@Param("virtualMember") Member virtualMember);

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.keeper.homepage.domain.ctf.entity.challenge.CtfDynamicChallengeInfo;
import org.springframework.data.jpa.repository.JpaRepository;

public interface CtfDynamicChallengeInfoRepository extends JpaRepository<CtfDynamicChallengeInfo, Long> {
public interface CtfDynamicChallengeInfoRepository extends
JpaRepository<CtfDynamicChallengeInfo, Long> {

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.keeper.homepage.domain.ctf.entity.team.CtfTeamHasMemberPK;
import org.springframework.data.jpa.repository.JpaRepository;

public interface CtfTeamHasMemberRepository extends JpaRepository<CtfTeamHasMember, CtfTeamHasMemberPK> {
public interface CtfTeamHasMemberRepository extends
JpaRepository<CtfTeamHasMember, CtfTeamHasMemberPK> {

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ public interface CtfTeamRepository extends JpaRepository<CtfTeam, Long> {

Optional<CtfTeam> findByIdAndIdNot(long teamId, long virtualId);

Page<CtfTeam> findAllByCtfContestAndNameIgnoreCaseContaining(CtfContest ctfContest, String search, Pageable pageable);
Page<CtfTeam> findAllByCtfContestAndNameIgnoreCaseContaining(CtfContest ctfContest, String search,
Pageable pageable);

@Modifying
@Query("UPDATE CtfTeam c "
+ "SET c.creator = :virtualMember "
+ "WHERE c.creator = :member")
void updateVirtualMember(@Param("member") Member member, @Param("virtualMember") Member virtualMember);
void updateVirtualMember(@Param("member") Member member,
@Param("virtualMember") Member virtualMember);

}
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ public class CtfSubmitLog {
private CtfContest ctfContest;

@Builder
private CtfSubmitLog(LocalDateTime submitTime, String flagSubmitted, Boolean isCorrect, String teamName,
private CtfSubmitLog(LocalDateTime submitTime, String flagSubmitted, Boolean isCorrect,
String teamName,
String submitterLoginId, String submitterRealName, String challengeName, String contestName,
CtfContest ctfContest) {
this.submitTime = submitTime;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ public class CtfChallengeHasCtfChallengeCategory {
private CtfChallengeCategory ctfChallengeCategory;

@Builder
private CtfChallengeHasCtfChallengeCategory(CtfChallenge ctfChallenge, CtfChallengeCategory ctfChallengeCategory) {
private CtfChallengeHasCtfChallengeCategory(CtfChallenge ctfChallenge,
CtfChallengeCategory ctfChallengeCategory) {
this.ctfChallenge = ctfChallenge;
this.ctfChallengeCategory = ctfChallengeCategory;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ public class CtfTeam extends BaseEntity {
private final Set<CtfTeamHasMember> ctfTeamHasMembers = new HashSet<>();

@Builder
private CtfTeam(String name, String description, Member creator, Integer score, CtfContest ctfContest,
private CtfTeam(String name, String description, Member creator, Integer score,
CtfContest ctfContest,
LocalDateTime lastSolveTime) {
this.name = name;
this.description = description;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ public class AdminElectionController {
public ResponseEntity<Void> createElection(
@LoginMember Member member,
@RequestBody @Valid ElectionCreateRequest request) {
adminElectionService.createElection(member, request.getName(), request.getDescription(), request.getIsAvailable());
adminElectionService.createElection(member, request.getName(), request.getDescription(),
request.getIsAvailable());
return ResponseEntity.status(HttpStatus.CREATED).build();
}

Expand Down Expand Up @@ -75,7 +76,8 @@ public ResponseEntity<Void> registerCandidate(
@RequestBody @Valid ElectionCandidateRegisterRequest request,
@PathVariable long electionId,
@PathVariable long candidateId) {
adminElectionService.registerCandidate(request.getDescription(), request.getMemberJobId(), electionId, candidateId);
adminElectionService.registerCandidate(request.getDescription(), request.getMemberJobId(),
electionId, candidateId);
return ResponseEntity.status(HttpStatus.CREATED).build();
}

Expand Down
Loading