|
16 | 16 | public class UserServiceV2 { |
17 | 17 |
|
18 | 18 | private final UserRepositoryV2 userRepositoryV2; |
19 | | - private final RedisTemplate<String, Object> redisTemplate; |
20 | | - |
21 | | -// // 사용자 등록 여부 확인 |
22 | | -// public int getUserCampusId(String userId) { |
23 | | -// // redis에서 데이터 찾음 |
24 | | -// String key = "campusId:" + userId; |
25 | | -// // null값 처리 위해 Integer 사용 |
26 | | -// Integer campusId = (Integer) redisTemplate.opsForValue().get(key); |
27 | | -// System.out.println("campusId:" + campusId); |
28 | | -// |
29 | | -// // redis에 데이터 없는 경우 db 조회 |
30 | | -// if (campusId == null) { |
31 | | -// campusId = userRepositoryV2.findCampusIdById(userId).orElse(-1); |
32 | | -// // campusId가 -1이 아니면 캐시 저장 |
33 | | -// if (campusId != -1) { |
34 | | -// redisTemplate.opsForValue().set(key, campusId, Duration.ofDays(1)); // 1일 TTL 설정 |
35 | | -// } |
36 | | -// } |
37 | | -// return campusId; |
38 | | -// } |
39 | | -// |
40 | | -// // 사용자 학과 id 찾기 |
41 | | -// public int getUserDepartmentId(String userId) { |
42 | | -// String key = "departmentId:" + userId; |
43 | | -// Integer departmentId = (Integer) redisTemplate.opsForValue().get(key); |
44 | | -// System.out.println("departmentId:" + departmentId); |
45 | | -// |
46 | | -// if (departmentId == null) { |
47 | | -// departmentId = userRepositoryV2.findDepartmentIdById(userId).orElse(-1); |
48 | | -// // campusId가 -1이 아니면 캐시 저장 |
49 | | -// if (departmentId != -1) { |
50 | | -// redisTemplate.opsForValue().set(key, departmentId, Duration.ofDays(1)); // 1일 TTL 설정 |
51 | | -// } |
52 | | -// } |
53 | | -// return getParentDepartmentId(departmentId); |
54 | | -// } |
55 | | -// |
56 | | -// // 부모 게시판 매핑 (해당 학과 ID가 없으면 기본값 그대로 유지) |
57 | | -// public int getParentDepartmentId(int childDepartmentId) { |
58 | | -// Map<Integer, Integer> parentDepartmentMap = Map.of( |
59 | | -// 52, 51, |
60 | | -// 53, 51, |
61 | | -// 103, 102, |
62 | | -// 104, 102, |
63 | | -// 106, 105, |
64 | | -// 107, 105 |
65 | | -// ); |
66 | | -// return parentDepartmentMap.getOrDefault(childDepartmentId, childDepartmentId); |
67 | | -// } |
68 | | - |
69 | | - |
70 | 19 |
|
71 | 20 | public int getUserCampusId(String userId) { |
72 | 21 | Optional<Integer> campusId = userRepositoryV2.findCampusIdById(userId); |
|
0 commit comments