From 530cf2533234958768588bfcdf45679f9c9f7fdf Mon Sep 17 00:00:00 2001 From: wanggang <76527413@qq.com> Date: Thu, 4 Jun 2020 09:55:26 +0800 Subject: [PATCH] update Former-commit-id: bd4af6992b973ca5a78de85ac0696225a2bbde9d --- projects/Infrastructure/Infrastructure.csproj | 5 +++-- projects/Infrastructure/Web/BaseStartup.cs | 3 ++- projects/IoTCenter/Api/NodeController.cs | 9 +++++++-- projects/IoTCenter/IoTCenter.csproj | 9 ++++----- .../UserCenter/Controllers/AccountController.cs | 17 ++++++----------- .../UserCenter/Controllers/HomeController.cs | 5 +---- 6 files changed, 23 insertions(+), 25 deletions(-) diff --git a/projects/Infrastructure/Infrastructure.csproj b/projects/Infrastructure/Infrastructure.csproj index 9bd70d07..efe7c610 100644 --- a/projects/Infrastructure/Infrastructure.csproj +++ b/projects/Infrastructure/Infrastructure.csproj @@ -26,15 +26,16 @@ + - + - + diff --git a/projects/Infrastructure/Web/BaseStartup.cs b/projects/Infrastructure/Web/BaseStartup.cs index 48171c82..7c08ce00 100644 --- a/projects/Infrastructure/Web/BaseStartup.cs +++ b/projects/Infrastructure/Web/BaseStartup.cs @@ -113,12 +113,13 @@ namespace Infrastructure.Web .SetCompatibilityVersion(CompatibilityVersion.Latest) .AddNewtonsoftJson() .AddControllersAsServices() + .AddMvcLocalization() .AddViewLocalization(LanguageViewLocationExpanderFormat.Suffix) .AddDataAnnotationsLocalization(options => { options.DataAnnotationLocalizerProvider = (type, factory) => { - var localizer = factory.Create("Resources.Resource", Assembly.GetEntryAssembly().FullName); + var localizer = factory.Create("Resources.Resource", Assembly.GetEntryAssembly().GetName().Name); return localizer; }; }); diff --git a/projects/IoTCenter/Api/NodeController.cs b/projects/IoTCenter/Api/NodeController.cs index 8b642117..d3ef86f3 100644 --- a/projects/IoTCenter/Api/NodeController.cs +++ b/projects/IoTCenter/Api/NodeController.cs @@ -3,15 +3,16 @@ using Application.Models; using Infrastructure.Application.Services.Settings; using Infrastructure.Data; using Infrastructure.Extensions; +using IoTCenter.Application.Domain; using IoTCenter.Services; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.SignalR; using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Logging; using System; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Threading; -using Microsoft.Extensions.Logging; namespace IoTCenter.Api.Controllers { @@ -22,6 +23,7 @@ namespace IoTCenter.Api.Controllers { private readonly ILogger _logger; private readonly ISettingService _settingService; + private readonly IRepository _nodeCategoryNodeRepo; private readonly IRepository _nodeRepo; private readonly IRepository _deviceRepo; private readonly IHubContext _hub; @@ -29,12 +31,14 @@ namespace IoTCenter.Api.Controllers public NodeController( ILogger logger, ISettingService settingService, + IRepository nodeCategoryNodeRepo, IRepository nodeRepo, IRepository deviceRepo, IHubContext hub) { this._logger = logger; this._settingService = settingService; + this._nodeCategoryNodeRepo = nodeCategoryNodeRepo; this._nodeRepo = nodeRepo; this._deviceRepo = deviceRepo; this._hub = hub; @@ -57,7 +61,8 @@ namespace IoTCenter.Api.Controllers o.IsOnline, o.Image, o.DisplayOrder, - Count = _deviceRepo.ReadOnlyTable().Count(d => d.NodeId == o.Id) + Count = _deviceRepo.ReadOnlyTable().Count(d => d.NodeId == o.Id), + Template = _nodeCategoryNodeRepo.ReadOnlyTable().FirstOrDefault(o => o.NodeId == o.Id)?.Category.Template }); return Ok(model); } diff --git a/projects/IoTCenter/IoTCenter.csproj b/projects/IoTCenter/IoTCenter.csproj index 7a33d6b4..6ebb47de 100644 --- a/projects/IoTCenter/IoTCenter.csproj +++ b/projects/IoTCenter/IoTCenter.csproj @@ -5,17 +5,16 @@ true false false + Linux + + + - - - - - \ No newline at end of file diff --git a/projects/UserCenter/Controllers/AccountController.cs b/projects/UserCenter/Controllers/AccountController.cs index 8542d6e5..d80b3a55 100644 --- a/projects/UserCenter/Controllers/AccountController.cs +++ b/projects/UserCenter/Controllers/AccountController.cs @@ -4,7 +4,6 @@ using Infrastructure.Application.Services.Settings; using Infrastructure.Data; using Infrastructure.Email; using Infrastructure.Extensions; -using Infrastructure.Resources; using Infrastructure.Security; using Infrastructure.Sms; using Infrastructure.Web; @@ -15,7 +14,6 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Localization; using Newtonsoft.Json; using System; using System.Collections.Generic; @@ -34,7 +32,6 @@ namespace UserCenter.Controllers private readonly ISettingService _settingService; private readonly IRepository _userRepo; private readonly IRepository _siteRepo; - private readonly IStringLocalizer _localizer; private readonly IEncryptionService _encryptionService; private readonly IEmailSender _emailSender; private readonly ISmsSender _smsSender; @@ -45,7 +42,6 @@ namespace UserCenter.Controllers IRepository userRepo, IRepository siteRepo, IEncryptionService encryptionService, - IStringLocalizer localizer, IEmailSender emaliSender, ISmsSender smsSender //FaceRecognitionService frs @@ -56,7 +52,6 @@ namespace UserCenter.Controllers this._userRepo = userRepo; this._siteRepo = siteRepo; this._encryptionService = encryptionService; - this._localizer = localizer; this._emailSender = emaliSender; this._smsSender = smsSender; //this._frs = frs; @@ -228,7 +223,7 @@ namespace UserCenter.Controllers #region 注册 [AllowAnonymous] - public JsonResult UserNameNotUsed([Required]string userName) + public JsonResult UserNameNotUsed([Required] string userName) { if (ModelState.IsValid) { @@ -292,7 +287,7 @@ namespace UserCenter.Controllers } [AllowAnonymous] - public JsonResult EmailNotUsed([Required]string email) + public JsonResult EmailNotUsed([Required] string email) { if (ModelState.IsValid) { @@ -302,7 +297,7 @@ namespace UserCenter.Controllers } [AllowAnonymous] - public JsonResult SendCodeToEmail([Required]string email) + public JsonResult SendCodeToEmail([Required] string email) { if (ModelState.IsValid) { @@ -383,7 +378,7 @@ namespace UserCenter.Controllers } [AllowAnonymous] - public JsonResult PhoneNumberNotUsed([Required]string phoneNumber) + public JsonResult PhoneNumberNotUsed([Required] string phoneNumber) { if (ModelState.IsValid) { @@ -393,7 +388,7 @@ namespace UserCenter.Controllers } [AllowAnonymous] - public JsonResult SendCodeToPhoneNumber([Required]string phoneNumber) + public JsonResult SendCodeToPhoneNumber([Required] string phoneNumber) { if (ModelState.IsValid) { @@ -450,7 +445,7 @@ namespace UserCenter.Controllers } [AllowAnonymous] - public JsonResult HasUser([Required]string userName) + public JsonResult HasUser([Required] string userName) { if (ModelState.IsValid) { diff --git a/projects/UserCenter/Controllers/HomeController.cs b/projects/UserCenter/Controllers/HomeController.cs index 406c6474..09f67f14 100644 --- a/projects/UserCenter/Controllers/HomeController.cs +++ b/projects/UserCenter/Controllers/HomeController.cs @@ -2,7 +2,6 @@ using Application.Domain.Entities; using Application.Models; using Infrastructure.Data; using Infrastructure.Extensions; -using Infrastructure.Resources; using Infrastructure.Security; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Configuration; @@ -17,16 +16,14 @@ namespace UserCenter.Controllers private readonly IRepository _userRepo; private readonly IRepository _siteRepo; private readonly IConfiguration _configuration; - private readonly IStringLocalizer _localizer; private readonly IEncryptionService _encryptionService; - public HomeController(IRepository userRepo, IRepository siteRepo, IEncryptionService encryptionService, IConfiguration configuration, IStringLocalizer localizer) + public HomeController(IRepository userRepo, IRepository siteRepo, IEncryptionService encryptionService, IConfiguration configuration) { this._userRepo = userRepo; this._siteRepo = siteRepo; this._encryptionService = encryptionService; this._configuration = configuration; - this._localizer = localizer; } public IActionResult Index()