package com.aircraft.modules.aircraft.controller;


import com.aircraft.modules.aircraft.domain.AircraftMaintenance;
import com.aircraft.modules.aircraft.service.AircraftMaintenanceService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 飞行器维保表 前端控制器
 * </p>
 *
 * @author cli
 * @since 2025-07-11
 */
@Api(tags = "飞行器维保管理")
@RequiredArgsConstructor
@RestController
@RequestMapping("/aircraft/maintenance")
public class AircraftMaintenanceController {

    private final AircraftMaintenanceService aircraftMaintenanceService;


    /**
     * 分页查询飞行器维保记录
     */
    @ApiOperation("分页查询飞行器维保记录")
    @GetMapping("/page")
    public ResponseEntity<IPage<AircraftMaintenance>> page(Long aircraftId,
                                                           Page page) {
        return ResponseEntity.ok(aircraftMaintenanceService.page(aircraftId, page));
    }

    /**
     * 新增飞行器维保记录
     */
    @ApiOperation("新增飞行器维保记录")
    @PostMapping
    public ResponseEntity<Object> create(@RequestBody @Validated AircraftMaintenance aircraftMaintenance) {
        aircraftMaintenanceService.create(aircraftMaintenance);
        return new ResponseEntity<>(HttpStatus.OK);
    }
}

