package cn.skcks.docking.gb28181.wvp.api.docking;

import cn.skcks.docking.gb28181.annotation.web.JsonMapping;
import cn.skcks.docking.gb28181.annotation.web.methods.GetJson;
import cn.skcks.docking.gb28181.common.json.JsonResponse;
import cn.skcks.docking.gb28181.common.page.PageWrapper;
import cn.skcks.docking.gb28181.wvp.api.docking.dto.DockingPageDTO;
import cn.skcks.docking.gb28181.wvp.config.SwaggerConfig;
import cn.skcks.docking.gb28181.wvp.orm.mybatis.dynamic.model.WvpProxyDocking;
import cn.skcks.docking.gb28181.wvp.service.docking.DockingService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springdoc.core.annotations.ParameterObject;
import org.springdoc.core.models.GroupedOpenApi;
import org.springframework.context.annotation.Bean;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;

@Tag(name = "设备/平台对接")
@RestController
@JsonMapping("/docking")
@RequiredArgsConstructor
public class DockingController {
    private final DockingService dockingService;
    @Bean
    public GroupedOpenApi dockingApi() {
        return SwaggerConfig.api("Docking", "/docking");
    }

    @Operation(summary = "分页查询对接的设备/平台列表")
    @GetJson("/page")
    private JsonResponse<PageWrapper<WvpProxyDocking>> page(@ParameterObject @Validated DockingPageDTO dto){
        return JsonResponse.success(PageWrapper.of(dockingService.getDockingWithPage(dto.getPage(), dto.getSize())));
    }
}
