package com.keao.edu.user.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
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.entity.ExamSong;
import com.keao.edu.user.entity.ExamSubjectSong;
import com.keao.edu.user.page.ExamSubjectSongQueryInfo;
import com.keao.edu.user.service.ExamSubjectSongService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author Joburgess
 * @Date 2020.06.18
 */
@RestController
@RequestMapping("examSubjectSong")
@Api(tags = "考级内容服务")
public class ExamSubjectSongController extends BaseController {

    @Autowired
    private ExamSubjectSongService examSubjectSongService;

    @ApiOperation("分页查询")
    @GetMapping(value = "/list")
    public HttpResponseResult<PageInfo<ExamSubjectSong>> getList(ExamSubjectSongQueryInfo queryInfo) {
        return succeed(examSubjectSongService.queryPage(queryInfo));
    }

    @ApiOperation("添加考试内容")
    @PostMapping(value = "/addExamSubjects")
    public HttpResponseResult addExamSubjects(@RequestBody List<ExamSubjectSong> examSubjectSongs) {
        examSubjectSongService.addExamSubjects(examSubjectSongs);
        return succeed();
    }

    @ApiOperation(value = "删除考试内容")
    @PostMapping(value = "del")
    public HttpResponseResult del(Long id) {
        examSubjectSongService.delete(id);
        return succeed();
    }

    @ApiOperation("获取考级专业相应级别列表-报名")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "examinationBasicId", value = "项目id", required = true, dataType = "Integer"),
            @ApiImplicitParam(name = "examSubjectId", value = "考试项目专业id", required = true, dataType = "Integer")})
    @GetMapping(value = "/getExamSubjectLevel")
    public HttpResponseResult<List<ExamSubjectSong>> getExamSubjectLevel(Integer examinationBasicId, Long examSubjectId) {
        return succeed(examSubjectSongService.getExamSubjectLevels(examinationBasicId, examSubjectId));
    }

    @ApiOperation("获取考级专业相应级别的曲目-报名")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "examinationBasicId", value = "项目id", required = true, dataType = "Integer"),
            @ApiImplicitParam(name = "examSubjectId", value = "考试项目专业id", required = true, dataType = "Integer"),
            @ApiImplicitParam(name = "level", value = "级别", required = true, dataType = "Integer")})
    @GetMapping(value = "/getExamSubjectSong")
    public HttpResponseResult<List<ExamSong>> getExamSubjectSong(Integer examinationBasicId, Long examSubjectId, Integer level) {
        return succeed(examSubjectSongService.getExamSubjectSong(examinationBasicId, examSubjectId, level));
    }

}
