diff --git a/src/hosts/ZhonTai.Host/Configs/appconfig.json b/src/hosts/ZhonTai.Host/Configs/appconfig.json
index 2bdacd43..fdfaf0fe 100644
--- a/src/hosts/ZhonTai.Host/Configs/appconfig.json
+++ b/src/hosts/ZhonTai.Host/Configs/appconfig.json
@@ -44,7 +44,7 @@
{
"name": "中台Admin",
"code": "admin",
- "version": "v5.2.0",
+ "version": "v8.0.0",
"description": ""
}
]
diff --git a/src/hosts/ZhonTai.Host/ZhonTai.Host.csproj b/src/hosts/ZhonTai.Host/ZhonTai.Host.csproj
index d2a1a7b3..89bb0da4 100644
--- a/src/hosts/ZhonTai.Host/ZhonTai.Host.csproj
+++ b/src/hosts/ZhonTai.Host/ZhonTai.Host.csproj
@@ -20,16 +20,16 @@
-
-
-
-
-
-
+
+
+
+
+
+
-
+
diff --git a/src/platform/Directory.Build.props b/src/platform/Directory.Build.props
index b17c2a6c..20bb893d 100644
--- a/src/platform/Directory.Build.props
+++ b/src/platform/Directory.Build.props
@@ -1,6 +1,6 @@
- 5.2.0
+ 8.0.0
net7.0;net8.0
true
true
diff --git a/src/platform/ZhonTai.Admin/Core/RegisterModules/RegisterModule.cs b/src/platform/ZhonTai.Admin/Core/RegisterModules/RegisterModule.cs
index a1cd0c32..b7888224 100644
--- a/src/platform/ZhonTai.Admin/Core/RegisterModules/RegisterModule.cs
+++ b/src/platform/ZhonTai.Admin/Core/RegisterModules/RegisterModule.cs
@@ -11,6 +11,7 @@
using ZhonTai.Admin.Core.Repositories;
using Microsoft.AspNetCore.Identity;
using ZhonTai.Common.Helpers;
+using ZhonTai.Admin.Repositories;
namespace ZhonTai.Admin.Core.RegisterModules;
@@ -70,6 +71,7 @@ static bool Predicate(Type a) => !a.IsDefined(typeof(NonRegisterIOCAttribute), t
//仓储泛型注入
builder.RegisterGeneric(typeof(RepositoryBase<>)).As(typeof(IRepositoryBase<>)).InstancePerLifetimeScope().PropertiesAutowired();
builder.RegisterGeneric(typeof(RepositoryBase<,>)).As(typeof(IRepositoryBase<,>)).InstancePerLifetimeScope().PropertiesAutowired();
+ builder.RegisterGeneric(typeof(AdminRepositoryBase<>)).InstancePerLifetimeScope().PropertiesAutowired();
}
}
}
diff --git a/src/platform/ZhonTai.Admin/Services/Api/ApiService.cs b/src/platform/ZhonTai.Admin/Services/Api/ApiService.cs
index 4084124c..ad34b73d 100644
--- a/src/platform/ZhonTai.Admin/Services/Api/ApiService.cs
+++ b/src/platform/ZhonTai.Admin/Services/Api/ApiService.cs
@@ -10,6 +10,7 @@
using ZhonTai.DynamicApi;
using ZhonTai.DynamicApi.Attributes;
using ZhonTai.Admin.Core.Consts;
+using ZhonTai.Admin.Repositories;
namespace ZhonTai.Admin.Services.Api;
@@ -20,11 +21,11 @@ namespace ZhonTai.Admin.Services.Api;
[DynamicApi(Area = AdminConsts.AreaName)]
public class ApiService : BaseService, IApiService, IDynamicApi
{
- private readonly IApiRepository _apiRepository;
+ private readonly AdminRepositoryBase _apiRep;
- public ApiService(IApiRepository moduleRepository)
+ public ApiService(AdminRepositoryBase apiRep)
{
- _apiRepository = moduleRepository;
+ _apiRep = apiRep;
}
///
@@ -34,7 +35,7 @@ public ApiService(IApiRepository moduleRepository)
///
public async Task GetAsync(long id)
{
- var result = await _apiRepository.GetAsync(id);
+ var result = await _apiRep.GetAsync(id);
return result;
}
@@ -45,7 +46,7 @@ public async Task GetAsync(long id)
///
public async Task> GetListAsync(string key)
{
- var data = await _apiRepository
+ var data = await _apiRep
.WhereIf(key.NotNull(), a => a.Path.Contains(key) || a.Label.Contains(key))
.OrderBy(a => a.ParentId)
.OrderBy(a => a.Sort)
@@ -64,7 +65,7 @@ public async Task> GetPageAsync(PageInput i
{
var key = input.Filter?.Label;
- var list = await _apiRepository.Select
+ var list = await _apiRep.Select
.WhereDynamicFilter(input.DynamicFilter)
.WhereIf(key.NotNull(), a => a.Path.Contains(key) || a.Label.Contains(key))
.Count(out var total)
@@ -91,7 +92,7 @@ public async Task AddAsync(ApiAddInput input)
{
var path = input.Path;
- var entity = await _apiRepository.Select.DisableGlobalFilter(FilterNames.Delete)
+ var entity = await _apiRep.Select.DisableGlobalFilter(FilterNames.Delete)
.Where(w => w.Path.Equals(path) && w.IsDeleted).FirstAsync();
if (entity?.Id > 0)
@@ -99,7 +100,7 @@ public async Task AddAsync(ApiAddInput input)
Mapper.Map(input, entity);
entity.IsDeleted = false;
entity.Enabled = true;
- await _apiRepository.UpdateDiy.DisableGlobalFilter(FilterNames.Delete).SetSource(entity).ExecuteAffrowsAsync();
+ await _apiRep.UpdateDiy.DisableGlobalFilter(FilterNames.Delete).SetSource(entity).ExecuteAffrowsAsync();
return entity.Id;
}
@@ -107,11 +108,11 @@ public async Task AddAsync(ApiAddInput input)
if (entity.Sort == 0)
{
- var sort = await _apiRepository.Select.DisableGlobalFilter(FilterNames.Delete).Where(a => a.ParentId == input.ParentId).MaxAsync(a => a.Sort);
+ var sort = await _apiRep.Select.DisableGlobalFilter(FilterNames.Delete).Where(a => a.ParentId == input.ParentId).MaxAsync(a => a.Sort);
entity.Sort = sort + 1;
}
- await _apiRepository.InsertAsync(entity);
+ await _apiRep.InsertAsync(entity);
return entity.Id;
}
@@ -123,14 +124,14 @@ public async Task AddAsync(ApiAddInput input)
///
public async Task UpdateAsync(ApiUpdateInput input)
{
- var entity = await _apiRepository.GetAsync(input.Id);
+ var entity = await _apiRep.GetAsync(input.Id);
if (!(entity?.Id > 0))
{
throw ResultOutput.Exception("接口不存在!");
}
Mapper.Map(input, entity);
- await _apiRepository.UpdateAsync(entity);
+ await _apiRep.UpdateAsync(entity);
}
///
@@ -140,7 +141,7 @@ public async Task UpdateAsync(ApiUpdateInput input)
///
public async Task DeleteAsync(long id)
{
- await _apiRepository.DeleteAsync(a => a.Id == id);
+ await _apiRep.DeleteAsync(a => a.Id == id);
}
///
@@ -150,7 +151,7 @@ public async Task DeleteAsync(long id)
///
public async Task BatchDeleteAsync(long[] ids)
{
- await _apiRepository.DeleteAsync(a => ids.Contains(a.Id));
+ await _apiRep.DeleteAsync(a => ids.Contains(a.Id));
}
///
@@ -161,7 +162,7 @@ public async Task BatchDeleteAsync(long[] ids)
[HttpDelete]
public async Task SoftDeleteAsync(long id)
{
- await _apiRepository.SoftDeleteAsync(id);
+ await _apiRep.SoftDeleteAsync(id);
}
///
@@ -171,7 +172,7 @@ public async Task SoftDeleteAsync(long id)
///
public async Task BatchSoftDeleteAsync(long[] ids)
{
- await _apiRepository.SoftDeleteAsync(ids);
+ await _apiRep.SoftDeleteAsync(ids);
}
///
@@ -186,13 +187,13 @@ public virtual async Task SyncAsync(ApiSyncInput input)
//查询分组下所有模块的api
var groupPaths = input.Apis.FindAll(a => a.ParentPath.IsNull()).Select(a => a.Path);
- var groups = await _apiRepository.Select.DisableGlobalFilter(FilterNames.Delete)
+ var groups = await _apiRep.Select.DisableGlobalFilter(FilterNames.Delete)
.Where(a => a.ParentId == 0 && groupPaths.Contains(a.Path)).ToListAsync();
var groupIds = groups.Select(a => a.Id);
- var modules = await _apiRepository.Select.DisableGlobalFilter(FilterNames.Delete)
+ var modules = await _apiRep.Select.DisableGlobalFilter(FilterNames.Delete)
.Where(a => groupIds.Contains(a.ParentId)).ToListAsync();
var moduleIds = modules.Select(a => a.Id);
- var apis = await _apiRepository.Select.DisableGlobalFilter(FilterNames.Delete)
+ var apis = await _apiRep.Select.DisableGlobalFilter(FilterNames.Delete)
.Where(a=> moduleIds.Contains(a.ParentId)).ToListAsync();
apis = groups.Concat(modules).Concat(apis).ToList();
@@ -213,7 +214,7 @@ public virtual async Task SyncAsync(ApiSyncInput input)
if (pApis.Count > 0)
{
var insertPApis = Mapper.Map>(pApis);
- insertPApis = await _apiRepository.InsertAsync(insertPApis);
+ insertPApis = await _apiRep.InsertAsync(insertPApis);
apis.AddRange(insertPApis);
}
@@ -223,7 +224,7 @@ public virtual async Task SyncAsync(ApiSyncInput input)
if (cApis.Count > 0)
{
var insertCApis = Mapper.Map>(cApis);
- insertCApis = await _apiRepository.InsertAsync(insertCApis);
+ insertCApis = await _apiRep.InsertAsync(insertCApis);
apis.AddRange(insertCApis);
}
@@ -301,7 +302,7 @@ public virtual async Task SyncAsync(ApiSyncInput input)
#endregion 修改和禁用
//批量更新
- await _apiRepository.UpdateDiy.DisableGlobalFilter(FilterNames.Delete).SetSource(apis)
+ await _apiRep.UpdateDiy.DisableGlobalFilter(FilterNames.Delete).SetSource(apis)
.UpdateColumns(a => new { a.ParentId, a.Label, a.HttpMethods, a.Description, a.Sort, a.Enabled, a.IsDeleted, a.ModifiedTime })
.ExecuteAffrowsAsync();
}
diff --git a/src/platform/ZhonTai.Admin/Services/Dict/DictService.cs b/src/platform/ZhonTai.Admin/Services/Dict/DictService.cs
index 9ce274fd..3b4c5f12 100644
--- a/src/platform/ZhonTai.Admin/Services/Dict/DictService.cs
+++ b/src/platform/ZhonTai.Admin/Services/Dict/DictService.cs
@@ -10,6 +10,8 @@
using System.Linq;
using System.Collections.Generic;
using Microsoft.AspNetCore.Authorization;
+using System;
+using ZhonTai.Admin.Repositories;
namespace ZhonTai.Admin.Services.Dict;
@@ -20,11 +22,11 @@ namespace ZhonTai.Admin.Services.Dict;
[DynamicApi(Area = AdminConsts.AreaName)]
public class DictService : BaseService, IDictService, IDynamicApi
{
- private readonly IDictRepository _dictRepository;
+ private readonly AdminRepositoryBase _dictRep;
- public DictService(IDictRepository dictRepository)
+ public DictService(AdminRepositoryBase dictRep)
{
- _dictRepository = dictRepository;
+ _dictRep = dictRep;
}
///
@@ -34,7 +36,7 @@ public DictService(IDictRepository dictRepository)
///
public async Task GetAsync(long id)
{
- var result = await _dictRepository.GetAsync(id);
+ var result = await _dictRep.GetAsync(id);
return result;
}
@@ -48,7 +50,7 @@ public async Task> GetPageAsync(PageInput 0, a => a.DictTypeId == dictTypeId)
.WhereIf(key.NotNull(), a => a.Name.Contains(key) || a.Code.Contains(key))
@@ -75,7 +77,7 @@ public async Task> GetPageAsync(PageInput>> GetListAsync(string[] codes)
{
- var list = await _dictRepository.Select
+ var list = await _dictRep.Select
.Where(a => codes.Contains(a.DictType.Code) && a.DictType.Enabled == true && a.Enabled == true)
.OrderBy(a => a.Sort)
.ToListAsync(a => new DictGetListDto { DictTypeCode = a.DictType.Code });
@@ -99,7 +101,7 @@ public async Task>> GetListAsync(string[
[HttpPost]
public async Task>> GetListByNamesAsync(string[] names)
{
- var list = await _dictRepository.Select
+ var list = await _dictRep.Select
.Where(a => names.Contains(a.DictType.Name) && a.DictType.Enabled == true && a.Enabled == true)
.OrderBy(a => a.Sort)
.ToListAsync(a => new DictGetListDto { DictTypeName = a.DictType.Name });
@@ -121,22 +123,22 @@ public async Task>> GetListByNamesAsync(
///
public async Task AddAsync(DictAddInput input)
{
- if (await _dictRepository.Select.AnyAsync(a => a.DictTypeId == input.DictTypeId && a.Name == input.Name))
+ if (await _dictRep.Select.AnyAsync(a => a.DictTypeId == input.DictTypeId && a.Name == input.Name))
{
throw ResultOutput.Exception($"字典已存在");
}
- if (input.Code.NotNull() && await _dictRepository.Select.AnyAsync(a => a.DictTypeId == input.DictTypeId && a.Code == input.Code))
+ if (input.Code.NotNull() && await _dictRep.Select.AnyAsync(a => a.DictTypeId == input.DictTypeId && a.Code == input.Code))
{
throw ResultOutput.Exception($"字典编码已存在");
}
- if (input.Code.NotNull() && await _dictRepository.Select.AnyAsync(a => a.DictTypeId == input.DictTypeId && a.Code == input.Code))
+ if (input.Code.NotNull() && await _dictRep.Select.AnyAsync(a => a.DictTypeId == input.DictTypeId && a.Code == input.Code))
{
throw ResultOutput.Exception($"字典编码已存在");
}
- if (input.Value.NotNull() && await _dictRepository.Select.AnyAsync(a => a.DictTypeId == input.DictTypeId && a.Value == input.Value))
+ if (input.Value.NotNull() && await _dictRep.Select.AnyAsync(a => a.DictTypeId == input.DictTypeId && a.Value == input.Value))
{
throw ResultOutput.Exception($"字典值已存在");
}
@@ -144,10 +146,10 @@ public async Task AddAsync(DictAddInput input)
var entity = Mapper.Map(input);
if (entity.Sort == 0)
{
- var sort = await _dictRepository.Select.Where(a => a.DictTypeId == input.DictTypeId).MaxAsync(a => a.Sort);
+ var sort = await _dictRep.Select.Where(a => a.DictTypeId == input.DictTypeId).MaxAsync(a => a.Sort);
entity.Sort = sort + 1;
}
- await _dictRepository.InsertAsync(entity);
+ await _dictRep.InsertAsync(entity);
return entity.Id;
}
@@ -158,29 +160,29 @@ public async Task AddAsync(DictAddInput input)
///
public async Task UpdateAsync(DictUpdateInput input)
{
- var entity = await _dictRepository.GetAsync(input.Id);
+ var entity = await _dictRep.GetAsync(input.Id);
if (!(entity?.Id > 0))
{
throw ResultOutput.Exception("字典不存在");
}
- if (await _dictRepository.Select.AnyAsync(a => a.Id != input.Id && a.DictTypeId == input.DictTypeId && a.Name == input.Name))
+ if (await _dictRep.Select.AnyAsync(a => a.Id != input.Id && a.DictTypeId == input.DictTypeId && a.Name == input.Name))
{
throw ResultOutput.Exception($"字典已存在");
}
- if (input.Code.NotNull() && await _dictRepository.Select.AnyAsync(a => a.Id != input.Id && a.DictTypeId == input.DictTypeId && a.Code == input.Code))
+ if (input.Code.NotNull() && await _dictRep.Select.AnyAsync(a => a.Id != input.Id && a.DictTypeId == input.DictTypeId && a.Code == input.Code))
{
throw ResultOutput.Exception($"字典编码已存在");
}
- if (input.Value.NotNull() && await _dictRepository.Select.AnyAsync(a => a.Id != input.Id && a.DictTypeId == input.DictTypeId && a.Value == input.Value))
+ if (input.Value.NotNull() && await _dictRep.Select.AnyAsync(a => a.Id != input.Id && a.DictTypeId == input.DictTypeId && a.Value == input.Value))
{
throw ResultOutput.Exception($"字典值已存在");
}
Mapper.Map(input, entity);
- await _dictRepository.UpdateAsync(entity);
+ await _dictRep.UpdateAsync(entity);
}
///
@@ -190,7 +192,7 @@ public async Task UpdateAsync(DictUpdateInput input)
///
public async Task DeleteAsync(long id)
{
- await _dictRepository.DeleteAsync(m => m.Id == id);
+ await _dictRep.DeleteAsync(m => m.Id == id);
}
///
@@ -200,7 +202,7 @@ public async Task DeleteAsync(long id)
///
public async Task BatchDeleteAsync(long[] ids)
{
- await _dictRepository.DeleteAsync(a => ids.Contains(a.Id));
+ await _dictRep.DeleteAsync(a => ids.Contains(a.Id));
}
///
@@ -210,7 +212,7 @@ public async Task BatchDeleteAsync(long[] ids)
///
public async Task SoftDeleteAsync(long id)
{
- await _dictRepository.SoftDeleteAsync(id);
+ await _dictRep.SoftDeleteAsync(id);
}
///
@@ -220,6 +222,6 @@ public async Task SoftDeleteAsync(long id)
///
public async Task BatchSoftDeleteAsync(long[] ids)
{
- await _dictRepository.SoftDeleteAsync(ids);
+ await _dictRep.SoftDeleteAsync(ids);
}
}
\ No newline at end of file
diff --git a/src/platform/ZhonTai.Admin/Services/DictType/DictTypeService.cs b/src/platform/ZhonTai.Admin/Services/DictType/DictTypeService.cs
index c566557a..d653154f 100644
--- a/src/platform/ZhonTai.Admin/Services/DictType/DictTypeService.cs
+++ b/src/platform/ZhonTai.Admin/Services/DictType/DictTypeService.cs
@@ -10,6 +10,7 @@
using ZhonTai.DynamicApi.Attributes;
using Microsoft.AspNetCore.Mvc;
using ZhonTai.Admin.Core.Consts;
+using ZhonTai.Admin.Repositories;
namespace ZhonTai.Admin.Services.DictType;
@@ -20,12 +21,14 @@ namespace ZhonTai.Admin.Services.DictType;
[DynamicApi(Area = AdminConsts.AreaName)]
public class DictTypeService : BaseService, IDictTypeService, IDynamicApi
{
- private readonly IDictTypeRepository _dictTypeRepository;
- private readonly IDictRepository _dictRepository;
- public DictTypeService(IDictTypeRepository DictionaryTypeRepository, IDictRepository dictRepository)
+ private readonly AdminRepositoryBase _dictTypeRep;
+ private readonly AdminRepositoryBase _dictRep;
+
+ public DictTypeService(AdminRepositoryBase dictTypeRep,
+ AdminRepositoryBase dictRep)
{
- _dictTypeRepository = DictionaryTypeRepository;
- _dictRepository = dictRepository;
+ _dictTypeRep = dictTypeRep;
+ _dictRep = dictRep;
}
///
@@ -35,7 +38,7 @@ public DictTypeService(IDictTypeRepository DictionaryTypeRepository, IDictReposi
///
public async Task GetAsync(long id)
{
- var result = await _dictTypeRepository.GetAsync(id);
+ var result = await _dictTypeRep.GetAsync(id);
return result;
}
@@ -49,7 +52,7 @@ public async Task> GetPageAsync(PageInput a.Name.Contains(key) || a.Code.Contains(key))
.Count(out var total)
@@ -73,12 +76,12 @@ public async Task> GetPageAsync(PageInput
public async Task AddAsync(DictTypeAddInput input)
{
- if (await _dictTypeRepository.Select.AnyAsync(a => a.Name == input.Name))
+ if (await _dictTypeRep.Select.AnyAsync(a => a.Name == input.Name))
{
throw ResultOutput.Exception($"字典类型已存在");
}
- if (input.Code.NotNull() && await _dictTypeRepository.Select.AnyAsync(a => a.Code == input.Code))
+ if (input.Code.NotNull() && await _dictTypeRep.Select.AnyAsync(a => a.Code == input.Code))
{
throw ResultOutput.Exception($"字典类型编码已存在");
}
@@ -86,10 +89,10 @@ public async Task AddAsync(DictTypeAddInput input)
var entity = Mapper.Map(input);
if (entity.Sort == 0)
{
- var sort = await _dictRepository.Select.MaxAsync(a => a.Sort);
+ var sort = await _dictRep.Select.MaxAsync(a => a.Sort);
entity.Sort = sort + 1;
}
- await _dictTypeRepository.InsertAsync(entity);
+ await _dictTypeRep.InsertAsync(entity);
return entity.Id;
}
@@ -100,24 +103,24 @@ public async Task AddAsync(DictTypeAddInput input)
///
public async Task UpdateAsync(DictTypeUpdateInput input)
{
- var entity = await _dictTypeRepository.GetAsync(input.Id);
+ var entity = await _dictTypeRep.GetAsync(input.Id);
if (!(entity?.Id > 0))
{
throw ResultOutput.Exception("数据字典不存在");
}
- if (await _dictTypeRepository.Select.AnyAsync(a => a.Id != input.Id && a.Name == input.Name))
+ if (await _dictTypeRep.Select.AnyAsync(a => a.Id != input.Id && a.Name == input.Name))
{
throw ResultOutput.Exception($"字典类型已存在");
}
- if (input.Code.NotNull() && await _dictTypeRepository.Select.AnyAsync(a => a.Id != input.Id && a.Code == input.Code))
+ if (input.Code.NotNull() && await _dictTypeRep.Select.AnyAsync(a => a.Id != input.Id && a.Code == input.Code))
{
throw ResultOutput.Exception($"字典类型编码已存在");
}
Mapper.Map(input, entity);
- await _dictTypeRepository.UpdateAsync(entity);
+ await _dictTypeRep.UpdateAsync(entity);
}
///
@@ -129,10 +132,10 @@ public async Task UpdateAsync(DictTypeUpdateInput input)
public virtual async Task DeleteAsync(long id)
{
//删除字典数据
- await _dictRepository.DeleteAsync(a => a.DictTypeId == id);
+ await _dictRep.DeleteAsync(a => a.DictTypeId == id);
//删除数据字典类型
- await _dictTypeRepository.DeleteAsync(a => a.Id == id);
+ await _dictTypeRep.DeleteAsync(a => a.Id == id);
}
///
@@ -144,10 +147,10 @@ public virtual async Task DeleteAsync(long id)
public virtual async Task BatchDeleteAsync(long[] ids)
{
//删除字典数据
- await _dictRepository.DeleteAsync(a => ids.Contains(a.DictTypeId));
+ await _dictRep.DeleteAsync(a => ids.Contains(a.DictTypeId));
//删除数据字典类型
- await _dictTypeRepository.DeleteAsync(a => ids.Contains(a.Id));
+ await _dictTypeRep.DeleteAsync(a => ids.Contains(a.Id));
}
///
@@ -158,8 +161,8 @@ public virtual async Task BatchDeleteAsync(long[] ids)
[AdminTransaction]
public virtual async Task SoftDeleteAsync(long id)
{
- await _dictRepository.SoftDeleteAsync(a => a.DictTypeId == id);
- await _dictTypeRepository.SoftDeleteAsync(id);
+ await _dictRep.SoftDeleteAsync(a => a.DictTypeId == id);
+ await _dictTypeRep.SoftDeleteAsync(id);
}
///
@@ -170,7 +173,7 @@ public virtual async Task SoftDeleteAsync(long id)
[AdminTransaction]
public virtual async Task BatchSoftDeleteAsync(long[] ids)
{
- await _dictRepository.SoftDeleteAsync(a => ids.Contains(a.DictTypeId));
- await _dictTypeRepository.SoftDeleteAsync(ids);
+ await _dictRep.SoftDeleteAsync(a => ids.Contains(a.DictTypeId));
+ await _dictTypeRep.SoftDeleteAsync(ids);
}
}
\ No newline at end of file
diff --git a/src/platform/ZhonTai.Admin/ZhonTai.Admin.csproj b/src/platform/ZhonTai.Admin/ZhonTai.Admin.csproj
index fe274d52..663d0230 100644
--- a/src/platform/ZhonTai.Admin/ZhonTai.Admin.csproj
+++ b/src/platform/ZhonTai.Admin/ZhonTai.Admin.csproj
@@ -22,9 +22,9 @@
-
-
-
+
+
+
@@ -36,7 +36,7 @@
-
+
diff --git a/src/platform/ZhonTai.Common/ZhonTai.Common.csproj b/src/platform/ZhonTai.Common/ZhonTai.Common.csproj
index b98982ff..1ad6e180 100644
--- a/src/platform/ZhonTai.Common/ZhonTai.Common.csproj
+++ b/src/platform/ZhonTai.Common/ZhonTai.Common.csproj
@@ -25,7 +25,7 @@
-
+
diff --git a/src/tests/ZhonTai.Tests/ZhonTai.Tests.csproj b/src/tests/ZhonTai.Tests/ZhonTai.Tests.csproj
index 5575b71e..d38ab0bb 100644
--- a/src/tests/ZhonTai.Tests/ZhonTai.Tests.csproj
+++ b/src/tests/ZhonTai.Tests/ZhonTai.Tests.csproj
@@ -5,9 +5,9 @@
-
-
-
+
+
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
@@ -19,8 +19,8 @@
-
-
+
+
diff --git a/templates/admin/content/src/hosts/MyApp.Host/Program.cs b/templates/admin/content/src/hosts/MyApp.Host/Program.cs
index af031d6f..1eb47b61 100644
--- a/templates/admin/content/src/hosts/MyApp.Host/Program.cs
+++ b/templates/admin/content/src/hosts/MyApp.Host/Program.cs
@@ -39,6 +39,8 @@
using ZhonTai.Admin.Services.Msg.Events;
using Mapster;
#endif
+using Autofac;
+using MyApp.Api.Core.Repositories;
#if (!NoTaskScheduler)
static void ConfigureScheduler(IFreeSql fsql)
@@ -260,7 +262,7 @@ await emailService.SingleSendAsync(new EamilSingleSendEvent
//配置Autofac容器
ConfigureAutofacContainer = (builder, context) =>
{
-
+ builder.RegisterGeneric(typeof(AppRepositoryBase<>)).InstancePerLifetimeScope().PropertiesAutowired();
},
//配置Mvc
ConfigureMvcBuilder = (builder, context) =>
diff --git a/templates/admin/content/src/platform/MyApp.Api/Services/Module/ModuleService.cs b/templates/admin/content/src/platform/MyApp.Api/Services/Module/ModuleService.cs
index 3a6c3ca2..f7b86d5f 100644
--- a/templates/admin/content/src/platform/MyApp.Api/Services/Module/ModuleService.cs
+++ b/templates/admin/content/src/platform/MyApp.Api/Services/Module/ModuleService.cs
@@ -10,6 +10,7 @@
using ZhonTai.DynamicApi.Attributes;
using Microsoft.AspNetCore.Mvc;
using MyApp.Api.Core.Consts;
+using MyApp.Api.Core.Repositories;
#if (!NoTaskScheduler)
using FreeScheduler;
using Newtonsoft.Json;
@@ -24,10 +25,11 @@ namespace MyApp.Api.Services.Module;
[DynamicApi(Area = ApiConsts.AreaName)]
public class ModuleService : BaseService, IModuleService, IDynamicApi
{
- private IModuleRepository _moduleRepository => LazyGetRequiredService();
+ private readonly AppRepositoryBase _moduleRep;
- public ModuleService()
+ public ModuleService(AppRepositoryBase moduleRep)
{
+ _moduleRep = moduleRep;
}
///
@@ -37,7 +39,7 @@ public ModuleService()
///
public async Task GetAsync(long id)
{
- var result = await _moduleRepository.GetAsync(id);
+ var result = await _moduleRep.GetAsync(id);
return result;
}
@@ -51,7 +53,7 @@ public async Task> GetPageAsync(PageInput a.Name.Contains(key))
.Count(out var total)
.OrderByDescending(true, c => c.Id)
@@ -75,7 +77,7 @@ public async Task> GetPageAsync(PageInput AddAsync(ModuleAddInput input)
{
var entity = Mapper.Map(input);
- await _moduleRepository.InsertAsync(entity);
+ await _moduleRep.InsertAsync(entity);
return entity.Id;
}
@@ -87,14 +89,14 @@ public async Task AddAsync(ModuleAddInput input)
///
public async Task UpdateAsync(ModuleUpdateInput input)
{
- var entity = await _moduleRepository.GetAsync(input.Id);
+ var entity = await _moduleRep.GetAsync(input.Id);
if (!(entity?.Id > 0))
{
throw ResultOutput.Exception("模块不存在");
}
Mapper.Map(input, entity);
- await _moduleRepository.UpdateAsync(entity);
+ await _moduleRep.UpdateAsync(entity);
}
///
@@ -104,7 +106,7 @@ public async Task UpdateAsync(ModuleUpdateInput input)
///
public async Task DeleteAsync(long id)
{
- await _moduleRepository.DeleteAsync(m => m.Id == id);
+ await _moduleRep.DeleteAsync(m => m.Id == id);
}
///
@@ -114,7 +116,7 @@ public async Task DeleteAsync(long id)
///
public async Task SoftDeleteAsync(long id)
{
- await _moduleRepository.SoftDeleteAsync(id);
+ await _moduleRep.SoftDeleteAsync(id);
}
///
@@ -124,7 +126,7 @@ public async Task SoftDeleteAsync(long id)
///
public async Task BatchSoftDeleteAsync(long[] ids)
{
- await _moduleRepository.SoftDeleteAsync(ids);
+ await _moduleRep.SoftDeleteAsync(ids);
}
#if (!NoTaskScheduler)