parent
de39bba323
commit
c18ee4036d
|
@ -9,19 +9,29 @@ using LFlow.Home.Services;
|
|||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace LFlow.Home;
|
||||
|
||||
/// <summary>
|
||||
/// 首页模块
|
||||
/// </summary>
|
||||
public class HomeModule : IModule
|
||||
{
|
||||
/// <summary>
|
||||
/// 配置模块
|
||||
/// </summary>
|
||||
/// <param name="services">启动前的IServiceCollection</param>
|
||||
public void ConfigureModule(IServiceCollection services)
|
||||
{
|
||||
// 将HomeModel注册到CodeFirst,将会在程序启动后自动创建表
|
||||
CodeFirst.AddType(typeof(HomeModel));
|
||||
|
||||
// 注册服务、仓储、模型
|
||||
var assembly = Assembly.GetAssembly(typeof(HomeService))!;
|
||||
var types = assembly.GetTypes().ToList();
|
||||
|
||||
RegisterModule.RegisterAllService(types, services);
|
||||
RegisterModule.RegisterAllRepo(types, services);
|
||||
RegisterModule.RegisterAllModule(types, services);
|
||||
RegisterModule.RegisterAllModel(types, services);
|
||||
|
||||
// 添加控制器
|
||||
services.AddControllers().AddApplicationPart(assembly);
|
||||
Console.WriteLine("HomeModule ConfigureModule");
|
||||
|
||||
|
|
|
@ -10,15 +10,29 @@ using Serilog;
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace LFlow.Home.Services;
|
||||
|
||||
/// <summary>
|
||||
/// 服务直接作为控制器
|
||||
/// </summary>
|
||||
/// <param name="repo"></param>
|
||||
/// <param name="logger"></param>
|
||||
public class HomeService(IRepo<HomeModel, string> repo, ILogger logger) : BaseController, IHomeService<HomeDto?, string>
|
||||
{
|
||||
/// <summary>
|
||||
/// 删除
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public HomeDto? DeleteById(string id)
|
||||
{
|
||||
var result = repo.Delete(id);
|
||||
return Mapper.Map<HomeDto>(result);
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public HomeDto? GetById(string id)
|
||||
{
|
||||
|
@ -26,12 +40,23 @@ public class HomeService(IRepo<HomeModel, string> repo, ILogger logger) : BaseCo
|
|||
var result = repo.Get(id);
|
||||
return Mapper.Map<HomeDto>(result);
|
||||
}
|
||||
/// <summary>
|
||||
/// 保存 (修改或者新增,按主键判断)
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public HomeDto? Save(HomeDto entity)
|
||||
{
|
||||
var result = repo.SaveOrUpdate(Mapper.Map<HomeModel>(entity), false);
|
||||
return Mapper.Map<HomeDto>(result);
|
||||
}
|
||||
/// <summary>
|
||||
/// 搜索
|
||||
/// </summary>
|
||||
/// <param name="whereObj"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
[HttpGet]
|
||||
public List<HomeDto>? Search(HomeDto whereObj)
|
||||
{
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
namespace LFlow.VersionManagement.Enums;
|
||||
|
||||
/// <summary>
|
||||
/// 更新目标类型
|
||||
/// </summary>
|
||||
public enum UpgradeTargetType
|
||||
{
|
||||
// 鼎捷插件
|
||||
SWI = 1,
|
||||
// XH工具箱
|
||||
XH_TOOL = 2,
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
namespace LFlow.VersionManagement.Enums;
|
||||
|
||||
/// <summary>
|
||||
/// 更新通道
|
||||
/// </summary>
|
||||
public enum VersionChannel
|
||||
{
|
||||
// 正式
|
||||
Official = 1,
|
||||
// 预览
|
||||
Preview = 2
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
namespace LFlow.VersionManagement.Enums;
|
||||
|
||||
/// <summary>
|
||||
/// 更新类型
|
||||
/// </summary>
|
||||
public enum VersionType
|
||||
{
|
||||
// 优化
|
||||
Optimize = 1,
|
||||
// 新增
|
||||
Add = 2,
|
||||
// 修复
|
||||
Fix = 3
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
<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>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Controller\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
|
@ -0,0 +1,89 @@
|
|||
using LFlow.Base.Interfaces;
|
||||
using LFlow.VersionManagement.Enums;
|
||||
|
||||
namespace LFlow.VersionManagement.Model;
|
||||
public class VersionDto : IModel
|
||||
{
|
||||
/// <summary>
|
||||
/// ID
|
||||
/// </summary>
|
||||
public string? ID
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
/// <summary>
|
||||
/// 版本号 eg:1.0.0.1
|
||||
/// </summary>
|
||||
public string? CurrentVersion
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
/// <summary>
|
||||
/// 更新说明
|
||||
/// </summary>
|
||||
public string? Description
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
public DateTime LastPublishTime
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
/// <summary>
|
||||
/// 下载地址
|
||||
/// </summary>
|
||||
public string? DownloadUrl
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
/// <summary>
|
||||
/// 文件名
|
||||
/// </summary>
|
||||
public string? FileName
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
/// <summary>
|
||||
/// 文件大小
|
||||
/// </summary>
|
||||
public string? FileSize
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
/// <summary>
|
||||
/// MD5 校验码
|
||||
/// </summary>
|
||||
public string? Md5
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
/// <summary>
|
||||
/// 是否强制更新
|
||||
/// </summary>
|
||||
public bool IsRequired
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
/// <summary>
|
||||
/// 更新通道
|
||||
/// </summary>
|
||||
public VersionChannel VersionChannel
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
/// <summary>
|
||||
/// 更新目标类型
|
||||
/// </summary>
|
||||
public UpgradeTargetType UpgradeTargetType
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
/// <summary>
|
||||
/// 更新类型
|
||||
/// </summary>
|
||||
public VersionType VersionType
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,97 @@
|
|||
using LFlow.Base.Interfaces;
|
||||
using LFlow.VersionManagement.Enums;
|
||||
using SqlSugar;
|
||||
|
||||
namespace LFlow.VersionManagement.Model;
|
||||
/// <summary>
|
||||
/// 版本信息
|
||||
/// </summary>
|
||||
[SugarTable("T_P_VERSION")]
|
||||
[Serializable]
|
||||
public class VersionModel : IDataModel
|
||||
{
|
||||
/// <summary>
|
||||
/// ID
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true)]
|
||||
public string ID
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
/// <summary>
|
||||
/// 版本号 eg:1.0.0.1
|
||||
/// </summary>
|
||||
public string? CurrentVersion
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
/// <summary>
|
||||
/// 更新说明
|
||||
/// </summary>
|
||||
public string? Description
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
public DateTime LastPublishTime
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
/// <summary>
|
||||
/// 下载地址
|
||||
/// </summary>
|
||||
public string? DownloadUrl
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
/// <summary>
|
||||
/// 文件名
|
||||
/// </summary>
|
||||
public string? FileName
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
/// <summary>
|
||||
/// 文件大小
|
||||
/// </summary>
|
||||
public string? FileSize
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
/// <summary>
|
||||
/// MD5 校验码
|
||||
/// </summary>
|
||||
public string? Md5
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
/// <summary>
|
||||
/// 是否强制更新
|
||||
/// </summary>
|
||||
public bool IsRequired
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
/// <summary>
|
||||
/// 更新通道
|
||||
/// </summary>
|
||||
public VersionChannel VersionChannel
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
/// <summary>
|
||||
/// 更新目标类型
|
||||
/// </summary>
|
||||
public UpgradeTargetType UpgradeTargetType
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
/// <summary>
|
||||
/// 更新类型
|
||||
/// </summary>
|
||||
public VersionType VersionType
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
using LFlow.Base.Default;
|
||||
using LFlow.Base.Utils;
|
||||
using LFlow.VersionManagement.Model;
|
||||
using SqlSugar;
|
||||
|
||||
namespace LFlow.VersionManagement.Repository;
|
||||
public class VersionManagementRepo(ISqlSugarClient db) : DefaultCurdRepo<VersionModel, string>(db)
|
||||
{
|
||||
public override List<VersionModel> Search(VersionModel whereObj)
|
||||
{
|
||||
return db.Queryable<VersionModel>()
|
||||
.Where(whereObj.ToWhereExp())
|
||||
.ToList();
|
||||
}
|
||||
public override List<string> WhereSearchId(VersionModel whereObj)
|
||||
{
|
||||
return db.Queryable<VersionModel>()
|
||||
.Where(whereObj.ToWhereExp())
|
||||
.Where(x => x.ID != null)
|
||||
.Select(x => x.ID)
|
||||
.ToList();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
using LFlow.Base.Interfaces;
|
||||
using LFlow.VersionManagement.Model;
|
||||
|
||||
namespace LFlow.VersionManagement.Service;
|
||||
public interface IVersionManagementService : IService<VersionDto>
|
||||
{
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
using LFlow.Base.Interfaces;
|
||||
using LFlow.Base.Utils;
|
||||
using LFlow.VersionManagement.Model;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace LFlow.VersionManagement.Service;
|
||||
/// <summary>
|
||||
/// 版本管理服务
|
||||
/// </summary>
|
||||
public class VersionManagementService : BaseController, IVersionManagementService
|
||||
{
|
||||
private readonly IRepo<VersionModel, string> _repo;
|
||||
public VersionManagementService(IRepo<VersionModel, string> repo)
|
||||
{
|
||||
_repo = repo;
|
||||
}
|
||||
[HttpDelete]
|
||||
public int DeleteById(string id)
|
||||
{
|
||||
return _repo.DeleteById(id);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public PagedApiResult<List<VersionDto>> GetAll(int pageIndex, int pageSize)
|
||||
{
|
||||
var total = 0;
|
||||
var result = _repo.GetAll(pageIndex, pageSize, ref total);
|
||||
return new PagedApiResult<List<VersionDto>>
|
||||
{
|
||||
Data = Mapper.Map<List<VersionDto>>(result),
|
||||
PageIndex = pageIndex,
|
||||
PageSize = pageSize,
|
||||
Message = "获取成功",
|
||||
Success = true,
|
||||
TotalCount = total
|
||||
};
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public VersionDto GetById(string id)
|
||||
{
|
||||
return _repo.Get(id).Adapt<VersionDto>();
|
||||
}
|
||||
[HttpPost]
|
||||
public VersionDto Save(VersionDto entity, bool isUpdate)
|
||||
{
|
||||
return _repo.SaveOrUpdate(entity.Adapt<VersionModel>(), isUpdate).Adapt<VersionDto>();
|
||||
}
|
||||
[HttpPost]
|
||||
public List<VersionDto> Search(VersionDto whereObj)
|
||||
{
|
||||
return _repo.Search(whereObj.Adapt<VersionModel>()).Adapt<List<VersionDto>>();
|
||||
}
|
||||
[HttpPost]
|
||||
public List<string> SearchAllId(VersionDto whereObj)
|
||||
{
|
||||
return _repo.WhereSearchId(whereObj.Adapt<VersionModel>());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
using System.Reflection;
|
||||
using LFlow.Base.Interfaces;
|
||||
using LFlow.Base.Utils;
|
||||
using LFlow.VersionManagement.Model;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace LFlow.User;
|
||||
|
||||
public class VersionManagementModule : IModule
|
||||
{
|
||||
public void ConfigureModule(IServiceCollection services)
|
||||
{
|
||||
CodeFirst.AddType(typeof(VersionModel));
|
||||
var assembly = Assembly.GetAssembly(typeof(VersionManagementModule))!;
|
||||
var types = assembly.GetTypes().ToList();
|
||||
RegisterModule.RegisterAllService(types, services);
|
||||
RegisterModule.RegisterAllRepo(types, services);
|
||||
RegisterModule.RegisterAllModel(types, services);
|
||||
services.AddControllers().AddApplicationPart(assembly);
|
||||
Console.WriteLine("UserModule ConfigureModule");
|
||||
}
|
||||
}
|
18
LFlow.sln
18
LFlow.sln
|
@ -3,11 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
|||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.5.002.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LFlow.Base", "LFlow.Base\LFlow.Base.csproj", "{C581AFB2-50BA-4357-AD0A-AF287194837D}"
|
||||
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.Home", "LFlow.Home\LFlow.Home.csproj", "{1F607791-03F0-45EA-8F13-A085E2D49DD4}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LFlow.User", "LFlow.User\LFlow.User.csproj", "{AC877BA7-45B8-4F8A-921E-6F11AC7A3638}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LFlow.VersionManagement", "LFlow.VersionManagement\LFlow.VersionManagement.csproj", "{D52CC594-B10C-4FC0-8B7A-68CE0645A95D}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
|
@ -19,14 +17,10 @@ Global
|
|||
{C581AFB2-50BA-4357-AD0A-AF287194837D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{C581AFB2-50BA-4357-AD0A-AF287194837D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C581AFB2-50BA-4357-AD0A-AF287194837D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{1F607791-03F0-45EA-8F13-A085E2D49DD4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1F607791-03F0-45EA-8F13-A085E2D49DD4}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1F607791-03F0-45EA-8F13-A085E2D49DD4}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1F607791-03F0-45EA-8F13-A085E2D49DD4}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{AC877BA7-45B8-4F8A-921E-6F11AC7A3638}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{AC877BA7-45B8-4F8A-921E-6F11AC7A3638}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{AC877BA7-45B8-4F8A-921E-6F11AC7A3638}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{AC877BA7-45B8-4F8A-921E-6F11AC7A3638}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{D52CC594-B10C-4FC0-8B7A-68CE0645A95D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{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
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
Loading…
Reference in New Issue