From 971e9c258971d4f7ce4c6553059287dd526cdf73 Mon Sep 17 00:00:00 2001 From: shikong <919411476@qq.com> Date: Tue, 29 Aug 2023 15:33:46 +0800 Subject: [PATCH] =?UTF-8?q?api=E8=B7=AF=E5=BE=84=E8=B0=83=E6=95=B4=20?= =?UTF-8?q?=E8=AE=BE=E5=A4=87=E5=88=97=E8=A1=A8=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gb28181/api/info/InfoController.java | 32 +++++++++++++++ .../gb28181/api/play/PlayController.java | 4 +- .../gb28181/api/record/RecordController.java | 4 +- .../gb28181/common/page/PageWrapper.java | 39 +++++++++++++++++++ .../gb28181/service/info/InfoService.java | 19 +++++++++ 5 files changed, 94 insertions(+), 4 deletions(-) create mode 100644 api/src/main/java/cn/skcks/docking/gb28181/api/info/InfoController.java create mode 100644 common/src/main/java/cn/skcks/docking/gb28181/common/page/PageWrapper.java create mode 100644 gb28181-service/src/main/java/cn/skcks/docking/gb28181/service/info/InfoService.java diff --git a/api/src/main/java/cn/skcks/docking/gb28181/api/info/InfoController.java b/api/src/main/java/cn/skcks/docking/gb28181/api/info/InfoController.java new file mode 100644 index 0000000..5932116 --- /dev/null +++ b/api/src/main/java/cn/skcks/docking/gb28181/api/info/InfoController.java @@ -0,0 +1,32 @@ +package cn.skcks.docking.gb28181.api.info; + +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.config.SwaggerConfig; +import cn.skcks.docking.gb28181.orm.mybatis.dynamic.model.DockingDevice; +import cn.skcks.docking.gb28181.service.info.InfoService; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.RequiredArgsConstructor; +import org.springdoc.core.models.GroupedOpenApi; +import org.springframework.context.annotation.Bean; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +@Tag(name="详情/信息") +@RestController +@JsonMapping("/api/device/info") +@RequiredArgsConstructor +public class InfoController { + private final InfoService infoService; + @Bean + public GroupedOpenApi infoApi() { + return SwaggerConfig.api("Info", "/api/device/info"); + } + + @GetJson("/list") + public JsonResponse> list(){ + return JsonResponse.success(infoService.getDeviceList()); + } +} diff --git a/api/src/main/java/cn/skcks/docking/gb28181/api/play/PlayController.java b/api/src/main/java/cn/skcks/docking/gb28181/api/play/PlayController.java index deace72..17e4361 100644 --- a/api/src/main/java/cn/skcks/docking/gb28181/api/play/PlayController.java +++ b/api/src/main/java/cn/skcks/docking/gb28181/api/play/PlayController.java @@ -18,14 +18,14 @@ import org.springframework.web.context.request.async.DeferredResult; @Tag(name="播放") @RestController -@JsonMapping("/device/play") +@JsonMapping("/api/device/play") @RequiredArgsConstructor public class PlayController { private final PlayService playService; @Bean public GroupedOpenApi playApi() { - return SwaggerConfig.api("Play", "/device/play"); + return SwaggerConfig.api("Play", "/api/device/play"); } @GetJson("/realTimePlay") diff --git a/api/src/main/java/cn/skcks/docking/gb28181/api/record/RecordController.java b/api/src/main/java/cn/skcks/docking/gb28181/api/record/RecordController.java index c61dadd..6f0c93e 100644 --- a/api/src/main/java/cn/skcks/docking/gb28181/api/record/RecordController.java +++ b/api/src/main/java/cn/skcks/docking/gb28181/api/record/RecordController.java @@ -20,14 +20,14 @@ import java.util.List; @Tag(name="历史录像") @RestController -@JsonMapping("/device/record") +@JsonMapping("/api/device/record") @RequiredArgsConstructor public class RecordController { private final RecordService recordService; @Bean public GroupedOpenApi recordApi() { - return SwaggerConfig.api("Record", "/device/record"); + return SwaggerConfig.api("Record", "/api/device/record"); } @GetJson("/getInfoList") diff --git a/common/src/main/java/cn/skcks/docking/gb28181/common/page/PageWrapper.java b/common/src/main/java/cn/skcks/docking/gb28181/common/page/PageWrapper.java new file mode 100644 index 0000000..086e7cd --- /dev/null +++ b/common/src/main/java/cn/skcks/docking/gb28181/common/page/PageWrapper.java @@ -0,0 +1,39 @@ +package cn.skcks.docking.gb28181.common.page; + +import com.github.pagehelper.PageInfo; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Collection; + +@AllArgsConstructor +@NoArgsConstructor +@Data +@SuppressWarnings({"unused"}) +@Schema(title = "分页数据") +public class PageWrapper { + @Schema(title = "数据") + private Collection data; + @Schema(title = "页码") + private long page; + @Schema(title = "每页大小") + private long pageSize; + @Schema(title = "总页数") + private long pageTotal; + @Schema(title = "数据总数") + private long total; + + public static PageWrapper of(Collection data, long page, long pageSize, long pageTotal, long total) { + return new PageWrapper<>(data, page, pageSize, pageTotal, total); + } + + public static PageWrapper of(PageInfo pageInfo) { + return new PageWrapper<>(pageInfo.getList(), + pageInfo.getPageNum(), + pageInfo.getPageSize(), + pageInfo.getPages(), + pageInfo.getTotal()); + } +} diff --git a/gb28181-service/src/main/java/cn/skcks/docking/gb28181/service/info/InfoService.java b/gb28181-service/src/main/java/cn/skcks/docking/gb28181/service/info/InfoService.java new file mode 100644 index 0000000..9b72a27 --- /dev/null +++ b/gb28181-service/src/main/java/cn/skcks/docking/gb28181/service/info/InfoService.java @@ -0,0 +1,19 @@ +package cn.skcks.docking.gb28181.service.info; + +import cn.skcks.docking.gb28181.orm.mybatis.dynamic.mapper.DockingDeviceMapper; +import cn.skcks.docking.gb28181.orm.mybatis.dynamic.model.DockingDevice; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +@RequiredArgsConstructor +public class InfoService { + private final DockingDeviceMapper dockingDeviceMapper; + + public List getDeviceList(){ +// PageHelper. + return dockingDeviceMapper.select((d->d)); + } +}