package com.game.business.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.util.List;

import com.game.common.annotation.DataSource;
import com.game.common.enums.DataSourceType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.game.business.mapper.AppGameClassifyMapper;
import com.game.business.domain.AppGameClassify;
import com.game.business.service.IAppGameClassifyService;

/**
 * 游戏分类Service业务层处理
 *
 * @author dos
 * @date 2024-06-14
 */
@Service
public class AppGameClassifyServiceImpl extends ServiceImpl<AppGameClassifyMapper, AppGameClassify> implements IAppGameClassifyService {
    @Autowired
    private AppGameClassifyMapper appGameClassifyMapper;

    /**
     * 查询游戏分类
     *
     * @param id 游戏分类主键
     * @return 游戏分类
     */
    @Override
    @DataSource(DataSourceType.SLAVE)
    public AppGameClassify selectAppGameClassifyById(Long id) {
        return appGameClassifyMapper.selectAppGameClassifyById(id);
    }

    /**
     * 查询游戏分类列表
     *
     * @param appGameClassify 游戏分类
     * @return 游戏分类
     */
    @Override
    @DataSource(DataSourceType.SLAVE)
    public List<AppGameClassify> selectAppGameClassifyList(AppGameClassify appGameClassify) {
        return appGameClassifyMapper.selectAppGameClassifyList(appGameClassify);
    }

    /**
     * 新增游戏分类
     *
     * @param appGameClassify 游戏分类
     * @return 结果
     */
    @Override
    @DataSource(DataSourceType.SLAVE)
    public int insertAppGameClassify(AppGameClassify appGameClassify) {
            return appGameClassifyMapper.insertAppGameClassify(appGameClassify);
    }

    /**
     * 修改游戏分类
     *
     * @param appGameClassify 游戏分类
     * @return 结果
     */
    @Override
    @DataSource(DataSourceType.SLAVE)
    public int updateAppGameClassify(AppGameClassify appGameClassify) {
        return appGameClassifyMapper.updateAppGameClassify(appGameClassify);
    }

    /**
     * 批量删除游戏分类
     *
     * @param ids 需要删除的游戏分类主键
     * @return 结果
     */
    @Override
    @DataSource(DataSourceType.SLAVE)
    public int deleteAppGameClassifyByIds(Long[] ids) {
        return appGameClassifyMapper.deleteAppGameClassifyByIds(ids);
    }

    /**
     * 删除游戏分类信息
     *
     * @param id 游戏分类主键
     * @return 结果
     */
    @Override
    @DataSource(DataSourceType.SLAVE)
    public int deleteAppGameClassifyById(Long id) {
        return appGameClassifyMapper.deleteAppGameClassifyById(id);
    }

    @Override
    @DataSource(DataSourceType.SLAVE)
    public AppGameClassify getByCode(String code) {
        LambdaQueryWrapper<AppGameClassify> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.eq(AppGameClassify::getCode, code);
        return appGameClassifyMapper.selectOne(queryWrapper);
    }
}