package com.loan.system.service.Impl;

import com.loan.system.domain.entity.LoanCase;
import com.loan.system.repository.LoanCaseRepository;
import com.loan.system.service.LoanCaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

@Service
public class LoanCaseServiceImpl implements LoanCaseService {
    @Autowired
    private LoanCaseRepository LoanCaseRepository;

    @Override

    public LoanCase findByIdAndIsDelete(Long id){
        return LoanCaseRepository.findByIdAndIsDelete(id,false);
    };
    @Override
    public void updateUpdatetimeByIdAndIsDeleted(Long id,boolean isDelete){
        LoanCaseRepository.updateUpdatetimeByIdAndIsDeleted(id,false, LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
    }
    @Override
    public void logic_delete(Long id){
           LoanCaseRepository.logic_delete(id, true, LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
    }
}
