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.common.tenant.TenantContextHolder;
import com.keao.edu.user.entity.ExamManualLedger;
import com.keao.edu.user.page.ExamManualLedgerQueryInfo;
import com.keao.edu.user.service.ExamManualLedgerService;
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.07.07
 */
@RestController
@RequestMapping("examManualLedger")
@Api(tags = "指出记录服务")
public class ExamManualLedgerController extends BaseController {

    @Autowired
    private ExamManualLedgerService examManualLedgerService;

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

    @ApiOperation("新增考点")
    @PostMapping(value = "/add")
    public HttpResponseResult add(@RequestBody ExamManualLedger examManualLedger) {
        examManualLedger.setTenantId(TenantContextHolder.getTenantId().toString());
        examManualLedgerService.insert(examManualLedger);
        return succeed();
    }

    @ApiOperation("更新考点")
    @PostMapping(value = "/update")
    public HttpResponseResult update(@RequestBody ExamManualLedger examManualLedger) {
        examManualLedgerService.update(examManualLedger);
        return succeed();
    }

    @ApiOperation("删除考点")
    @PostMapping(value = "/del")
    public HttpResponseResult add(Long id) {
        return succeed(examManualLedgerService.delete(id));
    }

}
