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.AircraftSubsystem;
import com.tfis.system.service.IAircraftSubsystemService;
import com.tfis.common.utils.poi.ExcelUtil;
import com.tfis.common.core.page.TableDataInfo;

/**
 * 分系统信息管理Controller
 * 
 * @author allen
 * @date 2023-11-23
 */
@RestController
@RequestMapping("/system/subsystem")
public class AircraftSubsystemController extends BaseController
{
    @Autowired
    private IAircraftSubsystemService aircraftSubsystemService;

    /**
     * 查询分系统信息管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:subsystem:list')")
    @GetMapping("/list")
    public TableDataInfo list(AircraftSubsystem aircraftSubsystem)
    {
        startPage();
        List<AircraftSubsystem> list = aircraftSubsystemService.selectAircraftSubsystemList(aircraftSubsystem);
        return getDataTable(list);
    }

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

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

    /**
     * 新增分系统信息管理
     */
    @PreAuthorize("@ss.hasPermi('system:subsystem:add')")
    @Log(title = "分系统信息管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AircraftSubsystem aircraftSubsystem)
    {
        return toAjax(aircraftSubsystemService.insertAircraftSubsystem(aircraftSubsystem));
    }

    /**
     * 修改分系统信息管理
     */
    @PreAuthorize("@ss.hasPermi('system:subsystem:edit')")
    @Log(title = "分系统信息管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AircraftSubsystem aircraftSubsystem)
    {
        return toAjax(aircraftSubsystemService.updateAircraftSubsystem(aircraftSubsystem));
    }

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