package com.yiboshi.science.rest.v1;

import com.yiboshi.arch.base.ResponseDataModel;
import com.yiboshi.science.base.Pagination;
import com.yiboshi.science.entity.ComEvaluationStandard;
import com.yiboshi.science.param.dto.ComBatchDTO;
import com.yiboshi.science.param.dto.ComEvaluationStandardDTO;
import com.yiboshi.science.param.query.ComEvaluationStandardQueryVO;
import com.yiboshi.science.rest.BaseController;
import com.yiboshi.science.service.ComEvaluationStandardService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "com-evaluation-standard", description = "评审标准表")
@RestController
@RequestMapping("/v1/science-admin/com-evaluation-standard")
public class ComEvaluationStandardController extends BaseController<ComEvaluationStandardService, ComEvaluationStandardQueryVO, ComEvaluationStandardDTO, ComEvaluationStandard> {

    @Autowired
    private ComEvaluationStandardService comEvaluationStandardService;

    @ApiOperation(value = "分页查询", httpMethod = "GET", notes = "根据参数获取列表")
    @GetMapping
    @RequestMapping("/getListByPage")
    public ResponseDataModel<Pagination<ComEvaluationStandardDTO>> getListByPage(@Validated ComEvaluationStandardQueryVO vo, BindingResult bindingResult) {
        Pagination<ComEvaluationStandardDTO> page = comEvaluationStandardService.getListByPage(vo);
        return ResponseDataModel.ok(page);
    }

    @ApiOperation(value = "获取评审标准信息", httpMethod = "GET", notes = "获取评审标准信息")
    @GetMapping
    @RequestMapping("/getEvaluationStandardById")
    public ResponseDataModel<ComEvaluationStandardDTO> getEvaluationStandardById(String id) {
        return ResponseDataModel.ok(comEvaluationStandardService.getEvaluationStandardById(id));
    }

    @ApiOperation(value = "获取当前年度批次（下拉）", httpMethod = "GET", notes = "获取当前年度批次（下拉）")
    @GetMapping
    @RequestMapping("/getEvaluationYearBatchList")
    public ResponseDataModel<List<ComBatchDTO>> getEvaluationYearBatchList() {
        return ResponseDataModel.ok(comEvaluationStandardService.getEvaluationYearBatchList());
    }

    @ApiOperation(value = "评审标准添加", httpMethod = "POST", notes = "评审标准添加")
    @RequestMapping("/insertEvaluationStandard")
    @PostMapping
    //@Logs(value = CommonEnum.LogType.BatchAdd)
    public ResponseDataModel<String> insertEvaluationStandard(@Validated @RequestBody ComEvaluationStandardDTO dto) {
        return ResponseDataModel.ok(comEvaluationStandardService.insertEvaluationStandard(dto));
    }

    @ApiOperation(value = "评审标准修改", httpMethod = "POST", notes = "评审标准修改")
    @RequestMapping("/updateEvaluationStandard")
    @PostMapping
    //@Logs(value = CommonEnum.LogType.BatchUpdate)
    public ResponseDataModel<String> updateEvaluationStandard(@Validated @RequestBody ComEvaluationStandardDTO dto) {
        return ResponseDataModel.ok(comEvaluationStandardService.updateEvaluationStandard(dto));
    }

    @ApiOperation(value = "删除评审标准", httpMethod = "DELETE", notes = "删除评审标准")
    @DeleteMapping(value = "deleteEvaluationStandard/{id}")
    //@Logs(value = CommonEnum.LogType.BatchDelete)
    public ResponseDataModel<String> deleteEvaluationStandard(@PathVariable String id) {
        return ResponseDataModel.ok(comEvaluationStandardService.deleteEvaluationStandard(id));
    }
}
