diff --git a/projects/Platform/Api/Api/ApiController.cs b/projects/Platform/Api/Api/ApiController.cs index 33f75b0e..b5d450a5 100644 --- a/projects/Platform/Api/Api/ApiController.cs +++ b/projects/Platform/Api/Api/ApiController.cs @@ -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 { diff --git a/projects/Platform/Api/Api/SiteController.cs b/projects/Platform/Api/Api/SiteController.cs index 6ae19e4e..ff4ee6f8 100644 --- a/projects/Platform/Api/Api/SiteController.cs +++ b/projects/Platform/Api/Api/SiteController.cs @@ -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 _appModuleRepo; diff --git a/projects/Platform/Api/SiteController.cs b/projects/Platform/Api/SiteController.cs index 0660171c..65202347 100644 --- a/projects/Platform/Api/SiteController.cs +++ b/projects/Platform/Api/SiteController.cs @@ -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 _logger; - private readonly IHttpClientFactory _httpClientFactory; - private readonly IRepository _organSceneTimerRepo; - private readonly ISettingService _settingService; - private readonly IRepository _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 _logger; +// private readonly IHttpClientFactory _httpClientFactory; +// private readonly IRepository _organSceneTimerRepo; +// private readonly ISettingService _settingService; +// private readonly IRepository _userRepo; - public SiteController(IConfiguration cfg, - IHttpClientFactory httpClientFactory, - IRepository organSceneTimerRepo, - ILogger logger, - ISettingService settingService, - IRepository 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 organSceneTimerRepo, +// ILogger logger, +// ISettingService settingService, +// IRepository 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(); - var permissions = new List(); - 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(); +// var permissions = new List(); +// 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); +// } +// } +// } +//} diff --git a/projects/Platform/Api/SrsController.cs b/projects/Platform/Api/SrsController.cs deleted file mode 100644 index 5cc90217..00000000 --- a/projects/Platform/Api/SrsController.cs +++ /dev/null @@ -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 _deviceRepo; - private readonly IRepository _liveRecordRepo; - - public SrsController(IRepository deviceRepo, - IRepository liveRecordRepo) - { - this._deviceRepo = deviceRepo; - this._liveRecordRepo = liveRecordRepo; - } - - /// - /// 录制完毕事件响应 - ///{"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"} - /// - /// - [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>(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; - } - } -} diff --git a/projects/Platform/EventHandlers/StatisticEventHandler.cs b/projects/Platform/EventHandlers/StatisticEventHandler.cs index 413c88e1..9c0755c3 100644 --- a/projects/Platform/EventHandlers/StatisticEventHandler.cs +++ b/projects/Platform/EventHandlers/StatisticEventHandler.cs @@ -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>, - IEventHander>, - IEventHander> - { - public StatisticEventHandler(IHubContext hub) : base(hub) - { - } +//namespace Platform.EventHandlers +//{ +// public class StatisticEventHandler : BaseEventHandler, +// IEventHander>, +// IEventHander>, +// IEventHander> +// { +// public StatisticEventHandler(IHubContext hub) : base(hub) +// { +// } - public void Handle(EntityInserted message) - { - this.Notify(message); - } +// public void Handle(EntityInserted message) +// { +// this.Notify(message); +// } - public void Handle(EntityUpdated message) - { - this.Notify(message); - } +// public void Handle(EntityUpdated message) +// { +// this.Notify(message); +// } - public void Handle(EntityDeleted message) - { - this.Notify(message); - } - } -} \ No newline at end of file +// public void Handle(EntityDeleted message) +// { +// this.Notify(message); +// } +// } +//} \ No newline at end of file diff --git a/publish/src/linux-x64/publish/docker-compose.override.yml b/publish/src/linux-x64/publish/docker-compose.override.yml index 4b62ec80..46a1f82a 100644 --- a/publish/src/linux-x64/publish/docker-compose.override.yml +++ b/publish/src/linux-x64/publish/docker-compose.override.yml @@ -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 diff --git a/publish/src/linux-x64/publish/docker-compose.yml b/publish/src/linux-x64/publish/docker-compose.yml index 4eabfb44..5322dfd2 100644 --- a/publish/src/linux-x64/publish/docker-compose.yml +++ b/publish/src/linux-x64/publish/docker-compose.yml @@ -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