package com.dhcc.finance.main.controller;

import java.util.List;

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.CwBdAccass;
import com.dhcc.finance.main.service.CwBdAccassService;
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;

/**
 * 功能描述：科目辅助配置Controller
 * @author dml
 * @date 2019年3月22日 下午2:16:07
 * @修改日志：
 */
@RestController
@RequestMapping(value = MsConfigConsts.MS_API_PREFIX + CwBdAccassController.API_PREFIX, 
  	          produces = {MediaType.APPLICATION_JSON_UTF8_VALUE }, consumes = { MediaType.APPLICATION_JSON_UTF8_VALUE })
@Api(value = "科目辅助配置controller", tags = { "科目辅助配置操作接口" })
public class CwBdAccassController {

	// 会计科目版本操作接口地址前缀
	public static final String API_PREFIX = "/cw_bd_accass";
	
	@Autowired
	CwBdAccassService cwBdAccassService;
	
	/**
	 * 功能描述：新增科目辅助配置
	 * @param cwBdAccass
	 * @return RestfulResponse<Object,CurrencyMeta>
	 * @author dml
	 * @date 2019年3月22日 下午2:20:34
	 * @修改日志：
	 */
	@ApiOperation(value = "新增科目辅助配置-传递复杂对象", notes = "新增科目辅助配置", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
	@ApiImplicitParam(name = "cwBdAccass", value = "科目辅助配置对象实体", required = true, dataType = "CwBdAccass")
	@RequestMapping(value = "/addCwBdCwBdAccass", method = RequestMethod.POST)
	RestfulResponse<Object, CurrencyMeta> addCwBdCwBdAccass(@RequestBody CwBdAccass cwBdAccass){
		return cwBdAccassService.addCwBdAccass(cwBdAccass);
	}
	
	/**
	 * 功能描述：修改科目辅助配置
	 * @param cwBdAccass
	 * @return RestfulResponse<Object,CurrencyMeta>
	 * @author dml
	 * @date 2019年3月22日 下午2:25:01
	 * @修改日志：
	 */
	@ApiOperation(value = "修改科目辅助配置-传递复杂对象", notes = "修改科目辅助配置", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
	@ApiImplicitParam(name = "cwBdAccass", value = "科目辅助配置对象实体", required = true, dataType = "CwBdAccass")
	@RequestMapping(value = "/updateCwBdAccassByPk", method = RequestMethod.PUT)
	RestfulResponse<Object, CurrencyMeta> updateCwBdAccassByPk(@RequestBody CwBdAccass cwBdAccass){
		return cwBdAccassService.updateCwBdAccassByPk(cwBdAccass);
	}
	
	/**
	 * 功能描述：逻辑删除科目辅助配置
	 * @param pkAccass
	 * @return RestfulResponse<Object,CurrencyMeta>
	 * @author dml
	 * @date 2019年3月22日 下午2:26:51
	 * @修改日志：
	 */
	@ApiOperation(value = "逻辑删除科目辅助配置", notes = "删除科目辅助配置", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
	@ApiImplicitParam(name = "pkAccass", value = "科目辅助配置编号", required = true, dataType = "String", paramType="query")
	@RequestMapping(value = "/deleteCwBdAccassByPk", method = RequestMethod.DELETE , consumes = MediaType.ALL_VALUE)
	RestfulResponse<Object, CurrencyMeta> deleteCwBdAccassByPk(@RequestParam("pkAccass") String pkAccass){
		return  cwBdAccassService.deleteCwBdAccassByPk(pkAccass);
	}
	
	/**
	 * 功能描述：根据科目查询科目辅助配置
	 * @param pkAccsubj
	 * @param pageNum
	 * @param pageSize
	 * @param navigatePages
	 * @return RestfulResponse<PageInfo<CwBdAccass>,CurrencyMeta>
	 * @author dml
	 * @date 2019年3月22日 下午2:28:51
	 * @修改日志：
	 */
	@ApiOperation(value = "根据科目查询科目辅助配置", notes = "", produces = MediaType.APPLICATION_JSON_UTF8_VALUE, consumes = MediaType.ALL_VALUE)
	@ApiImplicitParams({
		@ApiImplicitParam(name = "pkAccsubj", 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 = { "/searchCwBdAccassInfo" }, method = RequestMethod.GET, consumes = MediaType.ALL_VALUE)
	RestfulResponse<PageInfo<CwBdAccass>, CurrencyMeta> searchCwBdAccassInfo(@RequestParam("pkAccsubj") String pkAccsubj,
			@RequestParam("pageNum") int pageNum,
			@RequestParam("pageSize") int pageSize,
			@RequestParam("navigatePages") int navigatePages){
		return cwBdAccassService.searchCwBdAccassInfo(pkAccsubj, pageNum, pageSize, navigatePages);
	}
	/**
	 * 功能描述  根据科目主键科目版本主键查询科目下辅助配置信息
	 * @param pkAccsubj
	 * @param pkSubjscheme
	 * @return RestfulResponse<List<CwBdAccass>,CurrencyMeta>
	 * @author huangpeng
	 * @date 2019年6月17日 上午10:22:49
	 * 修改日志
	 */
	@ApiOperation(value = "根据科目主键科目版本主键查询科目下辅助配置信息", notes = "", produces = MediaType.APPLICATION_JSON_UTF8_VALUE, consumes = MediaType.ALL_VALUE)
	@ApiImplicitParams({
		@ApiImplicitParam(name = "pkSubjscheme", value = "科目版本主键", required = true, dataType = "String", paramType="query"),
		@ApiImplicitParam(name = "pkAccsubj", value = "科目主键", required = true, dataType = "String", paramType="query")
    }) 
	@RequestMapping(value = { "/searchCwBdAccassforAddVoucher" }, method = RequestMethod.GET, consumes = MediaType.ALL_VALUE)
	RestfulResponse<List<CwBdAccass>, CurrencyMeta> searchCwBdAccassInfoBy(@RequestParam("pkAccsubj") String pkAccsubj,
			@RequestParam("pkSubjscheme") String pkSubjscheme){
		return cwBdAccassService.searchCwBdAccassforAddVoucher(pkAccsubj,pkSubjscheme);
	}

}
