package com.yiqi.system.service.impl;

import java.util.List;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yiqi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.yiqi.system.mapper.SysConfigTabMapper;
import com.yiqi.system.domain.SysConfigTab;
import com.yiqi.system.service.ISysConfigTabService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

/**
 * 配置分类Service业务层处理
 *
 * @author douya
 * @date 2024-11-01
 */
@Service
public class SysConfigTabServiceImpl extends ServiceImpl<SysConfigTabMapper, SysConfigTab> implements ISysConfigTabService {

    //<editor-folder desc="基础韩素">

    /**
     * 查询配置分类
     *
     * @param id 配置分类主键
     * @return 配置分类
     */
    @Override
    public SysConfigTab selectSysConfigTabById(Integer id) {
        return baseMapper.selectSysConfigTabById(id);
    }

    /**
     * 查询配置分类列表
     *
     * @param sysConfigTab 配置分类
     * @return 配置分类
     */
    @Override
    public List<SysConfigTab> selectSysConfigTabList(SysConfigTab sysConfigTab) {
        return baseMapper.selectSysConfigTabList(sysConfigTab);
    }

    /**
     * 新增配置分类
     *
     * @param sysConfigTab 配置分类
     * @return 结果
     */
    @Override
    public int insertSysConfigTab(SysConfigTab sysConfigTab) {
        return baseMapper.insertSysConfigTab(sysConfigTab);
    }

    /**
     * 修改配置分类
     *
     * @param sysConfigTab 配置分类
     * @return 结果
     */
    @Override
    public int updateSysConfigTab(SysConfigTab sysConfigTab) {
        return baseMapper.updateSysConfigTab(sysConfigTab);
    }

    /**
     * 批量删除配置分类
     *
     * @param ids 需要删除的配置分类主键
     * @return 结果
     */
    @Override
    public int deleteSysConfigTabByIds(Integer[] ids) {
        return baseMapper.deleteSysConfigTabByIds(ids);
    }

    /**
     * 删除配置分类信息
     *
     * @param id 配置分类主键
     * @return 结果
     */
    @Override
    public int deleteSysConfigTabById(Integer id) {
        return baseMapper.deleteSysConfigTabById(id);
    }

    /**
     * 修改配置分类状态
     *
     * @param sysConfigTab 配置分类
     * @return 结果
     */
    @Override
    public int updateSysConfigTabStatus(SysConfigTab sysConfigTab) {
        return baseMapper.updateSysConfigTab(sysConfigTab);
    }

    @Override
    public List<SysConfigTab> selectSysConfigTabListByPid(Integer id) {
        QueryWrapper<SysConfigTab> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("pid", id);
        queryWrapper.eq("status", 1);
        return baseMapper.selectList(queryWrapper);
    }

    @Override
    public SysConfigTab selectSysConfigTabByTabKey(String tabKey) {
        QueryWrapper<SysConfigTab> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("eng_title", tabKey);
        queryWrapper.last("limit 1");
        return baseMapper.selectOne(queryWrapper);
    }
}
