|
|
@@ -3,6 +3,7 @@ package com.its.op.service.its.ifsc;
|
|
|
import com.its.op.dao.repository.its.ifsc.TbIfscRepository;
|
|
|
import com.its.op.dto.its.ifsc.TbIfscDto;
|
|
|
import com.its.op.entity.its.ifsc.TbIfsc;
|
|
|
+import com.its.op.global.TbIfscManager;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
@@ -12,6 +13,7 @@ import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.NoSuchElementException;
|
|
|
import java.util.Optional;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Slf4j
|
|
|
@RequiredArgsConstructor
|
|
|
@@ -19,6 +21,7 @@ import java.util.Optional;
|
|
|
public class TbIfscService {
|
|
|
|
|
|
private final TbIfscRepository repo;
|
|
|
+ private final TbIfscManager manager;
|
|
|
|
|
|
// 데이터 1건 조회, 없으면 exception
|
|
|
private TbIfsc requireOne(Long id) throws NoSuchElementException {
|
|
|
@@ -38,9 +41,14 @@ public class TbIfscService {
|
|
|
* @return
|
|
|
*/
|
|
|
@Transactional(readOnly = true)
|
|
|
- public List<TbIfscDto> findAll() {
|
|
|
+ public List<TbIfscDto> findAll(boolean isMemory) {
|
|
|
List<TbIfscDto> result = new ArrayList<>();
|
|
|
- List<TbIfsc> data = this.repo.findAll();
|
|
|
+ List<TbIfsc> data;
|
|
|
+ if (isMemory) {
|
|
|
+ data = this.manager.findAll();
|
|
|
+ } else {
|
|
|
+ data = this.repo.findAll();
|
|
|
+ }
|
|
|
for (TbIfsc entity : data) {
|
|
|
result.add(entity.toDto());
|
|
|
}
|
|
|
@@ -52,9 +60,15 @@ public class TbIfscService {
|
|
|
* @return
|
|
|
*/
|
|
|
@Transactional(readOnly = true)
|
|
|
- public List<TbIfscDto> findAllList() {
|
|
|
+ public List<TbIfscDto> findAllList(boolean isMemory) {
|
|
|
List<TbIfscDto> result = new ArrayList<>();
|
|
|
- List<TbIfsc> data = this.repo.findAllList();
|
|
|
+ List<TbIfsc> data;
|
|
|
+ if (isMemory) {
|
|
|
+ List<TbIfsc> temp = this.manager.findAll();
|
|
|
+ data = temp.stream().filter(obj -> "N".equals(obj.getDelYn())).collect(Collectors.toList());
|
|
|
+ } else {
|
|
|
+ data = this.repo.findAllList();
|
|
|
+ }
|
|
|
for (TbIfsc entity : data) {
|
|
|
result.add(entity.toDto());
|
|
|
}
|
|
|
@@ -74,6 +88,7 @@ public class TbIfscService {
|
|
|
TbIfsc entity = requireOne(id);
|
|
|
entity.updateInfo(req);
|
|
|
this.repo.save(entity);
|
|
|
+ this.manager.put(entity.getIfscId(), entity);
|
|
|
return entity.toDto();
|
|
|
}
|
|
|
|
|
|
@@ -84,6 +99,7 @@ public class TbIfscService {
|
|
|
for (TbIfscDto.TbIfscUpdReq req : reqList) {
|
|
|
TbIfsc obj = req.toEntity();
|
|
|
this.repo.save(obj);
|
|
|
+ this.manager.put(obj.getIfscId(), obj);
|
|
|
result.add(obj.toDto());
|
|
|
}
|
|
|
return result;
|
|
|
@@ -94,6 +110,7 @@ public class TbIfscService {
|
|
|
public TbIfscDto mergeInfo(TbIfscDto.TbIfscUpdReq req) {
|
|
|
TbIfsc obj = req.toEntity();
|
|
|
this.repo.save(obj);
|
|
|
+ this.manager.put(obj.getIfscId(), obj);
|
|
|
return obj.toDto();
|
|
|
}
|
|
|
|
|
|
@@ -102,6 +119,7 @@ public class TbIfscService {
|
|
|
public TbIfscDto deleteById(Long id) {
|
|
|
TbIfsc entity = requireOne(id);
|
|
|
this.repo.deleteById(id);
|
|
|
+ this.manager.remove(id);
|
|
|
return entity.toDto();
|
|
|
}
|
|
|
|
|
|
@@ -113,6 +131,7 @@ public class TbIfscService {
|
|
|
Optional<TbIfsc> obj = this.repo.findById(id);
|
|
|
if (obj.isPresent()) {
|
|
|
this.repo.deleteById(id);
|
|
|
+ this.manager.remove(id);
|
|
|
result.add(obj.get().toDto());
|
|
|
}
|
|
|
}
|
|
|
@@ -121,9 +140,16 @@ public class TbIfscService {
|
|
|
|
|
|
// 지역센터 전체 데이터 조회
|
|
|
@Transactional(readOnly = true)
|
|
|
- public List<TbIfscDto> findLocalAll() {
|
|
|
+ public List<TbIfscDto> findLocalAll(boolean isMemory) {
|
|
|
List<TbIfscDto> result = new ArrayList<>();
|
|
|
- List<TbIfsc> data = this.repo.findAll();
|
|
|
+ List<TbIfsc> data;
|
|
|
+ if (isMemory) {
|
|
|
+ List<TbIfsc> temp = this.manager.findAll();
|
|
|
+ data = temp.stream().filter(obj -> "N".equals(obj.getDelYn())).collect(Collectors.toList());
|
|
|
+ } else {
|
|
|
+ data = this.repo.findAllList();
|
|
|
+ }
|
|
|
+
|
|
|
for (TbIfsc entity : data) {
|
|
|
if (("LAT001").equals(entity.getAreaCd())) {
|
|
|
result.add(entity.toDto());
|
|
|
@@ -137,13 +163,17 @@ public class TbIfscService {
|
|
|
* @param filter
|
|
|
* @return
|
|
|
*/
|
|
|
- public List<TbIfscDto> findByFilter(String filter) {
|
|
|
+ public List<TbIfscDto> findByFilter(String filter, boolean isMemory) {
|
|
|
List<TbIfscDto> result = new ArrayList<>();
|
|
|
- List<TbIfsc> data = this.repo.findAll();
|
|
|
+ List<TbIfsc> data;
|
|
|
+ if (isMemory) {
|
|
|
+ List<TbIfsc> temp = this.manager.findAll();
|
|
|
+ data = temp.stream().filter(obj -> "N".equals(obj.getDelYn())).collect(Collectors.toList());
|
|
|
+ } else {
|
|
|
+ data = this.repo.findAllList();
|
|
|
+ }
|
|
|
+
|
|
|
data.forEach(obj -> {
|
|
|
- if (("Y").equals(obj.getDelYn())) {
|
|
|
- return;
|
|
|
- }
|
|
|
if (filter == null || filter.isEmpty()) {
|
|
|
result.add(obj.toDto());
|
|
|
} else {
|
|
|
@@ -161,6 +191,7 @@ public class TbIfscService {
|
|
|
TbIfsc entity = requireOne(id);
|
|
|
entity.updateName(req);
|
|
|
this.repo.save(entity);
|
|
|
+ this.manager.put(entity.getIfscId(), entity);
|
|
|
return entity.toDto();
|
|
|
}
|
|
|
|
|
|
@@ -169,6 +200,7 @@ public class TbIfscService {
|
|
|
TbIfsc entity = requireOne(id);
|
|
|
entity.updateSectGrad(req);
|
|
|
this.repo.save(entity);
|
|
|
+ this.manager.put(entity.getIfscId(), entity);
|
|
|
return entity.toDto();
|
|
|
}
|
|
|
}
|