package com.zd.exam.controller;

import com.zd.common.core.utils.SecurityUtils;
import com.zd.common.core.web.controller.BaseController;
import com.zd.common.core.web.domain.AjaxResult;
import com.zd.common.log.annotation.Log;
import com.zd.common.log.enums.BusinessType;
import com.zd.common.security.annotation.PreAuthorize;
import com.zd.exam.domain.ElSafeTrainRecord;
import com.zd.exam.service.IElSafeTrainRecordService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 培训学习记录Controller
 *
 * @author zhoupan
 * @date 2021-09-07
 */
@RestController
@RequestMapping("/learnrecord")
@Api(tags = {"学习记录"})
public class ElSafeTrainRecordController extends BaseController {
    @Autowired
    private IElSafeTrainRecordService elSafeTrainRecordService;


    /**
     * 完成培训 id = 培训资料ID
     */
    @Log(title = "培训学习记录", businessType = BusinessType.INSERT)
    @PostMapping("/{id}")
    public AjaxResult add(@PathVariable Long id) {
        ElSafeTrainRecord elSafeTrainRecord = new ElSafeTrainRecord();
        elSafeTrainRecord.setSafeTrainId(id);
        elSafeTrainRecord.setJoinUserId(SecurityUtils.getUserIdEx());
        return toAjax(elSafeTrainRecordService.insertElSafeTrainRecord(elSafeTrainRecord));
    }


}
