package com.huatek.frame.base.areas.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.dto.AreaDTO;
import com.huatek.frame.base.entity.Area;
import com.huatek.frame.base.service.AreaService;
import com.huatek.frame.base.vo.AreaVO;
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/area")
public class AreasController {

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

	@Reference(check = false)
	private AreaService areaService;

	/**
	 * 地域列表
	 *  
	 * @param Areas
	 * @return
	 */
	@ApiOperation(value = "地域列表",httpMethod="POST", notes= "地域列表", produces = "application/json;charset=utf-8",response=AreaVO.class)
	@PostMapping(value="/areas", produces = { "application/json;charset=utf-8"})
	public  @KerPermission("10023") Map<String, Object> areass(@RequestBody AreaDTO area) {
		Map<String, Object> map = areaService.findAreaPage(area);
		return map;
	}

	/**
	 * 查询地域对象
	 * 
	 * @param page
	 * @param limit
	 * @param Areas
	 * @return
	 */

	@ApiOperation(value = "查询地域对象",httpMethod="GET", notes= "查询地域对象", produces = "application/json;charset=utf-8",response=AreaVO.class)
	@GetMapping(value="/findAreas/{id}", produces = { "application/json;charset=utf-8"})
	public  @KerPermission("10024") Map<String, Object> findAreas(  @ApiParam(value="地域id") @PathVariable(value="id")String id) {
		Map<String, Object> map = areaService.findArea(id);
		return map;
	}

	/**
	 * 删除地域
	 * 
	 * @param ids
	 * @return
	 */
	@ApiOperation(value = "删除地域",httpMethod="POST", notes= "删除地域", produces = "application/json;charset=utf-8",response=Map.class)
	@PostMapping(value="/deleteAreas", produces = { "application/json;charset=utf-8"})
	public  @KerPermission("10027") Map<String, Object> deleteAreas(@ApiParam(value="地域id集合") @RequestBody String[] ids) {
		Map<String, Object> map = areaService.deleteArea(ids);
		return map;
	}

	/**
	 * 新增地域
	 * 
	 * @return
	 */
	@ApiOperation(value = "新增地域",httpMethod="POST", notes= "新增地域", produces = "application/json;charset=utf-8",response=Map.class)
	@PostMapping(value = "/addAreas", produces = { "application/json;charset=utf-8"})
	public  @KerPermission("10025") Map<String, Object> addAreas(@RequestBody Area area) {
		Map<String, Object> map = areaService.addArea(area);
		return map;
	}

	/**
	 * 修改地域
	 * 
	 * @return
	 */
	@ApiOperation(value = "修改地域",httpMethod="POST", notes= "修改地域", produces = "application/json;charset=utf-8",response=Map.class)
	@PostMapping(value = "/modifyAreas", produces = { "application/json;charset=utf-8"})
	public  @KerPermission("10026") Map<String, Object> modifyAreas(@RequestBody Area area) {
		Map<String, Object> map = areaService.updateArea(area);
		return map;
	} 
}
