package com.ruoyi.project.patrol.dev.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
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;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.patrol.dev.domain.TDevAidkit;
import com.ruoyi.project.patrol.dev.service.ITDevAidkitService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 急救箱Controller
 *
 * @author ssy
 * @date 2024-10-30
 */
@RestController
@RequestMapping("/dev/aidkit")
public class TDevAidkitController extends BaseController
{
    @Autowired
    private ITDevAidkitService tDevAidkitService;

    /**
     * 查询急救箱列表
     */
    @PreAuthorize("@ss.hasPermi('dev:aidkit:list')")
    @GetMapping("/list")
    public TableDataInfo list(TDevAidkit tDevAidkit)
    {
        startPage();
        List<TDevAidkit> list = tDevAidkitService.selectTDevAidkitList(tDevAidkit);
        return getDataTable(list);
    }

    /**
     * 导出急救箱列表
     */
    
    @Log(title = "急救箱", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TDevAidkit tDevAidkit)
    {
        List<TDevAidkit> list = tDevAidkitService.selectTDevAidkitList(tDevAidkit);
        ExcelUtil<TDevAidkit> util = new ExcelUtil<TDevAidkit>(TDevAidkit.class);
        return util.exportExcel(list, "aidkit");
    }

    /**
     * 获取急救箱详细信息
     */
    @PreAuthorize("@ss.hasPermi('dev:aidkit:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tDevAidkitService.selectTDevAidkitById(id));
    }

    /**
     * 新增急救箱
     */
    @PreAuthorize("@ss.hasPermi('dev:aidkit:add')")
    @Log(title = "急救箱", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TDevAidkit tDevAidkit)
    {
        return toAjax(tDevAidkitService.insertTDevAidkit(tDevAidkit));
    }

    /**
     * 修改急救箱
     */
    @PreAuthorize("@ss.hasPermi('dev:aidkit:edit')")
    @Log(title = "急救箱", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TDevAidkit tDevAidkit)
    {
        return toAjax(tDevAidkitService.updateTDevAidkit(tDevAidkit));
    }

    /**
     * 删除急救箱
     */
    @PreAuthorize("@ss.hasPermi('dev:aidkit:remove')")
    @Log(title = "急救箱", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tDevAidkitService.deleteTDevAidkitByIds(ids));
    }
}
