package com.dhcc.finance.main.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.dhcc.common.model.CurrencyMeta;
import com.dhcc.common.model.response.RestfulResponse;
import com.dhcc.finance.constant.MsConfigConsts;
import com.dhcc.finance.main.domain.CwBdRecordBatch;
import com.dhcc.finance.main.model.VoucherRequestInfo;
import com.dhcc.finance.main.service.CwBdRecordBatchService;
import com.github.pagehelper.PageInfo;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping(value = MsConfigConsts.MS_API_PREFIX + CwBdRecordBatchController.API_PREFIX, 
  	          produces = {MediaType.APPLICATION_JSON_UTF8_VALUE }, consumes = { MediaType.APPLICATION_JSON_UTF8_VALUE })
@Api(value = "自动生成凭证批次号记录controller", tags = { "自动生成凭证批次号记录接口" })
public class CwBdRecordBatchController {
	// 会计科目版本操作接口地址前缀
	public static final String API_PREFIX = "/cw_bd_record_batch";
	
	@Autowired
	CwBdRecordBatchService cwBdRecordBatchService;
	
	/**
	 * 功能描述   查询所有记录批次信息
	 * @param pageNum
	 * @param pageSize
	 * @param navigatePages
	 * @return RestfulResponse<PageInfo<CwBdRecordBatch>,CurrencyMeta>
	 * @author huangpeng
	 * @date 2019年7月16日 上午9:19:08
	 * 修改日志
	 */
	@ApiOperation(value = "查询所有批次信息", notes = "", produces = MediaType.APPLICATION_JSON_UTF8_VALUE, consumes = MediaType.ALL_VALUE)
	@ApiImplicitParams({
			@ApiImplicitParam(name = "signType", value = "是否记账", required = false, dataType = "String", paramType="query"),
			@ApiImplicitParam(name = "batchNo", value = "批次号", required = false, dataType = "String", paramType="query"),
			@ApiImplicitParam(name = "failReason", value = "失败原因", required = false, dataType = "String", paramType="query"),
		@ApiImplicitParam(name = "tradeCode", value = "交易码", required = false, dataType = "String", paramType="query"),
		@ApiImplicitParam(name = "xtzxmbh", value = "子项目名", required = false, dataType = "String", paramType="query"),
        @ApiImplicitParam(name = "pageNum", value = "页码", required = true, dataType = "String", paramType="query"),
        @ApiImplicitParam(name = "pageSize", value = "每页显示数量", required = true, dataType = "String", paramType="query"),
        @ApiImplicitParam(name = "navigatePages", value = "需要连续显示的页码数量", required = true, dataType = "String", paramType="query")
    }) 
	@RequestMapping(value = { "/searchCwBdRecordBatchAll" }, method = RequestMethod.GET, consumes = MediaType.ALL_VALUE)
	RestfulResponse<PageInfo<CwBdRecordBatch>, CurrencyMeta> searchCwBdRecordBatchAll(
			@RequestParam(value="signType",required=false) String signType,
			@RequestParam(value="batchNo",required=false) String batchNo,
			@RequestParam(value="failReason",required=false) String failReason,
			@RequestParam(value="tradeCode",required=false) String tradeCode,
			@RequestParam(value="xtzxmbh",required=false) String xtzxmbh,
			@RequestParam("pageNum") int pageNum,
			@RequestParam("pageSize") int pageSize,
			@RequestParam("navigatePages") int navigatePages){
		return cwBdRecordBatchService.searchCwBdRecordBatchAll(signType,batchNo,failReason,tradeCode,xtzxmbh,pageNum, pageSize, navigatePages);
	}
	/**
	 * 功能描述   根据批次号查询批次信息
	 *@param batchNo
	 *@param pageNum
	 *@param pageSize
	 *@param navigatePages
	 *@return RestfulResponse<PageInfo<CwBdRecordBatch>,CurrencyMeta>
	 *@author huangpeng
	 *@date 2019年10月24日 下午2:32:32
	 *修改日志:
	 */
	@ApiOperation(value = "根据批次号查询批次信息", notes = "", produces = MediaType.APPLICATION_JSON_UTF8_VALUE, consumes = MediaType.ALL_VALUE)
	@ApiImplicitParams({
		@ApiImplicitParam(name = "batchNo", value = "批次号", required = true, dataType = "String", paramType="query"),
        @ApiImplicitParam(name = "pageNum", value = "页码", required = true, dataType = "String", paramType="query"),
        @ApiImplicitParam(name = "pageSize", value = "每页显示数量", required = true, dataType = "String", paramType="query"),
        @ApiImplicitParam(name = "navigatePages", value = "需要连续显示的页码数量", required = true, dataType = "String", paramType="query")
    }) 
	@RequestMapping(value = { "/searchCwBdRecordBatchByBatchNo" }, method = RequestMethod.GET, consumes = MediaType.ALL_VALUE)
	RestfulResponse<PageInfo<CwBdRecordBatch>, CurrencyMeta> searchCwBdRecordBatchByBatchNo(
			@RequestParam(value="batchNo") String batchNo,
			@RequestParam("pageNum") int pageNum,
			@RequestParam("pageSize") int pageSize,
			@RequestParam("navigatePages") int navigatePages){
		return cwBdRecordBatchService.searchCwBdRecordBatchByBatchNo(batchNo,pageNum, pageSize, navigatePages);
	}
	/**
	 * 功能描述  生成凭证信息
	 *@param voucherRequestInfo
	 *@return RestfulResponse<Object,CurrencyMeta>
	 *@author huangpeng
	 *@date 2019年8月23日 下午9:32:39
	 *修改日志:
	 */
	@ApiOperation(value = "流水综合信息-生成凭证", notes = "生成凭证信息", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
	@ApiImplicitParam(name = "voucherRequestInfo", value = "流水综合信息", required = true, dataType = "VoucherRequestInfo")
	@RequestMapping(value = "/createVoucherByInterface", method = RequestMethod.POST)
	RestfulResponse<Object, CurrencyMeta> createVoucherInfo(@RequestBody VoucherRequestInfo voucherRequestInfo){
		return cwBdRecordBatchService.createVoucherByInterface(voucherRequestInfo);
	}
}
