package com.zhyc.module.base.service.impl;

import com.zhyc.module.base.domain.BasSheep;
import com.zhyc.module.base.domain.DaSheepfold;
import com.zhyc.module.base.mapper.BasSheepMapper;
import com.zhyc.module.base.mapper.DaSheepfoldMapper;
import com.zhyc.module.base.service.IDaSheepfoldService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 羊舍管理Service业务层处理
 * 
 * @author wyt
 * @date 2025-07-11
 */
@Service
public class DaSheepfoldServiceImpl implements IDaSheepfoldService 
{
    @Autowired
    private DaSheepfoldMapper daSheepfoldMapper;
    @Autowired
    private BasSheepMapper basSheepMapper;

    /**
     * 查询羊舍管理
     * 
     * @param id 羊舍管理主键
     * @return 羊舍管理
     */
    @Override
    public DaSheepfold selectDaSheepfoldById(Long id)
    {
        return daSheepfoldMapper.selectDaSheepfoldById(id);
    }

    /**
     * 查询羊舍管理列表
     * 
     * @param daSheepfold 羊舍管理
     * @return 羊舍管理
     */
    @Override
    public List<DaSheepfold> selectDaSheepfoldList(DaSheepfold daSheepfold)
    {
        return daSheepfoldMapper.selectDaSheepfoldList(daSheepfold);
    }

    /**
     * 新增羊舍管理
     * 
     * @param daSheepfold 羊舍管理
     * @return 结果
     */
    @Override
    public int insertDaSheepfold(DaSheepfold daSheepfold)
    {
        return daSheepfoldMapper.insertDaSheepfold(daSheepfold);
    }

    /**
     * 修改羊舍管理
     * 
     * @param daSheepfold 羊舍管理
     * @return 结果
     */
    @Override
    public int updateDaSheepfold(DaSheepfold daSheepfold)
    {
        return daSheepfoldMapper.updateDaSheepfold(daSheepfold);
    }

    /**
     * 批量删除羊舍管理
     * 
     * @param ids 需要删除的羊舍管理主键
     * @return 结果
     */
    @Override
    public int deleteDaSheepfoldByIds(Long[] ids)
    {
        return daSheepfoldMapper.deleteDaSheepfoldByIds(ids);
    }

    /**
     * 删除羊舍管理信息
     * 
     * @param id 羊舍管理主键
     * @return 结果
     */
    @Override
    public int deleteDaSheepfoldById(Long id)
    {
        return daSheepfoldMapper.deleteDaSheepfoldById(id);
    }


    @Override
    public boolean checkSheepfoldNoExist(Long ranchId, Long sheepfoldTypeId, String sheepfoldNo) {
        DaSheepfold query = new DaSheepfold();
        query.setRanchId(ranchId);
        query.setSheepfoldTypeId(sheepfoldTypeId);
        query.setSheepfoldNo(sheepfoldNo);
        return daSheepfoldMapper.selectCount(query) > 0;
    }

    @Override
    public List<BasSheep> sheepListById(String id) {
        List<BasSheep> basSheep = basSheepMapper.selectBasSheepBySheepfold(id);
        return basSheep;
    }
}
