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.entity.ExamMusicTheory;
import com.keao.edu.user.page.ExamMusicTheoryQueryInfo;
import com.keao.edu.user.service.ExamMusicTheoryService;
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;
import java.util.List;

/**
 * @Author Joburgess
 * @Date 2020.07.01
 */
@RestController
@RequestMapping("examMusicTheory")
@Api(tags = "考级乐理")
public class ExamMusicTheoryController extends BaseController {

    @Autowired
    private ExamMusicTheoryService examMusicTheoryService;

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

    @ApiOperation("新增")
    @PostMapping(value = "/add")
    public HttpResponseResult add(ExamMusicTheory examMusicTheory) {
        examMusicTheoryService.insert(examMusicTheory);
        return succeed();
    }

    @ApiOperation("更新")
    @PostMapping(value = "/update")
    public HttpResponseResult update(ExamMusicTheory examMusicTheory) {
        examMusicTheory.setUpdateTime(new Date());
        examMusicTheoryService.update(examMusicTheory);
        return succeed();
    }

    @ApiOperation("删除")
    @PostMapping(value = "/del/{id}")
    public HttpResponseResult add(@PathVariable("id") Integer id) {
        return succeed(examMusicTheoryService.delete(id));
    }


    @ApiOperation("获取项目乐理级别列表")
    @GetMapping(value = "/getTheoryLevelList")
    public HttpResponseResult<List<ExamMusicTheory>> getTheoryLevelList(Integer examinationBasicId) {
        return succeed(examMusicTheoryService.getTheoryLevelList(examinationBasicId));
    }

}
