package com.dbnt.faisp.authMgt;

import com.dbnt.faisp.authMgt.mapper.AuthMgtMapper;
import com.dbnt.faisp.authMgt.model.AccessConfig;
import com.dbnt.faisp.authMgt.model.ApprovalConfig;
import com.dbnt.faisp.authMgt.model.AuthMgt;
import com.dbnt.faisp.authMgt.repository.AccessConfigRepository;
import com.dbnt.faisp.authMgt.repository.ApprovalConfigRepository;
import com.dbnt.faisp.userInfo.model.UserInfo;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
@RequiredArgsConstructor
public class AuthMgtService {
  private final AuthMgtMapper authMgtMapper;
  private final AccessConfigRepository accessConfigRepository;
  private final ApprovalConfigRepository approvalConfigRepository;


  public List<AccessConfig> selectAccessConfigList(UserInfo userInfo) {
    return authMgtMapper.selectAccessConfigList(userInfo);
  }

  public List<ApprovalConfig> selectApprovalConfigList(UserInfo userInfo) {
    return authMgtMapper.selectApprovalConfigList(userInfo);
  }

  public void saveAuth(AuthMgt authMgt) {
    accessConfigRepository.saveAll(authMgt.getAccessConfigList());
    approvalConfigRepository.saveAll(authMgt.getApprovalConfigList());
  }
}
