package com.dhcc.finance.main.controller;

import java.util.List;

import org.apache.commons.lang.StringUtils;
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.CwBdVouchtempcom;
import com.dhcc.finance.main.model.CwBdVouchtempcomLike;
import com.dhcc.finance.main.model.FileUploadRequest;
import com.dhcc.finance.main.service.CwBdVouchtempcomService;
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 + CwBdVouchtempcomController.API_PREFIX, 
  	          produces = {MediaType.APPLICATION_JSON_UTF8_VALUE }, consumes = { MediaType.APPLICATION_JSON_UTF8_VALUE })
@Api(value = "单据和凭证模板对应关系controller", tags = { "单据和凭证模板对应关系操作接口" })
public class CwBdVouchtempcomController {
	// 单据和凭证模板对应关系操作接口地址前缀
	public static final String API_PREFIX = "/cw_bd_vouchtempcom";
	@Autowired
	CwBdVouchtempcomService cwBdVouchtempcomService;
	/**
	 * 功能描述:查询所有数据
	 * @return RestfulResponse<List<CwGlTransfer>,CurrencyMeta>
	 *@author baiyc
	 *@date 2019年4月5日 上午11:15:07
	 *@修改日志:
	 */
	@ApiOperation(value = "查询单据和凭证模板全部数据",notes = "",produces = MediaType.APPLICATION_JSON_UTF8_VALUE,consumes = MediaType.ALL_VALUE)
	@RequestMapping(value = "/searchCwBdVouchtempcomInfo", method = RequestMethod.GET,consumes = MediaType.ALL_VALUE)
	public RestfulResponse<List<CwBdVouchtempcom>, CurrencyMeta> searchCwBdVouchtempcomInfo(){
		return cwBdVouchtempcomService.searchCwBdVouchtempcomInfo();
	}
	/**
	 * 功能描述:根据单据名称查询单据和凭证模板对应关系
	 * @param nameLike
	 * @param pageNum
	 * @param pageSize
	 * @param navigatePages
	 * @return RestfulResponse<PageInfo<CwBdVouchtempcom>,CurrencyMeta>
	 *@author baiyc
	 *@date 2019年4月5日 上午10:22:49
	 *@修改日志:
	 */
	@ApiOperation(value = "根据单据名称查询单据和凭证模板对应关系", notes = "", produces = MediaType.APPLICATION_JSON_UTF8_VALUE, consumes = MediaType.ALL_VALUE)
	@ApiImplicitParams({
		@ApiImplicitParam(name = "nameLike", 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 = { "/searchCwBdVouchtempcomByNameLike" }, method = RequestMethod.GET, consumes = MediaType.ALL_VALUE)
	RestfulResponse<PageInfo<CwBdVouchtempcom>, CurrencyMeta> searchCwBdVouchtempcomByNameLike(
			@RequestParam(value="nameLike",required=false) String nameLike,
			@RequestParam("pageNum") int pageNum,
			@RequestParam("pageSize") int pageSize,
			@RequestParam("navigatePages") int navigatePages){
		CwBdVouchtempcomLike cwBdVouchtempcomLike=new CwBdVouchtempcomLike();
		cwBdVouchtempcomLike.setNameLike(StringUtils.isEmpty(nameLike)?null:nameLike);
		return cwBdVouchtempcomService.searchCwBdVouchtempcomByNameLike( cwBdVouchtempcomLike,pageNum, pageSize, navigatePages);
	}
	/**
	 * 功能描述:新增单据和凭证模板对应关系
	 * @param cwBdVouchtempcom
	 * @return RestfulResponse<Object,CurrencyMeta>
	 *@author baiyc
	 *@date 2019年4月5日 上午10:23:11
	 *@修改日志:
	 */
	@ApiOperation(value = "新增单据和凭证模板对应关系", notes = "新增单据和凭证模板对应关系", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
	@ApiImplicitParam(name = "cwBdVouchtempcom", value = "单据和凭证模板对应关系对象实体", required = true, dataType = "CwBdVouchtempcom")
	@RequestMapping(value = "/addCwBdVouchtempcom", method = RequestMethod.POST)
	RestfulResponse<Object, CurrencyMeta> addCwBdVouchtempcom(@RequestBody CwBdVouchtempcom cwBdVouchtempcom){
		return cwBdVouchtempcomService.addCwBdVouchtempcom(cwBdVouchtempcom);
	}
	/**
	 * 功能描述:修改单据和凭证模板对应关系
	 * @param cwBdVouchtempcom
	 * @return RestfulResponse<Object,CurrencyMeta>
	 *@author baiyc
	 *@date 2019年4月5日 上午10:24:03
	 *@修改日志:
	 */
	@ApiOperation(value = "修改单据和凭证模板对应关系", notes = "修改单据和凭证模板对应关系", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
	@ApiImplicitParam(name = "cwBdVouchtempcom", value = "单据和凭证模板对应关系对象实体", required = true, dataType = "CwBdVouchtempcom")
	@RequestMapping(value = "/updateCwBdVouchtempcomByPk", method = RequestMethod.PUT)
	RestfulResponse<Object, CurrencyMeta> updateCwBdVouchtempcomByPk(@RequestBody CwBdVouchtempcom cwBdVouchtempcom){
		return cwBdVouchtempcomService.updateCwBdVouchtempcomByPk(cwBdVouchtempcom);
	}
	/**
	 * 功能描述:逻辑删除单据和凭证模板对应关系
	 * @param pkVouchtempcom
	 * @return RestfulResponse<Object,CurrencyMeta>
	 *@author baiyc
	 *@date 2019年4月5日 上午10:24:17
	 *@修改日志:
	 */
	@ApiOperation(value = "逻辑删除单据和凭证模板对应关系", notes = "删除单据和凭证模板对应关系", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
	@ApiImplicitParam(name = "pkVouchtempcom", value = "辅助项设置编号", required = true, dataType = "String")
	@RequestMapping(value = "/deleteCwBdVouchtempcomByPk", method = RequestMethod.DELETE , consumes = MediaType.ALL_VALUE)
	RestfulResponse<Object, CurrencyMeta> deleteCwBdVouchtempcomByPk(@RequestParam("pkVouchtempcom") String pkVouchtempcom){
		return  cwBdVouchtempcomService.deleteCwBdVouchtempcomByPk(pkVouchtempcom);
	}
	/**
	 * 功能描述:Excel数据导入
	 * @param fileUploadRequest
	 * @param type
	 * @return RestfulResponse<String,CurrencyMeta>
	 *@author baiyc
	 *@date 2019年4月9日 上午11:39:38
	 *@修改日志:
	 */
	 @ApiOperation(value = "单据和凭证模板对应关系数据导入", notes = "", produces = MediaType.APPLICATION_JSON_UTF8_VALUE, consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
	    @RequestMapping(value = "/uploadVouchtempcomInfo", method = RequestMethod.POST, consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
	 RestfulResponse<String,CurrencyMeta> uploadVouchtempcomInfo( FileUploadRequest fileUploadRequest,
	                                                                 String  type) {
	        return cwBdVouchtempcomService.uploadVouchtempcomInfo(fileUploadRequest,type);
	        
	    }
}
