统一axios写法

This commit is contained in:
panlinlin
2021-04-12 16:04:04 +08:00
parent 27df8bd84c
commit 4010ed6c23
28 changed files with 243 additions and 218 deletions

View File

@@ -92,8 +92,8 @@ public class Swagger3Config {
return new ApiInfoBuilder()
.title("WVP-PRO 接口文档")
.description("更多请咨询服务开发者(18010473990@@163.com)。")
.contact(new Contact("Ray。", "http://www.ruiyeclub.cn", "ruiyeclub@foxmail.com"))
.version("1.0")
.contact(new Contact("panlinlin", "http://www.ruiyeclub.cn", "ruiyeclub@foxmail.com"))
.version("2.0")
.build();
}
}

View File

@@ -84,7 +84,7 @@ public class PlayServiceImpl implements IPlayService {
} else {
String streamId = streamInfo.getStreamId();
JSONObject rtpInfo = zlmresTfulUtils.getRtpInfo(streamId);
if (rtpInfo.getBoolean("exist")) {
if (rtpInfo != null && rtpInfo.getBoolean("exist")) {
RequestMessage msg = new RequestMessage();
msg.setId(DeferredResultHolder.CALLBACK_CMD_PlAY + uuid);
msg.setData(JSON.toJSONString(streamInfo));

View File

@@ -118,12 +118,11 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
public boolean stop(String app, String stream) {
boolean result = false;
StreamProxyItem streamProxyDto = videoManagerStorager.queryStreamProxy(app, stream);
if (streamProxyDto.isEnable() && streamProxyDto != null) {
if (streamProxyDto != null && streamProxyDto.isEnable()) {
JSONObject jsonObject = removeStreamProxyFromZlm(streamProxyDto);
if (jsonObject.getInteger("code") == 0) {
result = true;
streamProxyDto.setEnable(false);
videoManagerStorager.updateStreamProxy(streamProxyDto);
result = videoManagerStorager.updateStreamProxy(streamProxyDto);
}
}
return result;

View File

@@ -24,7 +24,7 @@ public interface GbStreamMapper {
"name=#{name}," +
"streamType=#{streamType}," +
"longitude=#{longitude}, " +
"latitude=#{latitude} " +
"latitude=#{latitude}," +
"status=${status} " +
"WHERE app=#{app} AND stream=#{stream} AND gbId=#{gbId}")
int update(GbStream gbStream);

View File

@@ -440,6 +440,7 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
dataSourceTransactionManager.commit(transactionStatus); //手动提交
result = true;
}catch (Exception e) {
e.printStackTrace();
dataSourceTransactionManager.rollback(transactionStatus);
}
return result;

View File

@@ -8,6 +8,7 @@ import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
@@ -25,11 +26,11 @@ public class SseController {
@Autowired
AlarmEventListener alarmEventListener;
@ApiOperation("设置响应")
@ApiOperation("浏览器推送")
@ApiImplicitParams({
@ApiImplicitParam(name = "browserId", value = "浏览器ID", dataTypeClass = String.class),
})
@RequestMapping("/emit")
@PostMapping("/emit")
public SseEmitter emit(@RequestParam String browserId) {
final SseEmitter sseEmitter = new SseEmitter(0L);
try {

View File

@@ -44,7 +44,7 @@ public class MediaController {
@ApiImplicitParam(name = "app", value = "应用名", dataTypeClass = String.class),
@ApiImplicitParam(name = "stream", value = "流id", dataTypeClass = String.class),
})
@RequestMapping(value = "/getStreamInfoByAppAndStream")
@GetMapping(value = "/stream_info_by_app_and_stream")
@ResponseBody
public StreamInfo getStreamInfoByAppAndStream(String app, String stream){
return mediaService.getStreamInfoByAppAndStreamWithCheck(app, stream);

View File

@@ -32,7 +32,7 @@ public class PlatformGbStreamController {
@ApiImplicitParam(name = "page", value = "当前页", dataTypeClass = Integer.class),
@ApiImplicitParam(name = "count", value = "每页条数", dataTypeClass = Integer.class),
})
@RequestMapping(value = "/list")
@GetMapping(value = "/list")
@ResponseBody
public PageInfo<GbStream> list(@RequestParam(required = false)Integer page,
@RequestParam(required = false)Integer count){

View File

@@ -93,7 +93,7 @@ public class PlayController {
@ApiImplicitParams({
@ApiImplicitParam(name = "streamId", value = "视频流ID", dataTypeClass = String.class),
})
@PostMapping("/stop/{streamId}")
@GetMapping("/stop/{streamId}")
public DeferredResult<ResponseEntity<String>> playStop(@PathVariable String streamId) {
logger.debug(String.format("设备预览/回放停止API调用streamId%s", streamId));

View File

@@ -105,7 +105,7 @@ public class PlaybackController {
@ApiImplicitParams({
@ApiImplicitParam(name = "ssrc", value = "视频流标识", dataTypeClass = String.class),
})
@RequestMapping("/stop/{ssrc}")
@GetMapping("/stop/{ssrc}")
public ResponseEntity<String> playStop(@PathVariable String ssrc) {
cmder.streamByeCmd(ssrc);

View File

@@ -25,7 +25,7 @@ public class ServerController {
@ApiOperation("重启服务")
@RequestMapping(value = "/restart")
@GetMapping(value = "/restart")
@ResponseBody
public Object restart(){
Thread restartThread = new Thread(new Runnable() {

View File

@@ -41,7 +41,7 @@ public class StreamProxyController {
@ApiImplicitParam(name="query", value = "查询内容", dataTypeClass = String.class),
@ApiImplicitParam(name="online", value = "是否在线", dataTypeClass = Boolean.class),
})
@RequestMapping(value = "/list")
@GetMapping(value = "/list")
@ResponseBody
public PageInfo<StreamProxyItem> list(@RequestParam(required = false)Integer page,
@RequestParam(required = false)Integer count,
@@ -55,7 +55,7 @@ public class StreamProxyController {
@ApiImplicitParams({
@ApiImplicitParam(name = "param", value = "代理参数", dataTypeClass = StreamProxyItem.class),
})
@RequestMapping(value = "/save")
@PostMapping(value = "/save")
@ResponseBody
public Object save(@RequestBody StreamProxyItem param){
logger.info("添加代理: " + JSONObject.toJSONString(param));
@@ -68,7 +68,7 @@ public class StreamProxyController {
@ApiImplicitParam(name = "app", value = "应用名", dataTypeClass = String.class),
@ApiImplicitParam(name = "stream", value = "流ID", dataTypeClass = String.class),
})
@RequestMapping(value = "/del")
@DeleteMapping(value = "/del")
@ResponseBody
public Object del(String app, String stream){
logger.info("移除代理: " + app + "/" + stream);
@@ -81,7 +81,7 @@ public class StreamProxyController {
@ApiImplicitParam(name = "app", value = "应用名", dataTypeClass = String.class),
@ApiImplicitParam(name = "stream", value = "流ID", dataTypeClass = String.class),
})
@RequestMapping(value = "/start")
@GetMapping(value = "/start")
@ResponseBody
public Object start(String app, String stream){
logger.info("启用代理: " + app + "/" + stream);
@@ -94,11 +94,11 @@ public class StreamProxyController {
@ApiImplicitParam(name = "app", value = "应用名", dataTypeClass = String.class),
@ApiImplicitParam(name = "stream", value = "流ID", dataTypeClass = String.class),
})
@RequestMapping(value = "/stop")
@GetMapping(value = "/stop")
@ResponseBody
public Object stop(String app, String stream){
logger.info("停用代理: " + app + "/" + stream);
boolean result = streamProxyService.stop(app, stream);
return "success";
return result?"success":"fail";
}
}

View File

@@ -32,7 +32,7 @@ public class StreamPushController {
@ApiImplicitParam(name="query", value = "查询内容", dataTypeClass = String.class),
@ApiImplicitParam(name="online", value = "是否在线", dataTypeClass = Boolean.class),
})
@RequestMapping(value = "/list")
@GetMapping(value = "/list")
@ResponseBody
public PageInfo<StreamPushItem> list(@RequestParam(required = false)Integer page,
@RequestParam(required = false)Integer count,
@@ -47,7 +47,7 @@ public class StreamPushController {
@ApiImplicitParams({
@ApiImplicitParam(name = "stream", value = "直播流关联国标平台", dataTypeClass = GbStream.class),
})
@RequestMapping(value = "/save_to_gb")
@PostMapping(value = "/save_to_gb")
@ResponseBody
public Object saveToGB(@RequestBody GbStream stream){
if (streamPushService.saveToGB(stream)){
@@ -62,7 +62,7 @@ public class StreamPushController {
@ApiImplicitParams({
@ApiImplicitParam(name = "stream", value = "直播流关联国标平台", dataTypeClass = GbStream.class),
})
@RequestMapping(value = "/remove_form_gb")
@DeleteMapping(value = "/remove_form_gb")
@ResponseBody
public Object removeFormGB(@RequestBody GbStream stream){
if (streamPushService.removeFromGB(stream)){

View File

@@ -8,6 +8,7 @@ import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@@ -28,7 +29,7 @@ public class UserController {
@ApiImplicitParam(name = "username", value = "用户名", dataTypeClass = String.class),
@ApiImplicitParam(name = "password", value = "密码32未md5加密", dataTypeClass = String.class),
})
@RequestMapping("/login")
@GetMapping("/login")
public String login(String username, String password){
if (!StringUtils.isEmpty(username) && username.equals(usernameConfig)
&& !StringUtils.isEmpty(password) && password.equals(passwordConfig)) {