😎1、优化种子判断 2、默认开启redis事件源 3、优化行政区域处理

This commit is contained in:
zuohuaijun 2024-07-17 18:01:34 +08:00
parent c8c9488c4f
commit 0b79002afb
3 changed files with 17 additions and 10 deletions

View File

@ -97,7 +97,11 @@ public class SysRegionService : IDynamicApiController, ITransient
if (input.Code.Length != 12 && input.Code.Length != 9 && input.Code.Length != 6) if (input.Code.Length != 12 && input.Code.Length != 9 && input.Code.Length != 6)
throw Oops.Oh(ErrorCodeEnum.R2003); throw Oops.Oh(ErrorCodeEnum.R2003);
if (input.Pid != input.Pid && input.Pid != 0) var sysRegion = await _sysRegionRep.GetFirstAsync(u => u.Id == input.Id);
if (sysRegion == null)
throw Oops.Oh(ErrorCodeEnum.D1002);
if (sysRegion.Pid != input.Pid && input.Pid != 0)
{ {
var pRegion = await _sysRegionRep.GetFirstAsync(u => u.Id == input.Pid); var pRegion = await _sysRegionRep.GetFirstAsync(u => u.Id == input.Pid);
pRegion ??= await _sysRegionRep.GetFirstAsync(u => u.Code == input.Pid.ToString()); pRegion ??= await _sysRegionRep.GetFirstAsync(u => u.Code == input.Pid.ToString());
@ -114,7 +118,6 @@ public class SysRegionService : IDynamicApiController, ITransient
if (input.Id == input.Pid) if (input.Id == input.Pid)
throw Oops.Oh(ErrorCodeEnum.R2001); throw Oops.Oh(ErrorCodeEnum.R2001);
var sysRegion = await _sysRegionRep.GetFirstAsync(u => u.Id == input.Id);
var isExist = await _sysRegionRep.IsAnyAsync(u => (u.Name == input.Name && u.Code == input.Code) && u.Id != sysRegion.Id); var isExist = await _sysRegionRep.IsAnyAsync(u => (u.Name == input.Name && u.Code == input.Code) && u.Id != sysRegion.Id);
if (isExist) if (isExist)
throw Oops.Oh(ErrorCodeEnum.R2002); throw Oops.Oh(ErrorCodeEnum.R2002);

View File

@ -316,7 +316,7 @@ public static class SqlSugarSetup
{ {
var seedDataTypes = App.EffectiveTypes.Where(u => !u.IsInterface && !u.IsAbstract && u.IsClass && u.GetInterfaces().Any(i => i.HasImplementedRawGeneric(typeof(ISqlSugarEntitySeedData<>)))) var seedDataTypes = App.EffectiveTypes.Where(u => !u.IsInterface && !u.IsAbstract && u.IsClass && u.GetInterfaces().Any(i => i.HasImplementedRawGeneric(typeof(ISqlSugarEntitySeedData<>))))
.WhereIF(config.SeedSettings.EnableIncreSeed, u => u.IsDefined(typeof(IncreSeedAttribute), false)) .WhereIF(config.SeedSettings.EnableIncreSeed, u => u.IsDefined(typeof(IncreSeedAttribute), false))
.OrderBy(u => u.GetCustomAttributes(typeof(SeedDataAttribute), false).Length > 0 ? (u.GetCustomAttributes(typeof(SeedDataAttribute), false)[0] as SeedDataAttribute).Order : 0).ToList(); .OrderBy(u => u.GetCustomAttributes(typeof(SeedDataAttribute), false).Length > 0 ? ((SeedDataAttribute)u.GetCustomAttributes(typeof(SeedDataAttribute), false)[0]).Order : 0).ToList();
foreach (var seedType in seedDataTypes) foreach (var seedType in seedDataTypes)
{ {

View File

@ -136,13 +136,17 @@ public class Startup : AppStartup
#region Redis消息队列 #region Redis消息队列
//// 替换事件源存储器 // 替换事件源存储器为Redis
//options.ReplaceStorer(serviceProvider => var cacheOptions = App.GetConfig<CacheOptions>("Cache", true);
//{ if (cacheOptions.CacheType == CacheTypeEnum.Redis.ToString())
// var cacheProvider = serviceProvider.GetRequiredService<NewLife.Caching.ICacheProvider>(); {
// // 创建默认内存通道事件源对象可自定义队列路由keyadminnet options.ReplaceStorer(serviceProvider =>
// return new RedisEventSourceStorer(cacheProvider, "adminnet", 3000); {
//}); var cacheProvider = serviceProvider.GetRequiredService<NewLife.Caching.ICacheProvider>();
// 创建默认内存通道事件源对象可自定义队列路由keyadminnet_eventsource_queue
return new RedisEventSourceStorer(cacheProvider, "adminnet_eventsource_queue", 3000);
});
}
#endregion Redis消息队列 #endregion Redis消息队列