2022-08-23 02:34:25 +00:00
|
|
|
package com.dbnt.faisp.codeMgt;
|
2022-08-19 09:04:45 +00:00
|
|
|
|
2022-08-23 02:34:25 +00:00
|
|
|
import com.dbnt.faisp.codeMgt.model.CodeCatg;
|
|
|
|
|
import com.dbnt.faisp.codeMgt.model.CodeMgt;
|
|
|
|
|
import com.dbnt.faisp.codeMgt.repository.CodeCatgRepository;
|
|
|
|
|
import com.dbnt.faisp.codeMgt.repository.CodeMgtRepository;
|
2022-08-19 09:04:45 +00:00
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
@RequiredArgsConstructor
|
|
|
|
|
public class CodeMgtService{
|
|
|
|
|
|
|
|
|
|
private final CodeMgtRepository codeMgtRepository;
|
|
|
|
|
private final CodeCatgRepository codeCatgRepository;
|
|
|
|
|
|
2022-08-22 09:35:33 +00:00
|
|
|
@Transactional
|
|
|
|
|
public String saveCode(List<CodeCatg> codeMgtList){
|
|
|
|
|
for(CodeCatg codeCatg: codeMgtList){
|
|
|
|
|
codeCatgRepository.save(codeCatg);
|
|
|
|
|
if (codeCatg.getItemList().size()>0){
|
|
|
|
|
codeItemSave(codeCatg.getItemList());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void codeItemSave(List<CodeMgt> itemList){
|
|
|
|
|
codeMgtRepository.saveAll(itemList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<CodeCatg> selectCodeCatgAndChild() {
|
|
|
|
|
List<CodeCatg> codeCatgList = codeCatgRepository.findAll();
|
|
|
|
|
for(CodeCatg codeCatg: codeCatgList){
|
|
|
|
|
codeCatg.setItemList(codeMgtRepository.findByCategoryCdOrderByItemCdAsc(codeCatg.getCategoryCd()));
|
|
|
|
|
}
|
|
|
|
|
return codeCatgList;
|
|
|
|
|
}
|
2022-08-23 00:44:44 +00:00
|
|
|
|
|
|
|
|
public List<CodeMgt> selectCommonCodeList() {
|
|
|
|
|
return codeMgtRepository.findByUseChkOrderByItemCdAsc("T");
|
|
|
|
|
}
|
2022-08-29 04:04:40 +00:00
|
|
|
|
2022-08-29 04:16:37 +00:00
|
|
|
public List<CodeMgt> selectCodeMgtList(String categoryCd) {
|
|
|
|
|
return codeMgtRepository.findByCategoryCdOrderByItemCdAsc(categoryCd);
|
|
|
|
|
}
|
2022-08-19 09:04:45 +00:00
|
|
|
}
|