package com.yeejoin.amos.boot.module.ccs.biz.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.module.ccs.api.dto.FireVehicleDto;
import com.yeejoin.amos.boot.module.ccs.biz.service.impl.FireVehicleServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;

import java.util.List;

/**
 * 消防车辆信息
 *
 * @author system_generator
 * @date 2021-11-09
 */
@RestController
@Api(tags = "消防车辆信息Api")
@RequestMapping(value = "/fire-vehicle")
public class FireVehicleController extends BaseController {

    @Autowired
    FireVehicleServiceImpl fireVehicleServiceImpl;

    /**
     * 列表分页查询
     *
     * @param current 当前页
     * @param current 每页大小
     * @return
     */
    @TycloudOperation(ApiLevel = UserType.AGENCY)
    @GetMapping(value = "/{stationCode}/page")
    @ApiOperation(httpMethod = "GET", value = "消防车辆信息分页查询", notes = "消防车辆信息分页查询")
    public ResponseModel<Page<FireVehicleDto>> queryForPage(
            @ApiParam(value = "建筑名称") @RequestParam(value = "name", required = false) String name,
            @ApiParam(value = "当前页", required = true) @RequestParam(value = "current") int current,
            @ApiParam(value = "页大小", required = true) @RequestParam(value = "size") int size,
            @ApiParam(value = "换流站code", required = true) @PathVariable String stationCode) {
        Page<FireVehicleDto> page = new Page<FireVehicleDto>();
        page.setCurrent(current);
        page.setSize(size);
        return ResponseHelper.buildResponse(fireVehicleServiceImpl.queryForFireVehiclePage(page, name, stationCode));
    }

    /**
     * 消防车辆信息列表
     *
     * @return List<FireVehicleDto>
     */
    @TycloudOperation(ApiLevel = UserType.AGENCY)
    @GetMapping(value = "/{stationCode}/list")
    @ApiOperation(httpMethod = "GET", value = "消防车辆信息列表", notes = "消防车辆信息列表")
    public ResponseModel<List<FireVehicleDto>> queryForList(
            @ApiParam(value = "换流站code", required = true) @PathVariable String stationCode) {
        return ResponseHelper.buildResponse(fireVehicleServiceImpl.queryForFireVehicleList(stationCode));
    }
}
