package com.unis.base.app.controller;

import com.unis.base.app.service.CompanyRecordsService;
import com.unis.base.client.CompanyRecordsFeign;
import com.unis.base.common.vo.CompanyRecordsQueryVO;
import com.unis.base.common.vo.CompanyRecordsVO;
import com.unis.base.common.vo.ExamineStampVO;
import com.unis.common.utils.ResponseWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author WangZL
 * @version 1.0
 * @Title CompanyRecordsController
 * @ProjectName 企业记录 Controller
 * @Description
 * @date 2019/07/22 17点26分
 */
@RestController
@Api(value = "企业记录", tags = "企业记录")
@Slf4j
public class CompanyRecordsController {

	@Autowired
	private CompanyRecordsFeign companyRecordsFeign;

	@Autowired
	private CompanyRecordsService companyRecordsService;

	@ApiOperation(value = "企业记录-分页查询列表", notes = "参数：涉粮企业备案记录ID，统一社会信用代码，备案时间（年度），是否备案")
	@PostMapping(value = "/companyRecordsPage/{pageNum}/{pageSize}")
	public ResponseWrapper getCompanyRecordsPage(@RequestBody CompanyRecordsQueryVO companyRecordsQueryVO, @PathVariable("pageNum")Integer pageNum, @PathVariable("pageSize") Integer pageSize) {
		return companyRecordsService.getCompanyRecordsPage(companyRecordsQueryVO,pageNum,pageSize) ;
	}

	@ApiOperation(value = "企业记录-查询详情", notes = "参数：企业记录ID")
	@GetMapping(value = "/companyRecords/{qybabh}")
	public ResponseWrapper getCompanyRecordsInfoById(@PathVariable("qybabh")String qybabh) {
        return companyRecordsService.getCompanyRecordsInfoById(qybabh);
	}

	@PostMapping(value = "/insertCompanyRecords/{type}")
	@ApiOperation(value = "企业信息-根据状态新增", notes = "参数：备案信息，保存状态")
	public ResponseWrapper insertCompanyRecords(@RequestBody CompanyRecordsVO CompanyRecordsVO,
												  @ApiParam(required = true, name ="type", value = "0、保存。1、提交")
												  @PathVariable("type")Integer type) {
		return companyRecordsService.insertCompanyRecords(CompanyRecordsVO,type);
	}

	@PostMapping(value = "/companyRecordsRelay/{qybabh}")
	@ApiOperation(value = "企业记录-提交", notes = "参数：企业记录ID")
	public ResponseWrapper companyRecordsRelay(@PathVariable("qybabh")String qybabh) {
		return companyRecordsService.companyRecordsRelay(qybabh);
	}

	@PostMapping(value = "/companyRecordsDirectorExamine")
	@ApiOperation(value = "企业记录-库区主任审批", notes = "参数：企业记录ID 审核状态status:1、审核通过。0、已驳回")
	public ResponseWrapper companyRecordsDirectorExamine(@RequestBody ExamineStampVO examineStampVO) {
		return companyRecordsService.companyRecordsDirectorExamine(examineStampVO);
	}

	@PostMapping(value = "/companyRecordsDistrictExamine")
	@ApiOperation(value = "企业记录-区粮办审批", notes = "参数：企业记录ID 审核状态status:1、审核通过。0、已驳回")
	public ResponseWrapper companyRecordsDistrictExamine(@RequestBody ExamineStampVO examineStampVO) {
		return companyRecordsService.companyRecordsDistrictExamine(examineStampVO);
	}

}
