package com.huatek.frame.base.errlog.controller;

import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.dubbo.config.annotation.Reference;
import com.huatek.frame.base.entity.ErrLogWithBLOBs;
import com.huatek.frame.base.service.ErrLogService;
import com.huatek.torch.frame.permission.KerPermission;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

/**
 * @author key 错误日志
 */
@Api(tags={"错误日志接口"})
@RestController
@RequestMapping("/api/errlog")
public class ErrLogController {

	@SuppressWarnings("unused")
	private static final Logger logger = LoggerFactory.getLogger(ErrLogController.class);

	@Reference(check = false)
	private ErrLogService errLogService;

	/**
	 * 错误日志列表
	 * 
	 * @param page
	 * @param limit
	 * @param Logs
	 * @return
	 */
	@ApiOperation(value = "错误日志列表",httpMethod="POST", notes= "错误日志列表", produces = "application/json;charset=utf-8",response=ErrLogWithBLOBs.class)
	@PostMapping(value="/logs", produces = { "application/json;charset=utf-8"})
	public  @KerPermission("10034") Map<String, Object> logss(@RequestBody ErrLogWithBLOBs log) {
		Map<String, Object> map = errLogService.findLogPage(log);
		return map;
	}

	/**
	 * 查询错误日志对象
	 * 
	 * @param page
	 * @param limit
	 * @param Logs
	 * @return
	 */
	@ApiOperation(value = "查询错误日志对象",httpMethod="GET", notes= "查询错误日志对象", produces = "application/json;charset=utf-8",response=ErrLogWithBLOBs.class)
	@GetMapping(value="/findLogs/{id}", produces = { "application/json;charset=utf-8"})
	public  @KerPermission("10035") Map<String, Object> findLogs(@ApiParam(value="id") @PathVariable("id")String id) {
		Map<String, Object> map = errLogService.findLogs(id);
		return map;
	}

	/**
	 * 删除错误日志
	 * 
	 * @param ids
	 * @return
	 */
	@ApiOperation(value = "删除错误日志",httpMethod="POST", notes= "删除错误日志", produces = "application/json;charset=utf-8",response=Map.class)
	@PostMapping(value="/deleteLogs", produces = { "application/json;charset=utf-8"})
	public  @KerPermission("10036") Map<String, Object> deleteLogs(@ApiParam(value="id集合") @RequestBody String[] ids) {
		Map<String, Object> map = errLogService.deleteLogs(ids);
		return map;
	}
}
