修改发现页面
This commit is contained in:
parent
eba2c0739c
commit
c91b39b3c5
|
|
@ -4,8 +4,10 @@ using HuanMeng.DotNetCore.Base;
|
|||
using HuanMeng.DotNetCore.JwtInfrastructure;
|
||||
using HuanMeng.DotNetCore.JwtInfrastructure.Interface;
|
||||
using HuanMeng.DotNetCore.MultiTenant;
|
||||
using HuanMeng.DotNetCore.MultiTenant.Contract;
|
||||
using HuanMeng.MiaoYu.Code.Cache;
|
||||
using HuanMeng.MiaoYu.Code.DataAccess;
|
||||
|
||||
using HuanMeng.MiaoYu.Code.TencentUtile;
|
||||
using HuanMeng.MiaoYu.Code.Users.UserAccount;
|
||||
using HuanMeng.MiaoYu.Code.Users.UserAccount.Contract;
|
||||
|
|
@ -58,17 +60,17 @@ namespace HuanMeng.MiaoYu.Code.Base
|
|||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
private TenantInfo _tenantInfo;
|
||||
private ITenantInfo _tenantInfo;
|
||||
/// <summary>
|
||||
/// 租户信息
|
||||
/// </summary>
|
||||
public TenantInfo TenantInfo
|
||||
public ITenantInfo TenantInfo
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_tenantInfo == null)
|
||||
{
|
||||
_tenantInfo = _serviceProvider.GetRequiredService<TenantInfo>();
|
||||
_tenantInfo = _serviceProvider.GetRequiredService<ITenantInfo>();
|
||||
}
|
||||
return _tenantInfo;
|
||||
}
|
||||
|
|
@ -277,6 +279,29 @@ namespace HuanMeng.MiaoYu.Code.Base
|
|||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 字典数据
|
||||
|
||||
/// <summary>
|
||||
/// 字典数据列表
|
||||
/// </summary>
|
||||
private IDictionaryInfo _dictionaryInfo;
|
||||
/// <summary>
|
||||
/// 字典数据列表
|
||||
/// </summary>
|
||||
public IDictionaryInfo DictionaryInfo
|
||||
{
|
||||
|
||||
get
|
||||
{
|
||||
if (_dictionaryInfo == null)
|
||||
{
|
||||
_dictionaryInfo = _serviceProvider.GetRequiredService<IDictionaryInfo>();
|
||||
}
|
||||
return _dictionaryInfo;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
using HuanMeng.DotNetCore.Base;
|
||||
using HuanMeng.MiaoYu.Code.Cache;
|
||||
using HuanMeng.MiaoYu.Code.SysDictionary.Contract;
|
||||
using HuanMeng.MiaoYu.Model.Dto.Category;
|
||||
using HuanMeng.MiaoYu.Model.Dto.Character;
|
||||
using HuanMeng.MiaoYu.Model.Dto.Find;
|
||||
|
|
@ -67,6 +69,21 @@ namespace HuanMeng.MiaoYu.Code.Category
|
|||
public BaseResponse<List<RecommendDto<DataListBaseDto>>> GetRecommendList()
|
||||
{
|
||||
List<RecommendDto<DataListBaseDto>> recommendDtos = new List<RecommendDto<DataListBaseDto>>();
|
||||
var menuList = Dao.daoDbMiaoYu.context.T_Category_Child_Menu.Where(it => it.IsEnabled).ToList();
|
||||
var node = DictionaryInfo.GetDictionariesChildNode(T_Sys_DictionaryEnum.categorymenu);
|
||||
node.ForEach(_node =>
|
||||
{
|
||||
var menu = menuList.Where(it => it.Type == _node.ExtendValue).OrderBy(it => it.OrderById).ToList();
|
||||
if (menu?.Count > 0)
|
||||
{
|
||||
RecommendDto<DataListBaseDto> banner = new RecommendDto<DataListBaseDto>();
|
||||
banner.Title = _node.Name;
|
||||
banner.Type = _node.Value;//动作Id
|
||||
var categoryPageRegion = CategoryPageRegionExtend.GetCategoryPageRegion(RecommendTypeEnum.banner, menu, this.MiaoYuCache);
|
||||
banner.Data = categoryPageRegion.GetRecommendData();
|
||||
|
||||
}
|
||||
});
|
||||
#region 假数据
|
||||
RecommendDto<DataListBaseDto> banner = new RecommendDto<DataListBaseDto>();
|
||||
banner.Title = "Banner";
|
||||
|
|
@ -112,7 +129,7 @@ namespace HuanMeng.MiaoYu.Code.Category
|
|||
data.ActionType = RecommendActionTypeEnum.Chat.ToString();
|
||||
data.ActionId = data.Id.ToString();
|
||||
data.ImageUrl = x.BgImage;//data.BgImage;
|
||||
|
||||
|
||||
tuijian.Data.Add(data);
|
||||
xiaoshuo.Data.Add(data);
|
||||
index++;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,110 @@
|
|||
using AutoMapper;
|
||||
|
||||
using HuanMeng.MiaoYu.Code.Cache;
|
||||
using HuanMeng.MiaoYu.Code.Category.Contract;
|
||||
using HuanMeng.MiaoYu.Model.Dto.Find;
|
||||
using HuanMeng.MiaoYu.Model.EnumModel.Find;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace HuanMeng.MiaoYu.Code.Category
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public static class CategoryPageRegionExtend
|
||||
{
|
||||
//, RecommendTypeEnum recommend
|
||||
|
||||
/// <summary>
|
||||
/// 获取页面返回类型
|
||||
/// </summary>
|
||||
/// <param name="recommend"></param>
|
||||
/// <param name="menu"></param>
|
||||
/// <param name="miaoYuCache"></param>
|
||||
/// <returns></returns>
|
||||
public static ICategoryPageRegion GetCategoryPageRegion(RecommendTypeEnum recommend, List<T_Category_Child_Menu> menu, MiaoYuCache miaoYuCache)
|
||||
{
|
||||
if (recommend == RecommendTypeEnum.tuijian || recommend == RecommendTypeEnum.xiaoshuo)
|
||||
{
|
||||
return new CategoryPageRegionBanner(menu, miaoYuCache);
|
||||
}
|
||||
if (recommend == RecommendTypeEnum.banner)
|
||||
{
|
||||
return new CategoryPageRegionBanner(menu, miaoYuCache);
|
||||
}
|
||||
|
||||
return new CategoryPageRegionBanner(menu, miaoYuCache);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///发现页-banner位实现
|
||||
/// </summary>
|
||||
public class CategoryPageRegionBanner(List<T_Category_Child_Menu> menu, MiaoYuCache miaoYuCache) : ICategoryPageRegion
|
||||
{
|
||||
public List<DataListBaseDto> GetRecommendData()
|
||||
{
|
||||
var data = new List<DataListBaseDto>();
|
||||
menu.ForEach(_menu =>
|
||||
{
|
||||
data.Add(new CommonRecommendData
|
||||
{
|
||||
ActionId = _menu.ActionId,
|
||||
ActionType = _menu.ActionType,
|
||||
ImageUrl = _menu.ImageId.GetImageUrl(miaoYuCache),
|
||||
});
|
||||
});
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 发现页-小说聊天
|
||||
/// </summary>
|
||||
/// <param name="menu"></param>
|
||||
/// <param name="miaoYuCache"></param>
|
||||
public class CategoryPageRegionChat(List<T_Category_Child_Menu> menu, MiaoYuCache miaoYuCache) : ICategoryPageRegion
|
||||
{
|
||||
public List<DataListBaseDto> GetRecommendData()
|
||||
{
|
||||
var data = new List<DataListBaseDto>();
|
||||
menu.ForEach(m =>
|
||||
{
|
||||
var d = new DataListDto();
|
||||
d.ActionType = RecommendActionTypeEnum.Chat.ToString();
|
||||
d.ActionId = m.Id.ToString();
|
||||
d.ImageUrl = m.ImageUrl;//data.BgImage;
|
||||
if (m.ActionType == RecommendActionTypeEnum.Chat.ToString())
|
||||
{
|
||||
|
||||
if (!int.TryParse(m.ActionId, out var chatId))
|
||||
{
|
||||
return;
|
||||
}
|
||||
var character = miaoYuCache.CharacterList.FirstOrDefault(it => it.Id == chatId);
|
||||
if (character == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(d.ImageUrl))
|
||||
{
|
||||
d.ImageUrl = character.BgImage;
|
||||
}
|
||||
d.Name = character.Name;
|
||||
d.Biography = character.Biography;
|
||||
d.Label = character.Label;
|
||||
d.Gender = character.Gender;
|
||||
|
||||
}
|
||||
data.Add(d);
|
||||
});
|
||||
return data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
using HuanMeng.MiaoYu.Model.Dto.Find;
|
||||
using HuanMeng.MiaoYu.Model.EnumModel.Find;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace HuanMeng.MiaoYu.Code.Category.Contract
|
||||
{
|
||||
/// <summary>
|
||||
/// 发现页区域配置
|
||||
/// </summary>
|
||||
public interface ICategoryPageRegion
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 根据页面类型返回页面数据
|
||||
/// </summary>
|
||||
/// <param name="recommend"></param>
|
||||
/// <returns></returns>
|
||||
List<DataListBaseDto> GetRecommendData();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
using HuanMeng.DotNetCore.Base;
|
||||
using HuanMeng.DotNetCore.MultiTenant;
|
||||
using HuanMeng.DotNetCore.MultiTenant.Contract;
|
||||
using HuanMeng.MiaoYu.Model.DbSqlServer.Db_MiaoYu;
|
||||
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
|
@ -18,21 +19,21 @@ namespace HuanMeng.MiaoYu.Code.DataAccess
|
|||
public class DAO : DaoBase
|
||||
{
|
||||
//private IMultiTenantProvider _multiTenantProvider;
|
||||
private TenantInfo _tenantInfo;
|
||||
private ITenantInfo _tenantInfo;
|
||||
/// <summary>
|
||||
/// 构造函数
|
||||
/// </summary>
|
||||
/// <param name="serviceProvider"></param>
|
||||
public DAO(IServiceProvider serviceProvider) : base(serviceProvider)
|
||||
{
|
||||
this._tenantInfo = serviceProvider.GetRequiredService<TenantInfo>();
|
||||
this._tenantInfo = serviceProvider.GetRequiredService<ITenantInfo>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 构造函数
|
||||
/// </summary>
|
||||
/// <param name="serviceProvider"></param>
|
||||
public DAO(IServiceProvider serviceProvider, TenantInfo tenantInfo) : base(serviceProvider)
|
||||
public DAO(IServiceProvider serviceProvider, ITenantInfo tenantInfo) : base(serviceProvider)
|
||||
{
|
||||
this._tenantInfo = tenantInfo;
|
||||
|
||||
|
|
|
|||
|
|
@ -6,3 +6,7 @@ global using System.Text.Json;
|
|||
global using System.Text.Json.Serialization;
|
||||
global using HuanMeng.MiaoYu.Model.EnumModel;
|
||||
global using HuanMeng.MiaoYu.Model.EnumModel.User;
|
||||
global using System.Collections.Concurrent;
|
||||
global using HuanMeng.MiaoYu.Code.SysDictionary.Contract;
|
||||
global using HuanMeng.MiaoYu.Code.SysDictionary;
|
||||
global using HuanMeng.MiaoYu.Code.SysDictionary.DictionaryNetwork;
|
||||
|
|
@ -14,6 +14,7 @@ using Microsoft.Extensions.Configuration;
|
|||
using HuanMeng.DotNetCore.MultiTenant;
|
||||
using HuanMeng.MiaoYu.Model.DbSqlServer.Db_MiaoYu;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using HuanMeng.DotNetCore.MultiTenant.Contract;
|
||||
|
||||
namespace HuanMeng.MiaoYu.Code.MultiTenantUtil
|
||||
{
|
||||
|
|
@ -37,7 +38,7 @@ namespace HuanMeng.MiaoYu.Code.MultiTenantUtil
|
|||
//添加注入全部的多租户配置项
|
||||
//builder.Services.AddSingleton<MiaoYuMultiTenantConfig>(sunnySportsMultiTenantConfig);
|
||||
////添加单个租户的配置项
|
||||
builder.Services.AddScoped<TenantInfo>();
|
||||
builder.Services.AddScoped<ITenantInfo,TenantInfo>();
|
||||
////添加教师端用户
|
||||
//builder.Services.AddScoped<LoginUserModel>();
|
||||
//builder.Services.AddScoped<TenantInfo>();
|
||||
|
|
@ -46,7 +47,7 @@ namespace HuanMeng.MiaoYu.Code.MultiTenantUtil
|
|||
//添加系统数据库
|
||||
builder.Services.AddDbContext<MiaoYuContext>((serviceProvider, options) =>
|
||||
{
|
||||
var m = serviceProvider.GetRequiredService<TenantInfo>();
|
||||
var m = serviceProvider.GetRequiredService<ITenantInfo>();
|
||||
string sunnySportConnectionString = "";
|
||||
if (m != null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using HuanMeng.DotNetCore.MultiTenant;
|
||||
using HuanMeng.DotNetCore.MultiTenant.Contract;
|
||||
|
||||
using Microsoft.AspNetCore.Http;
|
||||
|
||||
|
|
@ -34,7 +35,7 @@ namespace HuanMeng.MiaoYu.Code.MultiTenantUtil
|
|||
/// <returns></returns>
|
||||
public virtual async Task Invoke(HttpContext context,
|
||||
IServiceProvider _serviceProvider,
|
||||
TenantInfo tenantInfo,
|
||||
ITenantInfo tenantInfo,
|
||||
MiaoYuMultiTenantConfig miaoYuMultiTenantConfig
|
||||
)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -19,5 +19,5 @@ namespace HuanMeng.MiaoYu.Code.Other
|
|||
/// </summary>
|
||||
public static class JwtTokenManageExtension
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,44 @@
|
|||
using HuanMeng.MiaoYu.Model.Dto;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace HuanMeng.MiaoYu.Code.SysDictionary.Contract
|
||||
{
|
||||
/// <summary>
|
||||
/// 字典数据
|
||||
/// </summary>
|
||||
public interface IDictionaryInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取全部的字典数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
List<T_Sys_Dictionary> GetDictionaries();
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="dictionaryEnum"></param>
|
||||
/// <returns></returns>
|
||||
T_Sys_Dictionary GetDictionaryNode(T_Sys_DictionaryEnum dictionaryEnum);
|
||||
|
||||
/// <summary>
|
||||
/// 获取对象项目的字段数据
|
||||
/// </summary>
|
||||
/// <param name="ProjectCode"></param>
|
||||
/// <returns></returns>
|
||||
List<T_Sys_Dictionary> GetDictionariesChildNode(string ProjectCode);
|
||||
|
||||
/// <summary>
|
||||
/// 获取对象项目的字段数据
|
||||
/// </summary>
|
||||
/// <param name="dictionaryEnum"></param>
|
||||
/// <returns></returns>
|
||||
List<T_Sys_Dictionary> GetDictionariesChildNode(T_Sys_DictionaryEnum dictionaryEnum);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
using HuanMeng.DotNetCore.MultiTenant.Contract;
|
||||
using HuanMeng.MiaoYu.Model.Dto;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace HuanMeng.MiaoYu.Code.SysDictionary.Contract
|
||||
{
|
||||
/// <summary>
|
||||
/// 字典服务
|
||||
/// </summary>
|
||||
public interface IDictionaryInfoServer
|
||||
{
|
||||
/// <summary>
|
||||
/// 初始化的时候调用
|
||||
/// </summary>
|
||||
Task Initialization();
|
||||
/// <summary>
|
||||
/// 获取全部的字典数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
List<T_Sys_Dictionary> GetDictionaries();
|
||||
|
||||
/// <summary>
|
||||
/// 获取全部的字典数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
List<T_Sys_Dictionary> GetDictionaries(ITenantInfo tenantInfo);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="tenantInfo"></param>
|
||||
/// <returns></returns>
|
||||
List<T_Sys_Dictionary> this[ITenantInfo tenantInfo] { get; }
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,82 @@
|
|||
using HuanMeng.MiaoYu.Code.MultiTenantUtil;
|
||||
using HuanMeng.MiaoYu.Code.SysDictionary.Contract;
|
||||
using HuanMeng.MiaoYu.Code.SysDictionary.DictionaryNetwork;
|
||||
using HuanMeng.MiaoYu.Model.Dto;
|
||||
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace HuanMeng.MiaoYu.Code.SysDictionary
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public static class DictionaryInfoExtend
|
||||
{
|
||||
public static void AddDictionaryInfo(this IHostApplicationBuilder builder)
|
||||
{
|
||||
builder.Services.AddSingleton<IDictionaryInfoServer, DictionaryInfoServerNetwork>();
|
||||
|
||||
builder.Services.AddScoped<IDictionaryInfo, DictionaryInfoNetwork>();
|
||||
builder.Services.AddHostedService<DictionaryInfoExtendServer>();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前对象下的所有集合
|
||||
/// </summary>
|
||||
/// <param name="dictionarie"></param>
|
||||
/// <param name="dictionaries"></param>
|
||||
/// <returns></returns>
|
||||
public static List<T_Sys_Dictionary> GetChildDictionaries(this T_Sys_Dictionary dictionarie, List<T_Sys_Dictionary> dictionaries)
|
||||
{
|
||||
List<T_Sys_Dictionary> list = new List<T_Sys_Dictionary>();
|
||||
dictionaries.Where(it => it.ParentId == dictionarie.Id).ToList()?.ForEach(it =>
|
||||
{
|
||||
list.Add(it);
|
||||
var _list = it.GetChildDictionaries(list);
|
||||
list.AddRange(_list);
|
||||
});
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前对象下的所有集合
|
||||
/// </summary>
|
||||
/// <param name="dictionarie"></param>
|
||||
/// <param name="dictionaries"></param>
|
||||
/// <returns></returns>
|
||||
public static List<T_Sys_Dictionary> GetChildDictionariesFind(this T_Sys_Dictionary dictionarie, List<T_Sys_Dictionary> dictionaries)
|
||||
{
|
||||
List<T_Sys_Dictionary> list = new List<T_Sys_Dictionary>();
|
||||
|
||||
return dictionaries.Where(it => it.ParentId == dictionarie.Id).OrderBy(it=>it.Sort).ToList();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="dictionaryInfoServer"></param>
|
||||
public class DictionaryInfoExtendServer(IDictionaryInfoServer dictionaryInfoServer) : IHostedService
|
||||
{
|
||||
public async Task StartAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
await dictionaryInfoServer.Initialization();
|
||||
|
||||
}
|
||||
|
||||
public Task StopAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
using HuanMeng.DotNetCore.MultiTenant;
|
||||
using HuanMeng.DotNetCore.MultiTenant.Contract;
|
||||
using HuanMeng.MiaoYu.Code.SysDictionary.Contract;
|
||||
using HuanMeng.MiaoYu.Model.Dto;
|
||||
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace HuanMeng.MiaoYu.Code.SysDictionary.DictionaryNetwork
|
||||
{
|
||||
/// <summary>
|
||||
/// 字典数据
|
||||
/// </summary>
|
||||
/// <param name="dictionaryInfoServer"></param>
|
||||
/// <param name="tenantInfo"></param>
|
||||
public class DictionaryInfoNetwork(IDictionaryInfoServer dictionaryInfoServer, ITenantInfo tenantInfo) : IDictionaryInfo
|
||||
{
|
||||
private List<T_Sys_Dictionary>? _dictionaryInfo = null;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public List<T_Sys_Dictionary> DictionaryInfo
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_dictionaryInfo == null)
|
||||
{
|
||||
_dictionaryInfo = dictionaryInfoServer[tenantInfo];
|
||||
}
|
||||
return _dictionaryInfo;
|
||||
}
|
||||
}
|
||||
|
||||
public List<T_Sys_Dictionary> GetDictionaries()
|
||||
{
|
||||
|
||||
return DictionaryInfo;
|
||||
}
|
||||
|
||||
public List<T_Sys_Dictionary> GetDictionariesChildNode(string ProjectCode)
|
||||
{
|
||||
List<T_Sys_Dictionary> t_Sys_Dictionaries = new List<T_Sys_Dictionary>();
|
||||
|
||||
var list = DictionaryInfo.Where(it => it.ProjectCode == ProjectCode).OrderBy(it => it.Sort).ToList();
|
||||
foreach (var item in list)
|
||||
{
|
||||
var _list = item.GetChildDictionariesFind(DictionaryInfo);
|
||||
t_Sys_Dictionaries.AddRange(_list);
|
||||
}
|
||||
return t_Sys_Dictionaries;
|
||||
}
|
||||
|
||||
public List<T_Sys_Dictionary> GetDictionariesChildNode(T_Sys_DictionaryEnum dictionaryEnum)
|
||||
{
|
||||
return GetDictionariesChildNode(dictionaryEnum.ToString());
|
||||
}
|
||||
|
||||
public T_Sys_Dictionary GetDictionaryNode(T_Sys_DictionaryEnum dictionaryEnum)
|
||||
{
|
||||
return DictionaryInfo.Where(it => it.ProjectCode == dictionaryEnum.ToString()).OrderBy(it => it.Sort).FirstOrDefault();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,156 @@
|
|||
using HuanMeng.DotNetCore.MultiTenant.Contract;
|
||||
using HuanMeng.MiaoYu.Code.SysDictionary.Contract;
|
||||
using HuanMeng.MiaoYu.Model.Dto;
|
||||
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http.Json;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace HuanMeng.MiaoYu.Code.SysDictionary.DictionaryNetwork
|
||||
{
|
||||
/// <summary>
|
||||
/// 字典服务
|
||||
/// </summary>
|
||||
public class DictionaryInfoServerNetwork : IDictionaryInfoServer
|
||||
{
|
||||
private IConfiguration configuration;
|
||||
private IHttpClientFactory httpClientFactory;
|
||||
/// <summary>
|
||||
/// 数据字典
|
||||
/// </summary>
|
||||
/// <param name="configuration"></param>
|
||||
/// <param name="httpClientFactory"></param>
|
||||
public DictionaryInfoServerNetwork(IConfiguration configuration, IHttpClientFactory httpClientFactory)
|
||||
|
||||
{
|
||||
this.configuration = configuration;
|
||||
this.httpClientFactory = httpClientFactory;
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//ConcurrentDictionary<Guid,List<T_Sys_Dictionary>> Dictionarys { get; set; }
|
||||
ConcurrentDictionary<string, T_Sys_Dictionary> Dictionarys { get; set; } = new ConcurrentDictionary<string, T_Sys_Dictionary>();
|
||||
public List<T_Sys_Dictionary> GetDictionaries()
|
||||
{
|
||||
return Dictionarys.Values.ToList();
|
||||
}
|
||||
|
||||
|
||||
public List<T_Sys_Dictionary> GetDictionaries(ITenantInfo tenantInfo)
|
||||
{
|
||||
return Dictionarys.Values.Where(it => it.TenantId == tenantInfo.TenantId).ToList();
|
||||
|
||||
}
|
||||
|
||||
public List<T_Sys_Dictionary> this[ITenantInfo tenantInfo] => GetDictionaries(tenantInfo);
|
||||
|
||||
/// <summary>
|
||||
/// 请求地址
|
||||
/// </summary>
|
||||
private string? dictionaryUrl;
|
||||
/// <summary>
|
||||
/// 初始化节点
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task Initialization()
|
||||
{
|
||||
if (string.IsNullOrEmpty(dictionaryUrl))
|
||||
{
|
||||
dictionaryUrl = configuration.GetSection("SystemConfig:DictionaryUrl").Get<string>() ?? "";
|
||||
}
|
||||
|
||||
using var client = httpClientFactory.CreateClient();
|
||||
var request = await client.GetAsync(dictionaryUrl);
|
||||
if (request.IsSuccessStatusCode)
|
||||
{
|
||||
var json = await request.Content.ReadAsStringAsync();
|
||||
if (string.IsNullOrEmpty(json))
|
||||
{
|
||||
return;
|
||||
}
|
||||
var jobj = JsonConvert.DeserializeObject<JObject>(json);
|
||||
if (jobj == null || jobj?["code"]?.ToString() != "200")
|
||||
{
|
||||
return;
|
||||
}
|
||||
var _data = jobj["data"]?.ToString();
|
||||
if (string.IsNullOrEmpty(_data))
|
||||
{
|
||||
return;
|
||||
}
|
||||
var list = JsonConvert.DeserializeObject<List<T_Sys_Dictionary>>(_data);
|
||||
if (list == null || list.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
InitDictionary(list, null);
|
||||
//查找系统节点
|
||||
var xiangmu = list.Where(it => (it.NodePath ?? "").StartsWith("huanmeng:tenant:") && it.NodeDepth == 1).ToList();
|
||||
foreach (var item in xiangmu)
|
||||
{
|
||||
var nodePath = item.NodePath;
|
||||
//获取当前节点下的所有子节点
|
||||
var nodeList = list.Where(it => (it.NodePath ?? "").StartsWith(nodePath)).ToList();
|
||||
//初始化租户Id
|
||||
var tenantIdStr = item.Value ?? "";
|
||||
if (string.IsNullOrEmpty(tenantIdStr))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (Guid.TryParse(tenantIdStr, out var tenantId))
|
||||
{
|
||||
|
||||
item.TenantId = tenantId;
|
||||
//赋值
|
||||
nodeList?.ForEach(it => it.TenantId = tenantId);
|
||||
}
|
||||
}
|
||||
//赋值数据
|
||||
ConcurrentDictionary<string, T_Sys_Dictionary> dictionarys = new ConcurrentDictionary<string, T_Sys_Dictionary>();
|
||||
list?.Where(it => !string.IsNullOrEmpty(it.NodePath)).ToList()?.ForEach(item =>
|
||||
{
|
||||
dictionarys.TryAdd(item.NodePath ?? "", item);
|
||||
});
|
||||
Dictionarys = dictionarys;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 初始化数据
|
||||
/// </summary>
|
||||
/// <param name="dictionaries"></param>
|
||||
/// <param name="dictionary"></param>
|
||||
private void InitDictionary(List<T_Sys_Dictionary> dictionaries, T_Sys_Dictionary? dictionary)
|
||||
{
|
||||
|
||||
List<T_Sys_Dictionary> _dictionaries = null;
|
||||
if (dictionary == null)
|
||||
{
|
||||
_dictionaries = dictionaries.Where(it => it.ParentId == null || it.ParentId == 0).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
_dictionaries = dictionaries.Where(item => item.ParentId == dictionary.Id).ToList();
|
||||
}
|
||||
_dictionaries?.ForEach(it =>
|
||||
{
|
||||
it.ParentPath = (dictionary?.NodePath ?? "huanmeng");
|
||||
it.NodePath = (dictionary?.NodePath ?? "huanmeng") + ":" + it.Code;
|
||||
it.NodeDepth = (dictionary?.NodeDepth ?? -1) + 1;
|
||||
|
||||
InitDictionary(dictionaries, it);
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -38,6 +38,11 @@ public partial class MiaoYuContext : MultiTenantDbContext//DbContext
|
|||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 发现页类别菜单
|
||||
/// </summary>
|
||||
public virtual DbSet<T_Category_Child_Menu> T_Category_Child_Menu { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 人物表
|
||||
/// </summary>
|
||||
|
|
@ -163,6 +168,36 @@ public partial class MiaoYuContext : MultiTenantDbContext//DbContext
|
|||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.Entity<T_Category_Child_Menu>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("PK__T_Catego__3214EC07464F6CD1");
|
||||
|
||||
entity.ToTable(tb => tb.HasComment("发现页类别菜单"));
|
||||
|
||||
entity.Property(e => e.ActionId)
|
||||
.HasMaxLength(200)
|
||||
.HasComment("动作Id");
|
||||
entity.Property(e => e.ActionType)
|
||||
.HasMaxLength(200)
|
||||
.HasComment("动作类型");
|
||||
entity.Property(e => e.ImageId).HasComment("图片Id");
|
||||
entity.Property(e => e.ImageUrl)
|
||||
.HasMaxLength(300)
|
||||
.HasComment("图片补位");
|
||||
entity.Property(e => e.Name)
|
||||
.HasMaxLength(100)
|
||||
.HasComment("名称");
|
||||
entity.Property(e => e.OrderById).HasComment("排序");
|
||||
entity.Property(e => e.Type)
|
||||
.HasMaxLength(20)
|
||||
.HasComment("菜单类型(banner,热门推荐,热门小说)");
|
||||
//添加全局筛选器
|
||||
if (this.TenantInfo != null)
|
||||
{
|
||||
entity.HasQueryFilter(it => it.TenantId == this.TenantInfo.TenantId);
|
||||
}
|
||||
});
|
||||
|
||||
modelBuilder.Entity<T_Character>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("PK__T_Charac__3214EC070A8D79B3");
|
||||
|
|
|
|||
|
|
@ -0,0 +1,47 @@
|
|||
|
||||
namespace HuanMeng.MiaoYu.Model.DbSqlServer.Db_MiaoYu;
|
||||
|
||||
/// <summary>
|
||||
/// 发现页类别菜单
|
||||
/// </summary>
|
||||
public partial class T_Category_Child_Menu: MultiTenantEntity
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 菜单类型(banner,热门推荐,热门小说)
|
||||
/// </summary>
|
||||
public string Type { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 名称
|
||||
/// </summary>
|
||||
public string Name { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 动作Id
|
||||
/// </summary>
|
||||
public string ActionId { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 动作类型
|
||||
/// </summary>
|
||||
public string ActionType { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 图片Id
|
||||
/// </summary>
|
||||
public int ImageId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 排序
|
||||
/// </summary>
|
||||
public int OrderById { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 图片补位
|
||||
/// </summary>
|
||||
public string? ImageUrl { get; set; }
|
||||
|
||||
public bool IsEnabled { get; set; }
|
||||
}
|
||||
73
src/0-core/HuanMeng.MiaoYu.Model/Dto/T_Sys_Dictionary.cs
Normal file
73
src/0-core/HuanMeng.MiaoYu.Model/Dto/T_Sys_Dictionary.cs
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace HuanMeng.MiaoYu.Model.Dto
|
||||
{
|
||||
/// <summary>
|
||||
/// 数据字典
|
||||
/// </summary>
|
||||
public class T_Sys_Dictionary
|
||||
{
|
||||
/// <summary>
|
||||
/// Id
|
||||
/// </summary>
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 租户ID
|
||||
/// </summary>
|
||||
public Guid TenantId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 排序号
|
||||
/// </summary>
|
||||
public int Sort { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 编码
|
||||
/// </summary>
|
||||
public string? Code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 分组名称/键
|
||||
/// </summary>
|
||||
public string? Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 值
|
||||
/// </summary>
|
||||
public string? Value { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 父级Id
|
||||
/// </summary>
|
||||
public int? ParentId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 扩展属性
|
||||
/// </summary>
|
||||
public string? ExtendValue { get; set; }
|
||||
/// <summary>
|
||||
/// 项目编码
|
||||
/// </summary>
|
||||
public string? ProjectCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 路径
|
||||
/// </summary>
|
||||
public string? NodePath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 当前节点路径
|
||||
/// </summary>
|
||||
public string ParentPath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 节点深度
|
||||
/// </summary>
|
||||
public int? NodeDepth { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace HuanMeng.MiaoYu.Model.EnumModel
|
||||
{
|
||||
/// <summary>
|
||||
/// 字典数据类型
|
||||
/// </summary>
|
||||
public enum T_Sys_DictionaryEnum
|
||||
{
|
||||
/// <summary>
|
||||
/// 项目
|
||||
/// </summary>
|
||||
tenant = 0,
|
||||
/// <summary>
|
||||
/// 图片类型
|
||||
/// </summary>
|
||||
image_types = 1,
|
||||
/// <summary>
|
||||
/// 菜单
|
||||
/// </summary>
|
||||
categorymenu = 200,
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -17,6 +17,7 @@ using HuanMeng.MiaoYu.Model.Dto;
|
|||
using System.Text.Json.Serialization;
|
||||
using HuanMeng.DotNetCore.Json;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using HuanMeng.MiaoYu.Code.SysDictionary;
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
//Log.Logger = new LoggerConfiguration()
|
||||
// .WriteTo.Console()
|
||||
|
|
@ -115,6 +116,8 @@ builder.AddTencent();
|
|||
builder.AddMemoryVerificationCode();
|
||||
//添加jwt验证
|
||||
builder.AddJwtConfig();
|
||||
//添加数据字典
|
||||
builder.AddDictionaryInfo();
|
||||
//builder.Services.AddMemoryCache();
|
||||
//builder.Services.AddScoped<CharacterInfoBaseCache>();
|
||||
////builder.Services.AddScoped<ChatBLL>();
|
||||
|
|
|
|||
|
|
@ -60,6 +60,9 @@
|
|||
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
"SystemConfig": {
|
||||
"DictionaryUrl": "https://adminapi.shhuanmeng.com/api/v1/admin/SysDictionary/GetList"
|
||||
},
|
||||
//服务器配置
|
||||
"Kestrel": {
|
||||
"Endpoints": {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user