Former-commit-id: 08c188f8807c3057252ea80918ad3f05696df1cb
Former-commit-id: e997d09cf3a4293f2776383f55bd020a016f72f5
1.0
wanggang 4 years ago
parent 8403e74bd6
commit 208a89e842

@ -1,22 +1,19 @@
using Application.Domain.Entities;
using Infrastructure.Application.Services.Settings;
using Infrastructure.Data;
using Infrastructure.Events;
using IoT.Shared.Application.Models;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.SignalR;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Platform.EventHandlers;
using Platform.Services;
using System;
using System.Linq;
namespace Platform.Api.Api
{
[ApiVersion("1.0")]
[Route("api/v{version:apiVersion}/[controller]/[action]")]
[ApiVersion("1.0")]
[ApiController]
public class ApiController : ControllerBase
{

@ -10,7 +10,10 @@ using System.Security.Claims;
namespace Platform.Api
{
public class SiteController : Controller
[ApiVersion("1.0")]
[Route("api/v{version:apiVersion}/[controller]/[action]")]
[ApiController]
public class SiteController : ControllerBase
{
private readonly ISettingService _settingService;
private readonly IRepository<AppModule> _appModuleRepo;

@ -1,87 +1,87 @@
using Infrastructure.Application.Services.Settings;
using Infrastructure.Data;
using Infrastructure.Extensions;
using Application.Domain.Entities;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
//using Infrastructure.Application.Services.Settings;
//using Infrastructure.Data;
//using Infrastructure.Extensions;
//using Application.Domain.Entities;
//using Microsoft.AspNetCore.Mvc;
//using Microsoft.Extensions.Configuration;
//using Microsoft.Extensions.Logging;
//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Net.Http;
namespace Platform.Apis.Controllers
{
[ApiVersion("1.0")]
[Route("api/v{version:apiVersion}/[controller]/[action]")]
[ApiController]
public class SiteController : ControllerBase
{
private readonly IConfiguration _cfg;
private readonly ILogger<OrganController> _logger;
private readonly IHttpClientFactory _httpClientFactory;
private readonly IRepository<IoTTimer> _organSceneTimerRepo;
private readonly ISettingService _settingService;
private readonly IRepository<OrganUser> _userRepo;
//namespace Platform.Apis.Controllers
//{
// [ApiVersion("1.0")]
// [Route("api/v{version:apiVersion}/[controller]/[action]")]
// [ApiController]
// public class SiteController : ControllerBase
// {
// private readonly IConfiguration _cfg;
// private readonly ILogger<OrganController> _logger;
// private readonly IHttpClientFactory _httpClientFactory;
// private readonly IRepository<IoTTimer> _organSceneTimerRepo;
// private readonly ISettingService _settingService;
// private readonly IRepository<OrganUser> _userRepo;
public SiteController(IConfiguration cfg,
IHttpClientFactory httpClientFactory,
IRepository<IoTTimer> organSceneTimerRepo,
ILogger<OrganController> logger,
ISettingService settingService,
IRepository<OrganUser> userRepo)
{
this._cfg = cfg;
this._httpClientFactory = httpClientFactory;
this._organSceneTimerRepo = organSceneTimerRepo;
this._logger = logger;
this._settingService = settingService;
this._userRepo = userRepo;
}
// public SiteController(IConfiguration cfg,
// IHttpClientFactory httpClientFactory,
// IRepository<IoTTimer> organSceneTimerRepo,
// ILogger<OrganController> logger,
// ISettingService settingService,
// IRepository<OrganUser> userRepo)
// {
// this._cfg = cfg;
// this._httpClientFactory = httpClientFactory;
// this._organSceneTimerRepo = organSceneTimerRepo;
// this._logger = logger;
// this._settingService = settingService;
// this._userRepo = userRepo;
// }
[HttpPost]
public IActionResult GetSite(Guid? organId)
{
try
{
var username = User.Identity.IsAuthenticated ? this.HttpContext.User.Identity.Name : null;
var roles = new List<string>();
var permissions = new List<string>();
if (User.Identity.IsAuthenticated)
{
roles = this._userRepo.ReadOnlyTable()
.Where(o => o.User.UserName == username)
.WhereIf(organId.HasValue,o=>o.OrganId==organId.Value)
.SelectMany(o => o.UserRoles)
.Select(o => o.OrganRole.Name)
.ToList();
permissions = this._userRepo.ReadOnlyTable()
.Where(o => o.User.UserName == username)
.WhereIf(organId.HasValue, o => o.OrganId == organId.Value)
.SelectMany(o => o.UserRoles)
.Select(o => o.OrganRole)
.SelectMany(o => o.RolePermissions)
.Select(o => o.Permission)
.Select(o => o.Number)
.ToList();
}
return Ok(new
{
logo = this._settingService.GetValue("logo"),
name = this._settingService.GetValue("name"),
copyright = this._settingService.GetValue("copyright"),
version = Helper.Instance.GetVersion(),
username,
roles,
permissions,
sso = this._settingService.GetValue("sso")
});
}
catch (Exception ex)
{
this._logger.LogError(ex, ex.Message);
return Problem(ex.Message);
}
}
}
}
// [HttpPost]
// public IActionResult GetSite(Guid? organId)
// {
// try
// {
// var username = User.Identity.IsAuthenticated ? this.HttpContext.User.Identity.Name : null;
// var roles = new List<string>();
// var permissions = new List<string>();
// if (User.Identity.IsAuthenticated)
// {
// roles = this._userRepo.ReadOnlyTable()
// .Where(o => o.User.UserName == username)
// .WhereIf(organId.HasValue,o=>o.OrganId==organId.Value)
// .SelectMany(o => o.UserRoles)
// .Select(o => o.OrganRole.Name)
// .ToList();
// permissions = this._userRepo.ReadOnlyTable()
// .Where(o => o.User.UserName == username)
// .WhereIf(organId.HasValue, o => o.OrganId == organId.Value)
// .SelectMany(o => o.UserRoles)
// .Select(o => o.OrganRole)
// .SelectMany(o => o.RolePermissions)
// .Select(o => o.Permission)
// .Select(o => o.Number)
// .ToList();
// }
// return Ok(new
// {
// logo = this._settingService.GetValue("logo"),
// name = this._settingService.GetValue("name"),
// copyright = this._settingService.GetValue("copyright"),
// version = Helper.Instance.GetVersion(),
// username,
// roles,
// permissions,
// sso = this._settingService.GetValue("sso")
// });
// }
// catch (Exception ex)
// {
// this._logger.LogError(ex, ex.Message);
// return Problem(ex.Message);
// }
// }
// }
//}

@ -1,64 +0,0 @@
using Infrastructure.Data;
using Application.Domain.Entities;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
namespace Platform.Apis.Controllers
{
[ApiVersion("1.0")]
[Route("api/v{version:apiVersion}/[controller]/[action]")]
[ApiController]
public class SrsController : ControllerBase
{
private readonly IRepository<IoTDevice> _deviceRepo;
private readonly IRepository<LiveRecord> _liveRecordRepo;
public SrsController(IRepository<IoTDevice> deviceRepo,
IRepository<LiveRecord> liveRecordRepo)
{
this._deviceRepo = deviceRepo;
this._liveRecordRepo = liveRecordRepo;
}
/// <summary>
/// 录制完毕事件响应
///{"action":"on_dvr","client_id":107,"ip":"192.168.3.124","vhost":"__defaultVhost__","app":"live","stream":"main0a5d5deee43011b483884cbd8fd2b3dd","param":"","cwd":"/root/publish/apps/srs","file":"./objs/nginx/html/live.main0a5d5deee43011b483884cbd8fd2b3dd.1574832559180.mp4"}
/// </summary>
/// <returns></returns>
[AllowAnonymous]
[HttpPost]
public string OnDvr()
{
using (var reader = new StreamReader(Request.Body))
{
var json = reader.ReadToEndAsync().Result;
Debug.WriteLine("ondvr:");
Debug.WriteLine(json);
var result = JsonConvert.DeserializeObject<Dictionary<string, string>>(json);
if (result["action"] == "on_dvr")
{
var streamId = result["stream"];
var device = this._deviceRepo.ReadOnlyTable().FirstOrDefault(o => o.Number == streamId);
if (device != null)
{
this._liveRecordRepo.Add(new LiveRecord
{
DeviceNumber = device.Number,
DeviceName = device?.DisplayName,
Name = $"回放{DateTime.Now:yyyy-MM-dd HH:mm}",
Value = $"/video{result["file"].Substring(result["file"].LastIndexOf('/'))}"
});
this._liveRecordRepo.SaveChanges();
}
}
}
return string.Empty;
}
}
}

@ -1,32 +1,32 @@
using Application.Domain.Entities;
using Infrastructure.Events;
using Microsoft.AspNetCore.SignalR;
using Platform.Services;
//using Application.Domain.Entities;
//using Infrastructure.Events;
//using Microsoft.AspNetCore.SignalR;
//using Platform.Services;
namespace Platform.EventHandlers
{
public class StatisticEventHandler : BaseEventHandler,
IEventHander<EntityInserted<Statistic>>,
IEventHander<EntityUpdated<Statistic>>,
IEventHander<EntityDeleted<Statistic>>
{
public StatisticEventHandler(IHubContext<IoTCenterHub> hub) : base(hub)
{
}
//namespace Platform.EventHandlers
//{
// public class StatisticEventHandler : BaseEventHandler,
// IEventHander<EntityInserted<Statistic>>,
// IEventHander<EntityUpdated<Statistic>>,
// IEventHander<EntityDeleted<Statistic>>
// {
// public StatisticEventHandler(IHubContext<IoTCenterHub> hub) : base(hub)
// {
// }
public void Handle(EntityInserted<Statistic> message)
{
this.Notify<Statistic>(message);
}
// public void Handle(EntityInserted<Statistic> message)
// {
// this.Notify<Statistic>(message);
// }
public void Handle(EntityUpdated<Statistic> message)
{
this.Notify<Statistic>(message);
}
// public void Handle(EntityUpdated<Statistic> message)
// {
// this.Notify<Statistic>(message);
// }
public void Handle(EntityDeleted<Statistic> message)
{
this.Notify<Statistic>(message);
}
}
}
// public void Handle(EntityDeleted<Statistic> message)
// {
// this.Notify<Statistic>(message);
// }
// }
//}

@ -1,6 +1,9 @@
#docker-compose up -d
version: "3.8"
services:
srs:
volumes:
- ./docker/conf/srs/dev:/usr/local/srs/conf
website:
volumes:
- ../../../../projects/Platform/wwwroot:/root/nginx/html/desktop

@ -105,18 +105,15 @@ services:
ipv4_address: 172.172.0.40
#streaming server
srs:
image: ubuntu
environment:
TZ: "Asia/Shanghai"
image: ossrs/srs:v4.0.76
restart: always
ports:
- 1935:1935
- 8080:8080
- 1985:1985
working_dir: /usr/local/srs
command: bash -c "chmod +x ./objs/srs && ./objs/srs -c ./conf/srs.conf"
volumes:
- ./apps/srs:/usr/local/srs
- ./docker/conf/srs/conf:/usr/local/srs/conf
- ./docker/data/srs:/usr/local/srs/objs/nginx/html/video
networks:
default:
ipv4_address: 172.172.0.60

Loading…
Cancel
Save