package com.emergency.avenue.storage.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.emergency.avenue.common.core.util.R;
import com.emergency.avenue.common.log.annotation.SysLog;
import com.emergency.avenue.storage.api.entity.VehicleCapacityManagement;
import com.emergency.avenue.storage.service.VehicleCapacityManagementService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@AllArgsConstructor
@RequestMapping("/vehicleCapacity")
@Tag(description = "vehicleCapacity", name = "车辆运力管理")
public class VehicleCapacityManagementController {

	private final VehicleCapacityManagementService vehicleCapacityManagementService;
	/**
	 * 获取车辆运力管理列表
	 * @return 车辆运力管理列表
	 */
	@GetMapping("/list")
	public R<List<VehicleCapacityManagement>> listPosts() {
		return R.ok(vehicleCapacityManagementService.list(Wrappers.emptyWrapper()));
	}

	/**
	 * 分页查询
	 * @param page 分页对象
	 * @param vehicleCapacityManagement 车辆运力管理表
	 * @return
	 */
	@Operation(description = "分页查询", summary = "分页查询")
	@GetMapping("/page")
	public R getVehicleCapacityManagementPage(Page page, VehicleCapacityManagement vehicleCapacityManagement) {
		return R.ok(vehicleCapacityManagementService.page(page, Wrappers.query(vehicleCapacityManagement)));
	}

	/**
	 * 通过id查询车辆运力管理表
	 * @param vehicleId id
	 * @return R
	 */
	@Operation(description = "通过id查询", summary = "通过id查询")
	@GetMapping("/{vehicleId}")
	public R getById(@PathVariable("vehicleId") Long vehicleId) {
		return R.ok(vehicleCapacityManagementService.getById(vehicleId));
	}

	/**
	 * 新增车辆运力管理表
	 * @param vehicleCapacityManagement 车辆运力管理表
	 * @return R
	 */
	@Operation(description = "新增车辆运力管理表", summary = "新增车辆运力管理表")
	@SysLog("新增车辆运力管理表")
	@PostMapping
	public R save(@RequestBody VehicleCapacityManagement vehicleCapacityManagement) {
		return R.ok(vehicleCapacityManagementService.save(vehicleCapacityManagement));
	}

	/**
	 * 修改车辆运力管理表
	 * @param vehicleCapacityManagement 车辆运力管理表
	 * @return R
	 */
	@Operation(description = "修改车辆运力管理表", summary = "修改车辆运力管理表")
	@SysLog("修改车辆运力管理表")
	@PutMapping
	public R updateById(@RequestBody VehicleCapacityManagement vehicleCapacityManagement) {
		return R.ok(vehicleCapacityManagementService.updateById(vehicleCapacityManagement));
	}

	/**
	 * 通过id删除车辆运力管理表
	 * @param vehicleId id
	 * @return R
	 */
	@Operation(description = "通过id删除车辆运力管理表", summary = "通过id删除车辆运力管理表")
	@SysLog("通过id删除车辆运力管理表")
	@DeleteMapping("/{vehicleId}")
	public R removeById(@PathVariable Long vehicleId) {
		return R.ok(vehicleCapacityManagementService.removeById(vehicleId));
	}
}
