package com.dbnt.kcgfilemanager.service;

import com.dbnt.kcgfilemanager.mapper.CommonCodeMapper;
import com.dbnt.kcgfilemanager.model.CommonCode;
import com.dbnt.kcgfilemanager.model.UserInfo;
import com.dbnt.kcgfilemanager.repository.CommonCodeRepository;
import com.dbnt.kcgfilemanager.repository.UserInfoRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.security.crypto.password.Pbkdf2PasswordEncoder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@RequiredArgsConstructor
public class CommonCodeService {

  private final CommonCodeMapper commonCodeMapper;
  private final CommonCodeRepository commonCodeRepository;

  public List<CommonCode> selectCommonCodeCategory(CommonCode commonCode) {
    return commonCodeMapper.selectCommonCodeCategory(commonCode);
  }
  public List<CommonCode> selectCommonCodeValue(String category) {
    return commonCodeRepository.findByCategoryAndIsDeleted(category, "N");
  }
  public void insertCommonCode(CommonCode commonCode) {
    commonCodeRepository.save(commonCode);
  }

  public void updateCommonCode(List<CommonCode> codeList) {
    commonCodeRepository.saveAll(codeList);
  }
}
