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

import java.util.Date;
import java.util.List;

import com.zhyc.common.annotation.DataScope;
import org.springframework.stereotype.Service;
import com.zhyc.module.feed.mapper.SgFeedPlanMapper;
import com.zhyc.module.feed.domain.SgFeedPlan;
import com.zhyc.module.feed.service.ISgFeedPlanService;
import org.springframework.transaction.annotation.Transactional;

/**
 * 饲喂计划Service业务层处理
 *
 * @author HashMap
 * @date 2025-08-14
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class SgFeedPlanServiceImpl implements ISgFeedPlanService {
    private final SgFeedPlanMapper sgFeedPlanMapper;

    public SgFeedPlanServiceImpl(SgFeedPlanMapper sgFeedPlanMapper) {
        this.sgFeedPlanMapper = sgFeedPlanMapper;
    }

    /**
     * 查询饲喂计划
     *
     * @param createDate 饲喂计划主键
     * @return 饲喂计划
     */
    @Override
    public SgFeedPlan selectSgFeedPlanByCreateDate(Date createDate) {
        return sgFeedPlanMapper.selectSgFeedPlanByCreateDate(createDate);
    }

    /**
     * 查询饲喂计划列表
     *
     * @param sgFeedPlan 饲喂计划
     * @return 饲喂计划
     */
    @Override
    @DataScope(deptAlias = "sg_feed_plan_alias", userAlias = "sg_feed_plan_alias")
    public List<SgFeedPlan> selectSgFeedPlanList(SgFeedPlan sgFeedPlan) {
        return sgFeedPlanMapper.selectSgFeedPlanList(sgFeedPlan);
    }

    /**
     * 新增饲喂计划
     *
     * @param sgFeedPlan 饲喂计划
     * @return 结果
     */
    @Override
    public int insertSgFeedPlan(SgFeedPlan sgFeedPlan) {
        return sgFeedPlanMapper.insertSgFeedPlan(sgFeedPlan);
    }

    /**
     * 修改饲喂计划
     *
     * @param sgFeedPlan 饲喂计划
     * @return 结果
     */
    @Override
    public int updateSgFeedPlan(SgFeedPlan sgFeedPlan) {
        return sgFeedPlanMapper.updateSgFeedPlan(sgFeedPlan);
    }

    /**
     * 批量删除饲喂计划
     *
     * @param createDates 需要删除的饲喂计划主键
     * @return 结果
     */
    @Override
    public int deleteSgFeedPlanByCreateDates(Date[] createDates) {
        return sgFeedPlanMapper.deleteSgFeedPlanByCreateDates(createDates);
    }

    /**
     * 删除饲喂计划信息
     *
     * @param createDate 饲喂计划主键
     * @return 结果
     */
    @Override
    public int deleteSgFeedPlanByCreateDate(Date createDate) {
        return sgFeedPlanMapper.deleteSgFeedPlanByCreateDate(createDate);
    }

    @Override
    public int getSheepCountByFoldId(Integer foldId) {
        return sgFeedPlanMapper.selectSheepCountByFoldId(foldId);
    }
}
