Compare commits

..

10 Commits

Author SHA1 Message Date
lihanbo 548cc42d60 删除 LFlow-dev.db 2024-10-22 10:14:47 +08:00
lihanbo 61c853229a Merge branch 'dev' of http://192.168.1.144:8859/SinvoCSharp/LFlow.PluginAdmin into dev 2024-10-22 10:14:21 +08:00
lihanbo 5ed583a006 105040 Update 2024-10-22 10:14:13 +08:00
lihanbo aa79da6910 更新 .gitignore 2024-10-22 10:13:38 +08:00
lihanbo 250ba4a01a 增加在线管理模块 2024-10-19 08:33:19 +08:00
lihanbo 0a217e7b50 105040 打印Debug信息 2024-10-19 08:33:04 +08:00
lihanbo 4e17fa54c1 105040 调整可见性 2024-10-19 08:32:33 +08:00
lihanbo d6e19c291b 开发测试数据库提交 2024-10-18 11:33:56 +08:00
lihanbo 01391809a4 清理无用代码 2024-10-18 11:33:39 +08:00
lihanbo cb1ef1db08 增加获取最新版本接口 2024-10-18 11:33:00 +08:00
19 changed files with 206 additions and 16 deletions

2
.gitignore vendored
View File

@ -1,4 +1,3 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
@ -289,3 +288,4 @@ __pycache__/
*.odx.cs
*.xsd.cs
/LF[Ll]ow_Bin/
LFlow-dev.db

View File

@ -4,7 +4,7 @@ namespace LFlow.Base;
/// </summary>
public class App
{
public static IServiceCollection? services;
internal static IServiceCollection? services;
private static IServiceProvider? ServiceProvider => services?.BuildServiceProvider();
public static T? GetService<T>()
{

Binary file not shown.

View File

@ -1,7 +1,8 @@
{
"Urls": "https://127.0.0.1:8443;http://127.0.0.1:8088",
"Serilog": {
"MinimumLevel": {
"Default": "Information",
"Default": "Debug",
"Override": {
"Microsoft.AspNetCore.Mvc": "Information",
"Microsoft.AspNetCore.Routing": "Information",

View File

@ -0,0 +1,23 @@
using LFlow.Base.Interfaces;
using LFlow.Base.Utils;
using LFlow.OnlineManegement.Model;
using LFlow.OnlineManegement.Service;
using Microsoft.AspNetCore.Mvc;
namespace LFlow.OnlineManegement.Controller;
public class OnlineManagementController(IOnlineManagementService service) : BaseController
{
[HttpGet]
public PagedApiResult<List<OnlineDto>> ListAll(int pageIndex, int pageSize)
{
int dataTotal = 0;
var result = service.GetAllOnlineUser(pageIndex, pageSize, ref dataTotal);
return PagedApiResult<List<OnlineDto>>.SuccessResult(result, dataTotal, pageIndex, pageSize);
}
[HttpPost]
public ApiResult<OnlineDto> OnlineRegistered(OnlineDto onlineInfo)
{
return ApiResult<OnlineDto>.SuccessResult(service.OnlineRegistered(onlineInfo));
}
}

View File

@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<OutputPath>../LFlow_Bin/Services/</OutputPath>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
<UseCommonOutputDirectory>true</UseCommonOutputDirectory>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\LFlow.Base\LFlow.Base.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,15 @@
using LFlow.Base.Interfaces;
namespace LFlow.OnlineManegement.Model
{
public class OnlineDto : IModel
{
public string? ID { get; set; }
public string? HostName { get; set; }
public string? IPAddress { get; set; }
public string? MacAddress { get; set; }
public string? OS { get; set; }
public string? LastOnlineTime { get; set; }
}
}

View File

@ -0,0 +1,18 @@
using LFlow.Base.Interfaces;
using SqlSugar;
namespace LFlow.OnlineManegement.Model
{
[SugarTable("T_U_ONLINE")]
public class OnlineModel : IDataModel
{
[SugarColumn(IsPrimaryKey = true)]
public string ID { get; set; }
public string HostName { get; set; }
public string IPAddress { get; set; }
public string MacAddress { get; set; }
public string OS { get; set; }
public string LastOnlineTime { get; set; }
}
}

View File

@ -0,0 +1,28 @@
using LFlow.Base.Interfaces;
using LFlow.Base.Utils;
using LFlow.OnlineManegement.Model;
using Microsoft.Extensions.DependencyInjection;
using Serilog;
using System.Reflection;
namespace LFlow.OnlineManegement
{
public class OnlineManegementModule : IModule
{
public void ConfigureModule(IServiceCollection services)
{
// 将模型添加到需要初始化数据库表的队列中
CodeFirst.AddType(typeof(OnlineModel));
// 获取当前程序集
var assembly = Assembly.GetAssembly(typeof(OnlineManegementModule))!;
var types = assembly.GetTypes().ToList();
//注册服务
RegisterModule.RegisterAllService(types, services);
//注册仓储
RegisterModule.RegisterAllRepo(types, services);
//RegisterModule.RegisterAllModel(types, services);
services.AddControllers().AddApplicationPart(assembly);
Log.Logger?.Information("OnlineManegementModule ConfigureModule done");
}
}
}

View File

@ -0,0 +1,10 @@
using LFlow.Base.Default;
using LFlow.OnlineManegement.Model;
using SqlSugar;
namespace LFlow.OnlineManegement.Repository
{
public class OnlineManagementRepo(ISqlSugarClient db) : DefaultCurdRepo<OnlineModel, string>(db)
{
}
}

View File

@ -0,0 +1,10 @@
using LFlow.Base.Interfaces;
using LFlow.OnlineManegement.Model;
namespace LFlow.OnlineManegement.Service;
public interface IOnlineManagementService : IService//<VersionDto>
{
List<OnlineDto> GetAllOnlineUser(int pageIndex, int pageSize, ref int dataTotal);
OnlineDto OnlineRegistered(OnlineDto onlineInfo);
}

View File

@ -0,0 +1,38 @@
using LFlow.Base.Interfaces;
using LFlow.OnlineManegement.Model;
using Mapster;
namespace LFlow.OnlineManegement.Service;
/// <summary>
/// 在线管理服务
/// </summary>
public class OnlineManagementService(IRepo<OnlineModel, string> _repo) : IOnlineManagementService
{
public List<OnlineDto> GetAllOnlineUser(int pageIndex, int pageSize, ref int dataTotal)
{
var result = _repo.GetAll(pageIndex, pageSize, ref dataTotal).Adapt<List<OnlineDto>>();
return result;
}
public OnlineDto OnlineRegistered(OnlineDto onlineInfo)
{
bool isUpdate = false;
if (string.IsNullOrEmpty(onlineInfo.ID))
{
onlineInfo.ID = Guid.NewGuid().ToString();
}
else
{
if (_repo.Get(onlineInfo.ID) == null)
{
isUpdate = false;
}
else
{
isUpdate = true;
}
}
return _repo.SaveOrUpdate(onlineInfo.Adapt<OnlineModel>(), isUpdate).Adapt<OnlineDto>();
}
}

View File

@ -68,8 +68,8 @@ public class VersionManagementController(IVersionManagementService service) : Ba
//}
[HttpGet]
public ApiResult<VersionDto> GetLastUpdate(VersionType type, VersionChannel channel, UpgradeTargetType targetType)
public ApiResult<VersionDto> GetLastUpdate(VersionChannel channel, UpgradeTargetType targetType)
{
return ApiResult<VersionDto>.SuccessResult(service.GetLastVersion(type, channel, targetType));
return ApiResult<VersionDto>.SuccessResult(service.GetLastVersion(channel, targetType));
}
}

View File

@ -14,8 +14,4 @@
<ProjectReference Include="..\LFlow.Base\LFlow.Base.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Controller\" />
</ItemGroup>
</Project>

View File

@ -1,17 +1,28 @@
using LFlow.Base.Default;
using LFlow.Base.Utils;
using LFlow.VersionManagement.Enums;
using LFlow.VersionManagement.Model;
using SqlSugar;
namespace LFlow.VersionManagement.Repository;
public class VersionManagementRepo(ISqlSugarClient db) : DefaultCurdRepo<VersionModel, string>(db)
{
/// <summary>
/// 根据条件搜索
/// </summary>
/// <param name="whereObj"></param>
/// <returns></returns>
public override List<VersionModel> Search(VersionModel whereObj)
{
return db.Queryable<VersionModel>()
.Where(whereObj.ToWhereExp())
.ToList();
}
/// <summary>
/// 根据条件搜索ID
/// </summary>
/// <param name="whereObj"></param>
/// <returns></returns>
public override List<string> WhereSearchId(VersionModel whereObj)
{
return db.Queryable<VersionModel>()
@ -20,4 +31,19 @@ public class VersionManagementRepo(ISqlSugarClient db) : DefaultCurdRepo<Version
.Select(x => x.ID)
.ToList();
}
/// <summary>
/// 获取最新版本
/// </summary>
/// <param name="channel"></param>
/// <param name="targetType"></param>
/// <returns></returns>
public VersionModel GetLatestVersion(VersionChannel channel, UpgradeTargetType targetType)
{
return db.Queryable<VersionModel>()
.Where(mt => channel == mt.VersionChannel && targetType == mt.UpgradeTargetType)
.GroupBy(mt => mt.CurrentVersion)
.OrderBy(mt => mt.LastPublishTime, OrderByType.Desc)
.First();
}
}

View File

@ -13,5 +13,5 @@ public interface IVersionManagementService : IService//<VersionDto>
List<VersionDto> GetAll(int pageIndex, int pageSize, ref int total);
VersionDto? GetLastVersion(VersionType type, VersionChannel channel, UpgradeTargetType targetType);
VersionDto? GetLastVersion(VersionChannel channel, UpgradeTargetType targetType);
}

View File

@ -23,11 +23,11 @@ public class VersionManagementService : IVersionManagementService
// 搜索需要增加分页
public List<VersionDto> Search(VersionDto whereObj)
=> _repo.Search(whereObj.Adapt<VersionModel>()).Adapt<List<VersionDto>>();
public VersionDto? GetLastVersion(VersionType type, VersionChannel channel, UpgradeTargetType targetType)
public VersionDto? GetLastVersion(VersionChannel channel, UpgradeTargetType targetType)
{
if (_repo is VersionManagementRepo versionRepo)
{
return versionRepo.GetLatestVersion(type, channel, targetType).Adapt<VersionDto>();
return versionRepo.GetLatestVersion(channel, targetType).Adapt<VersionDto>();
}
else
{

View File

@ -1,8 +1,9 @@
using System.Reflection;
using LFlow.Base.Interfaces;
using LFlow.Base.Utils;
using LFlow.VersionManagement.Model;
using Microsoft.Extensions.DependencyInjection;
using Serilog;
using System.Reflection;
namespace LFlow.User;
@ -15,8 +16,9 @@ public class VersionManagementModule : IModule
var types = assembly.GetTypes().ToList();
RegisterModule.RegisterAllService(types, services);
RegisterModule.RegisterAllRepo(types, services);
RegisterModule.RegisterAllModel(types, services);
//RegisterModule.RegisterAllModel(types, services);
services.AddControllers().AddApplicationPart(assembly);
Console.WriteLine("UserModule ConfigureModule");
Log.Logger?.Information("VersionManagementModule ConfigureModule done");
//Console.WriteLine("UserModule ConfigureModule");
}
}

View File

@ -5,7 +5,9 @@ VisualStudioVersion = 17.5.002.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LFlow.Base", "LFlow.Base\LFlow.Base.csproj", "{C581AFB2-50BA-4357-AD0A-AF287194837D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LFlow.VersionManagement", "LFlow.VersionManagement\LFlow.VersionManagement.csproj", "{D52CC594-B10C-4FC0-8B7A-68CE0645A95D}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LFlow.VersionManagement", "LFlow.VersionManagement\LFlow.VersionManagement.csproj", "{D52CC594-B10C-4FC0-8B7A-68CE0645A95D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LFlow.OnlineManegement", "LFlow.OnlineManegement\LFlow.OnlineManegement.csproj", "{E849310F-64AD-453A-A2AA-557731508BF1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -21,6 +23,10 @@ Global
{D52CC594-B10C-4FC0-8B7A-68CE0645A95D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D52CC594-B10C-4FC0-8B7A-68CE0645A95D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D52CC594-B10C-4FC0-8B7A-68CE0645A95D}.Release|Any CPU.Build.0 = Release|Any CPU
{E849310F-64AD-453A-A2AA-557731508BF1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E849310F-64AD-453A-A2AA-557731508BF1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E849310F-64AD-453A-A2AA-557731508BF1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E849310F-64AD-453A-A2AA-557731508BF1}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE