package com.ruoyi.system.service.impl;

import java.util.List;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.StudentInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.TeacherInfoMapper;
import com.ruoyi.system.domain.TeacherInfo;
import com.ruoyi.system.service.ITeacherInfoService;

/**
 * 老师档案信息Service业务层处理
 * 
 * @author ruoyi
 * @date 2023-07-24
 */
@Service
public class TeacherInfoServiceImpl implements ITeacherInfoService 
{
    @Autowired
    private TeacherInfoMapper teacherInfoMapper;

    /**
     * 查询老师档案信息
     * 
     * @param id 老师档案信息主键
     * @return 老师档案信息
     */
    @Override
    public TeacherInfo selectTeacherInfoById(Long id)
    {
        return teacherInfoMapper.selectTeacherInfoById(id);
    }

    /**
     * 查询老师档案信息列表
     * 
     * @param teacherInfo 老师档案信息
     * @return 老师档案信息
     */
    @Override
    public List<TeacherInfo> selectTeacherInfoList(TeacherInfo teacherInfo)
    {
        return teacherInfoMapper.selectTeacherInfoList(teacherInfo);
    }

    /**
     * 新增老师档案信息
     * 
     * @param teacherInfo 老师档案信息
     * @return 结果
     */
    @Override
    public AjaxResult insertTeacherInfo(TeacherInfo teacherInfo)
    {
        //查询数据库是否存在信息
        TeacherInfo teacher = new TeacherInfo();
        teacher.setTeacherId(teacherInfo.getTeacherId());
        List<TeacherInfo> teacherInfos = teacherInfoMapper.selectTeacherInfoList(teacher);
        if(teacherInfos!=null && teacherInfos.size()>0){
            return AjaxResult.error("参数错误");
        }
        int rows = teacherInfoMapper.insertTeacherInfo(teacherInfo);
        return rows > 0 ? AjaxResult.success() : AjaxResult.error();
    }

    /**
     * 修改老师档案信息
     * 
     * @param teacherInfo 老师档案信息
     * @return 结果
     */
    @Override
    public int updateTeacherInfo(TeacherInfo teacherInfo)
    {
        teacherInfo.setUpdateTime(DateUtils.getNowDate());
        return teacherInfoMapper.updateTeacherInfo(teacherInfo);
    }

    /**
     * 批量删除老师档案信息
     * 
     * @param ids 需要删除的老师档案信息主键
     * @return 结果
     */
    @Override
    public int deleteTeacherInfoByIds(Long[] ids)
    {
        return teacherInfoMapper.deleteTeacherInfoByIds(ids);
    }

    /**
     * 删除老师档案信息信息
     * 
     * @param id 老师档案信息主键
     * @return 结果
     */
    @Override
    public int deleteTeacherInfoById(Long id)
    {
        return teacherInfoMapper.deleteTeacherInfoById(id);
    }
}
