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

import com.bonus.canteen.core.supermarket.domain.SupermarketInfo;
import com.bonus.canteen.core.supermarket.mapper.SupermarketInfoMapper;
import com.bonus.canteen.core.supermarket.service.SupermarketInfoService;
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 java.util.List;

/**
 * 超市Service业务层处理
 *
 * @author xsheng
 * @date 2025-04-05
 */
@Service
public class SupermarketInfoServiceImpl implements SupermarketInfoService {
    @Autowired
    private SupermarketInfoMapper supermarketInfoMapper;

    /**
     * 查询超市列表
     *
     * @param SupermarketInfo 超市
     * @return 超市
     */
    @Override
    public List<SupermarketInfo> selectSupermarketInfoList(SupermarketInfo SupermarketInfo) {
        return supermarketInfoMapper.selectSupermarketInfoList(SupermarketInfo);
    }

    /**
     * 新增超市
     *
     * @param SupermarketInfo 超市
     * @return 结果
     */
    @Override
    public int insertSupermarketInfo(SupermarketInfo supermarketInfo) {
        supermarketInfo.setCreateTime(DateUtils.getNowDate());
        supermarketInfo.setUpdateTime(DateUtils.getNowDate());
        try {
            return supermarketInfoMapper.insertSupermarketInfo(supermarketInfo);
        } catch (Exception e) {
            throw new ServiceException("错误信息描述");
        }
    }

    /**
     * 修改超市
     *
     * @param SupermarketInfo 超市
     * @return 结果
     */
    @Override
    public int updateSupermarketInfo(SupermarketInfo SupermarketInfo) {
        SupermarketInfo.setUpdateTime(DateUtils.getNowDate());
        try {
            return supermarketInfoMapper.updateSupermarketInfo(SupermarketInfo);
        } catch (Exception e) {
            throw new ServiceException("错误信息描述");
        }
    }

    /**
     * 批量删除超市
     *
     * @param SupermarketIds 需要删除的超市主键
     * @return 结果
     */
    @Override
    public int deleteSupermarketInfoBySupermarketIds(Long[] SupermarketIds) {
        return supermarketInfoMapper.deleteSupermarketInfoBySupermarketIds(SupermarketIds);
    }

    /**
     * 删除超市信息
     *
     * @param supermarketInfo 超市主键
     * @return 结果
     */
    @Override
    public int deleteSupermarketInfoBySupermarketId(SupermarketInfo supermarketInfo) {
        return supermarketInfoMapper.deleteSupermarketInfoBySupermarketId(supermarketInfo);
    }

    @Override
    public List<SupermarketInfo> getSupermarketList() {
        return supermarketInfoMapper.getSupermarketList();
    }
}
