package com.loan.system.service.Impl;

import com.loan.system.domain.entity.CollateralPlan;
import com.loan.system.repository.CollateralPlanRepository;
import com.loan.system.repository.CollateralRepository;
import com.loan.system.service.CollateralPlanService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CollateralPlanServiceImpl implements CollateralPlanService {

    private final CollateralPlanRepository collateralPlanRepository;

    public CollateralPlanServiceImpl(CollateralPlanRepository collateralPlanRepository) {
        this.collateralPlanRepository = collateralPlanRepository;
    }


    @Override
    public void save(CollateralPlan collateralPlan) {
        collateralPlanRepository.save(collateralPlan);
    }

    @Override
    public CollateralPlan findByCollateralPlanId(Long id){
        return collateralPlanRepository.findByIdAndIsDelete(id,false);
    }

    @Override
    public void logic_delete(Long id){
        collateralPlanRepository.logic_delete(id);
    }

    @Override
    public void updateCollateraluserIdByid(Long id,Long userId){
        collateralPlanRepository.updateCollateralUserIdeByid(id,userId);
    }

    @Override
    public List<CollateralPlan> findByCaseIdAndIsDelete(Long caseId, boolean isDelete){
        return collateralPlanRepository.findByCaseIdAndIsDelete(caseId,isDelete);
    };

    @Override
    public  void updateCollateralStatusByid(Long collateralId, String status){
        collateralPlanRepository.updateCollateralStatusByid(collateralId,status);
    }

    @Override
    public void updateCollateraloperatorIdByid(Long planId, Long operatorId, String operatorName){
        collateralPlanRepository.updateCollateraloperatorIdByid(planId,operatorId,operatorName);
    };

    @Override
    public List<CollateralPlan> findByCollateralIdAndIsDelete(Long collateralId){
        return collateralPlanRepository.findsByCollateralIdAndIsDelete(collateralId,false);
    }

    @Override
    public CollateralPlan findById(Long id){
        return collateralPlanRepository.findByIdAndIsDelete(id,false);
    }
}
