package com.djhk.uav.policeInfo.controller;


import com.djhk.common.api.domain.PoliceInfo;
import com.djhk.common.core.controller.BaseController;
import com.djhk.common.core.domain.AjaxResult;
import com.djhk.common.core.page.TableDataInfo;
import com.djhk.common.utils.poi.ExcelUtil;
import com.djhk.uav.policeInfo.service.IPoliceInfoService;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

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

/**
 * 【警员信息】Controller
 * 
 * @author ruoyi
 * @date 2024-07-08
 */
@RestController
@RequestMapping("/policeinfo")
public class PoliceInfoController extends BaseController
{
    @Autowired
    private IPoliceInfoService policeInfoService;

    /**
     * 查询列表
     */
    @PostMapping("/list")
    public TableDataInfo list(PoliceInfo policeInfo)
    {
//        startPage();
//        PageHelper.startPage(1, 20);
        List<PoliceInfo> list = policeInfoService.selectPoliceInfoList(policeInfo);
        return getDataTable(list);
    }

    /**
     * 导出列表
     */
    @PostMapping("/export")
    public void export(HttpServletResponse response, PoliceInfo policeInfo)
    {
        List<PoliceInfo> list = policeInfoService.selectPoliceInfoList(policeInfo);
        ExcelUtil<PoliceInfo> util = new ExcelUtil<PoliceInfo>(PoliceInfo.class);
        util.exportExcel(response, list, "数据");
    }


    /**
     * 新增
     */
    @PostMapping
    public AjaxResult add(@RequestBody PoliceInfo policeInfo)
    {
        return toAjax(policeInfoService.insertPoliceInfo(policeInfo));
    }

    /**
     * 修改
     */
    @PutMapping
    public AjaxResult edit(@RequestBody PoliceInfo policeInfo)
    {
        return toAjax(policeInfoService.updatePoliceInfo(policeInfo));
    }

    /**
     * 删除
     */
	@DeleteMapping("/{BGDHs}")
    public AjaxResult remove(@PathVariable String[] BGDHs)
    {
        return toAjax(policeInfoService.deletePoliceInfoByBGDHs(BGDHs));
    }
}
