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.CwBdProductcellDetail;
import com.dhcc.finance.main.model.CwBdProductcellWeb;
import com.dhcc.finance.main.service.CwBdProductcellDetailService;
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;
import lombok.extern.slf4j.Slf4j;

/**
 * 功能描述：项目单元详情Controller
 * @author dml
 * @date 2019年10月2日 上午10:23:37
 * @修改日志：
 */
@Slf4j
@RestController
@RequestMapping(value = MsConfigConsts.MS_API_PREFIX + CwBdProductcellDetailController.API_PREFIX, 
  	          produces = {MediaType.APPLICATION_JSON_UTF8_VALUE }, consumes = { MediaType.APPLICATION_JSON_UTF8_VALUE })
@Api(value = "项目单元详情controller", tags = { "项目单元详情接口" })
public class CwBdProductcellDetailController {
	// 产品单元详情接口地址前缀
	public static final String API_PREFIX = "/cw_bd_productcell_detail";
	
	@Autowired
	CwBdProductcellDetailService cwBdProductcellDetailService;
	
	/**
	 * 功能描述：根据项目单元编号查询详情
	 * @param cellCode
	 * @return RestfulResponse<List<CwBdProductcellDetail>,CurrencyMeta>
	 * @author dml
	 * @date 2019年10月2日 上午10:26:53
	 * @修改日志：
	 */
	@ApiOperation(value = "根据项目单元编号查询详情", notes = "", produces = MediaType.APPLICATION_JSON_UTF8_VALUE, consumes = MediaType.ALL_VALUE)
	@ApiImplicitParam(name = "cellCode", value = "产品单元编号", required = true, dataType = "String")
	@RequestMapping(value = { "/searchCwBdProductcellDetailByCode" }, method = RequestMethod.GET, consumes = MediaType.ALL_VALUE)
	public 	RestfulResponse<List<CwBdProductcellDetail>, CurrencyMeta> searchCwBdProductcellDetailByCode(
			@RequestParam("cellCode") String cellCode){
		return cwBdProductcellDetailService.searchCwBdProductcellDetailByCode(cellCode);
	}
	/**
	 * 功能描述  新增单元
	 *@param cwGlVoucherWeb
	 *@return RestfulResponse<Object,CurrencyMeta>
	 *@author huangpeng
	 *@date 2019年10月6日 上午8:59:11
	 *修改日志:
	 */
	@ApiOperation(value = "新增单元-传递复杂对象", notes = "新增项目信息", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
	@ApiImplicitParam(name = "cwBdProductcellWeb", value = "项目信息Web对象实体", required = true, dataType = "CwBdProductcellWeb")
	@RequestMapping(value = "/addCwBdProductcellDetail", method = RequestMethod.POST)
	public RestfulResponse<Object, CurrencyMeta> addCwBdProductcellDetail(@RequestBody CwBdProductcellWeb cwBdProductcellWeb){
		log.info(cwBdProductcellWeb.toString());
		return cwBdProductcellDetailService.addCwBdProductcellDetail(cwBdProductcellWeb);
	}
	/**
	 * 功能描述  根据项目单元主键查询详情
	 *@param cellId
	 *@return RestfulResponse<List<CwBdProductcellDetail>,CurrencyMeta>
	 *@author huangpeng
	 *@date 2019年10月6日 上午10:45:27
	 *修改日志:
	 */
	@ApiOperation(value = "根据项目单元主键查询详情", notes = "", produces = MediaType.APPLICATION_JSON_UTF8_VALUE, consumes = MediaType.ALL_VALUE)
	@ApiImplicitParam(name = "cellId", value = "产品单元主键", required = true, dataType = "String")
	@RequestMapping(value = { "/searchCwBdProductcellDetailById" }, method = RequestMethod.GET, consumes = MediaType.ALL_VALUE)
	public 	RestfulResponse<List<CwBdProductcellDetail>, CurrencyMeta> searchCwBdProductcellDetailById(
			@RequestParam("cellId") String cellId){
		return cwBdProductcellDetailService.searchCwBdProductcellDetailById(cellId);
	}
	/**
	 * 功能描述  修改单元
	 *@param cwGlVoucherWeb
	 *@return RestfulResponse<Object,CurrencyMeta>
	 *@author huangpeng
	 *@date 2019年10月6日 上午8:59:11
	 *修改日志:
	 */
	@ApiOperation(value = "新增单元-传递复杂对象", notes = "新增项目信息", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
	@ApiImplicitParam(name = "cwBdProductcellWeb", value = "项目信息Web对象实体", required = true, dataType = "CwBdProductcellWeb")
	@RequestMapping(value = "/updateCwBdProductcellDetail", method = RequestMethod.PUT)
	public RestfulResponse<Object, CurrencyMeta> updateCwBdProductcellDetail(@RequestBody CwBdProductcellWeb cwBdProductcellWeb){
		log.info(cwBdProductcellWeb.toString());
		return cwBdProductcellDetailService.updateCwBdProductcellDetail(cwBdProductcellWeb);
	}
	/**
	 * 功能描述 获取项目单元表详情数据列表
	 *@param cellId
	 *@param pageNum
	 *@param pageSize
	 *@param navigatePages
	 *@return RestfulResponse<PageInfo<CwBdProductcell>,CurrencyMeta>
	 *@author huangpeng
	 *@date 2019年10月6日 上午11:43:11
	 *修改日志:
	 */
	@ApiOperation(value = "获取项目单元表详情数据列表", notes = "", produces = MediaType.APPLICATION_JSON_UTF8_VALUE, consumes = MediaType.ALL_VALUE)
	@ApiImplicitParams({
		@ApiImplicitParam(name = "cellId", 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 = { "/searchCwBdProductcellDeatilOfList" }, method = RequestMethod.GET, consumes = MediaType.ALL_VALUE)
	public RestfulResponse<PageInfo<CwBdProductcellDetail>, CurrencyMeta> searchCwBdProductcellDeatilOfList(
			@RequestParam(value="cellId") String cellId,
			@RequestParam("pageNum") int pageNum,
    		@RequestParam("pageSize") int pageSize,
    		@RequestParam("navigatePages") int navigatePages){
		return cwBdProductcellDetailService.searchCwBdProductcellDeatilOfList(cellId,pageNum, pageSize, navigatePages);
}
}
