package com.yuchen.saas.park.service.controller.parking;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.yuchen.saas.park.api.entity.park.PmgLogFreeRelease;
import com.yuchen.saas.park.api.request.ParkingSpaceRequest;
import com.yuchen.saas.park.api.response.ParkingSpaceResponse;
import com.yuchen.saas.park.api.response.SpaceStaticResponse;
import com.yuchen.saas.park.service.service.ParkingSpaceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.nest.springwrap.core.mp.support.Query;
import org.nest.springwrap.core.tool.api.R;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * @author 肖祥
 * @version 1.0
 * @date 2022/11/29 14:26
 */
@RestController
@AllArgsConstructor
@RequestMapping("/parking/space")
@Api(value = "停车位管理记录", tags = "停车位管理记录")
public class ParkingSpaceController {

    @Resource
    private ParkingSpaceService parkingSpaceService;

    /**
     * 详情
     */
    @GetMapping("/detail")
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "停车位管理详情", notes = "停车位管理详情")
    public R detail(@RequestParam("id") Long id) {
        return parkingSpaceService.detail(id);
    }


    /**
     * 分页
     */
    @GetMapping("/list")
    @ApiOperationSupport(order = 3)
    @ApiOperation(value = "分页", notes = "停车位管理列表")
    public R<IPage<ParkingSpaceResponse>> list(ParkingSpaceRequest parkingSpaceRequest, Query query) {
        return parkingSpaceService.list(parkingSpaceRequest,query);
    }

    /**
     * 新增
     */
    @PostMapping("/save")
    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "新增", notes = "停车位管理新增")
    public R save(@Valid @RequestBody ParkingSpaceRequest parkingSpaceRequest) {
        return parkingSpaceService.save(parkingSpaceRequest);
    }

    /**
     * 修改
     */
    @PostMapping("/update")
    @ApiOperationSupport(order = 6)
    @ApiOperation(value = "修改", notes = "停车位管理更新")
    public R update(@Valid @RequestBody ParkingSpaceRequest parkingSpaceRequest) {
        return parkingSpaceService.update(parkingSpaceRequest);
    }

    /**
     * 删除
     */
    @PostMapping("/remove")
    @ApiOperationSupport(order = 7)
    @ApiOperation(value = "删除", notes = "停车位管理删除")
    public R remove(@Valid @RequestBody ParkingSpaceRequest parkingSpaceRequest) {
        return parkingSpaceService.remove(parkingSpaceRequest);
    }


    /**
     * 车位统计
     */
    @GetMapping("/statistical")
    @ApiOperationSupport(order = 7)
    @ApiOperation(value = "车位统计", notes = "车位统计")
    public R<SpaceStaticResponse> spaceStatics(ParkingSpaceRequest parkingSpaceRequest) {
        return parkingSpaceService.spaceStatics(parkingSpaceRequest);
    }
}
