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.CwBdAccass;
import com.dhcc.finance.main.domain.CwBdAccassitem;
import com.dhcc.finance.main.domain.CwBdSubjscheme;
import com.dhcc.finance.main.model.CwBdAccassitemLike;
import com.dhcc.finance.main.service.AssistedAccountingService;
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 + AssistedAccountingController.API_PREFIX, 
  	          produces = {MediaType.APPLICATION_JSON_UTF8_VALUE }, consumes = { MediaType.APPLICATION_JSON_UTF8_VALUE })
@Api(value = "辅助核算项设置controller", tags = { "辅助核算项设置操作接口" })
public class AssistedAccountingController {
	// 辅助核算项设置操作接口地址前缀
		public static final String API_PREFIX = "/cw_bd_accassitem";
		@Autowired
		AssistedAccountingService assistedAccountingService;
		/**
		 * 功能描述:根据类别名称查询辅助核算项设置
		 * @param pk_accassitem
		 * @param pageNum
		 * @param pageSize
		 * @param navigatePages
		 * @return RestfulResponse<PageInfo<CwBdAccass>,CurrencyMeta>
		 *@author baiyc
		 *@date 2019年4月1日 上午10:32:22
		 *@修改日志:
		 */
		@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 = { "/searchAssistedAccountingInfo" }, method = RequestMethod.GET, consumes = MediaType.ALL_VALUE)
		RestfulResponse<PageInfo<CwBdAccassitem>, CurrencyMeta> searchAssistedAccountingInfo(
				@RequestParam(value="nameLike",required=false) String nameLike,
				@RequestParam("pageNum") int pageNum,
				@RequestParam("pageSize") int pageSize,
				@RequestParam("navigatePages") int navigatePages){
			CwBdAccassitemLike cwBdAccassitemLike=new CwBdAccassitemLike();
			cwBdAccassitemLike.setNameLike(StringUtils.isEmpty(nameLike)?null:nameLike);
			return assistedAccountingService.searchAssistedAccountingInfo( cwBdAccassitemLike,pageNum, pageSize, navigatePages);
		}
		/**
		 * 功能描述:新增辅助项设置
		 * @param CwBdAccassitem
		 * @return RestfulResponse<Object,CurrencyMeta>
		 *@author baiyc
		 *@date 2019年4月1日 上午11:13:46
		 *@修改日志:
		 */
		@ApiOperation(value = "新增辅助项设置", notes = "新增辅助核算项设置", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
		@ApiImplicitParam(name = "cwBdAccassitem", value = "辅助核算项设置对象实体", required = true, dataType = "CwBdAccassitem")
		@RequestMapping(value = "/addAssistedAccounting", method = RequestMethod.POST)
		RestfulResponse<Object, CurrencyMeta> addAssistedAccounting(@RequestBody CwBdAccassitem cwBdAccassitem){
			return assistedAccountingService.addAssistedAccounting(cwBdAccassitem);
		}
		/**
		 * 功能描述:修改辅助项设置
		 * @param cwBdAccassitem
		 * @return RestfulResponse<Object,CurrencyMeta>
		 *@author baiyc
		 *@date 2019年4月4日 上午9:35:47
		 *@修改日志:
		 */
		@ApiOperation(value = "修改辅助项设置", notes = "修改辅助项设置", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
		@ApiImplicitParam(name = "cwBdAccassitem", value = "辅助项设置对象实体", required = true, dataType = "CwBdAccassitem")
		@RequestMapping(value = "/updateCwBdAccassitemByPk", method = RequestMethod.PUT)
		RestfulResponse<Object, CurrencyMeta> updateCwBdAccassitemByPk(@RequestBody CwBdAccassitem cwBdAccassitem){
			return assistedAccountingService.updateCwBdAccassitemByPk(cwBdAccassitem);
		}
		/**
		 * 功能描述:逻辑删除辅助项设置
		 * @param pkAccassitem
		 * @return RestfulResponse<Object,CurrencyMeta>
		 *@author baiyc
		 *@date 2019年4月4日 上午9:41:36
		 *@修改日志:
		 */
		@ApiOperation(value = "逻辑删除辅助项设置", notes = "删除辅助项设置", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
		@ApiImplicitParam(name = "pkAccassitem", value = "辅助项设置编号", required = true, dataType = "String")
		@RequestMapping(value = "/deleteCwBdAccassitemByPk", method = RequestMethod.DELETE , consumes = MediaType.ALL_VALUE)
		RestfulResponse<Object, CurrencyMeta> deleteCwBdAccassitemByPk(@RequestParam("pkAccassitem") String pkAccassitem){
			return  assistedAccountingService.deleteCwBdAccassByPk(pkAccassitem);
		}
		/**
		 * 功能描述:更新状态码
		 * @param cwBdAccassitem
		 * @return RestfulResponse<Integer,CurrencyMeta>
		 *@author baiyc
		 *@date 2019年4月4日 下午5:19:51
		 *@修改日志:
		 */
		@ApiOperation(value = "启动辅助核算项-传递复杂对象", notes = "启动辅助核算项", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
		@ApiImplicitParam(name = "cwBdAccassitem", value = "辅助核算项对象实体", required = true, dataType = "CwBdAccassitem")
		@RequestMapping(value = "/updateEnablestate", method = RequestMethod.PUT)
		RestfulResponse<Integer, CurrencyMeta> updateEnablestate(@RequestBody CwBdAccassitem cwBdAccassitem){
			return assistedAccountingService.updateEnablestate(cwBdAccassitem);
		}
		/**
		 * 功能描述:
		 * @return RestfulResponse<List<CwBdAccassitem>,CurrencyMeta>
		 *@author baiyc
		 *@date 2019年4月11日 下午7:38:55
		 *@修改日志:
		 */
		 @ApiOperation(value = "获取辅助核算项全部数据", notes = "", produces = MediaType.APPLICATION_JSON_UTF8_VALUE, consumes = MediaType.ALL_VALUE)
	       @RequestMapping(value = { "/searchCwBdAccassitem" }, method = RequestMethod.GET, consumes = MediaType.ALL_VALUE)
	       RestfulResponse<List<CwBdAccassitem>, CurrencyMeta> searchCwBdAccassitem(){
	             return assistedAccountingService.searchCwBdAccassitem();
	       }
}
