liurunyu
2025-09-01 cb9caeaf939dbc10522f395647ca7fefb3a8634b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
package com.dy.pipIrrWechat.video;
 
import com.dy.common.webUtil.BaseResponse;
import com.dy.common.webUtil.BaseResponseUtils;
import com.dy.common.webUtil.QueryResultVo;
import com.dy.common.webUtil.ResultCodeMsg;
import com.dy.pipIrrGlobal.pojoVi.ViYsApp;
import com.dy.pipIrrGlobal.voVi.VoCamera;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
 
import java.util.ArrayList;
import java.util.List;
 
/**
 * @Author: liurunyu
 * @Date: 2025/8/14 13:58
 * @Description
 */
@Slf4j
@Tag(name = "视频监控摄像头", description = "视频监控摄像头")
@RestController
@RequestMapping(path = "video")
@RequiredArgsConstructor
public class VideoCtrl{
 
    private VideoSv sv ;
 
    @Autowired
    public void setSv(VideoSv sv) {
        this.sv = sv;
    }
 
 
    /**
     * 客户端请求得到所有摄像头信息
     * @return 所有摄像头信息
     */
    @Operation(summary = "获得所有摄像头信息", description = "返回所有摄像头信息")
    @ApiResponses(value = {
            @ApiResponse(
                    responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
                    description = "返回所有摄像头信息数据(BaseResponse.content:TypesVo[{}])",
                    content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
                            schema = @Schema(implementation = VoVideo.class))}
            )
    })
    @GetMapping(path = "all")
    public BaseResponse<List<VoVideo>> all() {
        List<VoVideo> reList = new ArrayList<>() ;
        try {
            List<VoCamera> list = this.sv.allCamera() ;
            ViYsApp app = this.sv.ysApp() ;
            if(list != null && list.size() > 0){
                for (VoCamera voCamera : list) {
                    VoVideo vvo = new VoVideo() ;
                    vvo.from(voCamera, app == null ? null : app.accessToken);
                    reList.add(vvo) ;
                }
            }
            return BaseResponseUtils.buildSuccess(reList);
        } catch (Exception e) {
            log.error("查询全部摄像头信息异常", e);
            return BaseResponseUtils.buildException(e.getMessage());
        }
    }
 
    /**
     * 客户端分页请求摄像头信息
     * @param queryQo 查询条件
     * @return 分页请求摄像头信息
     * 
     * 使用示例:
     * GET /video/some?pageCurr=1&pageSize=10&name=摄像头1&type=1
     * 
     * 查询参数说明:
     * - pageCurr: 当前页码(默认1)
     * - pageSize: 每页记录数(默认10)
     * - name: 摄像头名称(支持模糊查询)
     * - type: 摄像头类型(1:萤石)
     * - onScreen: 是否大屏展示(1:是,0:否)
     * - devNo: 设备序列号
     */
    @Operation(summary = "分页获取摄像头信息", description = "根据查询条件分页返回摄像头信息")
    @ApiResponses(value = {
            @ApiResponse(
                    responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
                    description = "返回分页摄像头信息数据(BaseResponse.content:QueryResultVo[List[VoVideo]])",
                    content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
                            schema = @Schema(implementation = QueryResultVo.class))}
            )
    })
    @GetMapping(path = "some")
    public BaseResponse<QueryResultVo<List<VoVideo>>> some(VideoQo queryQo) {
        try {
            // 获取分页查询结果
            QueryResultVo<List<VoCamera>> pageResult = this.sv.some(queryQo);
            
            List<VoVideo> reList = new ArrayList<>();
            ViYsApp app = this.sv.ysApp();
            
            if (pageResult != null && pageResult.obj != null && pageResult.obj.size() > 0) {
                for (VoCamera voCamera : pageResult.obj) {
                    VoVideo vvo = new VoVideo();
                    vvo.from(voCamera, app == null ? null : app.accessToken);
                    reList.add(vvo);
                }
            }
            
            // 构建分页结果
            QueryResultVo<List<VoVideo>> result = new QueryResultVo<>();
            result.pageSize = pageResult.pageSize;
            result.pageCurr = pageResult.pageCurr;
            result.pageTotal = pageResult.pageTotal;
            result.itemTotal = pageResult.itemTotal;
            result.obj = reList;
            
            return BaseResponseUtils.buildSuccess(result);
        } catch (Exception e) {
            log.error("分页查询摄像头信息异常", e);
            return BaseResponseUtils.buildException(e.getMessage());
        }
    }
 
}