package com.jy.business.contract.service.impl;

import com.jy.business.contract.dao.ContractDetailDao;
import com.jy.business.contract.model.dto.ContractDetailDto;
import com.jy.business.contract.model.dto.ContractDetailSelectDto;
import com.jy.business.contract.model.vo.ContractDetailVo;
import com.jy.business.contract.service.ContractDetailService;
import com.jy.framework.utils.AssertUtil;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p>
 * 合同明细 服务实现类
 * </p>
 *
 * @author 
 * @since 2025-01-07
 */
@Service
public class ContractDetailServiceImpl implements ContractDetailService {

    @Resource
    private ContractDetailDao contractDetailDao;

    @Override
    public List<ContractDetailVo> getList(ContractDetailSelectDto dto) {
        return contractDetailDao.getList(dto);
    }

    @Override
    public ContractDetailVo getDetail(Long id) {
        ContractDetailVo vo = contractDetailDao.getDetail(id);
        AssertUtil.notNull(vo, "未知数据");
        return vo;
    }

    @Override
    public void add(ContractDetailDto dto) {
        contractDetailDao.save(dto);
    }

    @Override
    public void edit(ContractDetailDto dto) {
        contractDetailDao.updateById(dto);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public void delete(List<Long> idList) {
        contractDetailDao.removeBatchByIds(idList);
    }

}
