Skip to content

Commit

Permalink
Merge pull request #341 from SWM-NM/feat/#340
Browse files Browse the repository at this point in the history
[FEAT] 브/실/골 랜덤 디펜스 추가
  • Loading branch information
aj4941 authored Sep 22, 2023
2 parents a14a785 + 972a039 commit c79f102
Show file tree
Hide file tree
Showing 32 changed files with 150 additions and 96 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import lombok.Getter;
import lombok.NoArgsConstructor;
import swm_nm.morandi.domain.common.BaseEntity;
import swm_nm.morandi.domain.testExit.entity.TestType;
import swm_nm.morandi.domain.testInfo.entity.TestType;

import javax.persistence.*;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import org.springframework.stereotype.Component;
import swm_nm.morandi.domain.testDuring.dto.TestCheckDto;
import swm_nm.morandi.domain.testDuring.dto.TestStatus;
import swm_nm.morandi.domain.testExit.entity.Tests;
import swm_nm.morandi.domain.testInfo.entity.Tests;
import swm_nm.morandi.domain.testInfo.repository.TestRepository;
import swm_nm.morandi.domain.testStart.service.CheckAttemptProblemService;
import swm_nm.morandi.global.exception.MorandiException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import org.springframework.web.reactive.function.client.WebClient;
import swm_nm.morandi.domain.problem.entity.Problem;
import swm_nm.morandi.domain.testDuring.dto.TestCheckDto;
import swm_nm.morandi.domain.testExit.entity.AttemptProblem;
import swm_nm.morandi.domain.testExit.entity.Tests;
import swm_nm.morandi.domain.testInfo.entity.AttemptProblem;
import swm_nm.morandi.domain.testInfo.entity.Tests;
import swm_nm.morandi.domain.testExit.dto.AttemptProblemDto;
import swm_nm.morandi.domain.testInfo.repository.TestRepository;
import swm_nm.morandi.domain.testRecord.repository.AttemptProblemRepository;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package swm_nm.morandi.domain.testExit.dto;

import lombok.*;
import swm_nm.morandi.domain.testExit.entity.AttemptProblem;
import swm_nm.morandi.domain.testInfo.entity.AttemptProblem;

@Getter @Setter
@NoArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@
import org.springframework.stereotype.Service;
import swm_nm.morandi.domain.problem.dto.DifficultyLevel;
import swm_nm.morandi.domain.problem.entity.Problem;
import swm_nm.morandi.domain.testExit.entity.AttemptProblem;
import swm_nm.morandi.domain.testExit.entity.Tests;
import swm_nm.morandi.domain.testInfo.entity.AttemptProblem;
import swm_nm.morandi.domain.testInfo.entity.Tests;
import swm_nm.morandi.domain.testInfo.repository.TestRepository;
import swm_nm.morandi.domain.member.entity.Member;
import swm_nm.morandi.domain.testRecord.repository.AttemptProblemRepository;
import swm_nm.morandi.global.exception.MorandiException;
import swm_nm.morandi.global.exception.errorcode.TestErrorCode;

import javax.transaction.Transactional;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import swm_nm.morandi.domain.testExit.entity.AttemptProblem;
import swm_nm.morandi.domain.testInfo.entity.AttemptProblem;
import swm_nm.morandi.domain.testExit.dto.AttemptCodeDto;
import swm_nm.morandi.domain.testRecord.repository.AttemptProblemRepository;
import swm_nm.morandi.global.exception.MorandiException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import org.springframework.stereotype.Service;
import swm_nm.morandi.domain.testDuring.dto.TestCheckDto;
import swm_nm.morandi.domain.testDuring.dto.TestStatus;
import swm_nm.morandi.domain.testExit.entity.AttemptProblem;
import swm_nm.morandi.domain.testExit.entity.TestType;
import swm_nm.morandi.domain.testExit.entity.Tests;
import swm_nm.morandi.domain.testInfo.entity.AttemptProblem;
import swm_nm.morandi.domain.testInfo.entity.TestType;
import swm_nm.morandi.domain.testInfo.entity.Tests;
import swm_nm.morandi.domain.testExit.dto.AttemptProblemDto;
import swm_nm.morandi.domain.testInfo.repository.TestRepository;
import swm_nm.morandi.domain.testInfo.repository.TestTypeRepository;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public class TestInfoController {

private final CompanyTestInfoService companyTestInfoService;

private final RandomDefenseInfoService randomDefenseInfoService;

private final TestTypeInfoService testTypeInfoService;
@GetMapping("/latest")
@Operation(summary = "최근에 본 테스트 목록", description = "메인 페이지에서 최근에 본 테스트 5개를 제공합니다.")
Expand All @@ -39,6 +41,11 @@ public ResponseEntity<List<TestTypeDto>> getPracticeTestTypeDtos() {
public ResponseEntity<List<TestTypeDto>> getCompanyTestTypeDtos() {
return new ResponseEntity<>(companyTestInfoService.getCompanyTestTypeDtos(), HttpStatus.OK);
}
@GetMapping("/random-defense")
@Operation(summary = "랜덤 디펜스 목록", description = "메인 페이지에서 현재 있는 랜덤 디펜스 정보를 제공합니다.")
public ResponseEntity<List<TestTypeDto>> getRandomDefenseTestTypeDtos() {
return new ResponseEntity<>(randomDefenseInfoService.getRandomDefenseTestTypeDtos(), HttpStatus.OK);
}
@GetMapping("/{testTypeId}")
@Operation(summary = "테스트 상세 정보", description = "사용자가 원하는 테스트를 눌렀을 때 상세 테스트 정보를 제공합니다.")
public ResponseEntity<TestTypeDto> getTestTypeInfo(@PathVariable Long testTypeId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import lombok.RequiredArgsConstructor;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
import swm_nm.morandi.domain.testExit.entity.TestType;
import swm_nm.morandi.domain.testInfo.entity.TestType;
import swm_nm.morandi.domain.problem.dto.DifficultyLevel;
import swm_nm.morandi.domain.problem.dto.DifficultyRange;
import swm_nm.morandi.domain.testInfo.repository.TestTypeRepository;
Expand Down Expand Up @@ -142,7 +142,7 @@ private void insertTestTypeData() {

testTypeRepository.save(testType6);

// 삼성
// PK 7번 : 삼성
List<DifficultyRange> difficultyRanges7 = new ArrayList<>();
difficultyRanges7.add(new DifficultyRange(DifficultyLevel.S1, DifficultyLevel.G5));
difficultyRanges7.add(new DifficultyRange(DifficultyLevel.G4, DifficultyLevel.G1));
Expand All @@ -159,7 +159,7 @@ private void insertTestTypeData() {
.build();
testTypeRepository.save(testType7);

// 네이버
// PK 8번 : 네이버
List<DifficultyRange> difficultyRanges8 = new ArrayList<>();
difficultyRanges8.add(new DifficultyRange(DifficultyLevel.S2, DifficultyLevel.G5));
difficultyRanges8.add(new DifficultyRange(DifficultyLevel.G4, DifficultyLevel.G4));
Expand All @@ -179,7 +179,7 @@ private void insertTestTypeData() {

testTypeRepository.save(testType8);

// 카카오
// PK 9번 : 카카오
List<DifficultyRange> difficultyRanges9 = new ArrayList<>();
difficultyRanges9.add(new DifficultyRange(DifficultyLevel.S5, DifficultyLevel.S4));
difficultyRanges9.add(new DifficultyRange(DifficultyLevel.S3, DifficultyLevel.S2));
Expand All @@ -202,7 +202,7 @@ private void insertTestTypeData() {

testTypeRepository.save(testType9);

// 라인
// PK 10번 : 라인
List<DifficultyRange> difficultyRanges10 = new ArrayList<>();
difficultyRanges10.add(new DifficultyRange(DifficultyLevel.S4, DifficultyLevel.S3));
difficultyRanges10.add(new DifficultyRange(DifficultyLevel.S2, DifficultyLevel.S1));
Expand All @@ -224,7 +224,7 @@ private void insertTestTypeData() {

testTypeRepository.save(testType10);

// 쿠팡
// PK 11번 : 쿠팡
List<DifficultyRange> difficultyRanges11 = new ArrayList<>();
difficultyRanges11.add(new DifficultyRange(DifficultyLevel.S5, DifficultyLevel.S3));
difficultyRanges11.add(new DifficultyRange(DifficultyLevel.S2, DifficultyLevel.S1));
Expand All @@ -243,7 +243,7 @@ private void insertTestTypeData() {

testTypeRepository.save(testType11);

// 우아한형제들
// PK 12번 : 우아한형제들
List<DifficultyRange> difficultyRanges12 = new ArrayList<>();
difficultyRanges12.add(new DifficultyRange(DifficultyLevel.S4, DifficultyLevel.S3));
difficultyRanges12.add(new DifficultyRange(DifficultyLevel.S2, DifficultyLevel.G5));
Expand All @@ -261,5 +261,65 @@ private void insertTestTypeData() {
.build();

testTypeRepository.save(testType12);

// PK 13번 : 브론즈 랜덤 디펜스
List<DifficultyRange> difficultyRanges13 = new ArrayList<>();
difficultyRanges12.add(new DifficultyRange(DifficultyLevel.B4, DifficultyLevel.B3));
difficultyRanges12.add(new DifficultyRange(DifficultyLevel.B3, DifficultyLevel.B2));
difficultyRanges12.add(new DifficultyRange(DifficultyLevel.B2, DifficultyLevel.B1));
difficultyRanges12.add(new DifficultyRange(DifficultyLevel.B2, DifficultyLevel.B1));

TestType testType13 = TestType.builder()
.testTypename("브론즈 랜덤 디펜스")
.testTime(120L)
.problemCount(4)
.startDifficulty(DifficultyLevel.B4)
.endDifficulty(DifficultyLevel.B1)
.difficultyRanges(difficultyRanges13)
.numberOfTestTrial(0)
.averageCorrectAnswerRate(0L)
.build();

testTypeRepository.save(testType13);

// PK 14번 : 실버 랜덤 디펜스
List<DifficultyRange> difficultyRanges14 = new ArrayList<>();
difficultyRanges14.add(new DifficultyRange(DifficultyLevel.S5, DifficultyLevel.S4));
difficultyRanges14.add(new DifficultyRange(DifficultyLevel.S4, DifficultyLevel.S3));
difficultyRanges14.add(new DifficultyRange(DifficultyLevel.S3, DifficultyLevel.S2));
difficultyRanges14.add(new DifficultyRange(DifficultyLevel.S2, DifficultyLevel.S1));

TestType testType14 = TestType.builder()
.testTypename("실버 랜덤 디펜스")
.testTime(120L)
.problemCount(4)
.startDifficulty(DifficultyLevel.S5)
.endDifficulty(DifficultyLevel.S1)
.difficultyRanges(difficultyRanges14)
.numberOfTestTrial(0)
.averageCorrectAnswerRate(0L)
.build();

testTypeRepository.save(testType14);

// PK 15번 : 골드 랜덤 디펜스
List<DifficultyRange> difficultyRanges15 = new ArrayList<>();
difficultyRanges15.add(new DifficultyRange(DifficultyLevel.G5, DifficultyLevel.G4));
difficultyRanges15.add(new DifficultyRange(DifficultyLevel.G4, DifficultyLevel.G3));
difficultyRanges15.add(new DifficultyRange(DifficultyLevel.G3, DifficultyLevel.G2));
difficultyRanges15.add(new DifficultyRange(DifficultyLevel.G2, DifficultyLevel.G1));

TestType testType15 = TestType.builder()
.testTypename("골드 랜덤 디펜스")
.testTime(120L)
.problemCount(4)
.startDifficulty(DifficultyLevel.G5)
.endDifficulty(DifficultyLevel.G1)
.difficultyRanges(difficultyRanges13)
.numberOfTestTrial(0)
.averageCorrectAnswerRate(0L)
.build();

testTypeRepository.save(testType15);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package swm_nm.morandi.domain.testExit.entity;
package swm_nm.morandi.domain.testInfo.entity;

import lombok.*;
import swm_nm.morandi.domain.common.BaseEntity;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package swm_nm.morandi.domain.testExit.entity;
package swm_nm.morandi.domain.testInfo.entity;

import lombok.AllArgsConstructor;
import lombok.Builder;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package swm_nm.morandi.domain.testExit.entity;
package swm_nm.morandi.domain.testInfo.entity;

import lombok.AllArgsConstructor;
import lombok.Builder;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package swm_nm.morandi.domain.testInfo.mapper;

import swm_nm.morandi.domain.testExit.entity.TestType;
import swm_nm.morandi.domain.testInfo.entity.TestType;
import swm_nm.morandi.domain.testInfo.dto.TestTypeDto;

public class TestTypeMapper {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package swm_nm.morandi.domain.testInfo.repository;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import swm_nm.morandi.domain.testExit.entity.Tests;
import swm_nm.morandi.domain.testInfo.entity.Tests;

import java.util.List;
public interface TestRepository extends JpaRepository<Tests, Long> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package swm_nm.morandi.domain.testInfo.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import swm_nm.morandi.domain.testExit.entity.TestType;
import swm_nm.morandi.domain.testInfo.entity.TestType;

import java.util.Optional;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import swm_nm.morandi.domain.testRecord.dto.TestRecordDto;
import swm_nm.morandi.domain.testExit.entity.Tests;
import swm_nm.morandi.domain.testInfo.entity.Tests;
import swm_nm.morandi.domain.testRecord.mapper.TestRecordMapper;
import swm_nm.morandi.domain.testInfo.repository.TestRepository;
import swm_nm.morandi.global.utils.SecurityUtils;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package swm_nm.morandi.domain.testInfo.service;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import swm_nm.morandi.domain.testInfo.dto.TestTypeDto;
import swm_nm.morandi.domain.testInfo.mapper.TestTypeMapper;
import swm_nm.morandi.domain.testInfo.repository.TestTypeRepository;
import swm_nm.morandi.global.exception.MorandiException;
import swm_nm.morandi.global.exception.errorcode.TestTypeErrorCode;

import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.LongStream;

@Service
@RequiredArgsConstructor
@Slf4j
public class RandomDefenseInfoService {

private final TestTypeRepository testTypeRepository;
public List<TestTypeDto> getRandomDefenseTestTypeDtos() {
List<TestTypeDto> testTypeDtos = LongStream.rangeClosed(13, 15).mapToObj(i -> testTypeRepository.findById(i)
.orElseThrow(() -> new MorandiException(TestTypeErrorCode.TEST_TYPE_NOT_FOUND)))
.map(TestTypeMapper::convertToDto).collect(Collectors.toList());
return testTypeDtos;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import swm_nm.morandi.domain.testInfo.dto.TestTypeDto;
import swm_nm.morandi.domain.testExit.entity.TestType;
import swm_nm.morandi.domain.testInfo.entity.TestType;
import swm_nm.morandi.domain.testInfo.mapper.TestTypeMapper;
import swm_nm.morandi.domain.testInfo.repository.TestTypeRepository;
import swm_nm.morandi.global.exception.MorandiException;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package swm_nm.morandi.domain.testRecord.mapper;

import swm_nm.morandi.domain.testExit.entity.Tests;
import swm_nm.morandi.domain.testInfo.entity.Tests;
import swm_nm.morandi.domain.testRecord.dto.TestRecordDto;

import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package swm_nm.morandi.domain.testRecord.repository;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import swm_nm.morandi.domain.testExit.entity.Tests;
import swm_nm.morandi.domain.testExit.entity.AttemptProblem;
import swm_nm.morandi.domain.testInfo.entity.Tests;
import swm_nm.morandi.domain.testInfo.entity.AttemptProblem;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import swm_nm.morandi.domain.problem.entity.AlgorithmProblemList;
import swm_nm.morandi.domain.problem.repository.AlgorithmProblemListRepository;
import swm_nm.morandi.domain.problem.repository.AlgorithmRepository;
import swm_nm.morandi.domain.testExit.entity.AttemptProblem;
import swm_nm.morandi.domain.testInfo.entity.AttemptProblem;
import swm_nm.morandi.domain.testRecord.repository.AttemptProblemRepository;
import swm_nm.morandi.global.utils.SecurityUtils;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import swm_nm.morandi.domain.member.dto.GrassDto;
import swm_nm.morandi.domain.testExit.entity.AttemptProblem;
import swm_nm.morandi.domain.testInfo.entity.AttemptProblem;
import swm_nm.morandi.domain.testRecord.repository.AttemptProblemRepository;
import swm_nm.morandi.global.utils.SecurityUtils;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import org.springframework.stereotype.Service;
import swm_nm.morandi.domain.testRecord.dto.TestRatingDto;
import swm_nm.morandi.domain.testDuring.dto.TestStatus;
import swm_nm.morandi.domain.testExit.entity.Tests;
import swm_nm.morandi.domain.testInfo.entity.Tests;
import swm_nm.morandi.domain.testInfo.repository.TestRepository;
import swm_nm.morandi.global.utils.SecurityUtils;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import swm_nm.morandi.domain.testRecord.dto.TestRecordDto;
import swm_nm.morandi.domain.testExit.entity.AttemptProblem;
import swm_nm.morandi.domain.testExit.entity.Tests;
import swm_nm.morandi.domain.testInfo.entity.AttemptProblem;
import swm_nm.morandi.domain.testInfo.entity.Tests;
import swm_nm.morandi.domain.testExit.dto.AttemptProblemDto;
import swm_nm.morandi.domain.testInfo.repository.TestRepository;
import swm_nm.morandi.domain.testRecord.repository.AttemptProblemRepository;
Expand Down
Loading

0 comments on commit c79f102

Please sign in to comment.