package com.unis.base.app.controller;

import com.unis.base.app.service.SinkpointRecordsService;
import com.unis.base.client.SinkpointRecordsFeign;
import com.unis.base.common.vo.ExamineStampVO;
import com.unis.base.common.vo.SinkpointRecordsQueryVO;
import com.unis.base.common.vo.SinkpointRecordsVO;
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 SinkpointRecordsController
 * @ProjectName 库点记录 Controller
 * @Description
 * @date 2019/07/22 17点26分
 */
@RestController
@Api(value = "库点记录", tags = "库点记录")
@Slf4j
public class SinkpointRecordsController {

	@Autowired
	private SinkpointRecordsFeign sinkpointRecordsFeign;

	@Autowired
	private SinkpointRecordsService sinkpointRecordsService;

	@ApiOperation(value = "库点记录-查询列表", notes = "参数：涉粮库点备案记录ID，统一社会信用代码，备案时间（年度），是否备案")
	@PostMapping(value = "/sinkpointRecordsList")
    public ResponseWrapper getSinkpointRecordsList(@RequestBody SinkpointRecordsQueryVO sinkpointRecordsQueryVO){
        return sinkpointRecordsFeign.getSinkpointRecordsList(sinkpointRecordsQueryVO);
    }

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

	@ApiOperation(value = "库点记录-查询详情", notes = "参数：库点记录ID")
	@GetMapping(value = "/sinkpointRecords/{kdbabh}")
	public ResponseWrapper getSinkpointRecordsInfoById(@PathVariable("kdbabh")String kdbabh) {
        return sinkpointRecordsService.getSinkpointRecordsInfoById(kdbabh);
	}


	@PutMapping(value = "/sinkpointRecords")
	@ApiOperation(value = "库点记录-更新", notes = "参数：库点记录信息")
	public ResponseWrapper update(@RequestBody SinkpointRecordsVO sinkpointRecordsVO) {
		return sinkpointRecordsFeign.update(sinkpointRecordsVO);
	}

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

	@PostMapping(value = "/sinkpointRecordsRelay/{kdbabh}")
	@ApiOperation(value = "库点记录-提交", notes = "参数：库点记录ID")
	public ResponseWrapper sinkpointRecordsRelay(@PathVariable("kdbabh")String kdbabh) {
		return sinkpointRecordsService.sinkpointRecordsRelay(kdbabh);
	}

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

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

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

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