package com.keao.edu.user.controller;

import com.keao.edu.common.controller.BaseController;
import com.keao.edu.common.entity.HttpResponseResult;
import com.keao.edu.common.page.PageInfo;
import com.keao.edu.user.dto.ExaminationBasicDto;
import com.keao.edu.user.entity.ExaminationBasic;
import com.keao.edu.user.page.ExaminationQueryInfo;
import com.keao.edu.user.service.ExaminationBasicService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author Joburgess
 * @Date 2020.06.18
 */
@RestController
@RequestMapping("examinationBasic")
@Api(tags = "考级项目服务")
public class ExaminationBasicController extends BaseController {

    @Autowired
    private ExaminationBasicService examinationBasicService;

    @ApiOperation("查询指定考级项目")
    @GetMapping(value = "/getExaminationBasic")
    public HttpResponseResult<ExaminationBasicDto> getExaminationBasic(Integer examId) {
        return succeed(examinationBasicService.getExaminationBasic(examId));
    }

    @ApiOperation("分页查询")
    @GetMapping(value = "/list")
    public HttpResponseResult<PageInfo<ExaminationBasicDto>> getList(ExaminationQueryInfo queryInfo) {
        return succeed(examinationBasicService.findExaminationBasics(queryInfo));
    }

    @ApiOperation("创建考级项目")
    @PostMapping(value = "/addExaminationBasic")
    public HttpResponseResult<ExaminationBasic> addExaminationBasic(@RequestBody ExaminationBasic examinationBasic){
        return succeed(examinationBasicService.addExaminationBasic(examinationBasic));
    }

    @ApiOperation("关闭考级项目")
    @PostMapping(value = "/closeExam")
    public HttpResponseResult closeExam(Integer examId, String reason){
        examinationBasicService.closeExam(examId, reason);
        return succeed();
    }

    @ApiOperation("获取考级项目信息")
    @PostMapping(value = "/getInfo")
    public HttpResponseResult<ExaminationBasic> getInfo(Integer examId){
        return succeed(examinationBasicService.getInfo(examId));
    }
}
