Compare commits
3 Commits
1a362319d0
...
c18ee4036d
| Author | SHA1 | Date |
|---|---|---|
|
|
c18ee4036d | |
|
|
de39bba323 | |
|
|
e49fff6407 |
|
|
@ -1,15 +1,15 @@
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace LFlow.Base;
|
namespace LFlow.Base;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 程序对象
|
/// 程序对象
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class App
|
public class App
|
||||||
{
|
{
|
||||||
public static IServiceCollection? services;
|
public static IServiceCollection? services;
|
||||||
private static IServiceProvider? ServiceProvider => services?.BuildServiceProvider();
|
private static IServiceProvider? ServiceProvider => services?.BuildServiceProvider();
|
||||||
public static T? GetService<T>()
|
public static T? GetService<T>()
|
||||||
{
|
{
|
||||||
return ServiceProvider!.GetService<T>();
|
return ServiceProvider!.GetService<T>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,92 @@
|
||||||
|
using LFlow.Base.Interfaces;
|
||||||
|
using LFlow.Base.Utils;
|
||||||
|
using SqlSugar;
|
||||||
|
|
||||||
|
namespace LFlow.Base.Default;
|
||||||
|
/// <summary>
|
||||||
|
/// 默认的增删改查仓储
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <typeparam name="K"></typeparam>
|
||||||
|
public abstract class DefaultCurdRepo<T, K> : IRepo<T, K> where T : class, IDataModel, new()
|
||||||
|
{
|
||||||
|
private readonly ISqlSugarClient _client;
|
||||||
|
public DefaultCurdRepo(ISqlSugarClient client)
|
||||||
|
{
|
||||||
|
_client = client;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 根据ID删除对象
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <exception cref="Exception"></exception>
|
||||||
|
public virtual int DeleteById(K id)
|
||||||
|
{
|
||||||
|
if (Get(id) != null)
|
||||||
|
{
|
||||||
|
return _client.Deleteable<T>().In(id).ExecuteCommand();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception("删除的对象不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 根据ID获取对象
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public virtual T Get(K id)
|
||||||
|
{
|
||||||
|
return _client.Queryable<T>().InSingle(id);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 批量查询(分页)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pageIndex"></param>
|
||||||
|
/// <param name="pageSize"></param>
|
||||||
|
/// <param name="pageTotal"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public List<T> GetAll(int pageIndex, int pageSize, ref int pageTotal)
|
||||||
|
{
|
||||||
|
return _client.Queryable<T>().ToPageList(pageIndex, pageSize, ref pageTotal);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 报错或是更新对象
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity"></param>
|
||||||
|
/// <param name="isUpdate"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public virtual T SaveOrUpdate(T entity, bool isUpdate)
|
||||||
|
{
|
||||||
|
if (isUpdate)
|
||||||
|
{
|
||||||
|
_client.Updateable(entity).ExecuteCommand();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_client.Insertable(entity).ExecuteCommand();
|
||||||
|
}
|
||||||
|
return entity;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 搜索
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="whereObj"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public virtual List<T> Search(T whereObj)
|
||||||
|
{
|
||||||
|
return _client.Queryable<T>().Where(whereObj.ToWhereExp()).ToList();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 查找ID
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="whereObj"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public virtual List<K> WhereSearchId(T whereObj)
|
||||||
|
{
|
||||||
|
return _client.Queryable<T>().Where(whereObj.ToWhereExp()).Select(x => (K)Convert.ChangeType(x.ID, typeof(K))).ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,18 +1,14 @@
|
||||||
using System;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
|
namespace LFlow.Base.Interfaces;
|
||||||
namespace LFlow.Base.Interfaces;
|
|
||||||
|
/// <summary>
|
||||||
/// <summary>
|
/// 基础控制器
|
||||||
/// 基础控制器
|
/// </summary>
|
||||||
/// </summary>
|
/// <example> Route("api/[controller]/[action]") ApiController </example>
|
||||||
/// <example>
|
[Route("api/[controller]/[action]")]
|
||||||
/// [Route("api/[controller]/[action]")]
|
[ApiController]
|
||||||
/// [ApiController]
|
public abstract class BaseController : ControllerBase, IController
|
||||||
/// </example>
|
{
|
||||||
[Route("api/[controller]/[action]")]
|
|
||||||
[ApiController]
|
}
|
||||||
public abstract class BaseController : ControllerBase, IController
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace LFlow.Base.Interfaces;
|
namespace LFlow.Base.Interfaces;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 控制器接口
|
/// 控制器接口
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IController
|
public interface IController
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,11 +1,15 @@
|
||||||
using System;
|
namespace LFlow.Base.Interfaces;
|
||||||
|
|
||||||
namespace LFlow.Base.Interfaces;
|
/// <summary>
|
||||||
|
/// 数据模型接口 Repo层用
|
||||||
/// <summary>
|
/// </summary>
|
||||||
/// 数据模型接口 Repo层用
|
public interface IDataModel : IModel
|
||||||
/// </summary>
|
{
|
||||||
public interface IDataModel : IModel
|
/// <summary>
|
||||||
{
|
/// ID
|
||||||
|
/// </summary>
|
||||||
}
|
public string ID
|
||||||
|
{
|
||||||
|
get; set;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,11 +1,10 @@
|
||||||
using System;
|
namespace LFlow.Base.Interfaces;
|
||||||
|
|
||||||
namespace LFlow.Base.Interfaces;
|
/// <summary>
|
||||||
|
/// 模型顶层接口 Service层用
|
||||||
/// <summary>
|
/// </summary>
|
||||||
/// 模型顶层接口 Service层用
|
|
||||||
/// </summary>
|
public interface IModel
|
||||||
public interface IModel
|
{
|
||||||
{
|
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
@ -1,51 +1,49 @@
|
||||||
using System;
|
namespace LFlow.Base.Interfaces;
|
||||||
|
|
||||||
namespace LFlow.Base.Interfaces;
|
/// <summary>
|
||||||
|
/// 通用的仓库对象接口
|
||||||
/// <summary>
|
/// </summary>
|
||||||
/// 通用的仓库对象接口
|
/// <typeparam name="T">数据模型</typeparam>
|
||||||
/// </summary>
|
/// <typeparam name="K">主键</typeparam>
|
||||||
/// <typeparam name="T">数据模型</typeparam>
|
public interface IRepo<T, K> where T : IDataModel
|
||||||
/// <typeparam name="K">主键</typeparam>
|
{
|
||||||
public interface IRepo<T, K> where T : IDataModel
|
/// <summary>
|
||||||
{
|
/// 获取单个对象
|
||||||
/// <summary>
|
/// </summary>
|
||||||
/// 获取单个对象
|
/// <param name="id"></param>
|
||||||
/// </summary>
|
/// <returns></returns>
|
||||||
/// <param name="id"></param>
|
T Get(K id);
|
||||||
/// <returns></returns>
|
/// <summary>
|
||||||
T Get(K id);
|
/// 删除单个对象
|
||||||
/// <summary>
|
/// </summary>
|
||||||
/// 删除单个对象
|
/// <param name="id"></param>
|
||||||
/// </summary>
|
/// <returns></returns>
|
||||||
/// <param name="id"></param>
|
int DeleteById(K id);
|
||||||
/// <returns></returns>
|
/// <summary>
|
||||||
int Delete(K id);
|
/// 保存与更新
|
||||||
/// <summary>
|
/// </summary>
|
||||||
/// 保存与更新
|
/// <param name="entity"></param>
|
||||||
/// </summary>
|
/// <returns></returns>
|
||||||
/// <param name="entity"></param>
|
T SaveOrUpdate(T entity, bool isUpdate);
|
||||||
/// <returns></returns>
|
/// <summary>
|
||||||
T SaveOrUpdate(T entity, bool isUpdate);
|
/// 获取所有对象列表(默认分页)
|
||||||
/// <summary>
|
/// </summary>
|
||||||
/// 获取所有对象列表(默认分页)
|
/// <param name="pageIndex"></param>
|
||||||
/// </summary>
|
/// <param name="pageSize"></param>
|
||||||
/// <param name="pageIndex"></param>
|
/// <returns></returns>
|
||||||
/// <param name="pageSize"></param>
|
List<T> GetAll(int pageIndex, int pageSize, ref int pageTotal);
|
||||||
/// <returns></returns>
|
|
||||||
List<T> GetAll(int pageIndex, int pageSize, ref int pageTotal);
|
/// <summary>
|
||||||
|
/// 根据条件搜索对象列表
|
||||||
/// <summary>
|
/// </summary>
|
||||||
/// 根据条件搜索对象列表
|
/// <param name="whereObj"></param>
|
||||||
/// </summary>
|
/// <returns></returns>
|
||||||
/// <param name="whereObj"></param>
|
List<T> Search(T whereObj);
|
||||||
/// <returns></returns>
|
/// <summary>
|
||||||
List<T> Search(T whereObj);
|
/// 根据条件搜索主键列表
|
||||||
/// <summary>
|
/// </summary>
|
||||||
/// 根据条件搜索主键列表
|
/// <param name="whereObj"></param>
|
||||||
/// </summary>
|
/// <returns></returns>
|
||||||
/// <param name="whereObj"></param>
|
List<K> WhereSearchId(T whereObj);
|
||||||
/// <returns></returns>
|
|
||||||
List<K> WhereSearchId(T whereObj);
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
using LFlow.Base.Utils;
|
||||||
|
|
||||||
|
namespace LFlow.Base.Interfaces;
|
||||||
|
/// <summary>
|
||||||
|
/// ·þÎñ½Ó¿Ú
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
public interface IService<T> where T : class, IModel, new()
|
||||||
|
{
|
||||||
|
T GetById(string id);
|
||||||
|
List<T> Search(T whereObj);
|
||||||
|
|
||||||
|
int DeleteById(string id);
|
||||||
|
T Save(T entity, bool isUpdate);
|
||||||
|
|
||||||
|
PagedApiResult<List<T>> GetAll(int pageIndex, int pageSize);
|
||||||
|
}
|
||||||
Binary file not shown.
|
|
@ -1,11 +1,6 @@
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using LFlow.Base.Interfaces;
|
using LFlow.Base.Interfaces;
|
||||||
using LFlow.Base.Utils;
|
using LFlow.Base.Utils;
|
||||||
using Microsoft.AspNetCore.Builder;
|
|
||||||
using Microsoft.AspNetCore.Http;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using Microsoft.Extensions.Hosting;
|
|
||||||
using Npgsql.Replication;
|
|
||||||
using Serilog;
|
using Serilog;
|
||||||
using Serilog.Events;
|
using Serilog.Events;
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
|
|
@ -16,6 +11,7 @@ public static class Program
|
||||||
|
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
|
// 先用Serilog的BootstrapLogger
|
||||||
Log.Logger = new LoggerConfiguration()
|
Log.Logger = new LoggerConfiguration()
|
||||||
.MinimumLevel.Override("Microsoft", LogEventLevel.Information)
|
.MinimumLevel.Override("Microsoft", LogEventLevel.Information)
|
||||||
.Enrich.FromLogContext()
|
.Enrich.FromLogContext()
|
||||||
|
|
@ -23,7 +19,7 @@ public static class Program
|
||||||
.CreateBootstrapLogger();
|
.CreateBootstrapLogger();
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
// 添加到Service中
|
||||||
builder.Services.AddSerilog((services, lc) => lc
|
builder.Services.AddSerilog((services, lc) => lc
|
||||||
.ReadFrom.Configuration(builder.Configuration)
|
.ReadFrom.Configuration(builder.Configuration)
|
||||||
.ReadFrom.Services(services)
|
.ReadFrom.Services(services)
|
||||||
|
|
@ -57,7 +53,7 @@ public static class Program
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
// 使用Serilog,此处为了修复 `The logger is already frozen` 的问题,重新配置Serilog
|
||||||
builder.Host.UseSerilog((context, services, config) =>
|
builder.Host.UseSerilog((context, services, config) =>
|
||||||
{
|
{
|
||||||
config.ReadFrom.Configuration(context.Configuration)
|
config.ReadFrom.Configuration(context.Configuration)
|
||||||
|
|
@ -70,6 +66,7 @@ public static class Program
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
app.UseSerilogRequestLogging(options =>
|
app.UseSerilogRequestLogging(options =>
|
||||||
{
|
{
|
||||||
|
// 配置日志级别
|
||||||
options.GetLevel = (httpContext, elapsed, ex) => LogEventLevel.Information;
|
options.GetLevel = (httpContext, elapsed, ex) => LogEventLevel.Information;
|
||||||
});
|
});
|
||||||
app.MapControllers();
|
app.MapControllers();
|
||||||
|
|
@ -145,7 +142,7 @@ public static class Program
|
||||||
{
|
{
|
||||||
Log.Logger.Information($"\tFound IModule -> {type.FullName}");
|
Log.Logger.Information($"\tFound IModule -> {type.FullName}");
|
||||||
var module = Activator.CreateInstance(type) as IModule;
|
var module = Activator.CreateInstance(type) as IModule;
|
||||||
module.ConfigureModule(services);
|
module?.ConfigureModule(services);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
namespace LFlow.Base.Utils;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 返回结果包装
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
[Serializable]
|
||||||
|
public class ApiResult<T> where T : class, new()
|
||||||
|
{
|
||||||
|
public T? Data
|
||||||
|
{
|
||||||
|
get; set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApiResult()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApiResult(bool success, string message, T data)
|
||||||
|
{
|
||||||
|
Success = success;
|
||||||
|
Message = message;
|
||||||
|
Data = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Success
|
||||||
|
{
|
||||||
|
get; set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string? Message
|
||||||
|
{
|
||||||
|
get; set;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,32 +1,32 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
|
|
||||||
namespace LFlow.Base.Utils;
|
namespace LFlow.Base.Utils;
|
||||||
|
|
||||||
public static class CodeFirst
|
public static class CodeFirst
|
||||||
{
|
{
|
||||||
// 线程安全的类型列表
|
// 线程安全的类型列表
|
||||||
private static readonly ConcurrentBag<Type> _types = new();
|
private static readonly ConcurrentBag<Type> _types = new();
|
||||||
public static void AddType(Type type)
|
public static void AddType(Type type)
|
||||||
{
|
{
|
||||||
_types.Add(type);
|
_types.Add(type);
|
||||||
}
|
}
|
||||||
internal static void InitTable()
|
internal static void InitTable()
|
||||||
{
|
{
|
||||||
var logger = App.GetService<Serilog.ILogger>()!;
|
var logger = App.GetService<Serilog.ILogger>()!;
|
||||||
var db = App.GetService<ISqlSugarClient>()!;
|
var db = App.GetService<ISqlSugarClient>()!;
|
||||||
foreach (var type in _types)
|
foreach (var type in _types)
|
||||||
{
|
{
|
||||||
db.CodeFirst.InitTables(type);
|
db.CodeFirst.InitTables(type);
|
||||||
logger.Information($"Init table {type.Name} success");
|
logger.Information($"Init table {type.Name} success");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void InitDBSeed()
|
internal static void InitDBSeed()
|
||||||
{
|
{
|
||||||
//TODO: Seed data
|
//TODO: Seed data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,22 +1,22 @@
|
||||||
using System;
|
using System;
|
||||||
using Mapster;
|
using Mapster;
|
||||||
|
|
||||||
namespace LFlow.Base.Utils;
|
namespace LFlow.Base.Utils;
|
||||||
|
|
||||||
public class Mapper
|
public class Mapper
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 将一个对象映射到另一个对象
|
/// 将一个对象映射到另一个对象
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="T"></typeparam>
|
/// <typeparam name="T"></typeparam>
|
||||||
/// <param name="source"></param>
|
/// <param name="source"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static T? Map<T>(object source)
|
public static T? Map<T>(object source)
|
||||||
{
|
{
|
||||||
if (source == null)
|
if (source == null)
|
||||||
{
|
{
|
||||||
return default;
|
return default;
|
||||||
}
|
}
|
||||||
return source.Adapt<T>();
|
return source.Adapt<T>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,55 @@
|
||||||
|
using LFlow.Base.Interfaces;
|
||||||
|
|
||||||
|
namespace LFlow.Base.Utils;
|
||||||
|
|
||||||
|
public static class ObjectToWhereExp
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 将IModel对象转换为where条件
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="model"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string ToWhereExp(this IModel model)
|
||||||
|
{
|
||||||
|
var type = model.GetType();
|
||||||
|
var properties = type.GetProperties();
|
||||||
|
var whereExp = " 1=1 ";
|
||||||
|
foreach (var property in properties)
|
||||||
|
{
|
||||||
|
var value = property.GetValue(model);
|
||||||
|
if (value == null) continue;
|
||||||
|
if (property.PropertyType == typeof(string))
|
||||||
|
{
|
||||||
|
whereExp += $" and {property.Name} like '%{value}%'";
|
||||||
|
}
|
||||||
|
else if (property.PropertyType == typeof(DateTime) && value is DateTime dateTime)
|
||||||
|
{
|
||||||
|
if (dateTime != default(DateTime))
|
||||||
|
{
|
||||||
|
whereExp += $" and {property.Name} like '%{value}%'";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (property.PropertyType.IsEnum)
|
||||||
|
{
|
||||||
|
var enumValue = (int)value;
|
||||||
|
whereExp += $" and {property.Name} = '{enumValue}'";
|
||||||
|
}
|
||||||
|
else if (property.PropertyType == typeof(bool) && value is bool flag)
|
||||||
|
{
|
||||||
|
if (flag)
|
||||||
|
{
|
||||||
|
whereExp += $" and {property.Name} = 1";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
whereExp += $" and {property.Name} = 0";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (value != null)
|
||||||
|
{
|
||||||
|
whereExp += $" and {property.Name} = '{value}'";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return whereExp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
namespace LFlow.Base.Utils;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 返回结果包装 (分页)
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
[Serializable]
|
||||||
|
public class PagedApiResult<T> : ApiResult<T> where T : class, new()
|
||||||
|
{
|
||||||
|
public new T? Data
|
||||||
|
{
|
||||||
|
get; set;
|
||||||
|
}
|
||||||
|
public int TotalCount
|
||||||
|
{
|
||||||
|
get; set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int PageIndex
|
||||||
|
{
|
||||||
|
get; set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int PageSize
|
||||||
|
{
|
||||||
|
get; set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PagedApiResult()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public PagedApiResult(bool success, string message, T data, int totalCount, int pageIndex, int pageSize)
|
||||||
|
{
|
||||||
|
Success = success;
|
||||||
|
Message = message;
|
||||||
|
Data = data;
|
||||||
|
TotalCount = totalCount;
|
||||||
|
PageIndex = pageIndex;
|
||||||
|
PageSize = pageSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,11 +1,13 @@
|
||||||
using System;
|
|
||||||
using LFlow.Base.Interfaces;
|
|
||||||
|
|
||||||
namespace LFlow.Base.Utils;
|
namespace LFlow.Base.Utils;
|
||||||
|
|
||||||
public static class RegisterModule
|
public static class RegisterModule
|
||||||
{
|
{
|
||||||
public static void RegisterAllModule(this List<Type> types, IServiceCollection services)
|
/// <summary>
|
||||||
|
/// 注册所有模型
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="types"></param>
|
||||||
|
/// <param name="services"></param>
|
||||||
|
public static void RegisterAllModel(this List<Type> types, IServiceCollection services)
|
||||||
{
|
{
|
||||||
foreach (var type in types)
|
foreach (var type in types)
|
||||||
{
|
{
|
||||||
|
|
@ -24,6 +26,11 @@ public static class RegisterModule
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 注册所有服务
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="types"></param>
|
||||||
|
/// <param name="services"></param>
|
||||||
public static void RegisterAllService(this List<Type> types, IServiceCollection services)
|
public static void RegisterAllService(this List<Type> types, IServiceCollection services)
|
||||||
{
|
{
|
||||||
foreach (var type in types)
|
foreach (var type in types)
|
||||||
|
|
@ -45,6 +52,11 @@ public static class RegisterModule
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 注册所有数据仓库
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="types"></param>
|
||||||
|
/// <param name="services"></param>
|
||||||
public static void RegisterAllRepo(this List<Type> types, IServiceCollection services)
|
public static void RegisterAllRepo(this List<Type> types, IServiceCollection services)
|
||||||
{
|
{
|
||||||
foreach (var type in types)
|
foreach (var type in types)
|
||||||
|
|
@ -9,19 +9,29 @@ using LFlow.Home.Services;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
namespace LFlow.Home;
|
namespace LFlow.Home;
|
||||||
|
/// <summary>
|
||||||
|
/// 首页模块
|
||||||
|
/// </summary>
|
||||||
public class HomeModule : IModule
|
public class HomeModule : IModule
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 配置模块
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="services">启动前的IServiceCollection</param>
|
||||||
public void ConfigureModule(IServiceCollection services)
|
public void ConfigureModule(IServiceCollection services)
|
||||||
{
|
{
|
||||||
// 将HomeModel注册到CodeFirst,将会在程序启动后自动创建表
|
// 将HomeModel注册到CodeFirst,将会在程序启动后自动创建表
|
||||||
CodeFirst.AddType(typeof(HomeModel));
|
CodeFirst.AddType(typeof(HomeModel));
|
||||||
|
|
||||||
|
// 注册服务、仓储、模型
|
||||||
var assembly = Assembly.GetAssembly(typeof(HomeService))!;
|
var assembly = Assembly.GetAssembly(typeof(HomeService))!;
|
||||||
var types = assembly.GetTypes().ToList();
|
var types = assembly.GetTypes().ToList();
|
||||||
|
|
||||||
RegisterModule.RegisterAllService(types, services);
|
RegisterModule.RegisterAllService(types, services);
|
||||||
RegisterModule.RegisterAllRepo(types, services);
|
RegisterModule.RegisterAllRepo(types, services);
|
||||||
RegisterModule.RegisterAllModule(types, services);
|
RegisterModule.RegisterAllModel(types, services);
|
||||||
|
|
||||||
|
// 添加控制器
|
||||||
services.AddControllers().AddApplicationPart(assembly);
|
services.AddControllers().AddApplicationPart(assembly);
|
||||||
Console.WriteLine("HomeModule ConfigureModule");
|
Console.WriteLine("HomeModule ConfigureModule");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\LFlow\LFlow.Base.csproj" />
|
<ProjectReference Include="..\LFlow.Base\LFlow.Base.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
|
|
@ -10,15 +10,29 @@ using Serilog;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
namespace LFlow.Home.Services;
|
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>
|
public class HomeService(IRepo<HomeModel, string> repo, ILogger logger) : BaseController, IHomeService<HomeDto?, string>
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 删除
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <returns></returns>
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public HomeDto? DeleteById(string id)
|
public HomeDto? DeleteById(string id)
|
||||||
{
|
{
|
||||||
var result = repo.Delete(id);
|
var result = repo.Delete(id);
|
||||||
return Mapper.Map<HomeDto>(result);
|
return Mapper.Map<HomeDto>(result);
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 获取
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <returns></returns>
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public HomeDto? GetById(string id)
|
public HomeDto? GetById(string id)
|
||||||
{
|
{
|
||||||
|
|
@ -26,12 +40,23 @@ public class HomeService(IRepo<HomeModel, string> repo, ILogger logger) : BaseCo
|
||||||
var result = repo.Get(id);
|
var result = repo.Get(id);
|
||||||
return Mapper.Map<HomeDto>(result);
|
return Mapper.Map<HomeDto>(result);
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 保存 (修改或者新增,按主键判断)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity"></param>
|
||||||
|
/// <returns></returns>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public HomeDto? Save(HomeDto entity)
|
public HomeDto? Save(HomeDto entity)
|
||||||
{
|
{
|
||||||
var result = repo.SaveOrUpdate(Mapper.Map<HomeModel>(entity), false);
|
var result = repo.SaveOrUpdate(Mapper.Map<HomeModel>(entity), false);
|
||||||
return Mapper.Map<HomeDto>(result);
|
return Mapper.Map<HomeDto>(result);
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 搜索
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="whereObj"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <exception cref="NotImplementedException"></exception>
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public List<HomeDto>? Search(HomeDto whereObj)
|
public List<HomeDto>? Search(HomeDto whereObj)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\LFlow\LFlow.Base.csproj" />
|
<ProjectReference Include="..\LFlow.Base\LFlow.Base.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
|
|
|
||||||
|
|
@ -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
|
# Visual Studio Version 17
|
||||||
VisualStudioVersion = 17.5.002.0
|
VisualStudioVersion = 17.5.002.0
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LFlow.Base", "LFlow\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
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LFlow.Home", "LFlow.Home\LFlow.Home.csproj", "{1F607791-03F0-45EA-8F13-A085E2D49DD4}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LFlow.VersionManagement", "LFlow.VersionManagement\LFlow.VersionManagement.csproj", "{D52CC594-B10C-4FC0-8B7A-68CE0645A95D}"
|
||||||
EndProject
|
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LFlow.User", "LFlow.User\LFlow.User.csproj", "{AC877BA7-45B8-4F8A-921E-6F11AC7A3638}"
|
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
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}.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.ActiveCfg = Release|Any CPU
|
||||||
{C581AFB2-50BA-4357-AD0A-AF287194837D}.Release|Any CPU.Build.0 = 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
|
{D52CC594-B10C-4FC0-8B7A-68CE0645A95D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{1F607791-03F0-45EA-8F13-A085E2D49DD4}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{D52CC594-B10C-4FC0-8B7A-68CE0645A95D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{1F607791-03F0-45EA-8F13-A085E2D49DD4}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{D52CC594-B10C-4FC0-8B7A-68CE0645A95D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{1F607791-03F0-45EA-8F13-A085E2D49DD4}.Release|Any CPU.Build.0 = Release|Any CPU
|
{D52CC594-B10C-4FC0-8B7A-68CE0645A95D}.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
|
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|
|
||||||
|
|
@ -1,19 +0,0 @@
|
||||||
{
|
|
||||||
// Use IntelliSense to learn about possible attributes.
|
|
||||||
// Hover to view descriptions of existing attributes.
|
|
||||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
|
||||||
"version": "0.2.0",
|
|
||||||
"configurations": [
|
|
||||||
{
|
|
||||||
"name": ".NET Core Launch (console)",
|
|
||||||
"type": "coreclr",
|
|
||||||
"request": "launch",
|
|
||||||
"preLaunchTask": "dotnet: build",
|
|
||||||
"program": "${workspaceFolder}/bin/Debug/net8.0/LFlow.dll",
|
|
||||||
"args": [],
|
|
||||||
"cwd": "${workspaceFolder}",
|
|
||||||
"stopAtEntry": false,
|
|
||||||
"console": "internalConsole"
|
|
||||||
},
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
{
|
|
||||||
"version": "2.0.0",
|
|
||||||
"tasks": [
|
|
||||||
{
|
|
||||||
"type": "dotnet",
|
|
||||||
"task": "build",
|
|
||||||
"group": "build",
|
|
||||||
"problemMatcher": [],
|
|
||||||
"label": "dotnet: build"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
@ -1,40 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.Reflection;
|
|
||||||
using LFlow.Base.Interfaces;
|
|
||||||
|
|
||||||
namespace LFlow.Base.Default;
|
|
||||||
/// <summary>
|
|
||||||
/// 默认的CURD操作
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T"></typeparam>
|
|
||||||
/// <typeparam name="K"></typeparam>
|
|
||||||
public abstract class DefaultCurd<T, K> where T : IModel, IDataModel
|
|
||||||
{
|
|
||||||
private readonly IRepo<T, K> _repo;
|
|
||||||
public DefaultCurd(IRepo<T, K> repo)
|
|
||||||
{
|
|
||||||
_repo = repo;
|
|
||||||
}
|
|
||||||
public virtual T Add(T model)
|
|
||||||
{
|
|
||||||
return _repo.SaveOrUpdate(model, false);
|
|
||||||
}
|
|
||||||
public virtual int Delete(K id)
|
|
||||||
{
|
|
||||||
return _repo.Delete(id);
|
|
||||||
}
|
|
||||||
public virtual T Update(T model)
|
|
||||||
{
|
|
||||||
return _repo.SaveOrUpdate(model, true);
|
|
||||||
}
|
|
||||||
public virtual T Get(K id)
|
|
||||||
{
|
|
||||||
return _repo.Get(id);
|
|
||||||
}
|
|
||||||
public virtual List<T> GetAll(int pageIndex, int pageSize, ref int pageTotal)
|
|
||||||
{
|
|
||||||
return _repo.GetAll(pageIndex, pageSize, ref pageTotal);
|
|
||||||
}
|
|
||||||
public abstract List<T> GetWhere(T WhereObject);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,50 +0,0 @@
|
||||||
using System;
|
|
||||||
using LFlow.Base.Interfaces;
|
|
||||||
using SqlSugar;
|
|
||||||
|
|
||||||
namespace LFlow.Base.Default;
|
|
||||||
|
|
||||||
public abstract class DefaultCurdRepo<T, K> : IRepo<T, K> where T : class, IDataModel, new()
|
|
||||||
{
|
|
||||||
private readonly ISqlSugarClient _client;
|
|
||||||
public DefaultCurdRepo(ISqlSugarClient client)
|
|
||||||
{
|
|
||||||
_client = client;
|
|
||||||
}
|
|
||||||
public virtual int Delete(K id)
|
|
||||||
{
|
|
||||||
if (Get(id) != null)
|
|
||||||
{
|
|
||||||
return _client.Deleteable<T>().In(id).ExecuteCommand();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new Exception("删除的对象不存在");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
public virtual T Get(K id)
|
|
||||||
{
|
|
||||||
return _client.Queryable<T>().InSingle(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<T> GetAll(int pageIndex, int pageSize, ref int pageTotal)
|
|
||||||
{
|
|
||||||
return _client.Queryable<T>().ToPageList(pageIndex, pageSize, ref pageTotal);
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual T SaveOrUpdate(T entity, bool isUpdate)
|
|
||||||
{
|
|
||||||
if (isUpdate)
|
|
||||||
{
|
|
||||||
_client.Updateable(entity).ExecuteCommand();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_client.Insertable(entity).ExecuteCommand();
|
|
||||||
}
|
|
||||||
return entity;
|
|
||||||
}
|
|
||||||
public abstract List<T> Search(T whereObj);
|
|
||||||
public abstract List<K> WhereSearchId(T whereObj);
|
|
||||||
}
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
using System;
|
|
||||||
using LFlow.Base.Interfaces;
|
|
||||||
namespace LFlow.Base.BusinessInterface;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Home service interface
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T"></typeparam>
|
|
||||||
/// <typeparam name="K"></typeparam>
|
|
||||||
public interface IHomeService<T, K> : IService<T> where T : IModel
|
|
||||||
{
|
|
||||||
T DeleteById(K id);
|
|
||||||
|
|
||||||
T GetById(K id);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace LFlow.Base.Interfaces.BusinessInterface;
|
|
||||||
|
|
||||||
public interface IUserService<T> : IService<T> where T : IModel
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace LFlow.Base.Interfaces;
|
|
||||||
|
|
||||||
public interface IService<T> where T : IModel
|
|
||||||
{
|
|
||||||
T GetById(string id);
|
|
||||||
List<T> Search(T whereObj);
|
|
||||||
|
|
||||||
T DeleteById(string id);
|
|
||||||
T Save(T entity);
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue