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.SysTeachProjectAchievementMapper;
import com.vctgo.system.domain.SysTeachProjectAchievement;
import com.vctgo.system.service.ISysTeachProjectAchievementService;
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 SysTeachProjectAchievementServiceImpl implements ISysTeachProjectAchievementService {
    @Autowired
    private SysTeachProjectAchievementMapper sysTeachProjectAchievementMapper;

    /**
     * 查询幼儿园教职工与课题成果关联
     *
     * @param id 幼儿园教职工与课题成果关联主键
     * @return 幼儿园教职工与课题成果关联
     */
    @Override
    public SysTeachProjectAchievement selectSysTeachProjectAchievementById(Long id) {
        return sysTeachProjectAchievementMapper.selectById(id);
    }

    /**
     * 查询幼儿园教职工与课题成果关联列表-分页
     *
     * @param sysTeachProjectAchievement 幼儿园教职工与课题成果关联
     * @return 幼儿园教职工与课题成果关联
     */
    @Override
    public IPage<SysTeachProjectAchievement> selectSysTeachProjectAchievementPage(SysTeachProjectAchievement sysTeachProjectAchievement) {
        Page mpPage = new Page(Convert.toLong(ServletUtils.getParameterToInt(MybatisPageConstants.PAGE_NUM), 1L)
                , Convert.toLong(ServletUtils.getParameterToInt(MybatisPageConstants.PAGE_SIZE), 10L));
        return sysTeachProjectAchievementMapper.selectSysTeachProjectAchievementList(mpPage, sysTeachProjectAchievement);
    }

    /**
     * 查询幼儿园教职工与课题成果关联列表
     *
     * @param sysTeachProjectAchievement 幼儿园教职工与课题成果关联
     * @return 幼儿园教职工与课题成果关联
     */
    @Override
    public List<SysTeachProjectAchievement> selectSysTeachProjectAchievementList(SysTeachProjectAchievement sysTeachProjectAchievement) {
        return sysTeachProjectAchievementMapper.selectSysTeachProjectAchievementList(sysTeachProjectAchievement);
    }

    /**
     * 新增幼儿园教职工与课题成果关联
     *
     * @param sysTeachProjectAchievement 幼儿园教职工与课题成果关联
     * @return 结果
     */

    @Override
    public int insertSysTeachProjectAchievement(SysTeachProjectAchievement sysTeachProjectAchievement) {
        return sysTeachProjectAchievementMapper.insert(sysTeachProjectAchievement);
    }

    /**
     * 修改幼儿园教职工与课题成果关联
     *
     * @param sysTeachProjectAchievement 幼儿园教职工与课题成果关联
     * @return 结果
     */
    @Override
    public int updateSysTeachProjectAchievement(SysTeachProjectAchievement sysTeachProjectAchievement) {
        return sysTeachProjectAchievementMapper.updateById(sysTeachProjectAchievement);
    }

    /**
     * 逻辑删除幼儿园教职工与课题成果关联
     *
     * @param ids 需要删除的幼儿园教职工与课题成果关联主键
     * @return 结果
     */
    @Override
    public int logicalDeleteSysTeachProjectAchievementByIds(Long[] ids) {
        SysTeachProjectAchievement sysTeachProjectAchievement = new SysTeachProjectAchievement();
        sysTeachProjectAchievement.setUpdateById(SecurityUtils.getUserId());
        sysTeachProjectAchievement.setUpdateBy(SecurityUtils.getUsername());
        sysTeachProjectAchievement.setUpdateTime(new Date());
        sysTeachProjectAchievement.setIsDeleted(ConstantUtils.IS_DELETED_1);
        return sysTeachProjectAchievementMapper.logicalDeleteSysTeachProjectAchievementByIds(ids, sysTeachProjectAchievement);
    }

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

    /**
     * 删除幼儿园教职工与课题成果关联信息
     *
     * @param id 幼儿园教职工与课题成果关联主键
     * @return 结果
     */
    @Override
    public int deleteSysTeachProjectAchievementById(Long id) {
        return sysTeachProjectAchievementMapper.deleteById(id);
    }
}
