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.PathVariable;
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.CwGlTransfer;
import com.dhcc.finance.main.model.CwGlTransferAndSubjectName;
import com.dhcc.finance.main.model.CwGlTransferLike;
import com.dhcc.finance.main.service.CwGlTransferService;
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 + CwGlTransferController.API_PREFIX, produces = {MediaType.APPLICATION_JSON_UTF8_VALUE }, consumes = { MediaType.APPLICATION_JSON_UTF8_VALUE })
@Api(value = "转账定义controller", tags = { "转账定义操作接口" })
public class CwGlTransferController {
	 // 会计期间操作接口地址前缀
	public static final String API_PREFIX = "/cw-gl-transfer";
	
	@Autowired
	CwGlTransferService cwGlTransferService;
	
	/**
	 * 查询转账定义表所有数据
	 * @param pageNum
	 * @param pageSize
	 * @param navigatePages
	 * @return RestfulResponse<PageInfo<CwGlTransfer>,CurrencyMeta>
	 *@author huangpeng
	 *@date 2019年3月27日 下午1:54:38
	 *@修改日志：
	 */
	@ApiOperation(value = "查询转账定义表",notes = "",produces = MediaType.APPLICATION_JSON_UTF8_VALUE,consumes = MediaType.ALL_VALUE)
	@RequestMapping(value = "/searchCwGlTransfer", method = RequestMethod.GET,consumes = MediaType.ALL_VALUE)
	public RestfulResponse<List<CwGlTransfer>, CurrencyMeta> searchCwGlTransfer(){
		return cwGlTransferService.searchCwGlTranser();
	}
	/**
	 * 逻辑删除转账定义表
	 * @param pkTransfer
	 * @return RestfulResponse<Object,CurrencyMeta>
	 *@author huangpeng
	 *@date 2019年3月27日 下午1:54:45
	 *@修改日志：
	 */
	@ApiOperation(value="删除转账定义表", notes="结转方案表", produces = MediaType.APPLICATION_JSON_UTF8_VALUE, consumes = MediaType.ALL_VALUE)
    @ApiImplicitParam(name = "pkTransfer", value = "删除(单个)", required = true, dataType = "String")
    @RequestMapping(value="/deleteCwGlTransfer", method=RequestMethod.DELETE, consumes = MediaType.ALL_VALUE)
	public RestfulResponse<Object, CurrencyMeta> deleteCwGlTransfer(@RequestParam("pkTransfer") String pkTransfer){
		return cwGlTransferService.deleteCwGlTransfer(pkTransfer);
	}
	
	/**
	 * 增加结转方案
	 * @param cwGlTransfer
	 * @return RestfulResponse<Object,CurrencyMeta>
	 *@author huangpeng
	 *@date 2019年3月27日 下午1:55:00
	 *@修改日志：
	 */
	@ApiOperation(value="增加结转方案", notes="结转方案表", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
	@ApiImplicitParam(name = "cwGlTransfer", value = "结转方案", required = true, dataType = "CwGlTransfer") 
    @RequestMapping(value="/addCwGlTransfer", method=RequestMethod.POST)
	public RestfulResponse<Object, CurrencyMeta> addCwGlTransfer (@RequestBody CwGlTransfer cwGlTransfer) {
		return cwGlTransferService.addCwGlTransfer(cwGlTransfer);
	}
	/**
	 * 修改结转方案
	 * @param cwGlTransfer
	 * @return RestfulResponse<Object,CurrencyMeta>
	 *@author huangpeng
	 *@date 2019年3月27日 下午1:55:07
	 *@修改日志：
	 */
	@ApiOperation(value="修改结转方案", notes="更新放结转方案", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
	@ApiImplicitParam(name = "cwGlTransfer", value = "结转方案", required = true, dataType = "CwGlTransfer") 
    @RequestMapping(value="/updateCwGlTransfer", method=RequestMethod.PUT)
	public RestfulResponse<Object, CurrencyMeta> updateCwGlTransfer (@RequestBody CwGlTransfer cwGlTransfer) {
		return cwGlTransferService.updateCwGlTransfer(cwGlTransfer);
	}
	/**
	 * 根据结转方案名称模糊查询
	 * @param nameLike
	 * @param pageNum
	 * @param pageSize
	 * @param navigatePages
	 * @return RestfulResponse<PageInfo<CwGlTransfer>,CurrencyMeta>
	 *@author huangpeng
	 *@date 2019年3月27日 下午1:55:39
	 *@修改日志：
	 */
	@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 = false, dataType = "String", paramType="query"),
	    @ApiImplicitParam(name = "pageSize", value = "每页显示数量", required = false, dataType = "String", paramType="query"),
	    @ApiImplicitParam(name = "navigatePages", value = "需要连续显示的页码数量", required = false, dataType = "String", paramType="query")
	})
	@RequestMapping(value = "/searchCwGlTransferByNameLike", method = RequestMethod.GET,consumes = MediaType.ALL_VALUE)
	public RestfulResponse<PageInfo<CwGlTransfer>, CurrencyMeta> searchCwGlTransferByNameLike(@RequestParam(value="nameLike",required=false) String nameLike,
			@RequestParam("pageNum") int pageNum,
			@RequestParam("pageSize") int pageSize,
			@RequestParam("navigatePages") int navigatePages){
		CwGlTransferLike cwGlTransferLike = new CwGlTransferLike();
		cwGlTransferLike.setNameLike(StringUtils.isEmpty(nameLike)?null:nameLike);
		return cwGlTransferService.searchCwGlTransferByNameLike(cwGlTransferLike,pageNum, pageSize, navigatePages);
	}
	/**
	 * 根据结转方案名称模糊查询
	 * @param nameLike
	 * @param pageNum
	 * @param pageSize
	 * @param navigatePages
	 * @return RestfulResponse<PageInfo<CwGlTransfer>,CurrencyMeta>
	 *@author huangpeng
	 *@date 2019年3月27日 下午1:55:39
	 *@修改日志：
	 */
	@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 = false, dataType = "String", paramType="query"),
	    @ApiImplicitParam(name = "pageSize", value = "每页显示数量", required = false, dataType = "String", paramType="query"),
	    @ApiImplicitParam(name = "navigatePages", value = "需要连续显示的页码数量", required = false, dataType = "String", paramType="query")
	})
	@RequestMapping(value = "/searchTransferAndSubjscheme", method = RequestMethod.GET,consumes = MediaType.ALL_VALUE)
	public RestfulResponse<PageInfo<CwGlTransferAndSubjectName>, CurrencyMeta> searchTransferAndSubjscheme(@RequestParam(value="nameLike",required=false) String nameLike,
			@RequestParam("pageNum") int pageNum,
			@RequestParam("pageSize") int pageSize,
			@RequestParam("navigatePages") int navigatePages){
		CwGlTransferLike cwGlTransferLike = new CwGlTransferLike();
		cwGlTransferLike.setNameLike(StringUtils.isEmpty(nameLike)?null:nameLike);
		return cwGlTransferService.searchTransferAndSubjscheme(cwGlTransferLike,pageNum, pageSize, navigatePages);
	}
	/**
	 * 功能描述  查询正在启用的结转方案
	 * @return RestfulResponse<List<CwGlTransfer>,CurrencyMeta>
	 * @author huangpeng
	 * @date 2019年7月11日 上午11:24:17
	 * 修改日志
	 */
	@ApiOperation(value = "查询正在启用的结转方案",notes = "",produces = MediaType.APPLICATION_JSON_UTF8_VALUE,consumes = MediaType.ALL_VALUE)
	@RequestMapping(value = "/selectAllForEnablestate", method = RequestMethod.GET,consumes = MediaType.ALL_VALUE)
	public RestfulResponse<List<CwGlTransfer>, CurrencyMeta> selectAllForEnablestate(){
		return cwGlTransferService.selectAllForEnablestate();
	}
}
