package com.qmth.distributed.print.business.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qmth.distributed.print.business.entity.ExamTaskApplyTemp;
import com.qmth.distributed.print.business.mapper.ExamTaskApplyTempMapper;
import com.qmth.distributed.print.business.service.ExamTaskApplyTempService;
import com.qmth.teachcloud.common.entity.SysUser;
import com.qmth.teachcloud.common.util.ServletUtil;
import org.springframework.stereotype.Service;

import java.util.Objects;

/**
 * @Date: 2021/9/6.
 */
@Service
public class ExamTaskApplyTempServiceImpl extends ServiceImpl<ExamTaskApplyTempMapper, ExamTaskApplyTemp> implements ExamTaskApplyTempService {
    @Override
    public ExamTaskApplyTemp stageTaskApply(ExamTaskApplyTemp examTaskApplyTemp) {
        Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
        SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
        if (Objects.isNull(examTaskApplyTemp.getId())) {
            examTaskApplyTemp.setSchoolId(schoolId);
            examTaskApplyTemp.setOrgId(sysUser.getOrgId());
        }
        this.saveOrUpdate(examTaskApplyTemp);
        return examTaskApplyTemp;
    }
}
