package com.rongwei.training.controller;

import com.rongwei.rwcommon.base.R;
import com.rongwei.rwcommon.utils.StringUtils;
import com.rongwei.trainingcommon.sys.service.SubjectService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * SubjectController class
 *
 * @author XH
 * @date 2020/11/23
 */
@RestController
@RequestMapping("subject")
@Slf4j
public class SubjectController {
    @Autowired
    private SubjectService subjectService;


    @PostMapping("/check")
    public R saveEmpExam(@RequestBody List<String> subjectIds) {
        try {
            log.info("开始校验考题是否被试卷所引用");
            return subjectService.checkInfo(subjectIds);
        } catch (Exception e) {
            log.error(StringUtils.spliceErrorMsg(e), e.fillInStackTrace());
            return R.queryError();
        }

    }
}
