package com.xhkjedu.smarking.service.papercheck;

import com.xhkjedu.smarking.mapper.papercheck.MsPaperCheckTeacherScoresetMapper;
import com.xhkjedu.smarking.model.papercheck.MsPaperCheckTeacherScoreset;
import com.xhkjedu.utils.N_Utils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @Description 阅卷批阅教师常用分设置表 服务实现类
 * @Author auto
 * @Date 2024-10-15
 */
@Service
public class MsPaperCheckTeacherScoresetService {
    @Resource
    private MsPaperCheckTeacherScoresetMapper msPaperCheckTeacherScoresetMapper;

    /**
     * @Description 设置常用分
     * @Date 2024/11/1 14:39
     * @Author YWX
     * @Param [set]
     * @Return void
     **/
    public void add(MsPaperCheckTeacherScoreset set) {
        MsPaperCheckTeacherScoreset scoreset = msPaperCheckTeacherScoresetMapper.findByExamIdAndTeacherId(set.getExamid(), set.getTeacherid());
        set.setCreatetime(N_Utils.getSecondTimestamp());
        if (scoreset != null) {
            set.setMpctsid(scoreset.getMpctsid());
            msPaperCheckTeacherScoresetMapper.updateByPrimaryKey(set);
        } else {
            msPaperCheckTeacherScoresetMapper.insert(set);
        }
    }

    /**
     * @Description 常用给分详情
     * @Date 2024/11/1 14:42
     * @Author YWX
     * @Param [examid, teacherid]
     * @Return com.xhkjedu.smarking.model.papercheck.MsPaperCheckTeacherScoreset
     **/
    public MsPaperCheckTeacherScoreset findByExamIdAndTeacherId(Integer examid, Integer teacherid) {
        return msPaperCheckTeacherScoresetMapper.findByExamIdAndTeacherId(examid, teacherid);
    }
}
