package com.bonus.canteen.core.basic.service.impl;

import java.util.List;
import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.core.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.bonus.canteen.core.basic.mapper.BasicStallMealtimeMapper;
import com.bonus.canteen.core.basic.domain.BasicStallMealtime;
import com.bonus.canteen.core.basic.service.IBasicStallMealtimeService;

/**
 * 档口餐次配置Service业务层处理
 * 
 * @author xsheng
 * @date 2025-05-25
 */
@Service
public class BasicStallMealtimeServiceImpl implements IBasicStallMealtimeService {
    @Autowired
    private BasicStallMealtimeMapper basicStallMealtimeMapper;

    /**
     * 查询档口餐次配置
     * 
     * @param id 档口餐次配置主键
     * @return 档口餐次配置
     */
    @Override
    public BasicStallMealtime selectBasicStallMealtimeById(Long id) {
        return basicStallMealtimeMapper.selectBasicStallMealtimeById(id);
    }

    /**
     * 查询档口餐次配置列表
     * 
     * @param basicStallMealtime 档口餐次配置
     * @return 档口餐次配置
     */
    @Override
    public List<BasicStallMealtime> selectBasicStallMealtimeList(BasicStallMealtime basicStallMealtime) {
        return basicStallMealtimeMapper.selectBasicStallMealtimeList(basicStallMealtime);
    }

    /**
     * 新增档口餐次配置
     * 
     * @param basicStallMealtime 档口餐次配置
     * @return 结果
     */
    @Override
    public int insertBasicStallMealtime(BasicStallMealtime basicStallMealtime) {
        basicStallMealtime.setCreateTime(DateUtils.getNowDate());
        try {
            return basicStallMealtimeMapper.insertBasicStallMealtime(basicStallMealtime);
        } catch (Exception e) {
            throw new ServiceException(e.getMessage());
        }
    }

    /**
     * 修改档口餐次配置
     * 
     * @param basicStallMealtime 档口餐次配置
     * @return 结果
     */
    @Override
    public int updateBasicStallMealtime(BasicStallMealtime basicStallMealtime) {
        basicStallMealtime.setUpdateTime(DateUtils.getNowDate());
        try {
            return basicStallMealtimeMapper.updateBasicStallMealtime(basicStallMealtime);
        } catch (Exception e) {
            throw new ServiceException(e.getMessage());
        }
    }

    /**
     * 批量删除档口餐次配置
     * 
     * @param ids 需要删除的档口餐次配置主键
     * @return 结果
     */
    @Override
    public int deleteBasicStallMealtimeByIds(Long[] ids) {
        return basicStallMealtimeMapper.deleteBasicStallMealtimeByIds(ids);
    }

    /**
     * 删除档口餐次配置信息
     * 
     * @param id 档口餐次配置主键
     * @return 结果
     */
    @Override
    public int deleteBasicStallMealtimeById(Long id) {
        return basicStallMealtimeMapper.deleteBasicStallMealtimeById(id);
    }
}
