Skip to content

Commit

Permalink
fix: CtfChallengeHasCtfChallengeCategoryList 에 Entity를 add 하는 메서드 추가
Browse files Browse the repository at this point in the history
issue: #471
pr: #472
  • Loading branch information
shkisme committed Dec 23, 2022
1 parent bebaf38 commit cab11ae
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public class CtfChallengeEntity {
@Builder.Default
@OneToMany(mappedBy = "challenge", cascade = CascadeType.REMOVE)
List<CtfChallengeHasCtfChallengeCategoryEntity> ctfChallengeHasCtfChallengeCategoryList = new ArrayList<>();

@Column(nullable = false)
@Setter
Long score;
Expand Down Expand Up @@ -89,4 +90,8 @@ public class CtfChallengeEntity {
@PrimaryKeyJoinColumn
@Setter
CtfDynamicChallengeInfoEntity dynamicChallengeInfoEntity;

public void addCtfChallengeHasCtfChallengeCategory(CtfChallengeHasCtfChallengeCategoryEntity ctfChallengeHasCtfChallengeCategoryEntity) {
this.getCtfChallengeHasCtfChallengeCategoryList().add(ctfChallengeHasCtfChallengeCategoryEntity);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
import static keeper.project.homepage.util.service.CtfUtilService.VIRTUAL_TEAM_ID;

import java.nio.file.AccessDeniedException;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletRequest;
import keeper.project.homepage.ctf.dto.CtfChallengeAdminDto;
import keeper.project.homepage.ctf.dto.CtfChallengeCategoryDto;
Expand Down Expand Up @@ -338,17 +336,17 @@ private CtfChallengeEntity createChallengeEntityWithFileEntity(

private void setChallengeCategory(CtfChallengeEntity challenge,
CtfChallengeAdminDto challengeAdminDto) {
List<CtfChallengeCategoryEntity> ctfChallengeCategoryEntityList = challengeAdminDto.getCategory()
List<CtfChallengeCategoryEntity> ctfChallengeCategoryEntityList = challengeAdminDto.getCategories()
.stream()
.map(CtfChallengeCategoryDto::toEntity).toList();

for (CtfChallengeCategoryEntity ctfChallengeCategory : ctfChallengeCategoryEntityList) {
CtfChallengeHasCtfChallengeCategoryEntity save = ctfChallengeHasCtfChallengeCategoryRepository.save(
CtfChallengeHasCtfChallengeCategoryEntity.builder()
challenge.addCtfChallengeHasCtfChallengeCategory(ctfChallengeHasCtfChallengeCategoryRepository
.save(CtfChallengeHasCtfChallengeCategoryEntity
.builder()
.challenge(challenge)
.category(ctfChallengeCategory)
.build());
challenge.getCtfChallengeHasCtfChallengeCategoryList().add(save);
.build()));
}
}

Expand Down

0 comments on commit cab11ae

Please sign in to comment.