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 com.bonus.common.security.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.bonus.canteen.core.basic.mapper.BasicSettingMapper;
import com.bonus.canteen.core.basic.domain.BasicSetting;
import com.bonus.canteen.core.basic.service.IBasicSettingService;

/**
 * 功能参数配置Service业务层处理
 * 
 * @author xsheng
 * @date 2025-05-25
 */
@Service
public class BasicSettingServiceImpl implements IBasicSettingService {
    @Autowired
    private BasicSettingMapper basicSettingMapper;

    /**
     * 查询功能参数配置
     * 
     * @param id 功能参数配置主键
     * @return 功能参数配置
     */
    @Override
    public BasicSetting selectBasicSettingById(Long id) {
        return basicSettingMapper.selectBasicSettingById(id);
    }

    /**
     * 查询功能参数配置列表
     * 
     * @param basicSetting 功能参数配置
     * @return 功能参数配置
     */
    @Override
    public List<BasicSetting> selectBasicSettingList(BasicSetting basicSetting) {
        return basicSettingMapper.selectBasicSettingList(basicSetting);
    }

    /**
     * 新增功能参数配置
     * 
     * @param basicSetting 功能参数配置
     * @return 结果
     */
    @Override
    public int insertBasicSetting(BasicSetting basicSetting) {
        basicSetting.setCreateTime(DateUtils.getNowDate());
        basicSetting.setCreateBy(SecurityUtils.getUsername());
        try {
            return basicSettingMapper.insertBasicSetting(basicSetting);
        } catch (Exception e) {
            throw new ServiceException(e.getMessage());
        }
    }

    /**
     * 修改功能参数配置
     * 
     * @param basicSetting 功能参数配置
     * @return 结果
     */
    @Override
    public int updateBasicSetting(BasicSetting basicSetting) {
        basicSetting.setUpdateTime(DateUtils.getNowDate());
        basicSetting.setUpdateBy(SecurityUtils.getUsername());
        try {
            return basicSettingMapper.updateBasicSetting(basicSetting);
        } catch (Exception e) {
            throw new ServiceException(e.getMessage());
        }
    }

    /**
     * 批量删除功能参数配置
     * 
     * @param ids 需要删除的功能参数配置主键
     * @return 结果
     */
    @Override
    public int deleteBasicSettingByIds(Long[] ids) {
        return basicSettingMapper.deleteBasicSettingByIds(ids);
    }

    /**
     * 删除功能参数配置信息
     * 
     * @param id 功能参数配置主键
     * @return 结果
     */
    @Override
    public int deleteBasicSettingById(Long id) {
        return basicSettingMapper.deleteBasicSettingById(id);
    }
}
