package com.contract.review.service.impl;

import com.contract.review.entity.Regulation;
import com.contract.review.mapper.RegulationMapper;
import com.contract.review.service.RegulationService;
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 RegulationServiceImpl implements RegulationService {
    
    @Autowired
    private RegulationMapper regulationMapper;
    
    @Override
    public List<Regulation> getRegulationList(Map<String, Object> params) {
        return regulationMapper.getRegulationList(params);
    }
    
    @Override
    public int getRegulationCount(Map<String, Object> params) {
        return regulationMapper.getRegulationCount(params);
    }
    
    @Override
    public Regulation getRegulationById(Long id) {
        return regulationMapper.getRegulationById(id);
    }
    
    @Override
    public Regulation getRegulationByRuleNo(String ruleNo) {
        return regulationMapper.getRegulationByRuleNo(ruleNo);
    }
    
    @Override
    public Long addRegulation(Regulation regulation) {
        regulationMapper.addRegulation(regulation);
        return regulation.getId();
    }
    
    @Override
    public int updateRegulation(Regulation regulation) {
        return regulationMapper.updateRegulation(regulation);
    }
    
    @Override
    public int deleteRegulation(Long id) {
        return regulationMapper.deleteRegulation(id);
    }
    
    @Override
    public int updateRegulationStatus(Long id, Integer status) {
        Map<String, Object> params = new java.util.HashMap<>();
        params.put("id", id);
        params.put("status", status);
        return regulationMapper.updateRegulationStatus(params);
    }
}