package com.cool.store.dao;

import com.cool.store.entity.ContractConfigDO;
import com.cool.store.mapper.ContractConfigMapper;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author suzhuhong
 * @Date 2025/9/8 15:37
 * @Version 1.0
 */
@Repository
public class ContractConfigDAO {

    @Resource
    private ContractConfigMapper contractConfigMapper;


    public ContractConfigDO queryContractConfigById(Long id){
       return contractConfigMapper.selectByPrimaryKey(id);
    }

    public int addContractConfig(ContractConfigDO contractConfigDO){
       return contractConfigMapper.insertSelective(contractConfigDO);
    }

    public int updateContractConfig(ContractConfigDO contractConfigDO){
       return contractConfigMapper.updateByPrimaryKeySelective(contractConfigDO);
    }

    /**
     * 根据品牌查询对应排序是否存在
     * @param brand
     * @param serialNumber
     * @return
     */
    public ContractConfigDO queryContractConfigByBrand(String brand,Integer serialNumber){
        return contractConfigMapper.queryContractConfigByBrand(brand,serialNumber);
    }


    /**
     * 合同配置列表
     * @param brand
     * @return
     */
    public List<ContractConfigDO> queryContractConfigList(String brand) {
        return contractConfigMapper.queryContractConfigList(brand);
    }

    /**
     * 根据加盟品牌与加盟模式 查出所有的未删除状态的合并合同
     * @param brand
     * @param mode
     * @return
     */
    public List<ContractConfigDO> queryContractConfigListByBrandAndMode(String brand,String mode) {
        return contractConfigMapper.queryContractConfigListByBrandAndMode(brand,mode);
    }

    public void deleteContractConfig(Long id) {
        contractConfigMapper.deleteByPrimaryKey(id);
    }
}
