package com.ruoyi.web.controller.front;

import com.ruoyi.back.domain.BCustomerQuestionError;
import com.ruoyi.back.service.IBCustomerQuestionErrorService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

@Api(tags = "04 题目纠错")
@RestController
@RequestMapping("front/adjustWrong/")
public class FrontAdjustWrongController extends BaseController {
    @Autowired
    private IBCustomerQuestionErrorService bCustomerQuestionErrorService;

    @ApiOperation("02 题目纠错")
    @PostMapping(value = "/correctQuestion")
    @ResponseBody
    public AjaxResult correctQuestion(@RequestBody BCustomerQuestionError wrongQuestion) {
        if(StringUtils.isNull(wrongQuestion.getQuestionid())){
            return AjaxResult.error("题目id不能为空");
        }
        wrongQuestion.setCustomercode(String.valueOf(SecurityUtils.getLoginUser().getUserId()));
        wrongQuestion.setCreateTime(new Date());
        bCustomerQuestionErrorService.insertBCustomerQuestionError(wrongQuestion);
        return AjaxResult.success("纠错成功");
    }

}
