package com.fms.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.fms.common.annotation.Log;
import com.fms.common.core.controller.BaseController;
import com.fms.common.core.domain.AjaxResult;
import com.fms.common.enums.BusinessType;
import com.fms.system.domain.AircraftType;
import com.fms.system.service.IAircraftTypeService;
import com.fms.common.utils.poi.ExcelUtil;
import com.fms.common.core.page.TableDataInfo;

/**
 * 机型Controller
 * 
 * @author Allen
 * @date 2024-06-09
 */
@RestController
@RequestMapping("/system/aircraftType")
public class AircraftTypeController extends BaseController
{
    @Autowired
    private IAircraftTypeService aircraftTypeService;

    /**
     * 查询机型列表
     */
    @PreAuthorize("@ss.hasPermi('system:aircraftType:list')")
    @GetMapping("/list")
    public TableDataInfo list(AircraftType aircraftType)
    {
        startPage();
        List<AircraftType> list = aircraftTypeService.selectAircraftTypeList(aircraftType);
        return getDataTable(list);
    }

    /**
     * 导出机型列表
     */
    @PreAuthorize("@ss.hasPermi('system:aircraftType:export')")
    @Log(title = "机型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AircraftType aircraftType)
    {
        List<AircraftType> list = aircraftTypeService.selectAircraftTypeList(aircraftType);
        ExcelUtil<AircraftType> util = new ExcelUtil<AircraftType>(AircraftType.class);
        util.exportExcel(response, list, "机型数据");
    }

    /**
     * 获取机型详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:aircraftType:query')")
    @GetMapping(value = "/{aircraftTypeId}")
    public AjaxResult getInfo(@PathVariable("aircraftTypeId") Long aircraftTypeId)
    {
        return success(aircraftTypeService.selectAircraftTypeByAircraftTypeId(aircraftTypeId));
    }

    /**
     * 新增机型
     */
    @PreAuthorize("@ss.hasPermi('system:aircraftType:add')")
    @Log(title = "机型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AircraftType aircraftType)
    {
        return toAjax(aircraftTypeService.insertAircraftType(aircraftType));
    }

    /**
     * 修改机型
     */
    @PreAuthorize("@ss.hasPermi('system:aircraftType:edit')")
    @Log(title = "机型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AircraftType aircraftType)
    {
        return toAjax(aircraftTypeService.updateAircraftType(aircraftType));
    }

    /**
     * 删除机型
     */
    @PreAuthorize("@ss.hasPermi('system:aircraftType:remove')")
    @Log(title = "机型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{aircraftTypeIds}")
    public AjaxResult remove(@PathVariable Long[] aircraftTypeIds)
    {
        return toAjax(aircraftTypeService.deleteAircraftTypeByAircraftTypeIds(aircraftTypeIds));
    }
}
