package com.goldenwater.slaj.eme.controller;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import com.goldenwater.common.annotation.Log;
import com.goldenwater.common.core.controller.BaseController;
import com.goldenwater.common.core.domain.AjaxResult;
import com.goldenwater.common.core.page.TableDataInfo;
import com.goldenwater.common.enums.BusinessType;
import com.goldenwater.common.utils.poi.ExcelUtil;
import com.goldenwater.slaj.eme.domain.BusiTeamInfo;
import com.goldenwater.slaj.eme.service.IBusiTeamInfoService;

/**
 * 应急救援队伍
 */
@RestController
@RequestMapping("/eme/teaminfo")
public class BusiTeamInfoController extends BaseController {
    @Autowired
    private IBusiTeamInfoService busiTeamInfoService;

    @GetMapping("/list")
    public TableDataInfo list(BusiTeamInfo busiTeamInfo) {
        startPage();
        List<BusiTeamInfo> list = busiTeamInfoService.selectBusiTeamInfoList(busiTeamInfo);
        return getDataTable(list);
    }

    @GetMapping("/{guid}")
    public AjaxResult getInfo(@PathVariable String guid) {
        return AjaxResult.success(busiTeamInfoService.selectBusiTeamInfoByGuid(guid));
    }

    @PostMapping
    public AjaxResult add(@RequestBody BusiTeamInfo busiTeamInfo) {
        return toAjax(busiTeamInfoService.insertBusiTeamInfo(busiTeamInfo));
    }

    @PutMapping
    public AjaxResult edit(@RequestBody BusiTeamInfo busiTeamInfo) {
        return toAjax(busiTeamInfoService.updateBusiTeamInfo(busiTeamInfo));
    }

    @DeleteMapping("/{guids}")
    public AjaxResult remove(@PathVariable String[] guids) {
        return toAjax(busiTeamInfoService.deleteBusiTeamInfoByGuids(guids));
    }

    @Log(title = "应急救援队伍管理", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('eme:teaminfo:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, BusiTeamInfo busiTeamInfo) {
        List<BusiTeamInfo> list = busiTeamInfoService.selectBusiTeamInfoList(busiTeamInfo);
        ExcelUtil<BusiTeamInfo> util = new ExcelUtil<BusiTeamInfo>(BusiTeamInfo.class);
        util.exportExcel(response, list, "应急救援队伍数据");
    }
}
