/**
 * Copyright 2008-2009. Chongqing Communications Industry Services Co.,Ltd Information Technology Branch. All rights reserved. <a>http://www.crunii.com</a>
 */
package com.crunii.micro.core.controller;

import com.crunii.micro.common.dto.PageReq;
import com.crunii.micro.common.dto.PageRsp;
import com.crunii.micro.common.dto.Result;
import com.crunii.micro.core.dto.CacheRefresh;
import com.crunii.micro.core.dto.CacheRefreshC;
import com.crunii.micro.core.dto.CacheRefreshQ;
import com.crunii.micro.core.dto.CacheRefreshU;
import com.crunii.micro.core.service.CacheRefreshService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "刷新缓存")
@RestController
@RequestMapping("/auth/CacheRefreshController")
public class CacheRefreshController {

	@Autowired
	private CacheRefreshService cacheRefreshService;

	@ApiOperation(value = "缓存刷新实体分页")
	@RequestMapping(path = "/pageCacheRefresh", method = RequestMethod.POST)
	@ResponseBody
	public Result<PageRsp<CacheRefresh>> pageCacheRefresh(@RequestBody @ApiParam PageReq<CacheRefreshQ> req) {
		Result<PageRsp<CacheRefresh>> result = new Result<PageRsp<CacheRefresh>>();
		result.setData(cacheRefreshService.pageCacheRefresh(req));
		return result;
	}

	@ApiOperation(value = "创建缓存刷新")
	@RequestMapping(path = "/createCacheRefresh", method = RequestMethod.POST)
	@ResponseBody
	public Result<String> createCacheRefresh(@RequestBody @ApiParam CacheRefreshC cacheRefreshC) {
		Result<String> result = new Result<>();
		cacheRefreshService.createCacheRefresh(cacheRefreshC);
		return result;
	}

	@ApiOperation(value = "更新缓存刷新")
	@RequestMapping(path = "/updateCacheRefresh", method = RequestMethod.POST)
	@ResponseBody
	public Result<String> updateCacheRefresh(@RequestBody @ApiParam CacheRefreshU cacheRefreshU) {
		Result<String> result = new Result<>();
		cacheRefreshService.updateCacheRefresh(cacheRefreshU);
		return result;
	}

	@ApiOperation(value = "删除缓存刷新")
	@RequestMapping(path = "/deleteCacheRefresh", method = RequestMethod.DELETE)
	@ApiImplicitParams({
			@ApiImplicitParam(name = "refreshId", value = "刷新ID", required = true)
	})
	public Result<String> deleteCacheRefresh(int refreshId) {
		Result<String> result = new Result<>();
		cacheRefreshService.deleteCacheRefresh(refreshId);
		return result;
	}

}
