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.SysTeachWorkExperienceMapper;
import com.vctgo.system.domain.SysTeachWorkExperience;
import com.vctgo.system.service.ISysTeachWorkExperienceService;
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 SysTeachWorkExperienceServiceImpl implements ISysTeachWorkExperienceService {
    @Autowired
    private SysTeachWorkExperienceMapper sysTeachWorkExperienceMapper;

    /**
     * 查询幼儿园职工与工作经历关联
     *
     * @param id 幼儿园职工与工作经历关联主键
     * @return 幼儿园职工与工作经历关联
     */
    @Override
    public SysTeachWorkExperience selectSysTeachWorkExperienceById(Long id) {
        return sysTeachWorkExperienceMapper.selectById(id);
    }

    /**
     * 查询幼儿园职工与工作经历关联列表-分页
     *
     * @param sysTeachWorkExperience 幼儿园职工与工作经历关联
     * @return 幼儿园职工与工作经历关联
     */
    @Override
    public IPage<SysTeachWorkExperience> selectSysTeachWorkExperiencePage(SysTeachWorkExperience sysTeachWorkExperience) {
        Page mpPage = new Page(Convert.toLong(ServletUtils.getParameterToInt(MybatisPageConstants.PAGE_NUM), 1L)
                , Convert.toLong(ServletUtils.getParameterToInt(MybatisPageConstants.PAGE_SIZE), 10L));
        return sysTeachWorkExperienceMapper.selectSysTeachWorkExperienceList(mpPage, sysTeachWorkExperience);
    }

    /**
     * 查询幼儿园职工与工作经历关联列表
     *
     * @param sysTeachWorkExperience 幼儿园职工与工作经历关联
     * @return 幼儿园职工与工作经历关联
     */
    @Override
    public List<SysTeachWorkExperience> selectSysTeachWorkExperienceList(SysTeachWorkExperience sysTeachWorkExperience) {
        return sysTeachWorkExperienceMapper.selectSysTeachWorkExperienceList(sysTeachWorkExperience);
    }

    /**
     * 新增幼儿园职工与工作经历关联
     *
     * @param sysTeachWorkExperience 幼儿园职工与工作经历关联
     * @return 结果
     */

    @Override
    public int insertSysTeachWorkExperience(SysTeachWorkExperience sysTeachWorkExperience) {
        return sysTeachWorkExperienceMapper.insert(sysTeachWorkExperience);
    }

    /**
     * 修改幼儿园职工与工作经历关联
     *
     * @param sysTeachWorkExperience 幼儿园职工与工作经历关联
     * @return 结果
     */
    @Override
    public int updateSysTeachWorkExperience(SysTeachWorkExperience sysTeachWorkExperience) {
        return sysTeachWorkExperienceMapper.updateById(sysTeachWorkExperience);
    }

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

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

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