Skip to content

Commit 3ce0ff4

Browse files
committed
feat#87 - 현재 미사용하는 과거 코드 빠르게 주석처리
1 parent 49eadb6 commit 3ce0ff4

2 files changed

Lines changed: 187 additions & 187 deletions

File tree

indicator/src/main/java/com/smashup/indicator/module/gamerhint/controller/dto/GamerHintController.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import com.smashup.indicator.module.gamerhint.domain.entity.MatrixDocument;
66
import com.smashup.indicator.module.gamerhint.domain.entity.WinMatrixDocument;
77
import com.smashup.indicator.module.gamerhint.service.impl.GamerHintMatrixService;
8-
import com.smashup.indicator.module.gamerhint.service.impl.GamerHintService;
8+
//import com.smashup.indicator.module.gamerhint.service.impl.GamerHintService;
99
import lombok.RequiredArgsConstructor;
1010
import lombok.extern.slf4j.Slf4j;
1111
import org.springframework.http.ResponseEntity;
@@ -22,7 +22,7 @@
2222
public class GamerHintController extends AbstractRestController {
2323

2424
// 의존성 주입
25-
private final GamerHintService gamerHintService;
25+
// private final GamerHintService gamerHintService;
2626
private final GamerHintMatrixService gamerHintMatrixService;
2727

2828
// 데이터 수집 => API 테스트 성공
Lines changed: 185 additions & 185 deletions
Original file line numberDiff line numberDiff line change
@@ -1,185 +1,185 @@
1-
package com.smashup.indicator.module.gamerhint.service.impl;
2-
3-
import com.smashup.indicator.module.gamerhint.controller.dto.request.InsertDataListRequestDto;
4-
import com.smashup.indicator.module.gamerhint.controller.dto.request.InsertDataRequestDto;
5-
import com.smashup.indicator.module.gamerhint.domain.entity.GamerHintDocument1;
6-
import com.smashup.indicator.module.gamerhint.repository.GamerHintRepository1;
7-
import com.smashup.indicator.module.version.PoolManager;
8-
import com.smashup.indicator.module.version.service.impl.VersionService;
9-
import lombok.RequiredArgsConstructor;
10-
import org.springframework.stereotype.Service;
11-
import org.springframework.transaction.annotation.Transactional;
12-
13-
import java.util.*;
14-
15-
@Service
16-
@RequiredArgsConstructor
17-
public class GamerHintService {
18-
// 의존성 주입
19-
private final GamerHintRepository1 gamerHintRepository1;
20-
private final PoolManager poolManager;
21-
private final VersionService versionService;
22-
23-
// 상수
24-
private final String NO_CARD = "NO_CARD";
25-
26-
27-
28-
// 데이터 수집
29-
@Transactional
30-
public void insertData(InsertDataListRequestDto dto) throws Exception {
31-
// 공통 파트
32-
List<Integer> cardPool = poolManager.getCardPool();
33-
Map<Integer, Integer> cardPoolIndex = poolManager.getCardPoolIndex();
34-
List<Integer> classPool = poolManager.getClassPool();
35-
36-
37-
/// documentID 재료
38-
String documentId = String.join("/", dto.getPatchVersion(), versionService.getBatchCount()+"");
39-
40-
/// 전체 직업을 관리하는 Map<documentId, Map<deckId, List<카드ID> > > 세팅.
41-
Map<String, Map<String, List<Integer> > > resultMap = new HashMap<>();
42-
// 직업코드 풀을 순회하며 최종 documentId를 생성한다.
43-
// 생성 후 resultMap에 집어 넣는다.
44-
// 가져온 값이 없으면 new HashMap<>();을 넣는다.
45-
for (int i = 0; i < classPool.size(); i++) {
46-
String finalDocumentId = String.join("/", documentId, classPool.get(i)+"");
47-
// class document가 있는데 못 찾으면 사고. 진짜 없는거면 새로 채울때인데, 빈맵 넣으면 됨.
48-
GamerHintDocument1 classMap = gamerHintRepository1.findById(finalDocumentId)
49-
.orElseGet(() -> null);
50-
if(classMap != null){
51-
resultMap.putIfAbsent(finalDocumentId, classMap.getDecks());
52-
} else{
53-
resultMap.putIfAbsent(finalDocumentId, new HashMap<>());
54-
}
55-
}
56-
57-
58-
// 개별 파트 => 플레이어 단위 작업 시작.
59-
60-
// dto에서 작업할 리스트 추출
61-
List<InsertDataRequestDto> workingList = dto.getList();
62-
for (InsertDataRequestDto data : workingList){
63-
// documentId 생성
64-
String dataDocumentId = String.join("/",documentId, data.getClassCode()+"");
65-
66-
// documentId 에 대응되는 맵 없으면 생성.
67-
resultMap.putIfAbsent(dataDocumentId, new HashMap<>());
68-
Map<String, List<Integer>> classMap = resultMap.get(dataDocumentId);
69-
70-
// round1 deck 처리 => round 0에서 뽑은 선택지 처리.
71-
/// 덱ID와 대응되는 리스트 없으면 생성.
72-
if(classMap.containsKey(NO_CARD)==false){
73-
List<Integer> temp = new ArrayList<>(cardPool.size() + 1); // 이렇게 초기화하면 내부는 초기화 아예 안되어있어서 size() 도 0임
74-
for (int i = 0; i < cardPool.size() + 1; i++) {
75-
temp.add(0);
76-
}
77-
classMap.put(NO_CARD, temp);
78-
}
79-
80-
for (int i = 0; i < data.getRound1Set().size(); i++) {
81-
int cardId = data.getRound1Set().get(i); // 카드 선택
82-
int cardIndex = cardPoolIndex.get(cardId); // 카드 ID 기반으로 카드 인덱스 찾기.
83-
int oldValue = classMap.get(NO_CARD).get(cardIndex); // set에 필요한 값 미리 부팅
84-
classMap.get(NO_CARD).set(cardIndex, oldValue+1); // 맵에서 덱을 찾고. 덱의 배열에서 카드 인덱스 집계량 +1
85-
}
86-
// 디버깅 포인트. 이 덱이 플레이된 횟수인데 for문에서 더하고 있었음...플레이 횟수*3 하고 있었네.
87-
int oldTotalValue = classMap.get(NO_CARD).get(cardPool.size()); // 디버깅할때 편리함을 위해. oldValue 재사용 안함.
88-
classMap.get(NO_CARD).set(cardPool.size(), oldTotalValue+1); // 맵에서 덱을 찾고. 덱의 배열에서 마지막 인덱스 집계량 +1
89-
90-
// round2 deck 처리 => round 1에서 뽑은 선택지 처리.
91-
/// 덱ID 생성
92-
List<Integer> mergedList2 = new ArrayList<>();
93-
mergedList2.addAll(data.getRound1Set());
94-
mergedList2.addAll(data.getRound2Set());
95-
Collections.sort(mergedList2);
96-
StringBuilder stringBuilder = new StringBuilder();
97-
/// stringBuilder로 concat
98-
for (int i = 0; i < mergedList2.size()-1; i++) {
99-
stringBuilder.append(mergedList2.get(i)).append("/");
100-
}
101-
stringBuilder.append(mergedList2.get(mergedList2.size()-1));
102-
String deckId2 = stringBuilder.toString();
103-
stringBuilder.setLength(0); // stringBuilder 초기화
104-
105-
106-
/// 덱ID와 대응되는 배열 없으면 생성.
107-
if(classMap.containsKey(deckId2)==false){
108-
List<Integer> temp = new ArrayList<>(cardPool.size() + 1); // 이렇게 초기화하면 내부는 초기화 아예 안되어있어서 size() 도 0임
109-
for (int i = 0; i < cardPool.size() + 1; i++) {
110-
temp.add(0);
111-
}
112-
classMap.put(deckId2, temp);
113-
}
114-
115-
116-
for (int i = 0; i < data.getRound2Set().size(); i++) {
117-
int cardId = data.getRound2Set().get(i); // 카드 선택
118-
int cardIndex = cardPoolIndex.get(cardId); // 카드 ID 기반으로 카드 인덱스 찾기.
119-
120-
int oldValue = classMap.get(deckId2).get(cardIndex); // set에 필요한 값 미리 부팅
121-
classMap.get(deckId2).set(cardIndex, oldValue+1); // 맵에서 덱을 찾고. 덱의 배열에서 카드 인덱스 집계량 +1
122-
123-
}
124-
int oldTotalValue2 = classMap.get(deckId2).get(cardPool.size()); // 디버깅할때 편리함을 위해. oldValue 재사용 안함.
125-
classMap.get(deckId2).set(cardPool.size(), oldTotalValue2+1); // 맵에서 덱을 찾고. 덱의 배열에서 마지막 인덱스 집계량 +1
126-
127-
128-
// round3 deck 처리 => round 2에서 뽑은 선택지 처리.
129-
/// 덱ID 생성
130-
List<Integer> mergedList3 = new ArrayList<>();
131-
mergedList3.addAll(data.getRound1Set());
132-
mergedList3.addAll(data.getRound2Set());
133-
mergedList3.addAll(data.getRound3Set());
134-
Collections.sort(mergedList3);
135-
136-
/// stringBuilder로 concat
137-
for (int i = 0; i < mergedList3.size()-1; i++) {
138-
stringBuilder.append(mergedList3.get(i)).append("/");
139-
}
140-
stringBuilder.append(mergedList3.get(mergedList3.size()-1));
141-
String deckId3 = stringBuilder.toString();
142-
stringBuilder.setLength(0); // stringBuilder 초기화
143-
144-
145-
/// 덱ID와 대응되는 배열 없으면 생성.
146-
if(classMap.containsKey(deckId3)==false){
147-
List<Integer> temp = new ArrayList<>(cardPool.size() + 1); // 이렇게 초기화하면 내부는 초기화 아예 안되어있어서 size() 도 0임
148-
for (int i = 0; i < cardPool.size() + 1; i++) {
149-
temp.add(0);
150-
}
151-
classMap.put(deckId3, temp);
152-
}
153-
154-
155-
for (int i = 0; i < data.getRound3Set().size(); i++) {
156-
int cardId = data.getRound3Set().get(i); // 카드 선택
157-
int cardIndex = cardPoolIndex.get(cardId); // 카드 ID 기반으로 카드 인덱스 찾기.
158-
159-
int oldValue = classMap.get(deckId3).get(cardIndex); // set에 필요한 값 미리 부팅
160-
classMap.get(deckId3).set(cardIndex, oldValue+1); // 맵에서 덱을 찾고. 덱의 배열에서 카드 인덱스 집계량 +1
161-
162-
}
163-
int oldTotalValue3 = classMap.get(deckId3).get(cardPool.size()); // 디버깅할때 편리함을 위해. oldValue 재사용 안함.
164-
classMap.get(deckId3).set(cardPool.size(), oldTotalValue3+1); // 맵에서 덱을 찾고. 덱의 배열에서 마지막 인덱스 집계량 +1
165-
166-
}
167-
// 개별 파트 종료 => resultMap 순회하면서 Map<deckId, 카드풀[]> 고르고 덱별로 insert하기.
168-
169-
// resultMap 순회하면서 각각의 classMap을 GamerHintDocument1에 저장해서. 각각에 대해서
170-
for (String classMapId: resultMap.keySet()) {
171-
172-
GamerHintDocument1 gamerHintDocument1 = GamerHintDocument1.builder()
173-
.id(classMapId)
174-
.cardPool(cardPool)
175-
.decks(resultMap.get(classMapId))
176-
.build();
177-
178-
gamerHintRepository1.save(gamerHintDocument1);
179-
}
180-
// GamerHintRepository1.save(각각의 GamerHintDocument1) 해버리기
181-
182-
}
183-
184-
185-
}
1+
//package com.smashup.indicator.module.gamerhint.service.impl;
2+
//
3+
//import com.smashup.indicator.module.gamerhint.controller.dto.request.InsertDataListRequestDto;
4+
//import com.smashup.indicator.module.gamerhint.controller.dto.request.InsertDataRequestDto;
5+
//import com.smashup.indicator.module.gamerhint.domain.entity.GamerHintDocument1;
6+
//import com.smashup.indicator.module.gamerhint.repository.GamerHintRepository1;
7+
//import com.smashup.indicator.module.version.PoolManager;
8+
//import com.smashup.indicator.module.version.service.impl.VersionService;
9+
//import lombok.RequiredArgsConstructor;
10+
//import org.springframework.stereotype.Service;
11+
//import org.springframework.transaction.annotation.Transactional;
12+
//
13+
//import java.util.*;
14+
//
15+
//@Service
16+
//@RequiredArgsConstructor
17+
//public class GamerHintService {
18+
// // 의존성 주입
19+
// private final GamerHintRepository1 gamerHintRepository1;
20+
// private final PoolManager poolManager;
21+
// private final VersionService versionService;
22+
//
23+
// // 상수
24+
// private final String NO_CARD = "NO_CARD";
25+
//
26+
//
27+
//
28+
// // 데이터 수집
29+
// @Transactional
30+
// public void insertData(InsertDataListRequestDto dto) throws Exception {
31+
// // 공통 파트
32+
// List<Integer> cardPool = poolManager.getCardPool();
33+
// Map<Integer, Integer> cardPoolIndex = poolManager.getCardPoolIndex();
34+
// List<Integer> classPool = poolManager.getClassPool();
35+
//
36+
//
37+
// /// documentID 재료
38+
// String documentId = String.join("/", dto.getPatchVersion(), versionService.getBatchCount()+"");
39+
//
40+
// /// 전체 직업을 관리하는 Map<documentId, Map<deckId, List<카드ID> > > 세팅.
41+
// Map<String, Map<String, List<Integer> > > resultMap = new HashMap<>();
42+
// // 직업코드 풀을 순회하며 최종 documentId를 생성한다.
43+
// // 생성 후 resultMap에 집어 넣는다.
44+
// // 가져온 값이 없으면 new HashMap<>();을 넣는다.
45+
// for (int i = 0; i < classPool.size(); i++) {
46+
// String finalDocumentId = String.join("/", documentId, classPool.get(i)+"");
47+
// // class document가 있는데 못 찾으면 사고. 진짜 없는거면 새로 채울때인데, 빈맵 넣으면 됨.
48+
// GamerHintDocument1 classMap = gamerHintRepository1.findById(finalDocumentId)
49+
// .orElseGet(() -> null);
50+
// if(classMap != null){
51+
// resultMap.putIfAbsent(finalDocumentId, classMap.getDecks());
52+
// } else{
53+
// resultMap.putIfAbsent(finalDocumentId, new HashMap<>());
54+
// }
55+
// }
56+
//
57+
//
58+
// // 개별 파트 => 플레이어 단위 작업 시작.
59+
//
60+
// // dto에서 작업할 리스트 추출
61+
// List<InsertDataRequestDto> workingList = dto.getList();
62+
// for (InsertDataRequestDto data : workingList){
63+
// // documentId 생성
64+
// String dataDocumentId = String.join("/",documentId, data.getClassCode()+"");
65+
//
66+
// // documentId 에 대응되는 맵 없으면 생성.
67+
// resultMap.putIfAbsent(dataDocumentId, new HashMap<>());
68+
// Map<String, List<Integer>> classMap = resultMap.get(dataDocumentId);
69+
//
70+
// // round1 deck 처리 => round 0에서 뽑은 선택지 처리.
71+
// /// 덱ID와 대응되는 리스트 없으면 생성.
72+
// if(classMap.containsKey(NO_CARD)==false){
73+
// List<Integer> temp = new ArrayList<>(cardPool.size() + 1); // 이렇게 초기화하면 내부는 초기화 아예 안되어있어서 size() 도 0임
74+
// for (int i = 0; i < cardPool.size() + 1; i++) {
75+
// temp.add(0);
76+
// }
77+
// classMap.put(NO_CARD, temp);
78+
// }
79+
//
80+
// for (int i = 0; i < data.getRound1Set().size(); i++) {
81+
// int cardId = data.getRound1Set().get(i); // 카드 선택
82+
// int cardIndex = cardPoolIndex.get(cardId); // 카드 ID 기반으로 카드 인덱스 찾기.
83+
// int oldValue = classMap.get(NO_CARD).get(cardIndex); // set에 필요한 값 미리 부팅
84+
// classMap.get(NO_CARD).set(cardIndex, oldValue+1); // 맵에서 덱을 찾고. 덱의 배열에서 카드 인덱스 집계량 +1
85+
// }
86+
// // 디버깅 포인트. 이 덱이 플레이된 횟수인데 for문에서 더하고 있었음...플레이 횟수*3 하고 있었네.
87+
// int oldTotalValue = classMap.get(NO_CARD).get(cardPool.size()); // 디버깅할때 편리함을 위해. oldValue 재사용 안함.
88+
// classMap.get(NO_CARD).set(cardPool.size(), oldTotalValue+1); // 맵에서 덱을 찾고. 덱의 배열에서 마지막 인덱스 집계량 +1
89+
//
90+
// // round2 deck 처리 => round 1에서 뽑은 선택지 처리.
91+
// /// 덱ID 생성
92+
// List<Integer> mergedList2 = new ArrayList<>();
93+
// mergedList2.addAll(data.getRound1Set());
94+
// mergedList2.addAll(data.getRound2Set());
95+
// Collections.sort(mergedList2);
96+
// StringBuilder stringBuilder = new StringBuilder();
97+
// /// stringBuilder로 concat
98+
// for (int i = 0; i < mergedList2.size()-1; i++) {
99+
// stringBuilder.append(mergedList2.get(i)).append("/");
100+
// }
101+
// stringBuilder.append(mergedList2.get(mergedList2.size()-1));
102+
// String deckId2 = stringBuilder.toString();
103+
// stringBuilder.setLength(0); // stringBuilder 초기화
104+
//
105+
//
106+
// /// 덱ID와 대응되는 배열 없으면 생성.
107+
// if(classMap.containsKey(deckId2)==false){
108+
// List<Integer> temp = new ArrayList<>(cardPool.size() + 1); // 이렇게 초기화하면 내부는 초기화 아예 안되어있어서 size() 도 0임
109+
// for (int i = 0; i < cardPool.size() + 1; i++) {
110+
// temp.add(0);
111+
// }
112+
// classMap.put(deckId2, temp);
113+
// }
114+
//
115+
//
116+
// for (int i = 0; i < data.getRound2Set().size(); i++) {
117+
// int cardId = data.getRound2Set().get(i); // 카드 선택
118+
// int cardIndex = cardPoolIndex.get(cardId); // 카드 ID 기반으로 카드 인덱스 찾기.
119+
//
120+
// int oldValue = classMap.get(deckId2).get(cardIndex); // set에 필요한 값 미리 부팅
121+
// classMap.get(deckId2).set(cardIndex, oldValue+1); // 맵에서 덱을 찾고. 덱의 배열에서 카드 인덱스 집계량 +1
122+
//
123+
// }
124+
// int oldTotalValue2 = classMap.get(deckId2).get(cardPool.size()); // 디버깅할때 편리함을 위해. oldValue 재사용 안함.
125+
// classMap.get(deckId2).set(cardPool.size(), oldTotalValue2+1); // 맵에서 덱을 찾고. 덱의 배열에서 마지막 인덱스 집계량 +1
126+
//
127+
//
128+
// // round3 deck 처리 => round 2에서 뽑은 선택지 처리.
129+
// /// 덱ID 생성
130+
// List<Integer> mergedList3 = new ArrayList<>();
131+
// mergedList3.addAll(data.getRound1Set());
132+
// mergedList3.addAll(data.getRound2Set());
133+
// mergedList3.addAll(data.getRound3Set());
134+
// Collections.sort(mergedList3);
135+
//
136+
// /// stringBuilder로 concat
137+
// for (int i = 0; i < mergedList3.size()-1; i++) {
138+
// stringBuilder.append(mergedList3.get(i)).append("/");
139+
// }
140+
// stringBuilder.append(mergedList3.get(mergedList3.size()-1));
141+
// String deckId3 = stringBuilder.toString();
142+
// stringBuilder.setLength(0); // stringBuilder 초기화
143+
//
144+
//
145+
// /// 덱ID와 대응되는 배열 없으면 생성.
146+
// if(classMap.containsKey(deckId3)==false){
147+
// List<Integer> temp = new ArrayList<>(cardPool.size() + 1); // 이렇게 초기화하면 내부는 초기화 아예 안되어있어서 size() 도 0임
148+
// for (int i = 0; i < cardPool.size() + 1; i++) {
149+
// temp.add(0);
150+
// }
151+
// classMap.put(deckId3, temp);
152+
// }
153+
//
154+
//
155+
// for (int i = 0; i < data.getRound3Set().size(); i++) {
156+
// int cardId = data.getRound3Set().get(i); // 카드 선택
157+
// int cardIndex = cardPoolIndex.get(cardId); // 카드 ID 기반으로 카드 인덱스 찾기.
158+
//
159+
// int oldValue = classMap.get(deckId3).get(cardIndex); // set에 필요한 값 미리 부팅
160+
// classMap.get(deckId3).set(cardIndex, oldValue+1); // 맵에서 덱을 찾고. 덱의 배열에서 카드 인덱스 집계량 +1
161+
//
162+
// }
163+
// int oldTotalValue3 = classMap.get(deckId3).get(cardPool.size()); // 디버깅할때 편리함을 위해. oldValue 재사용 안함.
164+
// classMap.get(deckId3).set(cardPool.size(), oldTotalValue3+1); // 맵에서 덱을 찾고. 덱의 배열에서 마지막 인덱스 집계량 +1
165+
//
166+
// }
167+
// // 개별 파트 종료 => resultMap 순회하면서 Map<deckId, 카드풀[]> 고르고 덱별로 insert하기.
168+
//
169+
// // resultMap 순회하면서 각각의 classMap을 GamerHintDocument1에 저장해서. 각각에 대해서
170+
// for (String classMapId: resultMap.keySet()) {
171+
//
172+
// GamerHintDocument1 gamerHintDocument1 = GamerHintDocument1.builder()
173+
// .id(classMapId)
174+
// .cardPool(cardPool)
175+
// .decks(resultMap.get(classMapId))
176+
// .build();
177+
//
178+
// gamerHintRepository1.save(gamerHintDocument1);
179+
// }
180+
// // GamerHintRepository1.save(각각의 GamerHintDocument1) 해버리기
181+
//
182+
// }
183+
//
184+
//
185+
//}

0 commit comments

Comments
 (0)