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.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.CwBdAccperiod;
import com.dhcc.finance.main.domain.CwBdAccperiodmonth;
import com.dhcc.finance.main.domain.CwBdAccperiodquart;
import com.dhcc.finance.main.domain.CwBdAccperiodyear;
import com.dhcc.finance.main.service.AccountingPeriodService;
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 + AccountingPeriodController.API_PREFIX, produces = {MediaType.APPLICATION_JSON_UTF8_VALUE }, consumes = { MediaType.APPLICATION_JSON_UTF8_VALUE })
@Api(value = "会计期间controller", tags = { "会计期间操作接口" })
public class AccountingPeriodController {
	   // 会计期间操作接口地址前缀
		public static final String API_PREFIX = "/accounting-period";

		// 注入会计期间的service接口
		@Autowired
		AccountingPeriodService accountingPeriodService;
		/**
		 * 获取会计月份数据列表
		 * @param pageNum
		 * @param pageSize
		 * @param navigatePages
		 * @param pkAccperiod
		 * @return RestfulResponse<PageInfo<CwBdAccperiodmonth>,CurrencyMeta>
		 *@author huangpeng
		 *@date 2019年3月27日 下午1:53:07
		 *@修改日志：
		 */
		@ApiOperation(value = "获取会计月份数据列表",notes = "",produces = MediaType.APPLICATION_JSON_UTF8_VALUE,consumes = MediaType.ALL_VALUE)
		@ApiImplicitParams({
	        @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 = "/searchCwBdAccperiodmonth", method = RequestMethod.GET,consumes = MediaType.ALL_VALUE)
		public RestfulResponse<PageInfo<CwBdAccperiodmonth>, CurrencyMeta> searchCwBdAccperiodmonth(@RequestParam("pageNum") Integer pageNum,
				@RequestParam("pageSize") Integer pageSize, 
				@RequestParam("navigatePages") Integer navigatePages,@RequestParam(value = "pkAccperiod", required = false) String pkAccperiod){
			return accountingPeriodService.searchCwBdAccperiodmonth(pageNum,pageSize,navigatePages,pkAccperiod);
		}
		/**
		 * 获取会计季度数据列表
		 * @param pageNum
		 * @param pageSize
		 * @param navigatePages
		 * @param pkAccperiod
		 * @return RestfulResponse<PageInfo<CwBdAccperiodquart>,CurrencyMeta>
		 *@author huangpeng
		 *@date 2019年3月27日 下午1:53:38
		 *@修改日志：
		 */
		@ApiOperation(value = "获取会计季度数据列表",notes = "",produces = MediaType.APPLICATION_JSON_UTF8_VALUE,consumes = MediaType.ALL_VALUE)
		@ApiImplicitParams({
	        @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 = "/searchCwBdAccperiodquart", method = RequestMethod.GET,consumes = MediaType.ALL_VALUE)
		public RestfulResponse<PageInfo<CwBdAccperiodquart>, CurrencyMeta> searchCwBdAccperiodquart(@RequestParam("pageNum") Integer pageNum,
				@RequestParam("pageSize") Integer pageSize, 
				@RequestParam("navigatePages") Integer navigatePages,@RequestParam(value = "pkAccperiod", required = false) String pkAccperiod){
			return accountingPeriodService.searchCwBdAccperiodquart(pageNum,pageSize,navigatePages,pkAccperiod);
		}
		/**
		 * 获取会计半年份数据列表
		 * @param pageNum
		 * @param pageSize
		 * @param navigatePages
		 * @param pkAccperiod
		 * @return RestfulResponse<PageInfo<CwBdAccperiodyear>,CurrencyMeta>
		 *@author huangpeng
		 *@date 2019年3月27日 下午1:53:50
		 *@修改日志：
		 */
		@ApiOperation(value = "获取会计半年份数据列表",notes = "",produces = MediaType.APPLICATION_JSON_UTF8_VALUE,consumes = MediaType.ALL_VALUE)
		@ApiImplicitParams({
	        @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 = "/searchCwBdAccperiodyear", method = RequestMethod.GET,consumes = MediaType.ALL_VALUE)
		public RestfulResponse<PageInfo<CwBdAccperiodyear>, CurrencyMeta> searchCwBdAccperiodyear(@RequestParam("pageNum") Integer pageNum,
				@RequestParam("pageSize") Integer pageSize, 
				@RequestParam("navigatePages") Integer navigatePages,@RequestParam(value = "pkAccperiod", required = false) String pkAccperiod){
			return accountingPeriodService.searchCwBdAccperiodyear(pageNum,pageSize,navigatePages,pkAccperiod);
		}
		/**
		 * 获取会计年度年份
		 * @return RestfulResponse<List<CwBdAccperiod>,CurrencyMeta>
		 *@author huangpeng
		 *@date 2019年3月27日 下午1:54:16
		 *@修改日志：
		 */
		@ApiOperation(value = "获取会计年度年份",notes = "",produces = MediaType.APPLICATION_JSON_UTF8_VALUE,consumes = MediaType.ALL_VALUE)
		@RequestMapping(value = "/searchCwBdAccperiod", method = RequestMethod.GET,consumes = MediaType.ALL_VALUE)
		public RestfulResponse<List<CwBdAccperiod>, CurrencyMeta> searchCwBdAccperiod(){
			return accountingPeriodService.searchCwBdAccperiod();
		}
		
		/**
		 * 增加年份
		 * @param year
		 * @return RestfulResponse<Object,CurrencyMeta>
		 *@author huangpeng
		 *@date 2019年3月27日 下午1:54:25
		 *@修改日志：
		 */
		@ApiOperation(value = "增加年份", notes = "", produces = MediaType.APPLICATION_JSON_UTF8_VALUE,consumes = MediaType.ALL_VALUE)
		@ApiImplicitParam(name = "year", value = "年份", required = true, dataType = "String")
		@RequestMapping(value = "/addAccountingYear", method = RequestMethod.POST,consumes = MediaType.ALL_VALUE)
		public RestfulResponse<Object, CurrencyMeta> addAccountingYear(@RequestParam(value = "year", required = false) String year) {
			return accountingPeriodService.addAccountingYear(year);
		}
		
		
		
}
