package com.boman.web.core.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.boman.common.core.utils.StringUtils;
import com.boman.common.core.utils.poi.ExcelUtil;
import com.boman.common.core.web.controller.BaseController;
import com.boman.common.log.enums.BusinessType;
import com.boman.common.security.annotation.PreAuthorize;
import com.boman.domain.TableDataInfo;
import com.boman.domain.dto.AjaxResult;
import com.boman.web.core.domain.GridInfo;
import com.boman.web.core.service.grid.IGridInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
 * 网格信息Controller
 * 
 * @author boman
 * @date 2022-01-19
 */
@RestController
@RequestMapping("/gridInfo")
public class GridInfoController extends BaseController
{
    @Autowired
    private IGridInfoService gridInfoService;

    /**
     * 查询网格信息列表
     */
    @GetMapping("/list")
    public TableDataInfo list(GridInfo gridInfo)
    {
        startPage();
        List<GridInfo> list = gridInfoService.selectGridInfoList(gridInfo);
        return getDataTable(list);
    }


    /**
     * 获取网格信息详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(gridInfoService.selectGridInfoById(id));
    }

    /**
     * 新增网格信息
     */
    @PostMapping
    public AjaxResult add(@RequestBody GridInfo gridInfo)
    {
        return toAjax(gridInfoService.insertGridInfo(gridInfo));
    }

    /**
     * 修改网格信息
     */
    @PutMapping
    public AjaxResult edit(@RequestBody GridInfo gridInfo)
    {
        return toAjax(gridInfoService.updateGridInfo(gridInfo));
    }

    /**
     * 删除网格信息
     */
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(gridInfoService.deleteGridInfoByIds(ids));
    }


    /**
     * 网格信息下拉菜单
     */
    @PostMapping("/treeSelect")
    public AjaxResult treeSelect(@RequestBody GridInfo gridInfo)
    {
        AjaxResult ajaxResult = gridInfoService.treeSelect(gridInfo);
        return ajaxResult;
    }
}
