package com.dbnt.faisp.fpiMgt.monthPlan;


import com.dbnt.faisp.fpiMgt.monthPlan.model.BoardPlan;
import com.dbnt.faisp.fpiMgt.monthPlan.model.PlanFile;
import com.dbnt.faisp.fpiMgt.monthPlan.repository.BoardPlanRepository;
import com.dbnt.faisp.fpiMgt.monthPlan.repository.PlanFileRepository;
import com.dbnt.faisp.fpiMgt.monthPlan.repository.PlanMainInfoRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
public class MonthPlanService {
    private final BoardPlanRepository boardPlanRepository;
    private final PlanFileRepository planFileRepository;
    private final PlanMainInfoRepository planMainInfoRepository;

    public BoardPlan selectBoardPlan(Integer planKey) {
        BoardPlan savedPlan = boardPlanRepository.findById(planKey).orElse(null);
        savedPlan.setFileList(planFileRepository.findByPlanKey(planKey));
        savedPlan.setMainInfoList(planMainInfoRepository.findByPlanKey(planKey));
        return savedPlan;
    }
}
