提交代码
This commit is contained in:
parent
bdcf89bc35
commit
2bdd14da94
|
|
@ -84,7 +84,7 @@ namespace HuanMeng.MiaoYu.Code.Base
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (_mapper == null)
|
if (_HttpContextAccessor == null)
|
||||||
{
|
{
|
||||||
_HttpContextAccessor = _serviceProvider.GetRequiredService<IHttpContextAccessor>();
|
_HttpContextAccessor = _serviceProvider.GetRequiredService<IHttpContextAccessor>();
|
||||||
}
|
}
|
||||||
|
|
@ -184,25 +184,31 @@ namespace HuanMeng.MiaoYu.Code.Base
|
||||||
var accessToken = HttpContextAccessor.HttpContext.GetTokenAsync("Bearer", "access_token").Result;
|
var accessToken = HttpContextAccessor.HttpContext.GetTokenAsync("Bearer", "access_token").Result;
|
||||||
if (string.IsNullOrEmpty(accessToken))
|
if (string.IsNullOrEmpty(accessToken))
|
||||||
{
|
{
|
||||||
|
_userInfo = new RequestUserInfo()
|
||||||
|
{
|
||||||
|
UserId = 0
|
||||||
|
};
|
||||||
}
|
}
|
||||||
var (principal, jwtToken) = JwtAuthManager.DecodeJwtToken(accessToken);
|
else
|
||||||
if (jwtToken == null || !jwtToken.Header.Alg.Equals(SecurityAlgorithms.HmacSha256Signature))
|
|
||||||
{
|
{
|
||||||
throw new SecurityTokenException("无效的token");
|
var (principal, jwtToken) = JwtAuthManager.DecodeJwtToken(accessToken);
|
||||||
|
if (jwtToken == null || !jwtToken.Header.Alg.Equals(SecurityAlgorithms.HmacSha256Signature))
|
||||||
|
{
|
||||||
|
throw new SecurityTokenException("无效的token");
|
||||||
|
}
|
||||||
|
var userIdStr = principal.FindFirst("UserId")?.Value;
|
||||||
|
if (string.IsNullOrEmpty(userIdStr))
|
||||||
|
{
|
||||||
|
throw new SecurityTokenException("无效的token");
|
||||||
|
}
|
||||||
|
var nickName = principal.FindFirst("NickName")?.Value;
|
||||||
|
var userId = int.Parse(userIdStr);
|
||||||
|
_userInfo = new RequestUserInfo()
|
||||||
|
{
|
||||||
|
UserId = userId,
|
||||||
|
NickName = nickName
|
||||||
|
};
|
||||||
}
|
}
|
||||||
var userIdStr = principal.FindFirst("UserId")?.Value;
|
|
||||||
if (string.IsNullOrEmpty(userIdStr))
|
|
||||||
{
|
|
||||||
throw new SecurityTokenException("无效的token");
|
|
||||||
}
|
|
||||||
var nickName = principal.FindFirst("NickName")?.Value;
|
|
||||||
var userId = int.Parse(userIdStr);
|
|
||||||
_userInfo = new RequestUserInfo()
|
|
||||||
{
|
|
||||||
UserId = userId,
|
|
||||||
NickName = nickName
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
return _userInfo;
|
return _userInfo;
|
||||||
}
|
}
|
||||||
|
|
@ -221,7 +227,7 @@ namespace HuanMeng.MiaoYu.Code.Base
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 缓存实现类
|
#region 缓存实现类
|
||||||
private MiaoYuCache? _miaoYuCache ; //new MiaoYuCache(Dao, Mapper);
|
private MiaoYuCache? _miaoYuCache; //new MiaoYuCache(Dao, Mapper);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 妙语实现类
|
/// 妙语实现类
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
@ -34,19 +36,19 @@ namespace HuanMeng.MiaoYu.Code.Cache
|
||||||
{
|
{
|
||||||
if (_dataList == null)
|
if (_dataList == null)
|
||||||
{
|
{
|
||||||
|
var tempDataList = MemoryCacheHelper.GetCache<List<T>>(key);
|
||||||
_dataList = MemoryCacheHelper.GetCache<List<T>>(key);
|
if (tempDataList == null)
|
||||||
if (_dataList == null)
|
|
||||||
{
|
{
|
||||||
lock (lockObj)
|
lock (lockObj)
|
||||||
{
|
{
|
||||||
if (_dataList == null)
|
if (tempDataList == null)
|
||||||
{
|
{
|
||||||
_dataList = GetDataList();
|
tempDataList = GetDataList();
|
||||||
MemoryCacheHelper.SetCache(key, _dataList, cacheTime);
|
MemoryCacheHelper.SetCache(key, tempDataList, cacheTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
_dataList = JsonConvert.DeserializeObject<List<T>>(JsonConvert.SerializeObject(tempDataList));
|
||||||
}
|
}
|
||||||
return _dataList ?? new List<T>();
|
return _dataList ?? new List<T>();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -81,11 +81,39 @@ namespace HuanMeng.MiaoYu.Code.Cache
|
||||||
{
|
{
|
||||||
if (CharacterCache == null)
|
if (CharacterCache == null)
|
||||||
{
|
{
|
||||||
|
|
||||||
CharacterCache = new CharacterEntityCache(dao, mapper);
|
CharacterCache = new CharacterEntityCache(dao, mapper);
|
||||||
}
|
}
|
||||||
return CharacterCache.DataList ?? new List<CharacterCache>();
|
return CharacterCache.DataList ?? new List<CharacterCache>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region 图片缓存表
|
||||||
|
/// <summary>
|
||||||
|
/// 图片缓存表
|
||||||
|
/// </summary>
|
||||||
|
private static object ImageConfigLock = new object();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 图片缓存表
|
||||||
|
/// </summary>
|
||||||
|
public MiaoYuDataEntityCache<T_Image_Config>? ImageConfigCache { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 图片
|
||||||
|
/// </summary>
|
||||||
|
public List<T_Image_Config> ImageConfigList
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (ImageConfigCache == null)
|
||||||
|
{
|
||||||
|
ImageConfigCache = new MiaoYuDataEntityCache<T_Image_Config>(dao, ImageConfigLock);
|
||||||
|
}
|
||||||
|
return ImageConfigCache.DataList ?? new List<T_Image_Config>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
using AutoMapper;
|
using AutoMapper;
|
||||||
|
|
||||||
using HuanMeng.MiaoYu.Code.DataAccess;
|
using HuanMeng.MiaoYu.Code.DataAccess;
|
||||||
|
using HuanMeng.MiaoYu.Code.Other;
|
||||||
using HuanMeng.MiaoYu.Model.Dto.Character;
|
using HuanMeng.MiaoYu.Model.Dto.Character;
|
||||||
|
using HuanMeng.MiaoYu.Model.Dto.Label;
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
@ -21,37 +23,69 @@ namespace HuanMeng.MiaoYu.Code.Cache.Special
|
||||||
/// 锁
|
/// 锁
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static object CharacterCacheLock = new object();
|
private static object CharacterCacheLock = new object();
|
||||||
|
private static object ImageLock = new object();
|
||||||
|
private static object T_Character_LabelLock = new object();
|
||||||
|
private static object T_Character_Label_RelationLock = new object();
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取缓存数据
|
/// 获取缓存数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public override List<CharacterCache> GetDataList()
|
public override List<CharacterCache> GetDataList()
|
||||||
{
|
{
|
||||||
List<CharacterCache> characterCaches = null;
|
List<CharacterCache> characterCaches = new List<CharacterCache>();
|
||||||
//读取角色表
|
//读取角色表
|
||||||
var characters = _dao.daoDbMiaoYu.context.T_Character.ToList();
|
var characters = _dao.daoDbMiaoYu.context.T_Character.ToList();
|
||||||
if (characters == null)
|
if (characters == null)
|
||||||
{
|
{
|
||||||
return new List<CharacterCache>();
|
return characterCaches;
|
||||||
}
|
}
|
||||||
characterCaches = mapper.Map<List<CharacterCache>>(characters);
|
characterCaches = mapper.Map<List<CharacterCache>>(characters);
|
||||||
|
string sqlString = $"select TOP 100 CharacterId,count(DISTINCT UserId ) UserCount from T_User_Char where isdelete=0 and TenantId='{_dao.daoDbMiaoYu.context.TenantInfo?.TenantId}' GROUP BY CharacterId";
|
||||||
|
//获取查看次数
|
||||||
|
var characteChatCounts = _dao.daoDbMiaoYu.SqlQueryList<CharacteChatCountModel>(sqlString);
|
||||||
//查询配置表
|
//查询配置表
|
||||||
var modelConfigs = _dao.daoDbMiaoYu.context.T_Model_Config.ToList();
|
var modelConfigs = _dao.daoDbMiaoYu.context.T_Model_Config.ToList();
|
||||||
|
var ImageConfigCache = new MiaoYuDataEntityCache<T_Image_Config>(_dao, ImageLock);
|
||||||
|
var images = ImageConfigCache.DataList;
|
||||||
|
//标签
|
||||||
|
var labelCache = new MiaoYuDataEntityCache<T_Character_Label>(_dao, T_Character_LabelLock);
|
||||||
|
var labels = labelCache.DataList;
|
||||||
|
var labelRelationCache = new MiaoYuDataEntityCache<T_Character_Label_Relation>(_dao, T_Character_Label_RelationLock);
|
||||||
|
var labelRelations = labelRelationCache.DataList;
|
||||||
|
|
||||||
foreach (var characterCache in characterCaches)
|
foreach (var characterCache in characterCaches)
|
||||||
{
|
{
|
||||||
var modelConfig = modelConfigs.FirstOrDefault(it => it.Id == characterCache.ModelConfigId);
|
var modelConfig = modelConfigs.FirstOrDefault(it => it.Id == characterCache.ModelConfigId);
|
||||||
if (modelConfig != null)
|
if (modelConfig != null)
|
||||||
{
|
{
|
||||||
characterCache.ModelConfig = modelConfig;
|
characterCache.ModelConfig = modelConfig;
|
||||||
|
//查询图片
|
||||||
|
characterCache.IconImage = images.GetImageUrl(characterCache.IconImg ?? 0);
|
||||||
|
characterCache.BgImage = images.GetImageUrl(characterCache.BgImg ?? 0);
|
||||||
|
var c = characteChatCounts.FirstOrDefault(it => it.CharacterId == characterCache.Id);
|
||||||
|
if (c != null)
|
||||||
|
{
|
||||||
|
characterCache.LookCount = c.UserCount;
|
||||||
|
}
|
||||||
|
var characterLabelIds = labelRelations.Where(it => it.CharacterId == characterCache.Id).Select(it => it.CharacterLabelId).ToList();
|
||||||
|
if (characterLabelIds.Count > 0)
|
||||||
|
{
|
||||||
|
var lab = labels.Where(it => characterLabelIds.Contains(it.Id)).ToList();
|
||||||
|
var labs = mapper.Map<List<LabelDto>>(lab);
|
||||||
|
characterCache.Label = labs;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
characterCache.Label = new List<LabelDto>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
//移除没有配置模型的类
|
//移除没有配置模型的类
|
||||||
characterCaches.Where(it => it.ModelConfig == null).ToList().ForEach(characterCache =>
|
characterCaches.Where(it => it.ModelConfig == null).ToList().ForEach(characterCache =>
|
||||||
{
|
{
|
||||||
characterCaches.Remove(characterCache);
|
characterCaches.Remove(characterCache);
|
||||||
});
|
});
|
||||||
|
|
||||||
return characterCaches;
|
return characterCaches;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,13 @@
|
||||||
|
|
||||||
|
|
||||||
|
using AutoMapper;
|
||||||
|
|
||||||
|
using HuanMeng.DotNetCore.Base;
|
||||||
|
using HuanMeng.MiaoYu.Model.Dto.Character;
|
||||||
|
using HuanMeng.MiaoYu.Model.Dto.Chat;
|
||||||
|
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
@ -16,20 +26,74 @@ namespace HuanMeng.MiaoYu.Code.Character
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
/// 首页获取角色列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public Task<object> GetCharacter(int index)
|
public async Task<BaseResponse<List<CharacterInfoDto>>> GetHomeCharacter(RequestCharacterInfoPage requestCharacterInfo)
|
||||||
{
|
{
|
||||||
|
var index = requestCharacterInfo.Index ?? 0;
|
||||||
var charactersList = MiaoYuCache.CharactersList.Where(it => it.Visibility).ToList();
|
var size = requestCharacterInfo.Size ?? 10;
|
||||||
|
var charactersList = MiaoYuCache.CharacterList.OrderByDescending(it => it.LookCount)
|
||||||
|
.Skip((index - 1) * size).Take(size).ToList();
|
||||||
if (charactersList.Count == 0)
|
if (charactersList.Count == 0)
|
||||||
{
|
{
|
||||||
return null;
|
return new BaseResponse<List<CharacterInfoDto>>();
|
||||||
}
|
}
|
||||||
|
var list = Mapper.Map<List<CharacterInfoDto>>(charactersList);
|
||||||
return null;
|
//不是游客
|
||||||
|
if (_UserId != 0)
|
||||||
|
{
|
||||||
|
List<int> characterIds = list.Select(it => it.CharacterId).ToList();
|
||||||
|
//获取亲密值
|
||||||
|
var intimacys = await Dao.daoDbMiaoYu.context.T_Character_User_Intimacy.Where(it => it.UserId == _UserId
|
||||||
|
&& characterIds.Contains(it.CharacterId)).ToListAsync();
|
||||||
|
list.ForEach(it =>
|
||||||
|
{
|
||||||
|
it.Intimacy = intimacys.FirstOrDefault(item => item.CharacterId == it.CharacterId)?.IntimacyValue ?? 0;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return new BaseResponse<List<CharacterInfoDto>>(ResonseCode.Success, "", list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取角色详情
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="requestCharacterInfo"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<BaseResponse<CharacterInfoDto>> GetCharacterInfo(RequestCharacterInfo requestCharacterInfo)
|
||||||
|
{
|
||||||
|
var charactersinfo = MiaoYuCache.CharacterList.FirstOrDefault(it => it.Id == requestCharacterInfo.CharacterId);
|
||||||
|
if (charactersinfo == null)
|
||||||
|
{
|
||||||
|
return new BaseResponse<CharacterInfoDto>();
|
||||||
|
}
|
||||||
|
var info = Mapper.Map<CharacterInfoDto>(charactersinfo);
|
||||||
|
//不是游客
|
||||||
|
if (_UserId != 0)
|
||||||
|
{
|
||||||
|
//获取亲密值
|
||||||
|
var intimacys = await Dao.daoDbMiaoYu.context.T_Character_User_Intimacy.Where(it => it.UserId == _UserId
|
||||||
|
&& it.CharacterId == info.CharacterId).FirstOrDefaultAsync();
|
||||||
|
info.Intimacy = intimacys?.IntimacyValue ?? 0;
|
||||||
|
}
|
||||||
|
return new BaseResponse<CharacterInfoDto>(ResonseCode.Success, "", info);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取全部角色的Id
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public BaseResponse<List<int>> GetCharacters()
|
||||||
|
{
|
||||||
|
Random rng = new Random();
|
||||||
|
var charactersIds = MiaoYuCache.CharacterList.Select(it => it.Id).OrderBy(x => rng.Next()).ToList();
|
||||||
|
if (charactersIds == null)
|
||||||
|
{
|
||||||
|
charactersIds = new List<int>();
|
||||||
|
}
|
||||||
|
return new BaseResponse<List<int>>(ResonseCode.Success, "", charactersIds);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
using HuanMeng.DotNetCore.Base;
|
using HuanMeng.DotNetCore.Base;
|
||||||
using HuanMeng.MiaoYu.Code.Cache;
|
using HuanMeng.MiaoYu.Code.Cache;
|
||||||
using HuanMeng.MiaoYu.Model.DbSqlServer.Db_MiaoYu;
|
using HuanMeng.MiaoYu.Model.DbSqlServer.Db_MiaoYu;
|
||||||
using HuanMeng.MiaoYu.Model.Dto.Home;
|
|
||||||
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
|
||||||
29
src/0-core/HuanMeng.MiaoYu.Code/Other/ImageExtend.cs
Normal file
29
src/0-core/HuanMeng.MiaoYu.Code/Other/ImageExtend.cs
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace HuanMeng.MiaoYu.Code.Other
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 图片扩展类
|
||||||
|
/// </summary>
|
||||||
|
public static class ImageExtend
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 获取图片地址
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="configs"></param>
|
||||||
|
/// <param name="imageId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string GetImageUrl(this List<T_Image_Config> configs, int imageId)
|
||||||
|
{
|
||||||
|
if (imageId > 0 && configs != null && configs.Count > 0)
|
||||||
|
{
|
||||||
|
return configs.FirstOrDefault(it => it.ImageId == imageId)?.Url ?? "";
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -180,12 +180,8 @@ public partial class MiaoYuContext : MultiTenantDbContext//DbContext
|
||||||
|
|
||||||
entity.ToTable(tb => tb.HasComment("关联角色和标签"));
|
entity.ToTable(tb => tb.HasComment("关联角色和标签"));
|
||||||
|
|
||||||
entity.Property(e => e.Id)
|
entity.Property(e => e.Id).HasComment("人物和标签的关联id");
|
||||||
.ValueGeneratedNever()
|
entity.Property(e => e.CharacterId).HasComment("人物Id");
|
||||||
.HasComment("人物和标签的关联id");
|
|
||||||
entity.Property(e => e.CharacterId_)
|
|
||||||
.HasComment("人物Id")
|
|
||||||
.HasColumnName("CharacterId ");
|
|
||||||
entity.Property(e => e.CharacterLabelId).HasComment("人物标签id");
|
entity.Property(e => e.CharacterLabelId).HasComment("人物标签id");
|
||||||
entity.Property(e => e.CreateTime)
|
entity.Property(e => e.CreateTime)
|
||||||
.HasComment("创建时间")
|
.HasComment("创建时间")
|
||||||
|
|
@ -210,12 +206,16 @@ public partial class MiaoYuContext : MultiTenantDbContext//DbContext
|
||||||
entity.Property(e => e.Id)
|
entity.Property(e => e.Id)
|
||||||
.ValueGeneratedNever()
|
.ValueGeneratedNever()
|
||||||
.HasComment("类型id");
|
.HasComment("类型id");
|
||||||
entity.Property(e => e.CreateTime).HasComment("创建时间");
|
entity.Property(e => e.CreateTime)
|
||||||
|
.HasComment("创建时间")
|
||||||
|
.HasColumnType("datetime");
|
||||||
entity.Property(e => e.Name)
|
entity.Property(e => e.Name)
|
||||||
.HasMaxLength(255)
|
.HasMaxLength(255)
|
||||||
.HasComment("类型名称");
|
.HasComment("类型名称");
|
||||||
entity.Property(e => e.TenantId).HasComment("租户id");
|
entity.Property(e => e.TenantId).HasComment("租户id");
|
||||||
entity.Property(e => e.UpdateTime).HasComment("更新时间");
|
entity.Property(e => e.UpdateTime)
|
||||||
|
.HasComment("更新时间")
|
||||||
|
.HasColumnType("datetime");
|
||||||
//添加全局筛选器
|
//添加全局筛选器
|
||||||
if (this.TenantInfo != null)
|
if (this.TenantInfo != null)
|
||||||
{
|
{
|
||||||
|
|
@ -229,9 +229,7 @@ public partial class MiaoYuContext : MultiTenantDbContext//DbContext
|
||||||
|
|
||||||
entity.ToTable(tb => tb.HasComment("存储用户和角色之间的亲密值"));
|
entity.ToTable(tb => tb.HasComment("存储用户和角色之间的亲密值"));
|
||||||
|
|
||||||
entity.Property(e => e.Id)
|
entity.Property(e => e.Id).HasComment("亲密度id");
|
||||||
.ValueGeneratedNever()
|
|
||||||
.HasComment("亲密度id");
|
|
||||||
entity.Property(e => e.CharacterId).HasComment("人物Id");
|
entity.Property(e => e.CharacterId).HasComment("人物Id");
|
||||||
entity.Property(e => e.CreateTime)
|
entity.Property(e => e.CreateTime)
|
||||||
.HasComment("创建时间")
|
.HasComment("创建时间")
|
||||||
|
|
|
||||||
|
|
@ -12,24 +12,24 @@ public partial class T_Character_Label_Relation: MultiTenantEntity
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 人物Id
|
/// 人物Id
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int? CharacterId_ { get; set; }
|
public int CharacterId { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 人物标签id
|
/// 人物标签id
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int? CharacterLabelId { get; set; }
|
public int CharacterLabelId { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建时间
|
/// 创建时间
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DateTime? CreateTime { get; set; }
|
public DateTime CreateTime { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 更新时间
|
/// 更新时间
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DateTime? UpdateTime { get; set; }
|
public DateTime UpdateTime { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,7 @@ public partial class T_Character_Type: MultiTenantEntity
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 类型名称
|
/// 类型名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string? Name { get; set; }
|
public string Name { get; set; } = null!;
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建时间
|
/// 创建时间
|
||||||
|
|
@ -27,4 +26,5 @@ public partial class T_Character_Type: MultiTenantEntity
|
||||||
/// 更新时间
|
/// 更新时间
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DateTime UpdateTime { get; set; }
|
public DateTime UpdateTime { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,25 +16,25 @@ public partial class T_Character_User_Intimacy: MultiTenantEntity
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 人物Id
|
/// 人物Id
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int? CharacterId { get; set; }
|
public int CharacterId { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 用户Id
|
/// 用户Id
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int? UserId { get; set; }
|
public int UserId { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 亲密值
|
/// 亲密值
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int? IntimacyValue { get; set; }
|
public int IntimacyValue { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建时间
|
/// 创建时间
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DateTime? CreateTime { get; set; }
|
public DateTime CreateTime { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 更新时间
|
/// 更新时间
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DateTime? UpdateTime { get; set; }
|
public DateTime UpdateTime { get; set; }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace HuanMeng.MiaoYu.Model.Dto.Character
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 角色聊天次数
|
||||||
|
/// </summary>
|
||||||
|
public class CharacteChatCountModel
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 角色Id
|
||||||
|
/// </summary>
|
||||||
|
public int CharacterId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 聊天次数
|
||||||
|
/// </summary>
|
||||||
|
public int UserCount { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
using AutoMapper;
|
using AutoMapper;
|
||||||
|
|
||||||
using HuanMeng.MiaoYu.Model.DbSqlServer.Db_MiaoYu;
|
using HuanMeng.MiaoYu.Model.DbSqlServer.Db_MiaoYu;
|
||||||
|
using HuanMeng.MiaoYu.Model.Dto.Label;
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
@ -25,5 +26,20 @@ namespace HuanMeng.MiaoYu.Model.Dto.Character
|
||||||
/// 多少人聊天过
|
/// 多少人聊天过
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int LookCount { get; set; }
|
public int LookCount { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 背景图片
|
||||||
|
/// </summary>
|
||||||
|
public string BgImage { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 用户头像url
|
||||||
|
/// </summary>
|
||||||
|
public string IconImage { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 标签
|
||||||
|
/// </summary>
|
||||||
|
public List<LabelDto> Label { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace HuanMeng.MiaoYu.Model.Dto.Character
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public class RequestCharacterInfo
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 角色Id
|
||||||
|
/// </summary>
|
||||||
|
public int CharacterId { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace HuanMeng.MiaoYu.Model.Dto.Character
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 请求参数
|
||||||
|
/// </summary>
|
||||||
|
public class RequestCharacterInfoPage
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 起始页
|
||||||
|
/// </summary>
|
||||||
|
public int? Index { get; set; } = 1;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 页大小
|
||||||
|
/// </summary>
|
||||||
|
public int? Size { get; set; } = 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,10 +1,16 @@
|
||||||
|
using AutoMapper;
|
||||||
|
using AutoMapper.Configuration.Annotations;
|
||||||
|
|
||||||
|
using HuanMeng.MiaoYu.Model.Dto.Character;
|
||||||
|
using HuanMeng.MiaoYu.Model.Dto.Label;
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace HuanMeng.MiaoYu.Model.Dto.Home
|
namespace HuanMeng.MiaoYu.Model.Dto.Chat
|
||||||
{
|
{
|
||||||
public class CharacterInfo
|
public class CharacterInfo
|
||||||
{
|
{
|
||||||
|
|
@ -13,11 +19,13 @@ namespace HuanMeng.MiaoYu.Model.Dto.Home
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 用户和人物信息
|
/// 用户和人物信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[AutoMap(typeof(CharacterCache))]
|
||||||
public class CharacterInfoDto
|
public class CharacterInfoDto
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 头像
|
/// 头像
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[SourceMember(nameof(CharacterCache.IconImage))]
|
||||||
public string Icon { get; set; }
|
public string Icon { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -28,16 +36,19 @@ namespace HuanMeng.MiaoYu.Model.Dto.Home
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 人物id
|
/// 人物id
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[SourceMember(nameof(CharacterCache.Id))]
|
||||||
public int CharacterId { get; set; }
|
public int CharacterId { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 人物名称
|
/// 人物名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[SourceMember(nameof(CharacterCache.Name))]
|
||||||
public string CharacterName { get; set; }
|
public string CharacterName { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 性别
|
/// 性别
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
public int Gender { get; set; }
|
public int Gender { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -48,11 +59,13 @@ namespace HuanMeng.MiaoYu.Model.Dto.Home
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 背景图片
|
/// 背景图片
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[SourceMember(nameof(CharacterCache.BgImage))]
|
||||||
public string BgUrl { get; set; }
|
public string BgUrl { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 简介
|
/// 简介
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
public string Biography { get; set; }
|
public string Biography { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -63,6 +76,7 @@ namespace HuanMeng.MiaoYu.Model.Dto.Home
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 标签
|
/// 标签
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[SourceMember(nameof(CharacterCache.Label))]
|
||||||
public List<LabelDto> Label { get; set; }
|
public List<LabelDto> Label { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -71,14 +85,6 @@ namespace HuanMeng.MiaoYu.Model.Dto.Home
|
||||||
//public int RemainingChatCount { get; set; }
|
//public int RemainingChatCount { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 人物角色标签
|
|
||||||
/// </summary>
|
|
||||||
public class LabelDto
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
public string Name { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 聊天列表信息
|
/// 聊天列表信息
|
||||||
|
|
@ -128,6 +134,6 @@ namespace HuanMeng.MiaoYu.Model.Dto.Home
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 人物id
|
/// 人物id
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int CharacterId { get; set; }
|
public int CharacterId { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
32
src/0-core/HuanMeng.MiaoYu.Model/Dto/Label/LabelDto.cs
Normal file
32
src/0-core/HuanMeng.MiaoYu.Model/Dto/Label/LabelDto.cs
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
using AutoMapper;
|
||||||
|
using AutoMapper.Configuration.Annotations;
|
||||||
|
|
||||||
|
using HuanMeng.MiaoYu.Model.DbSqlServer.Db_MiaoYu;
|
||||||
|
using HuanMeng.MiaoYu.Model.Dto.Character;
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace HuanMeng.MiaoYu.Model.Dto.Label
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 人物角色标签
|
||||||
|
/// </summary>
|
||||||
|
[AutoMap(typeof(T_Character_Label))]
|
||||||
|
public class LabelDto
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public int Id { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 标签名称
|
||||||
|
/// </summary>
|
||||||
|
[SourceMember(nameof(T_Character_Label.LabelName))]
|
||||||
|
public string Name { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||||
|
<AnalysisLevel>latest</AnalysisLevel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
using HuanMeng.DotNetCore.Base;
|
using HuanMeng.DotNetCore.Base;
|
||||||
|
using HuanMeng.MiaoYu.Code.Character;
|
||||||
using HuanMeng.MiaoYu.Code.Chat;
|
using HuanMeng.MiaoYu.Code.Chat;
|
||||||
using HuanMeng.MiaoYu.Model.Dto.Home;
|
using HuanMeng.MiaoYu.Model.Dto.Character;
|
||||||
|
using HuanMeng.MiaoYu.Model.Dto.Chat;
|
||||||
using HuanMeng.MiaoYu.WebApi.Base;
|
using HuanMeng.MiaoYu.WebApi.Base;
|
||||||
|
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
|
@ -29,16 +31,32 @@ namespace HuanMeng.MiaoYu.WebApi.Controllers
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取人物信息
|
/// 获取角色Id
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
public async Task<BaseResponse<List<CharacterInfoDto>>> GetCharacterInfo()
|
public BaseResponse<List<int>> GetCharacterIdList()
|
||||||
{
|
{
|
||||||
|
CharacterBLL characterBLL = new CharacterBLL(ServiceProvider);
|
||||||
|
var obj = characterBLL.GetCharacters();
|
||||||
|
return obj;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取角色人物信息
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet]
|
||||||
|
[AllowAnonymous]
|
||||||
|
public async Task<BaseResponse<CharacterInfoDto>> GetCharacterInfo([FromQuery] RequestCharacterInfo requestCharacterInfo)
|
||||||
|
{
|
||||||
|
CharacterBLL characterBLL = new CharacterBLL(ServiceProvider);
|
||||||
|
var obj = await characterBLL.GetCharacterInfo(requestCharacterInfo);
|
||||||
|
return obj;
|
||||||
|
|
||||||
var obj = JsonConvert.DeserializeObject<List<CharacterInfoDto>>("[{\"Icon\":\"\",\"Intimacy\":10,\"CharacterId\":2,\"CharacterName\":\"许荷姻\",\"Gender\":1,\"LookCount\":2,\"BgUrl\":\"\",\"Biography\":\"你那商业联姻得来的妻子,原本的天才女孩,聪明伶俐,生的漂亮、端庄,不知贵圈多少人梦寐以求的存在。\",\"Prologue\":\"坐在轮椅上,眼神平静的看着你,语气也同样平静)你回来了。饭菜在桌上,我刚刚热了。(说到这,又垂下眸子道)我还做了碗醒酒汤,记得喝\",\"Label\":[{\"Id\":1,\"Name\":\"美女\"},{\"Id\":2,\"Name\":\"二次元\"}],\"RemainingChatCount\":1}]");
|
|
||||||
return new BaseResponse<List<CharacterInfoDto>>(ResonseCode.Success, "", obj);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ using HuanMeng.DotNetCore.CustomExtension;
|
||||||
using HuanMeng.MiaoYu.Code.Cache;
|
using HuanMeng.MiaoYu.Code.Cache;
|
||||||
using HuanMeng.MiaoYu.Code.Chat;
|
using HuanMeng.MiaoYu.Code.Chat;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
|
using HuanMeng.MiaoYu.Model.Dto;
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
//Log.Logger = new LoggerConfiguration()
|
//Log.Logger = new LoggerConfiguration()
|
||||||
// .WriteTo.Console()
|
// .WriteTo.Console()
|
||||||
|
|
@ -30,7 +31,20 @@ builder.Services.AddHttpContextAccessor(); //添加httpContext注入访问
|
||||||
var _myAllowSpecificOrigins = "_myAllowSpecificOrigins";
|
var _myAllowSpecificOrigins = "_myAllowSpecificOrigins";
|
||||||
builder.Services.AddCustomCors(_myAllowSpecificOrigins);
|
builder.Services.AddCustomCors(_myAllowSpecificOrigins);
|
||||||
#endregion
|
#endregion
|
||||||
builder.Services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies().Where(it => it.FullName.Contains("HuanMeng") || it.FullName.Contains("XLib.")).ToList());
|
#region automap
|
||||||
|
var mapperDomain = AppDomain.CurrentDomain.GetAssemblies().Where(it => it.FullName.Contains("HuanMeng") || it.FullName.Contains("XLib.")).ToList();
|
||||||
|
Type type = typeof(ResponseUserInfo);
|
||||||
|
if (type != null)
|
||||||
|
{
|
||||||
|
Assembly assembly = Assembly.GetAssembly(type);
|
||||||
|
if (!mapperDomain.Any(it => it.FullName == assembly.FullName))
|
||||||
|
{
|
||||||
|
mapperDomain.Add(assembly);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
builder.Services.AddAutoMapper(mapperDomain);
|
||||||
|
#endregion
|
||||||
builder.Services.AddControllers();
|
builder.Services.AddControllers();
|
||||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||||
builder.Services.AddEndpointsApiExplorer();
|
builder.Services.AddEndpointsApiExplorer();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user