package com.zjty.autotest.controller;

import com.zjty.autotest.pojo.sjq.TestReport;
import com.zjty.autotest.pojo.sjq.common.AppHttpCodeEnum;
import com.zjty.autotest.pojo.sjq.common.ResponseResult;
import com.zjty.autotest.service.TestReportService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 控制器层
 * @author Administrator
 *
 */
@RestController
@CrossOrigin
@RequestMapping("/report")
@Api(value = "报告管理接口",description = "提供输入输出查询接口")
public class TestReportController {

	@Autowired
	private TestReportService testReportService;

	
	/**
	 * 根据ID查询
	 * @param id ID
	 * @return*/
	@ApiOperation("根据AutoResultId查询输入")
	@RequestMapping(value="/in/{id}",method= RequestMethod.GET)
	public ResponseResult findByIdInData(@PathVariable String id){
		TestReport testReport = testReportService.findByResultId(id);
		if(testReport!=null) {
			return ResponseResult.okResult(testReport.getInputReport());
		}
		return ResponseResult.errorResult(AppHttpCodeEnum.ERROR);
	}

	/**
	 * 根据ID查询
	 * @param id ID
	 * @return*/
	@ApiOperation("根据AutoResultId查询输出")
	@RequestMapping(value="/out/{id}",method= RequestMethod.GET)
	public ResponseResult findByIdOutData(@PathVariable String id){
		TestReport testReport = testReportService.findByResultId(id);
		if(testReport!=null) {
			return ResponseResult.okResult(testReport.getOutReport());
		}
		return ResponseResult.errorResult(AppHttpCodeEnum.ERROR);
	}

}
