package com.vctgo.system.service.impl;

import java.util.Date;
import java.util.List;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.vctgo.common.security.utils.SecurityUtils;
import com.vctgo.system.domain.SysAdminManage;
import com.vctgo.system.mapper.SysAdminManageMapper;
import com.vctgo.system.service.ISysAdminManageService;
import com.vctgo.system.util.ConstantUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.vctgo.common.core.text.Convert;
import com.vctgo.common.core.utils.ServletUtils;
import com.vctgo.common.mybatisplus.constant.MybatisPageConstants;

/**
 * 租户超管菜单管理Service业务层处理
 *
 * @author caesar
 * @date 2023-11-13
 */
@Slf4j
@Service
public class SysAdminManageServiceImpl implements ISysAdminManageService {
    @Autowired
    private SysAdminManageMapper sysAdminManageMapper;

    /**
     * 查询租户超管菜单管理
     *
     * @param id 租户超管菜单管理主键
     * @return 租户超管菜单管理
     */
    @Override
    public SysAdminManage selectSysAdminManageById(Long id) {
        return sysAdminManageMapper.selectById(id);
    }

    /**
     * 查询租户超管菜单管理列表-分页
     *
     * @param sysAdminManage 租户超管菜单管理
     * @return 租户超管菜单管理
     */
    @Override
    public IPage<SysAdminManage> selectSysAdminManagePage(SysAdminManage sysAdminManage) {
        Page mpPage = new Page(Convert.toLong(ServletUtils.getParameterToInt(MybatisPageConstants.PAGE_NUM), 1L)
                , Convert.toLong(ServletUtils.getParameterToInt(MybatisPageConstants.PAGE_SIZE), 10L));
        return sysAdminManageMapper.selectSysAdminManageList(mpPage, sysAdminManage);
    }

    /**
     * 查询租户超管菜单管理列表
     *
     * @param sysAdminManage 租户超管菜单管理
     * @return 租户超管菜单管理
     */
    @Override
    public List<SysAdminManage> selectSysAdminManageList(SysAdminManage sysAdminManage) {
        return sysAdminManageMapper.selectSysAdminManageList(sysAdminManage);
    }

    /**
     * 新增租户超管菜单管理
     *
     * @param sysAdminManage 租户超管菜单管理
     * @return 结果
     */

    @Override
    public int insertSysAdminManage(SysAdminManage sysAdminManage) {
        return sysAdminManageMapper.insert(sysAdminManage);
    }

    /**
     * 修改租户超管菜单管理
     *
     * @param sysAdminManage 租户超管菜单管理
     * @return 结果
     */
    @Override
    public int updateSysAdminManage(SysAdminManage sysAdminManage) {
        return sysAdminManageMapper.updateById(sysAdminManage);
    }

    /**
     * 逻辑删除租户超管菜单管理
     *
     * @param ids 需要删除的租户超管菜单管理主键
     * @return 结果
     */
    @Override
    public int logicalDeleteSysAdminManageByIds(Long[] ids) {
        SysAdminManage sysAdminManage = new SysAdminManage();
        sysAdminManage.setUpdateById(SecurityUtils.getUserId());
        sysAdminManage.setUpdateBy(SecurityUtils.getUsername());
        sysAdminManage.setUpdateTime(new Date());
        sysAdminManage.setIsDeleted(ConstantUtils.IS_DELETED_1);
        return sysAdminManageMapper.logicalDeleteSysAdminManageByIds(ids, sysAdminManage);
    }

    /**
     * 批量删除租户超管菜单管理
     *
     * @param ids 需要删除的租户超管菜单管理主键
     * @return 结果
     */
    @Override
    public int deleteSysAdminManageByIds(Long[] ids) {
        return sysAdminManageMapper.deleteSysAdminManageByIds(ids);
    }

    /**
     * 删除租户超管菜单管理信息
     *
     * @param id 租户超管菜单管理主键
     * @return 结果
     */
    @Override
    public int deleteSysAdminManageById(Long id) {
        return sysAdminManageMapper.deleteById(id);
    }
}
