package com.qmth.themis.business.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qmth.themis.business.dao.TEExamStudentOnlineLogMapper;
import com.qmth.themis.business.dto.MqDto;
import com.qmth.themis.business.entity.TEExamStudentOnlineLog;
import com.qmth.themis.business.enums.MqTagEnum;
import com.qmth.themis.business.service.MqDtoService;
import com.qmth.themis.business.service.TEExamStudentOnlineLogService;
import com.qmth.themis.business.util.JacksonUtil;
import com.qmth.themis.business.util.MqUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 * 考生上线日志 服务实现类
 * </p>
 *
 * @author wangliang
 * @since 2022-08-22
 */
@Service
public class TEExamStudentOnlineLogServiceImpl extends ServiceImpl<TEExamStudentOnlineLogMapper, TEExamStudentOnlineLog> implements TEExamStudentOnlineLogService {

    @Resource
    MqUtil mqUtil;

    @Resource
    MqDtoService mqDtoService;

    /**
     * 保存考生上下线日志
     *
     * @param teExamStudentOnlineLog
     */
    @Override
    public void sendExamStudentOnlineLogSaveMq(TEExamStudentOnlineLog teExamStudentOnlineLog) {
        MqDto mqDto = new MqDto(mqUtil.getTopic(), MqTagEnum.ONLINE_LOG.name(), JacksonUtil.parseJson(teExamStudentOnlineLog), MqTagEnum.ONLINE_LOG, String.valueOf(teExamStudentOnlineLog.getExamRecordId()), String.valueOf(teExamStudentOnlineLog.getExamRecordId()));
        mqDtoService.assembleSendAsyncMsg(mqDto);
    }
}
