package com.xhkjedu.slive.service.liveplay;

import com.xhkjedu.slive.mapper.liveplay.CourseSectionAskstudentMapper;
import com.xhkjedu.slive.model.liveplay.LCourseSectionAskstudent;
import com.xhkjedu.utils.N_Utils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author ywx
 * @classname CSAskStudentService
 * @description
 * @date 2021/6/16 11:04
 **/
@Service
public class CSAskStudentService {
    @Resource
    private CourseSectionAskstudentMapper courseSectionAskstudentMapper;

    //添加
    public void save(LCourseSectionAskstudent ask) {
        LCourseSectionAskstudent askstudent = courseSectionAskstudentMapper.getBySatIdStudentId(ask);//获取学生互动记录
        if (askstudent != null) {//有学生互动记录更新
            ask.setSasid(askstudent.getSasid());
            courseSectionAskstudentMapper.updateByPrimaryKeySelective(ask);
        } else {//有学生互动记录添加
            ask.setCreatetime(N_Utils.getSecondTimestamp());
            courseSectionAskstudentMapper.insertSelective(ask);
        }
    }
}
