package com.vctgo.system.service.impl;

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

import com.vctgo.common.security.utils.SecurityUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.vctgo.system.mapper.SysTeachEducationMapper;
import com.vctgo.system.domain.SysTeachEducation;
import com.vctgo.system.service.ISysTeachEducationService;
import com.vctgo.system.util.ConstantUtils;
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;

/**
 * 幼儿园教职工与学历关联Service业务层处理
 *
 * @author caesar
 * @date 2024-03-27
 */
@Slf4j
@Service
public class SysTeachEducationServiceImpl implements ISysTeachEducationService {
    @Autowired
    private SysTeachEducationMapper sysTeachEducationMapper;

    /**
     * 查询幼儿园教职工与学历关联
     *
     * @param id 幼儿园教职工与学历关联主键
     * @return 幼儿园教职工与学历关联
     */
    @Override
    public SysTeachEducation selectSysTeachEducationById(Long id) {
        return sysTeachEducationMapper.selectById(id);
    }

    /**
     * 查询幼儿园教职工与学历关联列表-分页
     *
     * @param sysTeachEducation 幼儿园教职工与学历关联
     * @return 幼儿园教职工与学历关联
     */
    @Override
    public IPage<SysTeachEducation> selectSysTeachEducationPage(SysTeachEducation sysTeachEducation) {
        Page mpPage = new Page(Convert.toLong(ServletUtils.getParameterToInt(MybatisPageConstants.PAGE_NUM), 1L)
                , Convert.toLong(ServletUtils.getParameterToInt(MybatisPageConstants.PAGE_SIZE), 10L));
        return sysTeachEducationMapper.selectSysTeachEducationList(mpPage, sysTeachEducation);
    }

    /**
     * 查询幼儿园教职工与学历关联列表
     *
     * @param sysTeachEducation 幼儿园教职工与学历关联
     * @return 幼儿园教职工与学历关联
     */
    @Override
    public List<SysTeachEducation> selectSysTeachEducationList(SysTeachEducation sysTeachEducation) {
        return sysTeachEducationMapper.selectSysTeachEducationList(sysTeachEducation);
    }

    /**
     * 新增幼儿园教职工与学历关联
     *
     * @param sysTeachEducation 幼儿园教职工与学历关联
     * @return 结果
     */

    @Override
    public int insertSysTeachEducation(SysTeachEducation sysTeachEducation) {
        return sysTeachEducationMapper.insert(sysTeachEducation);
    }

    /**
     * 修改幼儿园教职工与学历关联
     *
     * @param sysTeachEducation 幼儿园教职工与学历关联
     * @return 结果
     */
    @Override
    public int updateSysTeachEducation(SysTeachEducation sysTeachEducation) {
        return sysTeachEducationMapper.updateById(sysTeachEducation);
    }

    /**
     * 逻辑删除幼儿园教职工与学历关联
     *
     * @param ids 需要删除的幼儿园教职工与学历关联主键
     * @return 结果
     */
    @Override
    public int logicalDeleteSysTeachEducationByIds(Long[] ids) {
        SysTeachEducation sysTeachEducation = new SysTeachEducation();
        sysTeachEducation.setUpdateById(SecurityUtils.getUserId());
        sysTeachEducation.setUpdateBy(SecurityUtils.getUsername());
        sysTeachEducation.setUpdateTime(new Date());
        sysTeachEducation.setIsDeleted(ConstantUtils.IS_DELETED_1);
        return sysTeachEducationMapper.logicalDeleteSysTeachEducationByIds(ids, sysTeachEducation);
    }

    /**
     * 批量删除幼儿园教职工与学历关联
     *
     * @param ids 需要删除的幼儿园教职工与学历关联主键
     * @return 结果
     */
    @Override
    public int deleteSysTeachEducationByIds(Long[] ids) {
        return sysTeachEducationMapper.deleteSysTeachEducationByIds(ids);
    }

    /**
     * 删除幼儿园教职工与学历关联信息
     *
     * @param id 幼儿园教职工与学历关联主键
     * @return 结果
     */
    @Override
    public int deleteSysTeachEducationById(Long id) {
        return sysTeachEducationMapper.deleteById(id);
    }
}
