package com.tfis.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
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.tfis.common.annotation.Log;
import com.tfis.common.core.controller.BaseController;
import com.tfis.common.core.domain.AjaxResult;
import com.tfis.common.enums.BusinessType;
import com.tfis.system.domain.AircraftSystem;
import com.tfis.system.service.IAircraftSystemService;
import com.tfis.common.utils.poi.ExcelUtil;
import com.tfis.common.core.page.TableDataInfo;

/**
 * 系统信息管理Controller
 * 
 * @author allen
 * @date 2023-11-23
 */
@RestController
@RequestMapping("/system/system")
public class AircraftSystemController extends BaseController
{
    @Autowired
    private IAircraftSystemService aircraftSystemService;

    /**
     * 查询系统信息管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:system:list')")
    @GetMapping("/list")
    public TableDataInfo list(AircraftSystem aircraftSystem)
    {
        startPage();
        List<AircraftSystem> list = aircraftSystemService.selectAircraftSystemList(aircraftSystem);
        return getDataTable(list);
    }

    /**
     * 导出系统信息管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:system:export')")
    @Log(title = "系统信息管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AircraftSystem aircraftSystem)
    {
        List<AircraftSystem> list = aircraftSystemService.selectAircraftSystemList(aircraftSystem);
        ExcelUtil<AircraftSystem> util = new ExcelUtil<AircraftSystem>(AircraftSystem.class);
        util.exportExcel(response, list, "系统信息管理数据");
    }

    /**
     * 获取系统信息管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:system:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(aircraftSystemService.selectAircraftSystemById(id));
    }

    /**
     * 新增系统信息管理
     */
    @PreAuthorize("@ss.hasPermi('system:system:add')")
    @Log(title = "系统信息管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AircraftSystem aircraftSystem)
    {
        return toAjax(aircraftSystemService.insertAircraftSystem(aircraftSystem));
    }

    /**
     * 修改系统信息管理
     */
    @PreAuthorize("@ss.hasPermi('system:system:edit')")
    @Log(title = "系统信息管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AircraftSystem aircraftSystem)
    {
        return toAjax(aircraftSystemService.updateAircraftSystem(aircraftSystem));
    }

    /**
     * 删除系统信息管理
     */
    @PreAuthorize("@ss.hasPermi('system:system:remove')")
    @Log(title = "系统信息管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(aircraftSystemService.deleteAircraftSystemByIds(ids));
    }
}
