package com.yiboshi.science.rest.v1;


import com.yiboshi.arch.base.ResponseDataModel;
import com.yiboshi.science.base.Pagination;
import com.yiboshi.science.config.annotation.Logs;
import com.yiboshi.science.entity.ComEvaluation;
import com.yiboshi.science.enumeration.CommonEnum;
import com.yiboshi.science.param.dto.ComBatchDTO;
import com.yiboshi.science.param.dto.ComEvaluationDTO;
import com.yiboshi.science.param.query.ComEvaluationQueryVO;
import com.yiboshi.science.rest.BaseController;
import com.yiboshi.science.service.ComEvaluationService;
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.*;


@Api(tags = "com-expert-spec", description = "评审表")
@RestController
@RequestMapping("/v1/science-admin/com-evaluation")
public class ComEvaluationController extends BaseController<ComEvaluationService, ComEvaluationQueryVO, ComEvaluationDTO, ComEvaluation> {

    @Autowired
    private   ComEvaluationService comEvaluationService;

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

    @ApiOperation(value = "获取评审表信息", httpMethod = "GET", notes = "获取评审表信息")
    @GetMapping
    @RequestMapping("/getEvaluationById")
    public ResponseDataModel<ComEvaluationDTO> getEvaluationById(String id) {
        return ResponseDataModel.ok(comEvaluationService.getEvaluationById(id));
    }

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

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

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