package com.vctgo.system.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
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;
import com.vctgo.common.security.utils.SecurityUtils;
import com.vctgo.system.domain.SysReTenantKindergarten;
import com.vctgo.system.mapper.SysReTenantKindergartenMapper;
import com.vctgo.system.service.ISysReTenantKindergartenService;
import com.vctgo.system.util.ConstantUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
/**
 * 租户幼儿园关联Service业务层处理
 *
 * @author wanglonghua
 * @date 2023-08-09
 */
@Slf4j
@Service
public class SysReTenantKindergartenServiceImpl implements ISysReTenantKindergartenService
{
    @Autowired
    private SysReTenantKindergartenMapper sysReTenantKindergartenMapper;

    /**
     * 查询租户幼儿园关联
     *
     * @param id 租户幼儿园关联主键
     * @return 租户幼儿园关联
     */
    @Override
    public SysReTenantKindergarten selectSysReTenantKindergartenById(Long id)
    {
        return sysReTenantKindergartenMapper.selectById(id);
    }

    /**
     * 查询租户幼儿园关联列表-分页
     *
     * @param sysReTenantKindergarten 租户幼儿园关联
     * @return 租户幼儿园关联
     */
    @Override
    public IPage<SysReTenantKindergarten> selectSysReTenantKindergartenPage(SysReTenantKindergarten sysReTenantKindergarten)
    {
        Page mpPage =new Page(Convert.toLong(ServletUtils.getParameterToInt(MybatisPageConstants.PAGE_NUM),1L)
                ,Convert.toLong(ServletUtils.getParameterToInt(MybatisPageConstants.PAGE_SIZE),10L));
        return sysReTenantKindergartenMapper.selectSysReTenantKindergartenList(mpPage,sysReTenantKindergarten);
    }
    /**
     * 查询租户幼儿园关联列表
     *
     * @param sysReTenantKindergarten 租户幼儿园关联
     * @return 租户幼儿园关联
     */
    @Override
    public List<SysReTenantKindergarten> selectSysReTenantKindergartenList(SysReTenantKindergarten sysReTenantKindergarten)
    {
        return sysReTenantKindergartenMapper.selectSysReTenantKindergartenList(sysReTenantKindergarten);
    }

    /**
     * 新增租户幼儿园关联
     *
     * @param sysReTenantKindergarten 租户幼儿园关联
     * @return 结果
     */

    @Override
    public int insertSysReTenantKindergarten(SysReTenantKindergarten sysReTenantKindergarten)
    {
        return sysReTenantKindergartenMapper.insert(sysReTenantKindergarten);
    }

    /**
     * 修改租户幼儿园关联
     *
     * @param sysReTenantKindergarten 租户幼儿园关联
     * @return 结果
     */
    @Override
    public int updateSysReTenantKindergarten(SysReTenantKindergarten sysReTenantKindergarten)
    {
        return sysReTenantKindergartenMapper.updateById(sysReTenantKindergarten);
    }

    /**
     * 逻辑删除租户幼儿园关联
     *
     * @param ids 需要删除的租户幼儿园关联主键
     * @return 结果
     */
    @Override
    public int logicalDeleteSysReTenantKindergartenByIds(Long[] ids)
    {
        SysReTenantKindergarten sysReTenantKindergarten = new SysReTenantKindergarten();
        sysReTenantKindergarten.setUpdateBy(SecurityUtils.getUsername());
        sysReTenantKindergarten.setUpdateTime(new Date());
        sysReTenantKindergarten.setIsDeleted(ConstantUtils.IS_DELETED_1);
        return sysReTenantKindergartenMapper.logicalDeleteSysReTenantKindergartenByIds(ids, sysReTenantKindergarten);
    }

    /**
     * 批量删除租户幼儿园关联
     *
     * @param ids 需要删除的租户幼儿园关联主键
     * @return 结果
     */
    @Override
    public int deleteSysReTenantKindergartenByIds(Long[] ids)
    {
        return sysReTenantKindergartenMapper.deleteSysReTenantKindergartenByTenantIds(ids);
    }

    /**
     * 删除租户幼儿园关联信息
     *
     * @param id 租户幼儿园关联主键
     * @return 结果
     */
    @Override
    public int deleteSysReTenantKindergartenById(Long id)
    {
        return sysReTenantKindergartenMapper.deleteById(id);
    }
}
