package com.zjty.autotest.controller;

import com.zjty.autotest.pojo.sjq.AutoResultSet;
import com.zjty.autotest.pojo.sjq.TestChannel;
import com.zjty.autotest.pojo.sjq.TestReport;
import com.zjty.autotest.pojo.sjq.common.PageResult;
import com.zjty.autotest.pojo.sjq.common.ResponseResult;
import com.zjty.autotest.service.AutoResultSetService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@CrossOrigin
@RequestMapping("/auto")
@Api(value = "自动测评管理接口",description = "自动测评管理接口,提供页面的增、删、改、查")
public class AutoResultSetController {

    @Autowired
    private AutoResultSetService autoResultSetService;


    /**
	 * 分页+多条件查询
	 * @param searchMap 查询条件封装
	 * @param page 页码
	 * @param size 页大小
	 * @return 分页结果
	 */
    @ApiOperation("根据条件分页排序查询")
    @RequestMapping(value="/search/{page}/{size}",method=RequestMethod.POST)
    public ResponseResult findSearch(@RequestBody Map searchMap , @PathVariable int page, @PathVariable int size){
        Page<AutoResultSet> pageList = autoResultSetService.findSearch(searchMap, page, size);
        return  ResponseResult.okResult( new PageResult<AutoResultSet>(pageList.getTotalElements(), pageList.getContent()) );
    }
    @ApiOperation("根据id删除")
    @RequestMapping(value="/{id}",method= RequestMethod.DELETE)
    public ResponseResult delete(@PathVariable String id ){
        return autoResultSetService.deleteByid(id);
    }
    @ApiOperation("新增")
    @RequestMapping(method=RequestMethod.POST)
    public ResponseResult add(@RequestBody TestChannel testChannel  ){
        return autoResultSetService.addResultSet(testChannel);
    }



}
