package com.zehong.web.controller.energency;

import com.zehong.common.annotation.Log;
import com.zehong.common.core.controller.BaseController;
import com.zehong.common.core.domain.AjaxResult;
import com.zehong.common.core.page.TableDataInfo;
import com.zehong.common.enums.BusinessType;
import com.zehong.common.utils.poi.ExcelUtil;
import com.zehong.system.domain.TEmergencyResources;
import com.zehong.system.service.ITEmergencyResourcesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 应急资源Controller
 *
 * @author zehong
 * @date 2025-06-16
 */
@RestController
@RequestMapping("/system/resources")
public class TEmergencyResourcesController extends BaseController
{
    @Autowired
    private ITEmergencyResourcesService tEmergencyResourcesService;


    /**
     * 查询应急资源列表
     */
    @GetMapping("/list")
    public TableDataInfo list(TEmergencyResources tEmergencyResources)
    {
        startPage();
        List<TEmergencyResources> list = tEmergencyResourcesService.selectTEmergencyResourcesList(tEmergencyResources);
        return getDataTable(list);
    }

    /**
     * 导出应急资源列表
     */
    @Log(title = "应急资源", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TEmergencyResources tEmergencyResources)
    {
        List<TEmergencyResources> list = tEmergencyResourcesService.selectTEmergencyResourcesList(tEmergencyResources);
        ExcelUtil<TEmergencyResources> util = new ExcelUtil<TEmergencyResources>(TEmergencyResources.class);
        return util.exportExcel(list, "应急资源数据");
    }

    /**
     * 获取应急资源详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tEmergencyResourcesService.selectTEmergencyResourcesById(id));
    }

    /**
     * 新增应急资源
     */
    @Log(title = "应急资源", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TEmergencyResources tEmergencyResources)
    {
        return toAjax(tEmergencyResourcesService.insertTEmergencyResources(tEmergencyResources));
    }

    /**
     * 修改应急资源
     */
    @Log(title = "应急资源", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TEmergencyResources tEmergencyResources)
    {
        return toAjax(tEmergencyResourcesService.updateTEmergencyResources(tEmergencyResources));
    }

    /**
     * 删除应急资源
     */
    @Log(title = "应急资源", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tEmergencyResourcesService.deleteTEmergencyResourcesByIds(ids));
    }
}