package com.contract.review.service.impl;

import com.contract.review.entity.ContractRisk;
import com.contract.review.mapper.ContractRiskMapper;
import com.contract.review.service.ContractRiskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

/**
 * 合同风险服务实现
 */
@Service
@Transactional
public class ContractRiskServiceImpl implements ContractRiskService {
    
    @Autowired
    private ContractRiskMapper contractRiskMapper;
    
    @Override
    public List<ContractRisk> getRiskList(Map<String, Object> params) {
        return contractRiskMapper.getRiskList(params);
    }
    
    @Override
    public List<ContractRisk> getRiskListByContractId(Long contractId) {
        return contractRiskMapper.getRiskListByContractId(contractId);
    }
    
    @Override
    public ContractRisk getRiskById(Long id) {
        return contractRiskMapper.getRiskById(id);
    }
    
    @Override
    public Long addRisk(ContractRisk risk) {
        contractRiskMapper.addRisk(risk);
        return risk.getId();
    }
    
    @Override
    public int updateRisk(ContractRisk risk) {
        return contractRiskMapper.updateRisk(risk);
    }
    
    @Override
    public int deleteRisk(Long id) {
        return contractRiskMapper.deleteRisk(id);
    }
    
    @Override
    public int deleteRiskByContractId(Long contractId) {
        return contractRiskMapper.deleteRiskByContractId(contractId);
    }
    
    @Override
    public int updateRiskStatus(Long id, Integer status) {
        Map<String, Object> params = new java.util.HashMap<>();
        params.put("id", id);
        params.put("status", status);
        return contractRiskMapper.updateRiskStatus(params);
    }
}
