liusuyi
2026-05-18 b5cd784d0cde5b7c82ea78aef4ac0e5a161d8c5d
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
package com.ard.zlm.controller;
 
import com.ard.common.core.web.controller.BaseController;
import com.ard.common.core.web.domain.AjaxResult;
import com.ard.zlm.api.domain.ZlmMediaServer;
import com.ard.zlm.domain.MediaServerLoad;
import com.ard.zlm.service.IMediaServerService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import java.util.ArrayList;
import java.util.List;
 
/**
 * @FileName ZlmServerController
 * @Description
 * @Author fengcheng
 * @date 2026-04-15
 **/
@Slf4j
@RestController
@RequestMapping("/server")
public class ZlmServerController extends BaseController {
 
    @Autowired
    private IMediaServerService mediaServerService;
 
    /**
     * 获取负载信息
     *
     * @return
     */
    @GetMapping(value = "/media_server/load")
    public AjaxResult getMediaLoad() {
        List<MediaServerLoad> result = new ArrayList<>();
        List<ZlmMediaServer> allOnline = mediaServerService.getAllOnlineMediaServe();
        if (allOnline.isEmpty()) {
            return success(result);
        } else {
            for (ZlmMediaServer mediaServerItem : allOnline) {
                result.add(mediaServerService.getLoad(mediaServerItem));
            }
        }
        return success(result);
    }
}