mirror of
https://gitee.com/ccnetcore/Yi
synced 2026-04-24 02:16:36 +08:00
Compare commits
50 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a50c45f7a3 | ||
|
|
2bc8837155 | ||
|
|
8a6e5abf48 | ||
|
|
8b191330b8 | ||
|
|
0d2f2cb826 | ||
|
|
571df74c43 | ||
|
|
cefde6848d | ||
|
|
551597765c | ||
|
|
5eaffe2ec2 | ||
|
|
2ec7b5f4fd | ||
|
|
4521212a90 | ||
|
|
94834f45c3 | ||
|
|
22ac150acd | ||
|
|
1cc5f2a14f | ||
|
|
d9997eeb28 | ||
|
|
06e77aa8fd | ||
|
|
e9e2228f6e | ||
|
|
d516a381d0 | ||
|
|
4e792ba976 | ||
|
|
f90d3871fa | ||
|
|
6005b9329d | ||
|
|
9d4b3e7d0c | ||
|
|
72795382a1 | ||
|
|
35cdff2afa | ||
|
|
dcf547f513 | ||
|
|
8660d45f36 | ||
|
|
63dd55e7a4 | ||
|
|
40cd89f90c | ||
|
|
901ccc7314 | ||
|
|
629add1e8a | ||
|
|
8b92cd6bed | ||
|
|
e63fb71ef6 | ||
|
|
aa122d2d82 | ||
|
|
5d6bfe36d0 | ||
|
|
26dadd7dae | ||
|
|
520dca6953 | ||
|
|
699f7febe4 | ||
|
|
87a14ebac1 | ||
|
|
29573342b5 | ||
|
|
91b216c06e | ||
|
|
83a6ec1b98 | ||
|
|
c5d636d697 | ||
|
|
3d704220f3 | ||
|
|
b830317608 | ||
|
|
21ff599a4e | ||
|
|
224c2b96e4 | ||
|
|
cbb3510d94 | ||
|
|
0b111852ec | ||
|
|
ff8038a616 | ||
|
|
710ad95eda |
10
README.md
10
README.md
@@ -7,6 +7,12 @@
|
||||
[](https://gitee.com/ccnetcore/Yi)
|
||||
[](https://gitee.com/ccnetcore/Yi)
|
||||
|
||||
本项目 CDN 加速及安全防护由 Tencent EdgeOne 赞助
|
||||
|
||||
[亚洲最佳CDN、边缘和安全解决方案 - Tencent EdgeOne](https://edgeone.ai/zh?from=github)
|
||||
|
||||
<img src="readme/edgeone.png"/>
|
||||
|
||||
[English](README-en.md) | 简体中文
|
||||
****
|
||||
## 🍍 简介:
|
||||
@@ -60,9 +66,9 @@ bbs前端:`docker run -d --name yi.bbs -p 18001:18001 -v /home/Yi/Yi.Bbs.Vue3/
|
||||
|
||||
Yi社区官网网址(Bbs社区正式):[ccnetcore.com](https://ccnetcore.com) (已上线,欢迎加入)
|
||||
|
||||
Rbac后台演示地址:https://ccnetcore.com:1000 (用户cc、密码123456)
|
||||
Rbac后台演示地址:https://data.ccnetcore.com:1000 (用户cc、密码123456)
|
||||
|
||||
Pure后台演示地址:https://ccnetcore.com:1001 (用户cc、密码123456)
|
||||
Pure后台演示地址:https://data.ccnetcore.com:1001 (用户cc、密码123456)
|
||||
|
||||
## 🍏 支持:
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<SatelliteResourceLanguages>en;zh-CN</SatelliteResourceLanguages>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<Version>1.0.0</Version>
|
||||
<NoWarn>$(NoWarn);CS1591;CS8618;CS1998;CS8604;CS8620;CS8600;CS8602</NoWarn>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// MIT 许可证
|
||||
// MIT 许可证
|
||||
//
|
||||
// 版权 © 2020-present 百小僧, 百签科技(广东)有限公司 和所有贡献者
|
||||
//
|
||||
@@ -17,25 +17,25 @@ using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Filters;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using Volo.Abp.AspNetCore.Mvc;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
using Volo.Abp.Validation;
|
||||
using Yi.Framework.Core.Extensions;
|
||||
|
||||
namespace Yi.Framework.AspNetCore.UnifyResult.Fiters;
|
||||
|
||||
/// <summary>
|
||||
/// 友好异常拦截器
|
||||
/// 友好异常拦截器
|
||||
/// </summary>
|
||||
public sealed class FriendlyExceptionFilter : IAsyncExceptionFilter
|
||||
{
|
||||
/// <summary>
|
||||
/// 异常拦截
|
||||
/// 异常拦截
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <returns></returns>
|
||||
public async Task OnExceptionAsync(ExceptionContext context)
|
||||
{
|
||||
|
||||
// 排除 WebSocket 请求处理
|
||||
if (context.HttpContext.IsWebSocketRequest()) return;
|
||||
|
||||
@@ -44,20 +44,23 @@ public sealed class FriendlyExceptionFilter : IAsyncExceptionFilter
|
||||
|
||||
// 解析异常信息
|
||||
var exceptionMetadata = GetExceptionMetadata(context);
|
||||
|
||||
IUnifyResultProvider unifyResult = context.GetRequiredService<IUnifyResultProvider>();
|
||||
var unifyResult = context.GetRequiredService<IUnifyResultProvider>();
|
||||
// 执行规范化异常处理
|
||||
context.Result = unifyResult.OnException(context, exceptionMetadata);
|
||||
|
||||
|
||||
// 创建日志记录器
|
||||
var logger = context.HttpContext.RequestServices.GetRequiredService<ILogger<FriendlyExceptionFilter>>();
|
||||
|
||||
var errorMsg = "";
|
||||
if (exceptionMetadata.Errors != null) errorMsg = "\n" + JsonConvert.SerializeObject(exceptionMetadata.Errors);
|
||||
|
||||
|
||||
// 记录拦截日常
|
||||
logger.LogError(context.Exception, context.Exception.Message);
|
||||
logger.LogError(context.Exception, context.Exception.Message + errorMsg);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取异常元数据
|
||||
/// 获取异常元数据
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <returns></returns>
|
||||
@@ -74,22 +77,25 @@ public sealed class FriendlyExceptionFilter : IAsyncExceptionFilter
|
||||
// 判断是否是 ExceptionContext 或者 ActionExecutedContext
|
||||
var exception = context is ExceptionContext exContext
|
||||
? exContext.Exception
|
||||
: (
|
||||
context is ActionExecutedContext edContext
|
||||
? edContext.Exception
|
||||
: default
|
||||
);
|
||||
: context is ActionExecutedContext edContext
|
||||
? edContext.Exception
|
||||
: default;
|
||||
|
||||
if (exception is AbpValidationException validationException)
|
||||
{
|
||||
errors = validationException.ValidationErrors;
|
||||
isValidationException = true;
|
||||
}
|
||||
|
||||
// 判断是否是友好异常
|
||||
if (exception is UserFriendlyException friendlyException)
|
||||
{
|
||||
int statusCode2 = 500;
|
||||
var statusCode2 = 500;
|
||||
int.TryParse(friendlyException.Code, out statusCode2);
|
||||
isFriendlyException = true;
|
||||
errorCode = friendlyException.Code;
|
||||
originErrorCode = friendlyException.Code;
|
||||
statusCode = statusCode2==0?403:statusCode2;
|
||||
isValidationException = false;
|
||||
statusCode = statusCode2 == 0 ? 403 : statusCode2;
|
||||
errors = friendlyException.Message;
|
||||
data = friendlyException.Data;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Swashbuckle.AspNetCore.SwaggerGen;
|
||||
using Volo.Abp.AspNetCore.Mvc.ExceptionHandling;
|
||||
using Volo.Abp.AspNetCore.Mvc.Response;
|
||||
using Yi.Framework.AspNetCore.UnifyResult.Fiters;
|
||||
|
||||
namespace Yi.Framework.AspNetCore.UnifyResult;
|
||||
@@ -20,9 +21,10 @@ public static class UnifyResultExtensions
|
||||
services.AddTransient<FriendlyExceptionFilter>();
|
||||
services.AddMvc(options =>
|
||||
{
|
||||
options.Filters.RemoveAll(x => (x as ServiceFilterAttribute)?.ServiceType == typeof(AbpExceptionFilter));
|
||||
options.Filters.RemoveAll(x => (x as ServiceFilterAttribute)?.ServiceType == typeof(AbpNoContentActionFilter));
|
||||
options.Filters.AddService<SucceededUnifyResultFilter>(99);
|
||||
options.Filters.AddService<FriendlyExceptionFilter>(100);
|
||||
options.Filters.RemoveAll(x => (x as ServiceFilterAttribute)?.ServiceType == typeof(AbpExceptionFilter));
|
||||
});
|
||||
return services;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace Yi.Framework.Core.Options;
|
||||
|
||||
public class SemanticKernelOptions
|
||||
{
|
||||
public List<string> ModelIds { get; set; }
|
||||
public string Endpoint { get; set; }
|
||||
public string ApiKey { get; set; }
|
||||
}
|
||||
@@ -11,12 +11,12 @@ namespace Yi.Framework.Ddd.Application
|
||||
/// <summary>
|
||||
/// CRUD应用服务基类 - 基础版本
|
||||
/// </summary>
|
||||
public abstract class YiCrudAppService<TEntity, TEntityDto, TKey>
|
||||
public abstract class YiCrudAppService<TEntity, TEntityDto, TKey>
|
||||
: YiCrudAppService<TEntity, TEntityDto, TKey, PagedAndSortedResultRequestDto>
|
||||
where TEntity : class, IEntity<TKey>
|
||||
where TEntityDto : IEntityDto<TKey>
|
||||
{
|
||||
protected YiCrudAppService(IRepository<TEntity, TKey> repository)
|
||||
protected YiCrudAppService(IRepository<TEntity, TKey> repository)
|
||||
: base(repository)
|
||||
{
|
||||
}
|
||||
@@ -30,7 +30,7 @@ namespace Yi.Framework.Ddd.Application
|
||||
where TEntity : class, IEntity<TKey>
|
||||
where TEntityDto : IEntityDto<TKey>
|
||||
{
|
||||
protected YiCrudAppService(IRepository<TEntity, TKey> repository)
|
||||
protected YiCrudAppService(IRepository<TEntity, TKey> repository)
|
||||
: base(repository)
|
||||
{
|
||||
}
|
||||
@@ -44,7 +44,7 @@ namespace Yi.Framework.Ddd.Application
|
||||
where TEntity : class, IEntity<TKey>
|
||||
where TEntityDto : IEntityDto<TKey>
|
||||
{
|
||||
protected YiCrudAppService(IRepository<TEntity, TKey> repository)
|
||||
protected YiCrudAppService(IRepository<TEntity, TKey> repository)
|
||||
: base(repository)
|
||||
{
|
||||
}
|
||||
@@ -58,7 +58,7 @@ namespace Yi.Framework.Ddd.Application
|
||||
where TEntity : class, IEntity<TKey>
|
||||
where TEntityDto : IEntityDto<TKey>
|
||||
{
|
||||
protected YiCrudAppService(IRepository<TEntity, TKey> repository)
|
||||
protected YiCrudAppService(IRepository<TEntity, TKey> repository)
|
||||
: base(repository)
|
||||
{
|
||||
}
|
||||
@@ -78,7 +78,7 @@ namespace Yi.Framework.Ddd.Application
|
||||
/// </summary>
|
||||
private const string TempFilePath = "/wwwroot/temp";
|
||||
|
||||
protected YiCrudAppService(IRepository<TEntity, TKey> repository)
|
||||
protected YiCrudAppService(IRepository<TEntity, TKey> repository)
|
||||
: base(repository)
|
||||
{
|
||||
}
|
||||
@@ -96,7 +96,7 @@ namespace Yi.Framework.Ddd.Application
|
||||
|
||||
// 获取并验证实体
|
||||
var entity = await GetEntityByIdAsync(id);
|
||||
|
||||
|
||||
// 检查更新输入
|
||||
await CheckUpdateInputDtoAsync(entity, input);
|
||||
|
||||
@@ -124,10 +124,10 @@ namespace Yi.Framework.Ddd.Application
|
||||
{
|
||||
// 检查创建权限
|
||||
await CheckCreatePolicyAsync();
|
||||
|
||||
|
||||
// 检查创建输入
|
||||
await CheckCreateInputDtoAsync(input);
|
||||
|
||||
|
||||
// 映射到实体
|
||||
var entity = await MapToEntityAsync(input);
|
||||
|
||||
@@ -156,13 +156,13 @@ namespace Yi.Framework.Ddd.Application
|
||||
public override async Task<PagedResultDto<TGetListOutputDto>> GetListAsync(TGetListInput input)
|
||||
{
|
||||
List<TEntity> entities;
|
||||
|
||||
|
||||
// 根据输入类型决定查询方式
|
||||
if (input is IPagedResultRequest pagedInput)
|
||||
{
|
||||
// 分页查询
|
||||
entities = await Repository.GetPagedListAsync(
|
||||
pagedInput.SkipCount,
|
||||
pagedInput.SkipCount,
|
||||
pagedInput.MaxResultCount,
|
||||
string.Empty
|
||||
);
|
||||
@@ -176,7 +176,23 @@ namespace Yi.Framework.Ddd.Application
|
||||
// 获取总数并映射结果
|
||||
var totalCount = await Repository.GetCountAsync();
|
||||
var dtos = await MapToGetListOutputDtosAsync(entities);
|
||||
|
||||
|
||||
return new PagedResultDto<TGetListOutputDto>(totalCount, dtos);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取实体动态下拉框列表,子类重写该方法,通过 keywords 进行筛选
|
||||
/// </summary>
|
||||
/// <param name="keywords">查询关键字</param>
|
||||
/// <returns></returns>
|
||||
public virtual async Task<PagedResultDto<TGetListOutputDto>> GetSelectDataListAsync(string? keywords = null)
|
||||
{
|
||||
List<TEntity> entities = await Repository.GetListAsync();
|
||||
|
||||
// 获取总数并映射结果
|
||||
var totalCount = entities.Count;
|
||||
var dtos = await MapToGetListOutputDtosAsync(entities);
|
||||
|
||||
return new PagedResultDto<TGetListOutputDto>(totalCount, dtos);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Volo.Abp.Modularity;
|
||||
using Volo.Abp.ObjectMapping;
|
||||
using Yi.Framework.Core;
|
||||
using Mapster;
|
||||
|
||||
namespace Yi.Framework.Mapster
|
||||
{
|
||||
@@ -22,7 +23,8 @@ namespace Yi.Framework.Mapster
|
||||
public override void ConfigureServices(ServiceConfigurationContext context)
|
||||
{
|
||||
var services = context.Services;
|
||||
|
||||
// 扫描并注册所有映射配置
|
||||
TypeAdapterConfig.GlobalSettings.Scan(AppDomain.CurrentDomain.GetAssemblies());
|
||||
// 注册Mapster相关服务
|
||||
services.AddTransient<IAutoObjectMappingProvider, MapsterAutoObjectMappingProvider>();
|
||||
services.AddTransient<IObjectMapper, MapsterObjectMapper>();
|
||||
|
||||
@@ -58,5 +58,10 @@ namespace Yi.Framework.SqlSugarCore.Abstractions
|
||||
/// 是否启用SaaS多租户
|
||||
/// </summary>
|
||||
public bool EnabledSaasMultiTenancy { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// 是否开启更新并发乐观锁
|
||||
/// </summary>
|
||||
public bool EnabledConcurrencyException { get;set; } = false;
|
||||
}
|
||||
}
|
||||
@@ -213,6 +213,10 @@ public class DefaultSqlSugarDbContext : SqlSugarDbContext
|
||||
{
|
||||
EntityChangeEventHelperService.PublishEntityDeletedEvent(entityInfo.EntityValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
EntityChangeEventHelperService.PublishEntityUpdatedEvent(entityInfo.EntityValue);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Text;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Linq.Expressions;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Nito.AsyncEx;
|
||||
using SqlSugar;
|
||||
using Volo.Abp;
|
||||
using Volo.Abp.Auditing;
|
||||
using Volo.Abp.Data;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
using Volo.Abp.Domain.Entities;
|
||||
using Volo.Abp.Domain.Repositories;
|
||||
using Volo.Abp.Linq;
|
||||
@@ -17,12 +14,17 @@ namespace Yi.Framework.SqlSugarCore.Repositories
|
||||
{
|
||||
public class SqlSugarRepository<TEntity> : ISqlSugarRepository<TEntity>, IRepository<TEntity> where TEntity : class, IEntity, new()
|
||||
{
|
||||
[Obsolete("使用GetDbContextAsync()")]
|
||||
public ISqlSugarClient _Db => AsyncContext.Run(async () => await GetDbContextAsync());
|
||||
|
||||
[Obsolete("使用AsQueryable()")]
|
||||
public ISugarQueryable<TEntity> _DbQueryable => _Db.Queryable<TEntity>();
|
||||
|
||||
private readonly ISugarDbContextProvider<ISqlSugarDbContext> _dbContextProvider;
|
||||
|
||||
public IAbpLazyServiceProvider LazyServiceProvider { get; set; }
|
||||
|
||||
protected DbConnOptions? Options => LazyServiceProvider?.LazyGetService<IOptions<DbConnOptions>>().Value;
|
||||
/// <summary>
|
||||
/// 异步查询执行器
|
||||
/// </summary>
|
||||
@@ -264,6 +266,7 @@ namespace Yi.Framework.SqlSugarCore.Repositories
|
||||
if (typeof(ISoftDelete).IsAssignableFrom(typeof(TEntity)))
|
||||
{
|
||||
var entity = await GetByIdAsync(id);
|
||||
if (entity == null) return false;
|
||||
//反射赋值
|
||||
ReflexHelper.SetModelValue(nameof(ISoftDelete.IsDeleted), true, entity);
|
||||
return await UpdateAsync(entity);
|
||||
@@ -319,12 +322,12 @@ namespace Yi.Framework.SqlSugarCore.Repositories
|
||||
|
||||
public virtual async Task<List<TEntity>> GetPageListAsync(Expression<Func<TEntity, bool>> whereExpression, int pageNum, int pageSize)
|
||||
{
|
||||
return await (await GetDbSimpleClientAsync()).GetPageListAsync(whereExpression, new PageModel() { PageIndex = pageNum, PageSize = pageSize });
|
||||
return await (await AsQueryable()).Where(whereExpression).ToPageListAsync(pageNum, pageSize);
|
||||
}
|
||||
|
||||
public virtual async Task<List<TEntity>> GetPageListAsync(Expression<Func<TEntity, bool>> whereExpression, int pageNum, int pageSize, Expression<Func<TEntity, object>>? orderByExpression = null, OrderByType orderByType = OrderByType.Asc)
|
||||
{
|
||||
return await (await GetDbSimpleClientAsync()).GetPageListAsync(whereExpression, new PageModel { PageIndex = pageNum, PageSize = pageSize }, orderByExpression, orderByType);
|
||||
return await (await AsQueryable()).Where(whereExpression) .OrderBy( orderByExpression,orderByType).ToPageListAsync(pageNum, pageSize);
|
||||
}
|
||||
|
||||
public virtual async Task<TEntity> GetSingleAsync(Expression<Func<TEntity, bool>> whereExpression)
|
||||
@@ -379,20 +382,24 @@ namespace Yi.Framework.SqlSugarCore.Repositories
|
||||
|
||||
public virtual async Task<bool> UpdateAsync(TEntity updateObj)
|
||||
{
|
||||
if (typeof(TEntity).IsAssignableTo<IHasConcurrencyStamp>())//带版本号乐观锁更新
|
||||
if (Options is not null && Options.EnabledConcurrencyException)
|
||||
{
|
||||
try
|
||||
if (typeof(TEntity).IsAssignableTo<IHasConcurrencyStamp>()) //带版本号乐观锁更新
|
||||
{
|
||||
int num = await (await GetDbSimpleClientAsync())
|
||||
.Context.Updateable(updateObj).ExecuteCommandWithOptLockAsync(true);
|
||||
return num>0;
|
||||
}
|
||||
catch (VersionExceptions ex)
|
||||
{
|
||||
|
||||
throw new AbpDbConcurrencyException($"{ex.Message}[更新失败:ConcurrencyStamp不是最新版本],entityInfo:{updateObj}", ex);
|
||||
try
|
||||
{
|
||||
int num = await (await GetDbSimpleClientAsync())
|
||||
.Context.Updateable(updateObj).ExecuteCommandWithOptLockAsync(true);
|
||||
return num > 0;
|
||||
}
|
||||
catch (VersionExceptions ex)
|
||||
{
|
||||
throw new AbpDbConcurrencyException(
|
||||
$"{ex.Message}[更新失败:ConcurrencyStamp不是最新版本],entityInfo:{updateObj}", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return await (await GetDbSimpleClientAsync()).UpdateAsync(updateObj);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ public static class SqlSugarCoreExtensions
|
||||
ServiceLifetime serviceLifetime = ServiceLifetime.Transient)
|
||||
where TDbContext : class, ISqlSugarDbContextDependencies
|
||||
{
|
||||
services.TryAdd(new ServiceDescriptor(
|
||||
services.Add(new ServiceDescriptor(
|
||||
typeof(ISqlSugarDbContextDependencies),
|
||||
typeof(TDbContext),
|
||||
serviceLifetime));
|
||||
|
||||
@@ -96,6 +96,7 @@ namespace Yi.Framework.Stock.Application.Services
|
||||
.WhereIF(input.StartTime.HasValue, p => p.RecordTime >= input.StartTime.Value)
|
||||
.WhereIF(input.EndTime.HasValue, p => p.RecordTime <= input.EndTime.Value)
|
||||
.WhereIF(input.PeriodType.HasValue, p => p.PeriodType == input.PeriodType.Value)
|
||||
.Where(x=>x.RecordTime<=DateTime.Now)
|
||||
.OrderByIF(!string.IsNullOrEmpty(input.Sorting),input.Sorting)
|
||||
.OrderByIF(string.IsNullOrEmpty(input.Sorting),p=>p.RecordTime);
|
||||
|
||||
|
||||
@@ -52,6 +52,7 @@ namespace Yi.Framework.Stock.Domain.Entities
|
||||
/// <summary>
|
||||
/// 新闻内容
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = StaticConfig.CodeFirst_BigString)]
|
||||
public string Content { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -2,7 +2,7 @@ namespace Yi.Framework.Stock.Domain.Managers.SemanticKernel
|
||||
{
|
||||
public class SemanticKernelOptions
|
||||
{
|
||||
public string ModelId { get; set; }
|
||||
public List<string> ModelIds { get; set; }
|
||||
public string Endpoint { get; set; }
|
||||
public string ApiKey { get; set; }
|
||||
}
|
||||
|
||||
@@ -211,6 +211,7 @@ namespace Yi.Framework.Stock.Domain.Managers
|
||||
// 获取最新的价格记录
|
||||
var latestPriceRecord = await _stockPriceRecordRepository._DbQueryable
|
||||
.Where(p => p.StockId == stockId)
|
||||
.Where(x=>x.RecordTime<=DateTime.Now)
|
||||
.OrderByDescending(p => p.RecordTime)
|
||||
.FirstAsync();
|
||||
|
||||
|
||||
@@ -32,9 +32,10 @@ namespace Yi.Framework.Stock.Domain
|
||||
#pragma warning disable SKEXP0010
|
||||
// 从配置中获取值
|
||||
var options = semanticKernelSection.Get<SemanticKernelOptions>();
|
||||
//股市优先使用第一个ai模型
|
||||
services.AddKernel()
|
||||
.AddOpenAIChatCompletion(
|
||||
modelId: options.ModelId,
|
||||
modelId: options.ModelIds.FirstOrDefault(),
|
||||
endpoint: new Uri(options.Endpoint),
|
||||
apiKey: options.ApiKey);
|
||||
#pragma warning restore SKEXP0010
|
||||
|
||||
@@ -5,8 +5,10 @@ namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Discuss
|
||||
/// <summary>
|
||||
/// Discuss输入创建对象
|
||||
/// </summary>
|
||||
public class DiscussCreateInputVo
|
||||
public class DiscussCreateInput
|
||||
{
|
||||
public DiscussTypeEnum DiscussType { get; set; }
|
||||
|
||||
public string Title { get; set; }
|
||||
public string? Types { get; set; }
|
||||
public string? Introduction { get; set; }
|
||||
@@ -41,5 +43,29 @@ namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Discuss
|
||||
/// 角色
|
||||
/// </summary>
|
||||
public List<string>? PermissionRoleCodes { get; set; } = new List<string>();
|
||||
|
||||
/// <summary>
|
||||
/// 悬赏类型主题
|
||||
/// </summary>
|
||||
public DiscussRewardCreateInput? RewardData { get; set; }
|
||||
}
|
||||
|
||||
|
||||
public class DiscussRewardCreateInput
|
||||
{
|
||||
/// <summary>
|
||||
/// 悬赏最小价值
|
||||
/// </summary>
|
||||
public decimal MinValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 悬赏最大价值
|
||||
/// </summary>
|
||||
public decimal? MaxValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 作者联系方式
|
||||
/// </summary>
|
||||
public string Contact { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,8 @@ namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Discuss
|
||||
//是否置顶,默认false
|
||||
public bool IsTop { get; set; }
|
||||
|
||||
public DiscussTypeEnum DiscussType { get; set; }
|
||||
|
||||
public DiscussPermissionTypeEnum PermissionType { get; set; }
|
||||
//是否禁止,默认false
|
||||
public bool IsBan { get; set; }
|
||||
|
||||
@@ -24,7 +24,10 @@ namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Discuss
|
||||
public Guid PlateId { get; set; }
|
||||
//是否置顶,默认false
|
||||
public bool IsTop { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 主题类型
|
||||
/// </summary>
|
||||
public DiscussTypeEnum DiscussType { get; set; }
|
||||
/// <summary>
|
||||
/// 封面
|
||||
/// </summary>
|
||||
@@ -50,6 +53,7 @@ namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Discuss
|
||||
|
||||
public bool HasPermission { get;internal set; }
|
||||
|
||||
public DiscussRewardGetOutputDto? RewardData { get; set; }
|
||||
/// <summary>
|
||||
/// 设置权限
|
||||
/// </summary>
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Discuss;
|
||||
|
||||
public class DiscussRewardGetOutputDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 是否已解决
|
||||
/// </summary>
|
||||
public bool IsResolved{ get; set; }
|
||||
/// <summary>
|
||||
/// 悬赏最小价值
|
||||
/// </summary>
|
||||
public decimal MinValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 悬赏最大价值
|
||||
/// </summary>
|
||||
public decimal? MaxValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 作者联系方式
|
||||
/// </summary>
|
||||
public string Contact { get; set; }
|
||||
}
|
||||
@@ -2,7 +2,7 @@ using Yi.Framework.Bbs.Domain.Shared.Enums;
|
||||
|
||||
namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Discuss
|
||||
{
|
||||
public class DiscussUpdateInputVo
|
||||
public class DiscussUpdateInput
|
||||
{
|
||||
public string Title { get; set; }
|
||||
public string? Types { get; set; }
|
||||
@@ -6,7 +6,7 @@ namespace Yi.Framework.Bbs.Application.Contracts.IServices
|
||||
/// <summary>
|
||||
/// Discuss服务抽象
|
||||
/// </summary>
|
||||
public interface IDiscussService : IYiCrudAppService<DiscussGetOutputDto, DiscussGetListOutputDto, Guid, DiscussGetListInputVo, DiscussCreateInputVo, DiscussUpdateInputVo>
|
||||
public interface IDiscussService : IYiCrudAppService<DiscussGetOutputDto, DiscussGetListOutputDto, Guid, DiscussGetListInputVo, DiscussCreateInput, DiscussUpdateInput>
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace Yi.Framework.Bbs.Application.Services
|
||||
{
|
||||
public class BbsUserInfoService : ApplicationService, IBbsUserInfoService
|
||||
{
|
||||
private BbsUserManager _bbsUserManager;
|
||||
private readonly BbsUserManager _bbsUserManager;
|
||||
public BbsUserInfoService(BbsUserManager bbsUserManager)
|
||||
{
|
||||
_bbsUserManager = bbsUserManager;
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
using Volo.Abp;
|
||||
using Volo.Abp.Application.Services;
|
||||
using Volo.Abp.Uow;
|
||||
using Volo.Abp.Users;
|
||||
using Yi.Framework.Bbs.Application.Contracts.Dtos.Argee;
|
||||
using Yi.Framework.Bbs.Domain.Entities.Forum;
|
||||
using Yi.Framework.Bbs.Domain.Managers;
|
||||
using Yi.Framework.SqlSugarCore.Abstractions;
|
||||
|
||||
namespace Yi.Framework.Bbs.Application.Services.Forum
|
||||
@@ -13,12 +15,13 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
|
||||
/// </summary>
|
||||
public class AgreeService : ApplicationService, IApplicationService
|
||||
{
|
||||
public AgreeService(ISqlSugarRepository<AgreeEntity> repository, ISqlSugarRepository<DiscussAggregateRoot> discssRepository)
|
||||
public AgreeService(ISqlSugarRepository<AgreeEntity> repository, ISqlSugarRepository<DiscussAggregateRoot> discssRepository, BbsUserManager bbsUserManager)
|
||||
{
|
||||
_repository = repository;
|
||||
_discssRepository = discssRepository;
|
||||
_bbsUserManager = bbsUserManager;
|
||||
}
|
||||
|
||||
private readonly BbsUserManager _bbsUserManager;
|
||||
private ISqlSugarRepository<AgreeEntity> _repository { get; set; }
|
||||
|
||||
private ISqlSugarRepository<DiscussAggregateRoot> _discssRepository { get; set; }
|
||||
@@ -26,17 +29,17 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
|
||||
|
||||
/// <summary>
|
||||
/// 点赞,返回true为点赞+1,返回false为点赞-1
|
||||
/// Todo: 可放入领域层
|
||||
/// Todo: 可放入领域层,但是没必要,这个项目太简单了
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[Authorize]
|
||||
public async Task<AgreeDto> PostOperateAsync(Guid discussId)
|
||||
{
|
||||
await _bbsUserManager.VerifyUserLimitAsync(CurrentUser.GetId());
|
||||
var entity = await _repository.GetFirstAsync(x => x.DiscussId == discussId && x.CreatorId == CurrentUser.Id);
|
||||
//判断是否已经点赞过
|
||||
if (entity is null)
|
||||
{
|
||||
|
||||
//没点赞过,添加记录即可,,修改总点赞数量
|
||||
await _repository.InsertAsync(new AgreeEntity(discussId));
|
||||
var discussEntity = await _discssRepository.GetByIdAsync(discussId);
|
||||
|
||||
@@ -1,28 +1,20 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Text;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using SqlSugar;
|
||||
using Volo.Abp;
|
||||
using Volo.Abp.Application.Dtos;
|
||||
using Volo.Abp.Domain.Repositories;
|
||||
using Yi.Framework.Bbs.Application.Contracts.Dtos.Article;
|
||||
using Yi.Framework.Bbs.Application.Contracts.Dtos.Plate;
|
||||
using Yi.Framework.Bbs.Application.Contracts.IServices;
|
||||
using Yi.Framework.Bbs.Domain.Entities.Forum;
|
||||
using Yi.Framework.Bbs.Domain.Managers;
|
||||
using Yi.Framework.Bbs.Domain.Repositories;
|
||||
using Yi.Framework.Bbs.Domain.Shared.Consts;
|
||||
using Yi.Framework.Bbs.Domain.Shared.Model;
|
||||
using Yi.Framework.Core.Extensions;
|
||||
using Yi.Framework.Ddd.Application;
|
||||
using Yi.Framework.Rbac.Domain.Authorization;
|
||||
using Yi.Framework.Rbac.Domain.Extensions;
|
||||
using Yi.Framework.Rbac.Domain.Shared.Consts;
|
||||
using Yi.Framework.SqlSugarCore.Abstractions;
|
||||
|
||||
namespace Yi.Framework.Bbs.Application.Services.Forum
|
||||
@@ -36,19 +28,16 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
|
||||
{
|
||||
public ArticleService(IArticleRepository articleRepository,
|
||||
ISqlSugarRepository<DiscussAggregateRoot> discussRepository,
|
||||
IDiscussService discussService,
|
||||
ForumManager forumManager) : base(articleRepository)
|
||||
{
|
||||
_articleRepository = articleRepository;
|
||||
_discussRepository = discussRepository;
|
||||
_discussService = discussService;
|
||||
_forumManager = forumManager;
|
||||
}
|
||||
|
||||
private ForumManager _forumManager;
|
||||
private IArticleRepository _articleRepository;
|
||||
private ISqlSugarRepository<DiscussAggregateRoot> _discussRepository;
|
||||
private IDiscussService _discussService;
|
||||
private readonly ForumManager _forumManager;
|
||||
private readonly IArticleRepository _articleRepository;
|
||||
private readonly ISqlSugarRepository<DiscussAggregateRoot> _discussRepository;
|
||||
|
||||
public override async Task<PagedResultDto<ArticleGetListOutputDto>> GetListAsync(ArticleGetListInputVo input)
|
||||
{
|
||||
@@ -123,7 +112,7 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
|
||||
/// <exception cref="UserFriendlyException"></exception>
|
||||
[Permission("bbs:article:add")]
|
||||
[Authorize]
|
||||
public async override Task<ArticleGetOutputDto> CreateAsync(ArticleCreateInputVo input)
|
||||
public override async Task<ArticleGetOutputDto> CreateAsync(ArticleCreateInputVo input)
|
||||
{
|
||||
await VerifyPermissionAsync(input.DiscussId);
|
||||
return await base.CreateAsync(input);
|
||||
|
||||
@@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
using Volo.Abp;
|
||||
using Volo.Abp.Application.Dtos;
|
||||
using Volo.Abp.Users;
|
||||
using Yi.Framework.Bbs.Application.Contracts.Dtos.BbsUser;
|
||||
using Yi.Framework.Bbs.Application.Contracts.Dtos.Comment;
|
||||
using Yi.Framework.Bbs.Application.Contracts.IServices;
|
||||
@@ -34,14 +35,11 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
|
||||
_repository = CommentRepository;
|
||||
_bbsUserManager = bbsUserManager;
|
||||
}
|
||||
|
||||
private ForumManager _forumManager { get; set; }
|
||||
|
||||
|
||||
|
||||
private ISqlSugarRepository<DiscussAggregateRoot> _discussRepository { get; set; }
|
||||
|
||||
private IDiscussService _discussService { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取改主题下的评论,结构为二维列表,该查询无分页
|
||||
/// </summary>
|
||||
@@ -127,7 +125,7 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
|
||||
{
|
||||
throw new UserFriendlyException("评论不能为空");
|
||||
}
|
||||
|
||||
await _bbsUserManager.VerifyUserLimitAsync(CurrentUser.GetId());
|
||||
var discuess = await _discussRepository.GetFirstAsync(x => x.Id == input.DiscussId);
|
||||
if (discuess is null)
|
||||
{
|
||||
|
||||
@@ -3,7 +3,6 @@ using Mapster;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
using TencentCloud.Pds.V20210701.Models;
|
||||
using Volo.Abp;
|
||||
using Volo.Abp.Application.Dtos;
|
||||
using Volo.Abp.EventBus.Local;
|
||||
@@ -33,17 +32,19 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
|
||||
/// Discuss应用服务实现,用于参数校验、领域服务业务组合、日志记录、事务处理、账户信息
|
||||
/// </summary>
|
||||
public class DiscussService : YiCrudAppService<DiscussAggregateRoot, DiscussGetOutputDto, DiscussGetListOutputDto,
|
||||
Guid, DiscussGetListInputVo, DiscussCreateInputVo, DiscussUpdateInputVo>,
|
||||
Guid, DiscussGetListInputVo, DiscussCreateInput, DiscussUpdateInput>,
|
||||
IDiscussService
|
||||
{
|
||||
private ISqlSugarRepository<DiscussTopEntity> _discussTopRepository;
|
||||
private ISqlSugarRepository<AgreeEntity> _agreeRepository;
|
||||
private BbsUserManager _bbsUserManager;
|
||||
private IDiscussLableRepository _discussLableRepository;
|
||||
|
||||
public DiscussService(BbsUserManager bbsUserManager, ForumManager forumManager,
|
||||
ISqlSugarRepository<DiscussTopEntity> discussTopRepository,
|
||||
ISqlSugarRepository<PlateAggregateRoot> plateEntityRepository, ILocalEventBus localEventBus,
|
||||
ISqlSugarRepository<AgreeEntity> agreeRepository, IDiscussLableRepository discussLableRepository) : base(forumManager._discussRepository)
|
||||
ISqlSugarRepository<AgreeEntity> agreeRepository, IDiscussLableRepository discussLableRepository) : base(
|
||||
forumManager._discussRepository)
|
||||
{
|
||||
_forumManager = forumManager;
|
||||
_plateEntityRepository = plateEntityRepository;
|
||||
@@ -59,13 +60,13 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
|
||||
|
||||
|
||||
private ISqlSugarRepository<PlateAggregateRoot> _plateEntityRepository { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 单查
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public async override Task<DiscussGetOutputDto> GetAsync(Guid id)
|
||||
public override async Task<DiscussGetOutputDto> GetAsync(Guid id)
|
||||
{
|
||||
//查询主题发布 浏览主题 事件,浏览数+1
|
||||
var output = await _forumManager._discussRepository._DbQueryable
|
||||
@@ -98,32 +99,44 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
|
||||
}, true)
|
||||
.FirstAsync(discuss => discuss.Id == id);
|
||||
|
||||
if (output is null)
|
||||
if (output is null)
|
||||
{
|
||||
throw new UserFriendlyException("该主题不存在", "404");
|
||||
}
|
||||
|
||||
|
||||
switch (output.DiscussType)
|
||||
{
|
||||
case DiscussTypeEnum.Article: break;
|
||||
//查询的是悬赏主题
|
||||
case DiscussTypeEnum.Reward:
|
||||
var reward = await _forumManager._discussRewardRepository.GetAsync(x => x.DiscussId == output.Id);
|
||||
output.RewardData = reward.Adapt<DiscussRewardGetOutputDto>();
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
//组装点赞
|
||||
var agreeCreatorList =
|
||||
(await _agreeRepository._DbQueryable.Where(x => x.DiscussId == output.Id).Select(x=>x.CreatorId).ToListAsync());
|
||||
(await _agreeRepository._DbQueryable.Where(x => x.DiscussId == output.Id).Select(x => x.CreatorId)
|
||||
.ToListAsync());
|
||||
//已登录
|
||||
if (CurrentUser.Id is not null)
|
||||
{
|
||||
output.IsAgree = agreeCreatorList.Contains(CurrentUser.Id);
|
||||
}
|
||||
|
||||
|
||||
//组装标签
|
||||
var lableDic=await _discussLableRepository.GetDiscussLableCacheMapAsync();
|
||||
var lableDic = await _discussLableRepository.GetDiscussLableCacheMapAsync();
|
||||
foreach (var lableId in output.DiscussLableIds)
|
||||
{
|
||||
if (lableDic.TryGetValue(lableId,out var item))
|
||||
if (lableDic.TryGetValue(lableId, out var item))
|
||||
{
|
||||
output.Lables.Add(item.Adapt<DiscussLableGetOutputDto>());
|
||||
}
|
||||
}
|
||||
|
||||
//如果没有权限
|
||||
if (!await _forumManager.VerifyDiscussPermissionAsync(output.Id,CurrentUser.Id, CurrentUser.Roles))
|
||||
if (!await _forumManager.VerifyDiscussPermissionAsync(output.Id, CurrentUser.Id, CurrentUser.Roles))
|
||||
{
|
||||
output.SetNoPermission();
|
||||
}
|
||||
@@ -131,11 +144,12 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
|
||||
{
|
||||
output.SetPassPermission();
|
||||
}
|
||||
|
||||
|
||||
await _localEventBus.PublishAsync(new SeeDiscussEventArgs
|
||||
{ DiscussId = output.Id, OldSeeNum = output.SeeNum });
|
||||
return output;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询
|
||||
/// </summary>
|
||||
@@ -159,7 +173,8 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
|
||||
// .OrderByIF(input.Type == QueryDiscussTypeEnum.New,
|
||||
// @"COALESCE(discuss.LastModificationTime, discuss.CreationTime) DESC")
|
||||
//采用上方写法
|
||||
.OrderByIF(input.Type == QueryDiscussTypeEnum.New,discuss=>SqlFunc.Coalesce(discuss.LastModificationTime,discuss.CreationTime),OrderByType.Desc)
|
||||
.OrderByIF(input.Type == QueryDiscussTypeEnum.New, discuss => discuss.CreationTime, OrderByType.Desc)
|
||||
// .OrderByIF(input.Type == QueryDiscussTypeEnum.New,discuss=>SqlFunc.Coalesce(discuss.LastModificationTime,discuss.CreationTime),OrderByType.Desc)
|
||||
.OrderByIF(input.Type == QueryDiscussTypeEnum.Host, discuss => discuss.SeeNum, OrderByType.Desc)
|
||||
.OrderByIF(input.Type == QueryDiscussTypeEnum.Suggest, discuss => discuss.AgreeNum, OrderByType.Desc)
|
||||
.Select((discuss, user, info) => new DiscussGetListOutputDto
|
||||
@@ -187,10 +202,10 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
|
||||
(await _agreeRepository._DbQueryable.Where(x => discussId.Contains(x.DiscussId)).ToListAsync())
|
||||
.GroupBy(x => x.DiscussId)
|
||||
.ToDictionary(x => x.Key, y => y.Select(y => y.CreatorId).ToList());
|
||||
|
||||
var levelCacheDic= await _bbsUserManager.GetLevelCacheMapAsync();
|
||||
var lableDic=await _discussLableRepository.GetDiscussLableCacheMapAsync();
|
||||
|
||||
|
||||
var levelCacheDic = await _bbsUserManager.GetLevelCacheMapAsync();
|
||||
var lableDic = await _discussLableRepository.GetDiscussLableCacheMapAsync();
|
||||
|
||||
//组装等级、是否点赞赋值、标签
|
||||
items?.ForEach(x =>
|
||||
{
|
||||
@@ -198,20 +213,19 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
|
||||
if (CurrentUser.Id is not null)
|
||||
{
|
||||
//默认fasle
|
||||
if (agreeDic.TryGetValue(x.Id,out var userIds))
|
||||
if (agreeDic.TryGetValue(x.Id, out var userIds))
|
||||
{
|
||||
x.IsAgree = userIds.Contains(CurrentUser.Id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
foreach (var lableId in x.DiscussLableIds)
|
||||
{
|
||||
if (lableDic.TryGetValue(lableId,out var item))
|
||||
if (lableDic.TryGetValue(lableId, out var item))
|
||||
{
|
||||
x.Lables.Add(item.Adapt<DiscussLableGetOutputDto>());
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
return new PagedResultDto<DiscussGetListOutputDto>(total, items);
|
||||
}
|
||||
@@ -253,15 +267,15 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
|
||||
}
|
||||
}, true)
|
||||
.ToListAsync();
|
||||
var levelCacheDic= await _bbsUserManager.GetLevelCacheMapAsync();
|
||||
var lableDic=await _discussLableRepository.GetDiscussLableCacheMapAsync();
|
||||
|
||||
var levelCacheDic = await _bbsUserManager.GetLevelCacheMapAsync();
|
||||
var lableDic = await _discussLableRepository.GetDiscussLableCacheMapAsync();
|
||||
|
||||
output?.ForEach(x =>
|
||||
{
|
||||
x.User.LevelName = levelCacheDic[x.User.Level].Name;
|
||||
x.User.LevelName = levelCacheDic[x.User.Level].Name;
|
||||
foreach (var lableId in x.DiscussLableIds)
|
||||
{
|
||||
if (lableDic.TryGetValue(lableId,out var item))
|
||||
if (lableDic.TryGetValue(lableId, out var item))
|
||||
{
|
||||
x.Lables.Add(item.Adapt<DiscussLableGetOutputDto>());
|
||||
}
|
||||
@@ -277,7 +291,7 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
|
||||
/// <returns></returns>
|
||||
[Permission("bbs:discuss:add")]
|
||||
[Authorize]
|
||||
public override async Task<DiscussGetOutputDto> CreateAsync(DiscussCreateInputVo input)
|
||||
public override async Task<DiscussGetOutputDto> CreateAsync(DiscussCreateInput input)
|
||||
{
|
||||
var plate = await _plateEntityRepository.FindAsync(x => x.Id == input.PlateId);
|
||||
if (plate is null)
|
||||
@@ -300,14 +314,30 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
|
||||
}
|
||||
}
|
||||
|
||||
var entity = await _forumManager.CreateDiscussAsync(await MapToEntityAsync(input));
|
||||
await _bbsUserManager.VerifyUserLimitAsync(CurrentUser.GetId());
|
||||
var entity = await _forumManager.CreateDiscussAsync(await MapToEntityAsync(input),
|
||||
input.RewardData.Adapt<DiscussRewardAggregateRoot>());
|
||||
return await MapToGetOutputDtoAsync(entity);
|
||||
}
|
||||
|
||||
|
||||
public override Task<DiscussGetOutputDto> UpdateAsync(Guid id, DiscussUpdateInputVo input)
|
||||
/// <summary>
|
||||
/// 设置悬赏主题已解决
|
||||
/// </summary>
|
||||
/// <param name="discussId"></param>
|
||||
/// <exception cref="UserFriendlyException"></exception>
|
||||
[HttpPut("discuss/reward/resolve/{discussId}")]
|
||||
[Authorize]
|
||||
public async Task SetRewardResolvedAsync([FromRoute] Guid discussId)
|
||||
{
|
||||
return base.UpdateAsync(id, input);
|
||||
var reward = await _forumManager._discussRewardRepository.GetFirstAsync(x => x.DiscussId == discussId);
|
||||
if (reward is null)
|
||||
{
|
||||
throw new UserFriendlyException("未找到该悬赏主题", "404");
|
||||
}
|
||||
|
||||
//设置已解决
|
||||
reward.SetResolved();
|
||||
await _forumManager._discussRewardRepository.UpdateAsync(reward);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
namespace Yi.Framework.Bbs.Domain.Shared.Enums;
|
||||
|
||||
/// <summary>
|
||||
/// 主题类型
|
||||
/// </summary>
|
||||
public enum DiscussTypeEnum
|
||||
{
|
||||
/// <summary>
|
||||
/// 文章
|
||||
/// </summary>
|
||||
Article = 0,
|
||||
|
||||
/// <summary>
|
||||
/// 悬赏
|
||||
/// </summary>
|
||||
Reward=1
|
||||
}
|
||||
@@ -39,6 +39,11 @@ namespace Yi.Framework.Bbs.Domain.Entities.Forum
|
||||
public string? Introduction { get; set; }
|
||||
public int AgreeNum { get; set; }
|
||||
public int SeeNum { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 主题类型
|
||||
/// </summary>
|
||||
public DiscussTypeEnum DiscussType { get; set; }
|
||||
/// <summary>
|
||||
/// 封面
|
||||
/// </summary>
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
using SqlSugar;
|
||||
using Volo.Abp.Auditing;
|
||||
using Volo.Abp.Domain.Entities;
|
||||
using Volo.Abp.Domain.Entities.Auditing;
|
||||
|
||||
namespace Yi.Framework.Bbs.Domain.Entities.Forum;
|
||||
|
||||
[SugarTable("DiscussReward")]
|
||||
[SugarIndex($"index_{nameof(DiscussId)}", nameof(DiscussId), OrderByType.Asc)]
|
||||
public class DiscussRewardAggregateRoot : FullAuditedAggregateRoot<Guid>
|
||||
{
|
||||
public Guid DiscussId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否已解决
|
||||
/// </summary>
|
||||
public bool IsResolved{ get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 悬赏最小价值
|
||||
/// </summary>
|
||||
public decimal? MinValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 悬赏最大价值
|
||||
/// </summary>
|
||||
public decimal? MaxValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 作者联系方式
|
||||
/// </summary>
|
||||
public string Contact { get; set; }
|
||||
|
||||
public void SetResolved()
|
||||
{
|
||||
IsResolved = true;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
using TencentCloud.Tbm.V20180129.Models;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
using Volo.Abp.Domain.Entities.Events;
|
||||
using Volo.Abp.EventBus;
|
||||
using Volo.Abp.EventBus.Local;
|
||||
|
||||
@@ -13,25 +13,49 @@ namespace Yi.Framework.Bbs.Domain.Managers
|
||||
public class BbsUserManager : DomainService
|
||||
{
|
||||
public ISqlSugarRepository<UserAggregateRoot> _userRepository;
|
||||
public ISqlSugarRepository<BbsUserExtraInfoEntity> _bbsUserInfoRepository;
|
||||
// public Dictionary<int, LevelCacheItem> _levelCacheDic;
|
||||
private LevelManager _levelManager;
|
||||
|
||||
|
||||
private readonly LevelManager _levelManager;
|
||||
public BbsUserManager(ISqlSugarRepository<UserAggregateRoot> userRepository,
|
||||
ISqlSugarRepository<BbsUserExtraInfoEntity> bbsUserInfoRepository,
|
||||
LevelManager levelManager
|
||||
)
|
||||
{
|
||||
_userRepository = userRepository;
|
||||
_bbsUserInfoRepository = bbsUserInfoRepository;
|
||||
_levelManager = levelManager;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 校验用户限制
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <exception cref="UserFriendlyException"></exception>
|
||||
public async Task VerifyUserLimitAsync(Guid userId)
|
||||
{
|
||||
var userInfo = await GetBbsUserInfoAsync(userId);
|
||||
if (userInfo.UserLimit == UserLimitEnum.Ban)
|
||||
{
|
||||
throw new UserFriendlyException("你已被禁用,如存疑虑,请联系管理员进行申诉");
|
||||
}
|
||||
if (userInfo.UserLimit == UserLimitEnum.Dangerous)
|
||||
{
|
||||
throw new UserFriendlyException("您的账号被标记为危险状态,请遵规守法,等待后续解除");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取等级关系
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<Dictionary<int, LevelCacheItem>> GetLevelCacheMapAsync()
|
||||
{
|
||||
return await _levelManager.GetCacheMapAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取bbs用户信息
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<BbsUserInfoDto?> GetBbsUserInfoAsync(Guid userId)
|
||||
{
|
||||
var userInfo = await _userRepository._DbQueryable
|
||||
@@ -50,7 +74,7 @@ namespace Yi.Framework.Bbs.Domain.Managers
|
||||
}, true)
|
||||
.FirstAsync(user => user.Id == userId);
|
||||
|
||||
var levelCacheDic= await GetLevelCacheMapAsync();
|
||||
var levelCacheDic = await GetLevelCacheMapAsync();
|
||||
userInfo.LevelName = levelCacheDic[userInfo.Level].Name;
|
||||
return userInfo;
|
||||
}
|
||||
@@ -73,8 +97,8 @@ namespace Yi.Framework.Bbs.Domain.Managers
|
||||
DiscussNumber = info.DiscussNumber
|
||||
}, true)
|
||||
.ToListAsync();
|
||||
var levelCacheDic= await GetLevelCacheMapAsync();
|
||||
userInfos?.ForEach(userInfo => userInfo.LevelName =levelCacheDic[userInfo.Level].Name);
|
||||
var levelCacheDic = await GetLevelCacheMapAsync();
|
||||
userInfos?.ForEach(userInfo => userInfo.LevelName = levelCacheDic[userInfo.Level].Name);
|
||||
|
||||
return userInfos ?? new List<BbsUserInfoDto>();
|
||||
}
|
||||
|
||||
@@ -21,21 +21,30 @@ namespace Yi.Framework.Bbs.Domain.Managers
|
||||
public readonly ISqlSugarRepository<PlateAggregateRoot, Guid> _plateEntityRepository;
|
||||
public readonly ISqlSugarRepository<CommentAggregateRoot, Guid> _commentRepository;
|
||||
public readonly ISqlSugarRepository<ArticleAggregateRoot, Guid> _articleRepository;
|
||||
public ForumManager(ISqlSugarRepository<DiscussAggregateRoot, Guid> discussRepository, ISqlSugarRepository<PlateAggregateRoot, Guid> plateEntityRepository, ISqlSugarRepository<CommentAggregateRoot, Guid> commentRepository, ISqlSugarRepository<ArticleAggregateRoot, Guid> articleRepository)
|
||||
public readonly ISqlSugarRepository<DiscussRewardAggregateRoot,Guid> _discussRewardRepository;
|
||||
public ForumManager(ISqlSugarRepository<DiscussAggregateRoot, Guid> discussRepository, ISqlSugarRepository<PlateAggregateRoot, Guid> plateEntityRepository, ISqlSugarRepository<CommentAggregateRoot, Guid> commentRepository, ISqlSugarRepository<ArticleAggregateRoot, Guid> articleRepository, ISqlSugarRepository<DiscussRewardAggregateRoot, Guid> discussRewardRepository)
|
||||
{
|
||||
_discussRepository = discussRepository;
|
||||
_plateEntityRepository = plateEntityRepository;
|
||||
_commentRepository = commentRepository;
|
||||
_articleRepository = articleRepository;
|
||||
_discussRewardRepository = discussRewardRepository;
|
||||
}
|
||||
|
||||
//主题是不能直接创建的,需要由领域服务统一创建
|
||||
public async Task<DiscussAggregateRoot> CreateDiscussAsync(DiscussAggregateRoot entity)
|
||||
public async Task<DiscussAggregateRoot> CreateDiscussAsync(DiscussAggregateRoot entity,DiscussRewardAggregateRoot rewardEntity=null)
|
||||
{
|
||||
entity.CreationTime = DateTime.Now;
|
||||
entity.AgreeNum = 0;
|
||||
entity.SeeNum = 0;
|
||||
return await _discussRepository.InsertReturnEntityAsync(entity);
|
||||
var discuss = await _discussRepository.InsertReturnEntityAsync(entity);
|
||||
if (discuss.DiscussType==DiscussTypeEnum.Reward)
|
||||
{
|
||||
rewardEntity.DiscussId=discuss.Id;
|
||||
Check.NotNull(rewardEntity,"悬赏类型,悬赏信息不能为空");
|
||||
await _discussRewardRepository.InsertAsync(rewardEntity);
|
||||
}
|
||||
return discuss;
|
||||
}
|
||||
|
||||
public async Task<CommentAggregateRoot> CreateCommentAsync(Guid discussId, Guid parentId, Guid rootId, string content)
|
||||
|
||||
@@ -37,10 +37,10 @@ namespace Yi.Framework.Bbs.Domain.Managers
|
||||
/// <returns></returns>
|
||||
public async Task<Dictionary<int, LevelCacheItem>> GetCacheMapAsync()
|
||||
{
|
||||
var items = _levelCache.GetOrAdd(LevelConst.LevelCacheKey, () =>
|
||||
var items =await _levelCache.GetOrAddAsync(LevelConst.LevelCacheKey,async () =>
|
||||
{
|
||||
var cacheItem = (_repository.GetListAsync().Result)
|
||||
.OrderByDescending(x => x.CurrentLevel).ToList()
|
||||
var cacheItem = ((await _repository.GetListAsync())
|
||||
.OrderByDescending(x => x.CurrentLevel))
|
||||
.Adapt<List<LevelCacheItem>>();
|
||||
return cacheItem;
|
||||
});
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace Yi.Framework.ChatHub.Application.Services
|
||||
/// <param name="chatContext"></param>
|
||||
/// <returns></returns>
|
||||
[Authorize]
|
||||
[HttpPost("ai-chat/chat/{model}")]
|
||||
[HttpPost("ai-chat/chat/{*model}")]
|
||||
public async Task ChatAsync([FromRoute]string model, [FromBody] List<AiChatContextDto> chatContext)
|
||||
{
|
||||
const int maxChar = 10;
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Microsoft.SemanticKernel;
|
||||
using Microsoft.SemanticKernel.ChatCompletion;
|
||||
using Microsoft.SemanticKernel.Connectors.OpenAI;
|
||||
// using OpenAI;
|
||||
// using OpenAI.Managers;
|
||||
// using OpenAI.ObjectModels;
|
||||
@@ -14,61 +17,50 @@ namespace Yi.Framework.ChatHub.Domain.Managers
|
||||
{
|
||||
public class AiManager : ISingletonDependency
|
||||
{
|
||||
public AiManager(IOptions<AiOptions> options)
|
||||
private readonly Kernel _kernel;
|
||||
public AiManager(Kernel kernel)
|
||||
{
|
||||
// this.OpenAIService = new OpenAIService(new OpenAiOptions()
|
||||
// {
|
||||
// ApiKey = options.Value.ApiKey,
|
||||
// BaseDomain = options.Value.BaseDomain
|
||||
// });
|
||||
_kernel = kernel;
|
||||
}
|
||||
// private OpenAIService OpenAIService { get; }
|
||||
|
||||
public async IAsyncEnumerable<string> ChatAsStreamAsync(string model, List<AiChatContextDto> aiChatContextDtos)
|
||||
public async IAsyncEnumerable<string?> ChatAsStreamAsync(string model, List<AiChatContextDto> aiChatContextDtos)
|
||||
{
|
||||
throw new NotImplementedException("准备sk重构");
|
||||
yield break;
|
||||
// if (aiChatContextDtos.Count == 0)
|
||||
// {
|
||||
// yield return null;
|
||||
// }
|
||||
//
|
||||
// List<ChatMessage> messages = aiChatContextDtos.Select(x =>
|
||||
// {
|
||||
// if (x.AnswererType == AnswererTypeEnum.Ai)
|
||||
// {
|
||||
// return ChatMessage.FromSystem(x.Message);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return ChatMessage.FromUser(x.Message);
|
||||
// }
|
||||
// }).ToList();
|
||||
// var completionResult = OpenAIService.ChatCompletion.CreateCompletionAsStream(new ChatCompletionCreateRequest
|
||||
// {
|
||||
// Messages = messages,
|
||||
// Model =model
|
||||
// });
|
||||
//
|
||||
// HttpStatusCode? error = null;
|
||||
// await foreach (var result in completionResult)
|
||||
// {
|
||||
// if (result.Successful)
|
||||
// {
|
||||
// yield return result.Choices.FirstOrDefault()?.Message.Content ?? null;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// error = result.HttpStatusCode;
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// if (error == HttpStatusCode.PaymentRequired)
|
||||
// {
|
||||
// yield return "余额不足,请联系站长充值";
|
||||
//
|
||||
// }
|
||||
if (aiChatContextDtos.Count == 0)
|
||||
{
|
||||
yield return null;
|
||||
}
|
||||
var openSettings = new OpenAIPromptExecutionSettings()
|
||||
{
|
||||
MaxTokens =1000
|
||||
};
|
||||
|
||||
var chatCompletionService = this._kernel.GetRequiredService<IChatCompletionService>(model);
|
||||
|
||||
var history =new ChatHistory();
|
||||
foreach (var aiChatContextDto in aiChatContextDtos)
|
||||
{
|
||||
if (aiChatContextDto.AnswererType==AnswererTypeEnum.Ai)
|
||||
{
|
||||
history.AddSystemMessage(aiChatContextDto.Message);
|
||||
}
|
||||
else if(aiChatContextDto.AnswererType==AnswererTypeEnum.User)
|
||||
{
|
||||
history.AddUserMessage(aiChatContextDto.Message);
|
||||
}
|
||||
}
|
||||
|
||||
var results = chatCompletionService.GetStreamingChatMessageContentsAsync(
|
||||
chatHistory: history,
|
||||
executionSettings: openSettings,
|
||||
kernel: _kernel);
|
||||
if (results is null)
|
||||
{
|
||||
yield return null;
|
||||
}
|
||||
await foreach (var result in results)
|
||||
{
|
||||
yield return result.Content;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Volo.Abp.AspNetCore.SignalR" Version="$(AbpVersion)" />
|
||||
|
||||
<PackageReference Include="Microsoft.SemanticKernel" Version="1.40.0" />
|
||||
<PackageReference Include="Volo.Abp.Ddd.Domain" Version="$(AbpVersion)" />
|
||||
<PackageReference Include="Volo.Abp.Caching" Version="$(AbpVersion)" />
|
||||
<ProjectReference Include="..\..\..\framework\Yi.Framework.Caching.FreeRedis\Yi.Framework.Caching.FreeRedis.csproj" />
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
using Volo.Abp.Domain;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.SemanticKernel;
|
||||
using Volo.Abp.Domain;
|
||||
using Yi.Framework.Caching.FreeRedis;
|
||||
using Yi.Framework.ChatHub.Domain.Shared;
|
||||
using Yi.Framework.Core.Options;
|
||||
|
||||
|
||||
namespace Yi.Framework.ChatHub.Domain
|
||||
@@ -13,9 +17,27 @@ namespace Yi.Framework.ChatHub.Domain
|
||||
)]
|
||||
public class YiFrameworkChatHubDomainModule : AbpModule
|
||||
{
|
||||
public override async Task OnPostApplicationInitializationAsync(ApplicationInitializationContext context)
|
||||
public override void ConfigureServices(ServiceConfigurationContext context)
|
||||
{
|
||||
|
||||
var configuration = context.Services.GetConfiguration();
|
||||
var services = context.Services;
|
||||
|
||||
// 配置绑定
|
||||
var semanticKernelSection = configuration.GetSection("SemanticKernel");
|
||||
services.Configure<SemanticKernelOptions>(configuration.GetSection("SemanticKernel"));
|
||||
#pragma warning disable SKEXP0010
|
||||
// 从配置中获取值
|
||||
var options = semanticKernelSection.Get<SemanticKernelOptions>();
|
||||
foreach (var optionsModelId in options.ModelIds)
|
||||
{
|
||||
services.AddKernel()
|
||||
.AddOpenAIChatCompletion(
|
||||
serviceId: optionsModelId,
|
||||
modelId: optionsModelId,
|
||||
endpoint: new Uri(options.Endpoint),
|
||||
apiKey: options.ApiKey);
|
||||
}
|
||||
#pragma warning restore SKEXP0010
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,8 +6,10 @@ using System.Threading.Tasks;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Volo.Abp;
|
||||
using Volo.Abp.Application.Services;
|
||||
using Volo.Abp.Caching;
|
||||
using Volo.Abp.Domain.Repositories;
|
||||
using Volo.Abp.Guids;
|
||||
using Yi.Framework.Core.Enums;
|
||||
@@ -16,6 +18,7 @@ using Yi.Framework.Rbac.Application.Contracts.Dtos.FileManager;
|
||||
using Yi.Framework.Rbac.Application.Contracts.IServices;
|
||||
using Yi.Framework.Rbac.Domain.Entities;
|
||||
using Yi.Framework.Rbac.Domain.Managers;
|
||||
using Yi.Framework.Rbac.Domain.Shared.Caches;
|
||||
|
||||
namespace Yi.Framework.Rbac.Application.Services
|
||||
{
|
||||
@@ -23,11 +26,13 @@ namespace Yi.Framework.Rbac.Application.Services
|
||||
{
|
||||
private readonly IRepository<FileAggregateRoot> _repository;
|
||||
private readonly FileManager _fileManager;
|
||||
private readonly IMemoryCache _memoryCache;
|
||||
|
||||
public FileService(IRepository<FileAggregateRoot> repository, FileManager fileManager)
|
||||
public FileService(IRepository<FileAggregateRoot> repository, FileManager fileManager, IMemoryCache memoryCache)
|
||||
{
|
||||
_repository = repository;
|
||||
_fileManager = fileManager;
|
||||
_memoryCache = memoryCache;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -37,14 +42,22 @@ namespace Yi.Framework.Rbac.Application.Services
|
||||
[Route("file/{code}/{isThumbnail?}")]
|
||||
public async Task<IActionResult> Get([FromRoute] Guid code, [FromRoute] bool? isThumbnail)
|
||||
{
|
||||
var file = await _repository.GetAsync(x => x.Id == code);
|
||||
var fileCache = await _memoryCache.GetOrCreateAsync($"File:{code}", async (options) =>
|
||||
{
|
||||
options.AbsoluteExpiration = DateTime.Now.AddDays(1);
|
||||
var file = await _repository.GetAsync(x => x.Id == code);
|
||||
if (file == null!) return null;
|
||||
return file.Adapt<FileCacheItem>();
|
||||
});
|
||||
var file = fileCache?.Adapt<FileAggregateRoot>();
|
||||
var path = file?.GetQueryFileSavePath(isThumbnail);
|
||||
if (path is null || !File.Exists(path))
|
||||
{
|
||||
return new NotFoundResult();
|
||||
}
|
||||
var steam = await File.ReadAllBytesAsync(path);
|
||||
return new FileContentResult(steam, file.GetMimeMapping());
|
||||
|
||||
var stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||
return new FileStreamResult(stream, file!.GetMimeMapping());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -57,12 +70,13 @@ namespace Yi.Framework.Rbac.Application.Services
|
||||
|
||||
for (int i = 0; i < file.Count; i++)
|
||||
{
|
||||
var entity= entities[i];
|
||||
using (var steam = file[i].OpenReadStream())
|
||||
{
|
||||
await _fileManager.SaveFileAsync(entity,steam);
|
||||
}
|
||||
var entity = entities[i];
|
||||
using (var steam = file[i].OpenReadStream())
|
||||
{
|
||||
await _fileManager.SaveFileAsync(entity, steam);
|
||||
}
|
||||
}
|
||||
|
||||
return entities.Adapt<List<FileGetListOutputDto>>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Microsoft.VisualBasic;
|
||||
using TencentCloud.Mna.V20210119.Models;
|
||||
using Volo.Abp.Application.Services;
|
||||
using Volo.Abp.Caching;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace Yi.Framework.Rbac.Application.Services.System
|
||||
.WhereIF(!string.IsNullOrEmpty(input.DeptName), u => u.DeptName.Contains(input.DeptName!))
|
||||
.WhereIF(input.State is not null, u => u.State == input.State)
|
||||
.OrderBy(u => u.OrderNum, OrderByType.Asc)
|
||||
.ToPageListAsync(input.SkipCount, input.MaxResultCount, total);
|
||||
.ToListAsync();
|
||||
return new PagedResultDto<DeptGetListOutputDto>
|
||||
{
|
||||
Items = await MapToGetListOutputDtosAsync(entities),
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
using Volo.Abp.Application.Dtos;
|
||||
using Yi.Framework.Ddd.Application;
|
||||
@@ -54,5 +55,25 @@ namespace Yi.Framework.Rbac.Application.Services.System
|
||||
throw new UserFriendlyException(RoleConst.Exist);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新状态
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="state"></param>
|
||||
/// <returns></returns>
|
||||
[Route("post/{id}/{state}")]
|
||||
public async Task<PostGetOutputDto> UpdateStateAsync([FromRoute] Guid id, [FromRoute] bool state)
|
||||
{
|
||||
var entity = await _repository.GetByIdAsync(id);
|
||||
if (entity is null)
|
||||
{
|
||||
throw new ApplicationException("岗位未存在");
|
||||
}
|
||||
|
||||
entity.State = state;
|
||||
await _repository.UpdateAsync(entity);
|
||||
return await MapToGetOutputDtoAsync(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
using TencentCloud.Tcr.V20190924.Models;
|
||||
using Volo.Abp;
|
||||
using Volo.Abp.Application.Dtos;
|
||||
using Volo.Abp.Caching;
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
namespace Yi.Framework.Rbac.Domain.Shared.Caches;
|
||||
|
||||
public class FileCacheItem
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 文件大小
|
||||
///</summary>
|
||||
public decimal FileSize { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 文件名
|
||||
///</summary>
|
||||
public string FileName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 文件路径
|
||||
///</summary>
|
||||
public string FilePath { get; set; }
|
||||
|
||||
public DateTime CreationTime { get; set; }
|
||||
|
||||
public Guid? CreatorId { get; set; }
|
||||
|
||||
public Guid? LastModifierId { get; set; }
|
||||
|
||||
public DateTime? LastModificationTime { get; set; }
|
||||
}
|
||||
@@ -34,8 +34,7 @@ namespace Yi.Framework.Rbac.Domain.Entities
|
||||
var type = GetFileType();
|
||||
|
||||
var savePath = GetSaveFilePath();
|
||||
var filePath = Path.Combine(savePath, this.FileName);
|
||||
this.FilePath = filePath;
|
||||
this.FilePath = savePath;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,59 +1,59 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TencentCloud.Common.Profile;
|
||||
using TencentCloud.Common;
|
||||
using TencentCloud.Sms.V20210111.Models;
|
||||
using TencentCloud.Sms.V20210111;
|
||||
using Volo.Abp.Domain.Services;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Yi.Framework.Rbac.Domain.Managers
|
||||
{
|
||||
public class TencentCloudManager : DomainService
|
||||
{
|
||||
private ILogger<TencentCloudManager> _logger;
|
||||
public TencentCloudManager(ILogger<TencentCloudManager> logger)
|
||||
{
|
||||
_logger= logger;
|
||||
}
|
||||
|
||||
public async Task SendSmsAsync()
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
// 实例化一个认证对象,入参需要传入腾讯云账户 SecretId 和 SecretKey,此处还需注意密钥对的保密
|
||||
// 代码泄露可能会导致 SecretId 和 SecretKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考,建议采用更安全的方式来使用密钥,请参见:https://cloud.tencent.com/document/product/1278/85305
|
||||
// 密钥可前往官网控制台 https://console.cloud.tencent.com/cam/capi 进行获取
|
||||
Credential cred = new Credential
|
||||
{
|
||||
SecretId = "SecretId",
|
||||
SecretKey = "SecretKey"
|
||||
};
|
||||
// 实例化一个client选项,可选的,没有特殊需求可以跳过
|
||||
ClientProfile clientProfile = new ClientProfile();
|
||||
// 实例化一个http选项,可选的,没有特殊需求可以跳过
|
||||
HttpProfile httpProfile = new HttpProfile();
|
||||
httpProfile.Endpoint = ("sms.tencentcloudapi.com");
|
||||
clientProfile.HttpProfile = httpProfile;
|
||||
|
||||
// 实例化要请求产品的client对象,clientProfile是可选的
|
||||
SmsClient client = new SmsClient(cred, "", clientProfile);
|
||||
// 实例化一个请求对象,每个接口都会对应一个request对象
|
||||
SendSmsRequest req = new SendSmsRequest();
|
||||
|
||||
// 返回的resp是一个SendSmsResponse的实例,与请求对象对应
|
||||
SendSmsResponse resp = await client.SendSms(req);
|
||||
// 输出json格式的字符串回包
|
||||
_logger.LogInformation("腾讯云Sms返回:"+AbstractModel.ToJsonString(resp));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.LogError(e,e.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// using System;
|
||||
// using System.Collections.Generic;
|
||||
// using System.Linq;
|
||||
// using System.Text;
|
||||
// using System.Threading.Tasks;
|
||||
// using TencentCloud.Common.Profile;
|
||||
// using TencentCloud.Common;
|
||||
// using TencentCloud.Sms.V20210111.Models;
|
||||
// using TencentCloud.Sms.V20210111;
|
||||
// using Volo.Abp.Domain.Services;
|
||||
// using Microsoft.Extensions.Logging;
|
||||
//
|
||||
// namespace Yi.Framework.Rbac.Domain.Managers
|
||||
// {
|
||||
// public class TencentCloudManager : DomainService
|
||||
// {
|
||||
// private ILogger<TencentCloudManager> _logger;
|
||||
// public TencentCloudManager(ILogger<TencentCloudManager> logger)
|
||||
// {
|
||||
// _logger= logger;
|
||||
// }
|
||||
//
|
||||
// public async Task SendSmsAsync()
|
||||
// {
|
||||
//
|
||||
// try
|
||||
// {
|
||||
// // 实例化一个认证对象,入参需要传入腾讯云账户 SecretId 和 SecretKey,此处还需注意密钥对的保密
|
||||
// // 代码泄露可能会导致 SecretId 和 SecretKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考,建议采用更安全的方式来使用密钥,请参见:https://cloud.tencent.com/document/product/1278/85305
|
||||
// // 密钥可前往官网控制台 https://console.cloud.tencent.com/cam/capi 进行获取
|
||||
// Credential cred = new Credential
|
||||
// {
|
||||
// SecretId = "SecretId",
|
||||
// SecretKey = "SecretKey"
|
||||
// };
|
||||
// // 实例化一个client选项,可选的,没有特殊需求可以跳过
|
||||
// ClientProfile clientProfile = new ClientProfile();
|
||||
// // 实例化一个http选项,可选的,没有特殊需求可以跳过
|
||||
// HttpProfile httpProfile = new HttpProfile();
|
||||
// httpProfile.Endpoint = ("sms.tencentcloudapi.com");
|
||||
// clientProfile.HttpProfile = httpProfile;
|
||||
//
|
||||
// // 实例化要请求产品的client对象,clientProfile是可选的
|
||||
// SmsClient client = new SmsClient(cred, "", clientProfile);
|
||||
// // 实例化一个请求对象,每个接口都会对应一个request对象
|
||||
// SendSmsRequest req = new SendSmsRequest();
|
||||
//
|
||||
// // 返回的resp是一个SendSmsResponse的实例,与请求对象对应
|
||||
// SendSmsResponse resp = await client.SendSms(req);
|
||||
// // 输出json格式的字符串回包
|
||||
// _logger.LogInformation("腾讯云Sms返回:"+AbstractModel.ToJsonString(resp));
|
||||
// }
|
||||
// catch (Exception e)
|
||||
// {
|
||||
// _logger.LogError(e,e.ToString());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
<PackageReference Include="IPTools.China" Version="1.6.0" />
|
||||
|
||||
<PackageReference Include="TencentCloudSDK" Version="3.0.966" />
|
||||
<!-- <PackageReference Include="TencentCloudSDK" Version="3.0.966" />-->
|
||||
|
||||
<PackageReference Include="UAParser" Version="3.1.47" />
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Medallion.Threading;
|
||||
using Medallion.Threading.Redis;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using StackExchange.Redis;
|
||||
using Volo.Abp.AspNetCore.SignalR;
|
||||
@@ -42,14 +43,18 @@ namespace Yi.Framework.Rbac.Domain
|
||||
//配置阿里云短信
|
||||
Configure<AliyunOptions>(configuration.GetSection(nameof(AliyunOptions)));
|
||||
|
||||
//分布式锁
|
||||
context.Services.AddSingleton<IDistributedLockProvider>(sp =>
|
||||
//分布式锁,需要redis
|
||||
if (configuration.GetSection("Redis").GetValue<bool>("IsEnabled"))
|
||||
{
|
||||
var connection = ConnectionMultiplexer
|
||||
.Connect(configuration["Redis:Configuration"]);
|
||||
return new
|
||||
RedisDistributedSynchronizationProvider(connection.GetDatabase());
|
||||
});
|
||||
context.Services.AddSingleton<IDistributedLockProvider>(sp =>
|
||||
{
|
||||
var connection = ConnectionMultiplexer
|
||||
.Connect(configuration["Redis:Configuration"]);
|
||||
return new
|
||||
RedisDistributedSynchronizationProvider(connection.GetDatabase());
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -185,12 +185,12 @@ namespace Yi.Abp.Application.Services
|
||||
/// <summary>
|
||||
/// 分布式送abp版本:abp套了一层娃。但是纯粹鸡肋,不建议使用这个
|
||||
/// </summary>
|
||||
public IAbpDistributedLock AbpDistributedLock { get; set; }
|
||||
|
||||
public IAbpDistributedLock AbpDistributedLock => LazyServiceProvider.LazyGetService<IAbpDistributedLock>();
|
||||
|
||||
/// <summary>
|
||||
/// 分布式锁推荐使用版本:yyds,分布式锁永远的神!
|
||||
/// </summary>
|
||||
public IDistributedLockProvider DistributedLock { get; set; }
|
||||
public IDistributedLockProvider DistributedLock => LazyServiceProvider.LazyGetService<IDistributedLockProvider>();
|
||||
|
||||
/// <summary>
|
||||
/// 分布式锁
|
||||
|
||||
@@ -4,15 +4,17 @@ using Yi.Abp.Web;
|
||||
|
||||
//创建日志,可使用{SourceContext}记录
|
||||
Log.Logger = new LoggerConfiguration()
|
||||
.MinimumLevel.Debug()
|
||||
.MinimumLevel.Override("Microsoft", LogEventLevel.Information)
|
||||
.MinimumLevel.Override("Microsoft.AspNetCore.Hosting.Diagnostics", LogEventLevel.Error)
|
||||
.MinimumLevel.Override("Quartz", LogEventLevel.Warning)
|
||||
.Enrich.FromLogContext()
|
||||
.WriteTo.Async(c => c.File("logs/all/log-.txt", rollingInterval: RollingInterval.Day, restrictedToMinimumLevel: LogEventLevel.Debug))
|
||||
.WriteTo.Async(c => c.File("logs/error/errorlog-.txt", rollingInterval: RollingInterval.Day, restrictedToMinimumLevel: LogEventLevel.Error))
|
||||
.WriteTo.Async(c => c.Console())
|
||||
.CreateLogger();
|
||||
//由于后端处理请求中,前端请求已经结束,此类日志可不记录
|
||||
.Filter.ByExcluding(log =>log.Exception?.GetType() == typeof(TaskCanceledException)||log.MessageTemplate.Text.Contains("\"message\": \"A task was canceled.\""))
|
||||
.MinimumLevel.Debug()
|
||||
.MinimumLevel.Override("Microsoft", LogEventLevel.Information)
|
||||
.MinimumLevel.Override("Microsoft.AspNetCore.Hosting.Diagnostics", LogEventLevel.Error)
|
||||
.MinimumLevel.Override("Quartz", LogEventLevel.Warning)
|
||||
.Enrich.FromLogContext()
|
||||
.WriteTo.Async(c => c.File("logs/all/log-.txt", rollingInterval: RollingInterval.Day, restrictedToMinimumLevel: LogEventLevel.Debug))
|
||||
.WriteTo.Async(c => c.File("logs/error/errorlog-.txt", rollingInterval: RollingInterval.Day, restrictedToMinimumLevel: LogEventLevel.Error))
|
||||
.WriteTo.Async(c => c.Console())
|
||||
.CreateLogger();
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
@@ -39,6 +39,7 @@ using Yi.Framework.AspNetCore.Authentication.OAuth.Gitee;
|
||||
using Yi.Framework.AspNetCore.Authentication.OAuth.QQ;
|
||||
using Yi.Framework.AspNetCore.Microsoft.AspNetCore.Builder;
|
||||
using Yi.Framework.AspNetCore.Microsoft.Extensions.DependencyInjection;
|
||||
using Yi.Framework.AspNetCore.UnifyResult;
|
||||
using Yi.Framework.BackgroundWorkers.Hangfire;
|
||||
using Yi.Framework.Bbs.Application;
|
||||
using Yi.Framework.Bbs.Application.Extensions;
|
||||
@@ -130,6 +131,7 @@ namespace Yi.Abp.Web
|
||||
});
|
||||
|
||||
//采用furion格式的规范化api,默认不开启,使用abp优雅的方式
|
||||
//前置:需要将管道工作单元前加上app.Properties.Add("_AbpExceptionHandlingMiddleware_Added",false);
|
||||
//你没看错。。。
|
||||
//service.AddFurionUnifyResultApi();
|
||||
|
||||
@@ -204,7 +206,7 @@ namespace Yi.Abp.Web
|
||||
var redisConfiguration = configuration["Redis:Configuration"];
|
||||
context.Services.AddHangfire(config=>
|
||||
{
|
||||
bool.TryParse( configuration["Redis:IsEnabled"], out var redisEnabled);
|
||||
var redisEnabled=configuration.GetSection("Redis").GetValue<bool>("IsEnabled");
|
||||
if (redisEnabled)
|
||||
{
|
||||
var jobDb=configuration.GetSection("Redis").GetValue<int>("JobDb");
|
||||
@@ -278,19 +280,19 @@ namespace Yi.Abp.Web
|
||||
};
|
||||
options.Events = new JwtBearerEvents
|
||||
{
|
||||
OnMessageReceived = context =>
|
||||
OnMessageReceived = messageContext =>
|
||||
{
|
||||
//优先Query中获取,再去cookies中获取
|
||||
var accessToken = context.Request.Query["access_token"];
|
||||
var accessToken = messageContext.Request.Query["access_token"];
|
||||
if (!string.IsNullOrEmpty(accessToken))
|
||||
{
|
||||
context.Token = accessToken;
|
||||
messageContext.Token = accessToken;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (context.Request.Cookies.TryGetValue("Token", out var cookiesToken))
|
||||
if (messageContext.Request.Cookies.TryGetValue("Token", out var cookiesToken))
|
||||
{
|
||||
context.Token = cookiesToken;
|
||||
messageContext.Token = cookiesToken;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -311,19 +313,19 @@ namespace Yi.Abp.Web
|
||||
};
|
||||
options.Events = new JwtBearerEvents
|
||||
{
|
||||
OnMessageReceived = context =>
|
||||
OnMessageReceived = messageContext =>
|
||||
{
|
||||
var refresh_token = context.Request.Headers["refresh_token"];
|
||||
if (!string.IsNullOrEmpty(refresh_token))
|
||||
var headerRefreshToken = messageContext.Request.Headers["refresh_token"];
|
||||
if (!string.IsNullOrEmpty(headerRefreshToken))
|
||||
{
|
||||
context.Token = refresh_token;
|
||||
messageContext.Token = headerRefreshToken;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
var refreshToken = context.Request.Query["refresh_token"];
|
||||
if (!string.IsNullOrEmpty(refreshToken))
|
||||
var queryRefreshToken = messageContext.Request.Query["refresh_token"];
|
||||
if (!string.IsNullOrEmpty(queryRefreshToken))
|
||||
{
|
||||
context.Token = refreshToken;
|
||||
messageContext.Token = queryRefreshToken;
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
@@ -393,8 +395,7 @@ namespace Yi.Abp.Web
|
||||
app.UseDefaultFiles();
|
||||
app.UseDirectoryBrowser("/api/app/wwwroot");
|
||||
|
||||
|
||||
// app.Properties.Add("_AbpExceptionHandlingMiddleware_Added",false);
|
||||
//app.Properties.Add("_AbpExceptionHandlingMiddleware_Added",false);
|
||||
//工作单元
|
||||
app.UseUnitOfWork();
|
||||
|
||||
|
||||
@@ -40,7 +40,8 @@
|
||||
"EnabledDbSeed": true,
|
||||
"EnableUnderLine": false, // 启用驼峰转下划线
|
||||
//SAAS多租户
|
||||
"EnabledSaasMultiTenancy": true
|
||||
"EnabledSaasMultiTenancy": true,
|
||||
"EnabledConcurrencyException": false
|
||||
//读写分离地址
|
||||
//"ReadUrl": [
|
||||
// "DataSource=[xxxx]", //Sqlite
|
||||
@@ -103,18 +104,10 @@
|
||||
//开启定时数据库备份
|
||||
"EnableDataBaseBackup": false
|
||||
},
|
||||
|
||||
|
||||
//OpenAi
|
||||
"AiOptions": {
|
||||
"ApiKey": "",
|
||||
"BaseDomain": ""
|
||||
},
|
||||
|
||||
|
||||
|
||||
//语义内核
|
||||
"SemanticKernel": {
|
||||
"ModelId": "gpt-4o",
|
||||
"ModelIds": ["gpt-4o"],
|
||||
"Endpoint": "https://xxx.com/v1",
|
||||
"ApiKey": "sk-xxxxxx"
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
- 一天24小时下来整体价格变化的趋势应该比较连贯,可以部分小时的价格大幅度变化
|
||||
- 变化幅度可以大一些,为了更吸引用户
|
||||
- 可能下跌,可能上涨
|
||||
- 最低价值为1,最高价值为100
|
||||
- 最低价格为5,最高价格为100,如果小于等于5,就固定一直是5,如果大于等于100,要即时的修正扣减
|
||||
- 可能出现暴跌或者暴涨,一天直接减少或增加百分之50
|
||||
|
||||
请确保数据格式正确,以便系统能够自动处理。
|
||||
@@ -1,6 +1,4 @@
|
||||
基于以下最近的新闻背景,预测趋势生成一条其他新闻。
|
||||
|
||||
{{newsContext}}
|
||||
生成一条有趣并通俗易懂的新闻
|
||||
|
||||
包含以下要素:
|
||||
1. 新闻标题:吸引人且简短,涉及不同行业
|
||||
@@ -14,6 +12,5 @@
|
||||
- 内容应当暗示可能对不同行业公司产生某种影响(积极或消极),不能太过于明显
|
||||
- 行业焦点可以包括娱乐、科技、金融、医疗、食品等多个领域
|
||||
- 新闻有很小的概率造假,如果是造假的,新闻来源就得来自小的工作室
|
||||
- 不要一直重复着一个公司、一个行业的新闻
|
||||
- 可以加一些很离谱的元素增加新闻的趣味性
|
||||
- 不要一直重复着一个公司、一个行业、一个事件的新闻
|
||||
- 只需生成一次即可
|
||||
@@ -1,7 +1,5 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Shouldly;
|
||||
using TencentCloud.Ame.V20190916.Models;
|
||||
using TencentCloud.Tiw.V20190919.Models;
|
||||
using Volo.Abp.Domain.Repositories;
|
||||
using Xunit;
|
||||
using Yi.Framework.Rbac.Application.Contracts.Dtos.User;
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
import request from "@/config/axios/service";
|
||||
|
||||
export function setResolve(discussId) {
|
||||
return request({
|
||||
url: `/discuss/reward/resolve/${discussId}`,
|
||||
method: "put"
|
||||
});
|
||||
}
|
||||
|
||||
export function getList(data) {
|
||||
return request({
|
||||
url: "/discuss",
|
||||
|
||||
@@ -35,7 +35,8 @@ export function getStockPriceRecords(stockId, startTime, endTime, periodType = '
|
||||
StockId: stockId,
|
||||
StartTime: startTime,
|
||||
EndTime: endTime,
|
||||
PeriodType: periodType
|
||||
PeriodType: periodType,
|
||||
MaxResultCount : 100
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
24
Yi.Bbs.Vue3/src/components/DiscussTypeLable.vue
Normal file
24
Yi.Bbs.Vue3/src/components/DiscussTypeLable.vue
Normal file
@@ -0,0 +1,24 @@
|
||||
|
||||
<script setup>
|
||||
import {computed} from "vue";
|
||||
|
||||
const model = defineModel();
|
||||
const items=[
|
||||
{ type: 'primary', label: '主题',key:"Article" },
|
||||
{ type: 'primary', label: '悬赏',key:"Reward" }
|
||||
];
|
||||
const currentValue=computed(()=>{
|
||||
return items.filter(item=>item.key===model.value)[0];
|
||||
})
|
||||
</script>
|
||||
|
||||
|
||||
<template>
|
||||
<el-tag
|
||||
v-if="currentValue"
|
||||
:type="currentValue?.type"
|
||||
effect="light"
|
||||
>
|
||||
{{ currentValue?.label }}
|
||||
</el-tag>
|
||||
</template>
|
||||
@@ -1,13 +1,15 @@
|
||||
<template>
|
||||
<el-badge class="box-card">
|
||||
<el-card shadow="never" :style="{ 'border-color': discuss.color }"
|
||||
class="discuss-subscript"
|
||||
>
|
||||
<span class="recommend" v-if="discuss.discussType==='Reward'"> </span>
|
||||
<div class="card-header">
|
||||
<AvatarInfo :userInfo="discuss.user" />
|
||||
</div>
|
||||
|
||||
<div style="display: flex;
|
||||
justify-content: space-between;">
|
||||
justify-content: space-between;">
|
||||
<div>
|
||||
<div v-if="discuss.isBan" class="item item-title">
|
||||
<el-link size="100" :underline="false" style="color: #f56c6c">{{
|
||||
@@ -42,10 +44,11 @@
|
||||
<div class="item item-bottom">
|
||||
<div class="tag-list">
|
||||
|
||||
<el-tag v-for="item in discuss.permissionRoleCodes" effect="dark" type="danger" :key="item">{{item}}</el-tag>
|
||||
<el-tag v-if="discuss.permissionRoleCodes.length>0" v-for="item in discuss.permissionRoleCodes" effect="dark" type="danger" :key="item">{{item}}</el-tag>
|
||||
|
||||
<el-tag v-if="discuss.lables.length===0">暂无标签</el-tag>
|
||||
<el-tag v-for="item in discuss.lables" :key="item.id">{{item.name}}</el-tag>
|
||||
<el-tag v-if="discuss.title!=''&& discuss.lables.length===0">暂无标签</el-tag>
|
||||
|
||||
<el-tag v-if="discuss.lables.length>0" v-for="item in discuss.lables" :key="item.id">{{item.name}}</el-tag>
|
||||
</div>
|
||||
<el-space :size="10" :spacer="spacer">
|
||||
<div class="item-description">
|
||||
@@ -86,7 +89,9 @@ const discuss = reactive({
|
||||
isAgree: false,
|
||||
cover: "",
|
||||
isBan: false,
|
||||
lables:[]
|
||||
lables:[],
|
||||
permissionRoleCodes:[],
|
||||
discussType:""
|
||||
});
|
||||
const router = useRouter();
|
||||
const spacer = h(ElDivider, { direction: "vertical" });
|
||||
@@ -132,6 +137,7 @@ onMounted(() => {
|
||||
discuss.cover = props.discuss.cover;
|
||||
discuss.lables=props.discuss.lables;
|
||||
discuss.permissionRoleCodes=props.discuss.permissionRoleCodes;
|
||||
discuss.discussType=props.discuss.discussType;
|
||||
});
|
||||
</script>
|
||||
<style scoped lang="scss">
|
||||
@@ -207,4 +213,41 @@ onMounted(() => {
|
||||
:deep(.el-card__body) {
|
||||
padding: 10px 20px;
|
||||
}
|
||||
|
||||
.discuss-subscript{
|
||||
position: relative;
|
||||
.recommend:before {
|
||||
cursor: pointer;
|
||||
content: "悬赏";
|
||||
position: absolute;
|
||||
top: -8px;
|
||||
right: -26px;
|
||||
z-index: 1;
|
||||
padding: 14px 22px 2px;
|
||||
background-color: #ff9900;
|
||||
transform: rotate(45deg);
|
||||
font-size: 12px;
|
||||
color: #ffffff;
|
||||
}
|
||||
.recommend:hover::after {
|
||||
width: 100px;
|
||||
content: "选择悬赏主题,帮助他人解决问题,赚取小费"; /* 鼠标悬浮时显示的文字 */
|
||||
position: absolute;
|
||||
top: 30px; /* 距离盒子顶部的距离 */
|
||||
left: 70%; /* 盒子中央位置 */
|
||||
transform: translateX(-50%); /* 水平居中 */
|
||||
padding: 5px 10px;
|
||||
background-color: #ff9900;
|
||||
color: #ffffff;
|
||||
font-size: 12px;
|
||||
border-radius: 5px;
|
||||
z-index: 9999;
|
||||
opacity: 0; /* 初始状态不透明 */
|
||||
transition: opacity 0.5s; /* 添加过渡效果 */
|
||||
}
|
||||
|
||||
.recommend:hover::after {
|
||||
opacity: 1; /* 鼠标悬浮时完全显示 */
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<el-menu-item index="2" @click="enterStart"
|
||||
>开始</el-menu-item>
|
||||
<el-menu-item index="3" @click="enterTemp" style="color: red;font-weight: bolder;font-size: large;"
|
||||
>Ai炒股</el-menu-item>
|
||||
>有偿悬赏</el-menu-item>
|
||||
<el-menu-item index="4" @click="enterShop"
|
||||
>商城</el-menu-item>
|
||||
<!-- <el-sub-menu index="4">-->
|
||||
@@ -234,7 +234,7 @@ const enterStart = () => {
|
||||
}
|
||||
|
||||
const enterTemp=()=>{
|
||||
router.push("/stock");
|
||||
router.push("/discuss/24cc0526-86e7-aabf-e091-3a0f83c3e604/false");
|
||||
}
|
||||
const enterShop=()=>{
|
||||
router.push("/shop");
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<el-row :gutter="20" class="top-div">
|
||||
<el-col :span="5">
|
||||
<el-row class="art-info-left">
|
||||
<el-col :span="24">
|
||||
<el-col :span="24" v-if="discuss.discussType=='Article'">
|
||||
<InfoCard header="文章信息" text="展开" hideDivider="true" :isPadding="false" style="padding: 10px">
|
||||
<template #content>
|
||||
<el-button
|
||||
@@ -35,6 +35,35 @@
|
||||
</template>
|
||||
</InfoCard>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="24" v-if="discuss.discussType=='Reward'">
|
||||
<InfoCard header="悬赏信息" text="有偿" hideDivider="true" :isPadding="true" style="padding: 10px">
|
||||
<template #content>
|
||||
<p>
|
||||
当前状态:
|
||||
<el-tag
|
||||
v-if="discuss.rewardData.isResolved"
|
||||
type="success"
|
||||
effect="dark"
|
||||
round
|
||||
>已解决</el-tag>
|
||||
|
||||
<el-tag
|
||||
v-else
|
||||
type="danger"
|
||||
effect="dark"
|
||||
round
|
||||
>未解决</el-tag>
|
||||
</p>
|
||||
<el-divider/>
|
||||
<p>参考价格:{{discuss.rewardData.minValue}}~{{discuss.rewardData.maxValue}}RMB</p>
|
||||
<el-divider/>
|
||||
<p style="color: #AB9AAA">联系作者:</p>
|
||||
<p>{{discuss.rewardData.contact}}</p>
|
||||
</template>
|
||||
</InfoCard>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="24">
|
||||
<InfoCard :items="authorList" :isPadding="false" header="作者分享" height="410" text="更多" style="padding:0 20px">
|
||||
<template #item="temp">
|
||||
@@ -42,13 +71,6 @@
|
||||
</template>
|
||||
</InfoCard>
|
||||
</el-col>
|
||||
<!-- <el-col :span="24">-->
|
||||
<!-- <InfoCard :items="items" header="内容推荐" text="更多">-->
|
||||
<!-- <template #item="temp">-->
|
||||
<!-- <AvatarInfo />-->
|
||||
<!-- </template>-->
|
||||
<!-- </InfoCard>-->
|
||||
<!-- </el-col>-->
|
||||
</el-row>
|
||||
</el-col>
|
||||
|
||||
@@ -56,16 +78,15 @@
|
||||
<el-row class="left-div">
|
||||
<el-col :span="24">
|
||||
<Breadcrumb :breadcrumbsList="breadcrumbsList" class="breadcrumb"/>
|
||||
<!-- {{ discuss.user }} -->
|
||||
|
||||
<AvatarInfo
|
||||
:size="50"
|
||||
:showWatching="true"
|
||||
:time="discuss.creationTime"
|
||||
:userInfo="discuss.user"
|
||||
></AvatarInfo>
|
||||
<!-- :userInfo="{nick:'qwe'} -->
|
||||
|
||||
<h2>{{ discuss.title }}</h2>
|
||||
|
||||
<h2> <DiscussTypeLable style="margin-right: 8px;height: 35px;" v-model="discuss.discussType" /> {{ discuss.title }}</h2>
|
||||
<h5 class="subtitle">{{ discuss.introduction }}</h5>
|
||||
<el-image
|
||||
:preview-src-list="[getUrl(discuss.cover)]"
|
||||
@@ -73,7 +94,14 @@
|
||||
:src="getUrl(discuss.cover)"
|
||||
style="width: 150px; height: 150px"
|
||||
/>
|
||||
|
||||
<div v-if="discuss.discussType=='Reward'">
|
||||
<el-divider/>
|
||||
<p style="color: red">通过”悬赏主题“发布问题,双方达成一致并解决问题后,建议有偿提供RMB给解决人员</p>
|
||||
<p style="color: red">社区只提供解决问题平台,不参与任何交易,请自行联系</p>
|
||||
</div>
|
||||
<el-divider/>
|
||||
<el-skeleton :rows="10" animated v-if="discuss.content==undefined" />
|
||||
<ArticleContentInfo
|
||||
:code="discuss.content ?? ''"
|
||||
></ArticleContentInfo>
|
||||
@@ -111,11 +139,21 @@
|
||||
<el-button
|
||||
type="primary"
|
||||
size="default"
|
||||
v-if="isEditTheme && isArticleUser"
|
||||
v-if="isEditTheme && isArticleUser&&discuss.discussType=='Article'"
|
||||
@click="updateHander(route.params.discussId)"
|
||||
>编辑
|
||||
</el-button
|
||||
>
|
||||
<el-button
|
||||
type="warning"
|
||||
size="default"
|
||||
v-if="isEditTheme && isArticleUser&&discuss.discussType=='Reward'&&discuss.rewardData.isResolved==false"
|
||||
@click="updateSolveHander(route.params.discussId)"
|
||||
>设置已解决
|
||||
</el-button
|
||||
>
|
||||
|
||||
|
||||
<el-button
|
||||
style="margin-left: 1rem"
|
||||
type="danger"
|
||||
@@ -165,19 +203,7 @@
|
||||
<ThemeData :themeData="temp"/>
|
||||
</template>
|
||||
</InfoCard>
|
||||
<!-- <InfoCard :items="items" header="其他" text="更多">-->
|
||||
<!-- <template #item="temp">-->
|
||||
<!-- <AvatarInfo />-->
|
||||
<!-- </template>-->
|
||||
<!-- </InfoCard>-->
|
||||
</el-col>
|
||||
<!-- <el-col :span="24">-->
|
||||
<!-- <InfoCard :items="items" header="其他" text="更多">-->
|
||||
<!-- <template #item="temp">-->
|
||||
<!-- <AvatarInfo />-->
|
||||
<!-- </template>-->
|
||||
<!-- </InfoCard>-->
|
||||
<!-- </el-col>-->
|
||||
</el-row>
|
||||
</el-col>
|
||||
</el-row>
|
||||
@@ -193,7 +219,8 @@ import BottomInfo from "@/components/BottomInfo.vue";
|
||||
import TreeArticleInfo from "@/components/TreeArticleInfo.vue";
|
||||
import {useRoute, useRouter} from "vue-router";
|
||||
import AgreeInfo from "@/components/AgreeInfo.vue";
|
||||
import {get as discussGet, del as discussDel} from "@/apis/discussApi.js";
|
||||
import DiscussTypeLable from "@/components/DiscussTypeLable.vue";
|
||||
import {get as discussGet, del as discussDel,setResolve} from "@/apis/discussApi.js";
|
||||
import {
|
||||
all as articleall,
|
||||
del as articleDel,
|
||||
@@ -311,6 +338,22 @@ const delHander = async (ids) => {
|
||||
});
|
||||
});
|
||||
};
|
||||
//设置已解决
|
||||
const updateSolveHander=(discussId)=>{
|
||||
ElMessageBox.confirm(`确定要将此悬赏主题设置已解决吗?`, "警告", {
|
||||
confirmButtonText: "确认",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning",
|
||||
}).then(async () => {
|
||||
await setResolve(discussId);
|
||||
ElMessage({
|
||||
type: "success",
|
||||
message: "设置成功",
|
||||
});
|
||||
await loadDiscuss();
|
||||
|
||||
});
|
||||
};
|
||||
//更新操作
|
||||
const updateHander = (discussId) => {
|
||||
//跳转路由
|
||||
|
||||
@@ -12,8 +12,7 @@
|
||||
<el-radio-group v-model="radio">
|
||||
<el-radio-button label="discuss" :disabled="artType !== 'discuss'"
|
||||
>主题
|
||||
</el-radio-button
|
||||
>
|
||||
</el-radio-button>
|
||||
<el-radio-button label="article" :disabled="artType !== 'article'"
|
||||
>文章
|
||||
</el-radio-button
|
||||
@@ -28,132 +27,161 @@
|
||||
>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="权限:" v-if="radio == 'discuss'">
|
||||
<el-radio-group v-model="perRadio">
|
||||
<el-radio-button label="Public">公开</el-radio-button>
|
||||
<el-radio-button label="Role">所选角色可见</el-radio-button>
|
||||
|
||||
<el-form-item label="主题类型:" v-if="radio == 'discuss'">
|
||||
<el-radio-group v-model="editForm.discussType">
|
||||
<el-radio-button label="Article">基础</el-radio-button>
|
||||
<el-radio-button label="Reward">有偿悬赏</el-radio-button>
|
||||
<el-radio-button label="Test" :disabled="true">问答</el-radio-button>
|
||||
<el-radio-button label="Test" :disabled="true">投票</el-radio-button>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
label="可见角色:"
|
||||
v-if="radio == 'discuss' && perRadio == 'Role'"
|
||||
>
|
||||
<el-input-tag
|
||||
v-model="editForm.permissionRoleCodes"
|
||||
placeholder="请输入角色code"
|
||||
aria-label="按下回车,可选择多个"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="悬赏金额:" v-if="editForm.discussType == 'Reward'">
|
||||
<div class="reward-div">
|
||||
<p style="color: red">通过”悬赏主题“发布问题,双方达成一致并解决问题后,建议有偿提供RMB给解决人员</p>
|
||||
<p style="color: red">社区只提供解决问题平台,不参与任何交易,请自行联系</p>
|
||||
<div>
|
||||
<span>最少RMB:</span>
|
||||
<el-input-number style="margin-right: 40px;" v-model="editForm.rewardData.minValue" :min="10">
|
||||
</el-input-number>
|
||||
|
||||
<el-form-item
|
||||
v-if="radio == 'article'"
|
||||
label="子文章名称:"
|
||||
prop="name"
|
||||
>
|
||||
<el-input placeholder="请输入" v-model="editForm.name"/>
|
||||
</el-form-item>
|
||||
<el-form-item v-else label="标题:" prop="title">
|
||||
<el-input placeholder="请输入" v-model="editForm.title"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="描述:" prop="introduction">
|
||||
<el-input placeholder="请输入" v-model="editForm.introduction"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="内容:" prop="content">
|
||||
<MavonEdit
|
||||
height="30rem"
|
||||
v-model="editForm.content"
|
||||
:codeStyle="codeStyle"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="首页:" v-if="radio == 'discuss'">
|
||||
|
||||
<el-image
|
||||
v-if="dialogImageUrl"
|
||||
:src="getUrl"
|
||||
style="width: 178px; height: 178px"
|
||||
class="avatar"
|
||||
/>
|
||||
|
||||
<!-- 主题首页选择 -->
|
||||
<el-upload
|
||||
class="avatar-uploader"
|
||||
:action="fileUploadUrl"
|
||||
:show-file-list="false"
|
||||
:on-success="onSuccess"
|
||||
>
|
||||
<el-icon class="avatar-uploader-icon">
|
||||
<Plus/>
|
||||
</el-icon>
|
||||
</el-upload>
|
||||
</el-form-item>
|
||||
<el-form-item label="分类标签:" prop="discussLable" v-if="radio == 'discuss'">
|
||||
<el-select
|
||||
value-key="id"
|
||||
v-model="selectLabelList"
|
||||
multiple
|
||||
filterable
|
||||
remote
|
||||
reserve-keyword
|
||||
placeholder="请选择合适的文章标签"
|
||||
:remote-method="remoteMethod"
|
||||
:loading="labelLoading"
|
||||
style="width: 435px"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in labelListData"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button
|
||||
@click="submit(ruleFormRef)"
|
||||
class="submit-btn"
|
||||
type="primary"
|
||||
>提交
|
||||
</el-button
|
||||
>
|
||||
</el-form-item
|
||||
>
|
||||
</el-form>
|
||||
<div class="import-content" v-show="radio == 'article'">
|
||||
<div class="text">上传类型:</div>
|
||||
<el-select
|
||||
v-model="currentType"
|
||||
placeholder="请选择"
|
||||
style="width: 120px"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in typeOptions"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
<el-button
|
||||
type="primary"
|
||||
:icon="Download"
|
||||
:loading="importLoading"
|
||||
@click="handleImport"
|
||||
class="import-btn"
|
||||
>导入文章
|
||||
</el-button
|
||||
>
|
||||
</div>
|
||||
<span>最多RMB:</span>
|
||||
<el-input-number v-model="editForm.rewardData.maxValue" :min="10">
|
||||
</el-input-number>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<!-- 文件弹框 -->
|
||||
<div>
|
||||
<input
|
||||
v-show="false"
|
||||
ref="fileRef"
|
||||
type="file"
|
||||
multiple
|
||||
@change="getFile"
|
||||
</el-form-item>
|
||||
<el-form-item label="联系方式:" v-if="editForm.discussType == 'Reward'">
|
||||
<el-input v-model="editForm.rewardData.contact" placeholder="输入你的联系方式(例如微信号/QQ号)" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="权限:" v-if="radio == 'discuss'">
|
||||
<el-radio-group v-model="perRadio">
|
||||
<el-radio-button label="Public">公开</el-radio-button>
|
||||
<el-radio-button label="Role">所选角色可见</el-radio-button>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
label="可见角色:"
|
||||
v-if="radio == 'discuss' && perRadio == 'Role'"
|
||||
>
|
||||
<el-input-tag
|
||||
v-model="editForm.permissionRoleCodes"
|
||||
placeholder="请输入角色code"
|
||||
aria-label="按下回车,可选择多个"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item
|
||||
v-if="radio == 'article'"
|
||||
label="子文章名称:"
|
||||
prop="name"
|
||||
>
|
||||
<el-input placeholder="请输入" v-model="editForm.name"/>
|
||||
</el-form-item>
|
||||
<el-form-item v-else label="标题:" prop="title">
|
||||
<el-input placeholder="请输入" v-model="editForm.title"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="描述:" prop="introduction">
|
||||
<el-input placeholder="请输入" v-model="editForm.introduction"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="内容:" prop="content">
|
||||
<MavonEdit
|
||||
height="30rem"
|
||||
v-model="editForm.content"
|
||||
:codeStyle="codeStyle"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="首页:" v-if="radio == 'discuss'">
|
||||
|
||||
<el-image
|
||||
v-if="dialogImageUrl"
|
||||
:src="getUrl"
|
||||
style="width: 178px; height: 178px"
|
||||
class="avatar"
|
||||
/>
|
||||
|
||||
<!-- 主题首页选择 -->
|
||||
<el-upload
|
||||
class="avatar-uploader"
|
||||
:action="fileUploadUrl"
|
||||
:show-file-list="false"
|
||||
:on-success="onSuccess"
|
||||
>
|
||||
<el-icon class="avatar-uploader-icon">
|
||||
<Plus/>
|
||||
</el-icon>
|
||||
</el-upload>
|
||||
</el-form-item>
|
||||
<el-form-item label="分类标签:" prop="discussLable" v-if="radio == 'discuss'">
|
||||
<el-select
|
||||
value-key="id"
|
||||
v-model="selectLabelList"
|
||||
multiple
|
||||
filterable
|
||||
remote
|
||||
reserve-keyword
|
||||
placeholder="请选择合适的文章标签"
|
||||
:remote-method="remoteMethod"
|
||||
:loading="labelLoading"
|
||||
style="width: 435px"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in labelListData"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button
|
||||
@click="submit(ruleFormRef)"
|
||||
class="submit-btn"
|
||||
type="primary"
|
||||
>提交
|
||||
</el-button
|
||||
>
|
||||
</el-form-item
|
||||
>
|
||||
</el-form>
|
||||
<div class="import-content" v-show="radio == 'article'">
|
||||
<div class="text">上传类型:</div>
|
||||
<el-select
|
||||
v-model="currentType"
|
||||
placeholder="请选择"
|
||||
style="width: 120px"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in typeOptions"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
<el-button
|
||||
type="primary"
|
||||
:icon="Download"
|
||||
:loading="importLoading"
|
||||
@click="handleImport"
|
||||
class="import-btn"
|
||||
>导入文章
|
||||
</el-button
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 文件弹框 -->
|
||||
<div>
|
||||
<input
|
||||
v-show="false"
|
||||
ref="fileRef"
|
||||
type="file"
|
||||
multiple
|
||||
@change="getFile"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script setup>
|
||||
import MavonEdit from "@/components/MavonEdit.vue";
|
||||
@@ -187,7 +215,6 @@ const codeStyle = "atom-one-dark";
|
||||
|
||||
// 用于禁用判断
|
||||
const artType = ref(route.query.artType);
|
||||
|
||||
//封面完整显示的url
|
||||
const fileUploadUrl = `${import.meta.env.VITE_APP_BASEAPI}/file`;
|
||||
//封面的url
|
||||
@@ -200,7 +227,7 @@ const selectLabelList = ref([]);
|
||||
//远程下拉框查询文章标签
|
||||
const remoteMethod = async (query) => {
|
||||
labelLoading.value = true
|
||||
const {data} = await getLableAllList({name:query});
|
||||
const {data} = await getLableAllList({name: query});
|
||||
labelLoading.value = false
|
||||
labelListData.value = data.items;
|
||||
}
|
||||
@@ -218,12 +245,19 @@ const getUrl = computed(() => {
|
||||
|
||||
//整个页面上的表单
|
||||
const editForm = reactive({
|
||||
|
||||
discussType: "Article",
|
||||
title: "",
|
||||
introduction: "",
|
||||
content: "",
|
||||
name: "",
|
||||
permissionRoleCodes: [],
|
||||
discussLableIds:[]
|
||||
discussLableIds: [],
|
||||
rewardData: {
|
||||
minValue: 10,
|
||||
maxValue: 200,
|
||||
contact:""
|
||||
}
|
||||
});
|
||||
|
||||
//组装主题内容: 需要更新主题信息
|
||||
@@ -252,7 +286,8 @@ const submit = async (formEl) => {
|
||||
if (valid) {
|
||||
//dicuss主题处理
|
||||
if (radio.value == "discuss") {
|
||||
discuss.discussLableIds=selectLabelList.value.map((item) =>item.id);
|
||||
discuss.discussType=editForm.discussType;
|
||||
discuss.discussLableIds = selectLabelList.value.map((item) => item.id);
|
||||
discuss.title = editForm.title;
|
||||
discuss.introduction = editForm.introduction;
|
||||
discuss.content = editForm.content;
|
||||
@@ -260,7 +295,22 @@ const submit = async (formEl) => {
|
||||
discuss.cover = dialogImageUrl.value;
|
||||
discuss.permissionType = perRadio.value;
|
||||
discuss.permissionRoleCodes = editForm.permissionRoleCodes;
|
||||
//主题创建
|
||||
//悬赏还需要新增参数
|
||||
if (editForm.discussType == 'Reward')
|
||||
{
|
||||
discuss.rewardData= editForm.rewardData;
|
||||
if (editForm.rewardData.contact=="")
|
||||
{
|
||||
ElMessage.error("悬赏的联系方式不能为空!");
|
||||
return;
|
||||
}
|
||||
if (editForm.rewardData.maxValue<editForm.rewardData.minValue)
|
||||
{
|
||||
ElMessage.error("悬赏设置的最多金额不能小于最少金额");
|
||||
return;
|
||||
}
|
||||
}
|
||||
//主题创建
|
||||
if (route.query.operType == "create") {
|
||||
const response = await discussAdd(discuss);
|
||||
|
||||
@@ -273,7 +323,7 @@ const submit = async (formEl) => {
|
||||
}
|
||||
//主题更新
|
||||
else if (route.query.operType == "update") {
|
||||
discuss.discussLableIds=selectLabelList.value.map((item) =>item.id);
|
||||
discuss.discussLableIds = selectLabelList.value.map((item) => item.id);
|
||||
await discussUpdate(route.query.discussId, discuss);
|
||||
|
||||
ElMessage({
|
||||
@@ -341,13 +391,13 @@ const loadDiscuss = async () => {
|
||||
editForm.content = res.content;
|
||||
editForm.title = res.title;
|
||||
editForm.introduction = res.introduction;
|
||||
editForm.discussLableIds=res.discussLableIds;
|
||||
editForm.discussLableIds = res.discussLableIds;
|
||||
editForm.permissionRoleCodes = res.permissionRoleCodes;
|
||||
|
||||
|
||||
//编辑状态,已选择的就是全部
|
||||
labelListData.value=res.lables;
|
||||
selectLabelList.value=res.lables;
|
||||
|
||||
labelListData.value = res.lables;
|
||||
selectLabelList.value = res.lables;
|
||||
|
||||
discuss.plateId = res.plateId;
|
||||
dialogImageUrl.value = res.cover;
|
||||
perRadio.value = res.permissionType;
|
||||
@@ -412,6 +462,11 @@ const getFile = async (e) => {
|
||||
width: 40%;
|
||||
}
|
||||
|
||||
.reward-div {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.body-div {
|
||||
position: relative;
|
||||
min-height: 1000px;
|
||||
|
||||
@@ -43,13 +43,15 @@ const inputListDataStore = ref([
|
||||
|
||||
{key: "ai@gpt-4o-mini", name: "ChatGpt聊天", titleName: "ChatGpt-全能神!综合能力最强!", logo: "openAi.png", value: ""},
|
||||
|
||||
{key: "ai@claude-3-7-sonnet-20250219", name: "Claude聊天", titleName: "Claude3.7 代码逻辑地表最强!", logo: "claudeAi.png", value: ""},
|
||||
{key: "ai@grok-2-latest", name: "Grok聊天", titleName: "Grok2 即将为3.0王的诞生献上礼炮", logo: "grokAi.png", value: ""},
|
||||
{key: "ai@claude-3-7-sonnet", name: "Claude聊天", titleName: "Claude3.7 代码逻辑地表最强!", logo: "claudeAi.png", value: ""},
|
||||
{key: "ai@claude-3.7-sonnet-thinking", name: "Claude思索", titleName: "Claude3.7 思索模式,强中强!", logo: "claudeAi.png", value: ""},
|
||||
|
||||
{key: "ai@Qwen/QVQ-72B-Preview", name: "QWen聊天", titleName: "国产阿里千问通义72B", logo: "qwenAi.png", value: ""},
|
||||
{key: "ai@grok-3", name: "Grok聊天", titleName: "Grok3 为3.0王的诞生献上礼炮", logo: "grokAi.png", value: ""},
|
||||
|
||||
{key: "ai@deepseek-chat", name: "DeepSeek聊天", titleName: "满血DeepSeek-聊天模式,开源模型第一", logo: "deepSeekAi.png", value: ""},
|
||||
{key: "ai@deepseek-ai/deepseek-r1", name: "DeepSeek思索", titleName: "满血DeepSeek-思索模式", logo: "deepSeekAi.png", value: ""}
|
||||
{key: "ai@Qwen/QwQ-32B-Preview", name: "QWen聊天", titleName: "国产阿里千问通义", logo: "qwenAi.png", value: ""},
|
||||
|
||||
{key: "ai@DeepSeek-V3", name: "DeepSeek聊天", titleName: "满血DeepSeek-聊天模式,开源模型第一", logo: "deepSeekAi.png", value: ""},
|
||||
{key: "ai@DeepSeek-R1", name: "DeepSeek思索", titleName: "满血DeepSeek-思索模式", logo: "deepSeekAi.png", value: ""}
|
||||
]);
|
||||
//AI聊天临时存储
|
||||
const sendAiChatContext = ref([]);
|
||||
@@ -57,6 +59,14 @@ var timer = null;
|
||||
|
||||
let codeCopyDic = [];
|
||||
|
||||
// 添加可调整大小的变量
|
||||
const middleWidth = ref(380);
|
||||
const contentHeight = ref(535);
|
||||
const isDraggingVertical = ref(false);
|
||||
const isDraggingHorizontal = ref(false);
|
||||
const startX = ref(0);
|
||||
const startY = ref(0);
|
||||
|
||||
//初始化
|
||||
onMounted(async () => {
|
||||
if (!isLogin.value) {
|
||||
@@ -92,7 +102,12 @@ onMounted(async () => {
|
||||
//在线用户列表
|
||||
chatStore.setUserList((await getChatUserList()).data);
|
||||
startCountTip();
|
||||
|
||||
// 添加全局鼠标事件监听
|
||||
document.addEventListener('mousemove', handleMouseMove);
|
||||
document.addEventListener('mouseup', handleMouseUp);
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
if (timer != null) {
|
||||
clearInterval(timer)
|
||||
@@ -100,8 +115,57 @@ onUnmounted(() => {
|
||||
if (timerTip != null) {
|
||||
clearInterval(timerTip)
|
||||
}
|
||||
|
||||
// 移除全局鼠标事件监听
|
||||
document.removeEventListener('mousemove', handleMouseMove);
|
||||
document.removeEventListener('mouseup', handleMouseUp);
|
||||
})
|
||||
|
||||
// 开始垂直拖拽(左右分割线)
|
||||
const startDragVertical = (e) => {
|
||||
isDraggingVertical.value = true;
|
||||
startX.value = e.clientX;
|
||||
e.preventDefault();
|
||||
};
|
||||
|
||||
// 开始水平拖拽(上下分割线)
|
||||
const startDragHorizontal = (e) => {
|
||||
isDraggingHorizontal.value = true;
|
||||
startY.value = e.clientY;
|
||||
e.preventDefault();
|
||||
};
|
||||
|
||||
// 处理鼠标移动事件
|
||||
const handleMouseMove = (e) => {
|
||||
if (isDraggingVertical.value) {
|
||||
const deltaX = e.clientX - startX.value;
|
||||
const newWidth = middleWidth.value + deltaX;
|
||||
|
||||
// 限制最小宽度和最大宽度
|
||||
if (newWidth >= 250 && newWidth <= 500) {
|
||||
middleWidth.value = newWidth;
|
||||
startX.value = e.clientX;
|
||||
}
|
||||
}
|
||||
|
||||
if (isDraggingHorizontal.value) {
|
||||
const deltaY = e.clientY - startY.value;
|
||||
const newHeight = contentHeight.value + deltaY;
|
||||
|
||||
// 限制最小高度和最大高度
|
||||
if (newHeight >= 300 && newHeight <= 600) {
|
||||
contentHeight.value = newHeight;
|
||||
startY.value = e.clientY;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// 处理鼠标松开事件
|
||||
const handleMouseUp = () => {
|
||||
isDraggingVertical.value = false;
|
||||
isDraggingHorizontal.value = false;
|
||||
};
|
||||
|
||||
/*-----计算属性-----*/
|
||||
//当前聊天框内容显示的消息
|
||||
const currentMsgContext = computed(() => {
|
||||
@@ -366,7 +430,7 @@ const toMarkDownHtml = (text) => {
|
||||
const codeHandler = (code, language) => {
|
||||
const codeIndex = parseInt(Date.now() + "") + Math.floor(Math.random() * 10000000);
|
||||
//console.log(codeIndex,"codeIndex");
|
||||
// 格式化第一行是右侧language和 “复制” 按钮;
|
||||
// 格式化第一行是右侧language和 "复制" 按钮;
|
||||
if (code) {
|
||||
const navCode = navHandler(code)
|
||||
try {
|
||||
@@ -440,9 +504,9 @@ const clickCopyEvent = async function (event) {
|
||||
<template>
|
||||
|
||||
<div style="position: absolute; top: 0;left: 0;" v-show="isShowTipNumber>0">
|
||||
<p>当前版本:2.2.0</p>
|
||||
<p>当前版本:2.4.0</p>
|
||||
<p>tip:官方学习交流群每次发送消息消耗 1 钱钱</p>
|
||||
<p>tip:点击聊天窗口右上角“X”可退出</p>
|
||||
<p>tip:点击聊天窗口右上角"X"可退出</p>
|
||||
<p>tip:多人同时在聊天室时,左侧可显示其他成员</p>
|
||||
|
||||
<p>tip:当前支持多种AI模式,由于接口收费原因,还请各位手下留情</p>
|
||||
@@ -473,7 +537,7 @@ const clickCopyEvent = async function (event) {
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="middle">
|
||||
<div class="middle" :style="{ width: middleWidth + 'px' }">
|
||||
<div class="header">
|
||||
<div class="header-div">
|
||||
<div class="search">
|
||||
@@ -515,7 +579,10 @@ const clickCopyEvent = async function (event) {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="right">
|
||||
<!-- 垂直分割线 -->
|
||||
<div class="vertical-resizer" @mousedown="startDragVertical"></div>
|
||||
|
||||
<div class="right" :style="{ width: 'calc(1400px - ' + (middleWidth + 70) + 'px)' }">
|
||||
<div class="header">
|
||||
<div class="header-left">{{ currentHeaderName }} <span class="clear-msg" v-show="selectIsAi()"
|
||||
@click="clearAiMsg">点击此处清空当前对话</span>
|
||||
@@ -536,7 +603,7 @@ const clickCopyEvent = async function (event) {
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="content">
|
||||
<div class="content" :style="{ height: contentHeight + 'px' }">
|
||||
<div v-for="(item, i) in currentMsgContext" :key="i">
|
||||
|
||||
|
||||
@@ -563,7 +630,11 @@ const clickCopyEvent = async function (event) {
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="bottom">
|
||||
|
||||
<!-- 水平分割线 -->
|
||||
<div class="horizontal-resizer" @mousedown="startDragHorizontal"></div>
|
||||
|
||||
<div class="bottom" :style="{ height: 'calc(100% - ' + (contentHeight + 75) + 'px)' }">
|
||||
<div class="bottom-tool">
|
||||
|
||||
<ul class="ul-left">
|
||||
@@ -609,8 +680,35 @@ ul {
|
||||
height: 790px;
|
||||
width: 1400px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
justify-content: flex-start;
|
||||
box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.2);
|
||||
position: relative;
|
||||
}
|
||||
|
||||
/* 垂直分割线样式 */
|
||||
.vertical-resizer {
|
||||
width: 5px;
|
||||
height: 100%;
|
||||
background-color: #e7e7e7;
|
||||
cursor: col-resize;
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
.vertical-resizer:hover {
|
||||
background-color: #c0c0c0;
|
||||
}
|
||||
|
||||
/* 水平分割线样式 */
|
||||
.horizontal-resizer {
|
||||
width: 100%;
|
||||
height: 5px;
|
||||
background-color: #e7e7e7;
|
||||
cursor: row-resize;
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
.horizontal-resizer:hover {
|
||||
background-color: #c0c0c0;
|
||||
}
|
||||
|
||||
.select-user-item {
|
||||
@@ -621,6 +719,7 @@ ul {
|
||||
background-color: #2a2a2a;
|
||||
width: 70px;
|
||||
padding: 46px 10px 0 10px;
|
||||
flex-shrink: 0;
|
||||
|
||||
.icon {
|
||||
background-color: burlywood;
|
||||
@@ -637,6 +736,7 @@ ul {
|
||||
.middle {
|
||||
background-color: #dadbdc;
|
||||
width: 380px;
|
||||
flex-shrink: 0;
|
||||
|
||||
.header {
|
||||
height: 75px;
|
||||
@@ -646,13 +746,13 @@ ul {
|
||||
.header-div {
|
||||
background-color: #F7F7F7;
|
||||
height: 30px;
|
||||
width: 338px;
|
||||
width: 90%;
|
||||
margin: auto;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
|
||||
.search {
|
||||
width: 300px;
|
||||
width: 85%;
|
||||
height: 100%;
|
||||
background-color: #E2E2E2;
|
||||
border-radius: 5px;
|
||||
@@ -756,7 +856,9 @@ ul {
|
||||
|
||||
.right {
|
||||
background-color: #f5f5f5;
|
||||
width: 950px;
|
||||
flex-grow: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
.header {
|
||||
height: 75px;
|
||||
@@ -764,6 +866,7 @@ ul {
|
||||
border: 1px solid #e7e7e7;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
flex-shrink: 0;
|
||||
|
||||
.header-left {
|
||||
padding: 25px;
|
||||
@@ -801,21 +904,24 @@ ul {
|
||||
.content {
|
||||
overflow-y: auto;
|
||||
/* 只启用垂直方向滚动条 */
|
||||
height: 535px;
|
||||
padding: 20px 40px;
|
||||
flex-grow: 1;
|
||||
|
||||
}
|
||||
|
||||
.bottom {
|
||||
height: calc(100% - 610px);
|
||||
background: #f7f7f7;
|
||||
border-top: 1.5px solid #e7e7e7;
|
||||
padding: 15px 35px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 150px;
|
||||
|
||||
&-tool {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
height: 22px;
|
||||
margin-bottom: 5px;
|
||||
|
||||
.ul-left {
|
||||
display: flex;
|
||||
@@ -851,7 +957,7 @@ ul {
|
||||
|
||||
&-input {
|
||||
font-family: "Microsoft YaHei", sans-serif;
|
||||
height: 70px;
|
||||
flex-grow: 1;
|
||||
width: 100%;
|
||||
overflow-y: auto;
|
||||
padding: 10px 0;
|
||||
@@ -860,6 +966,7 @@ ul {
|
||||
border: none;
|
||||
resize: none;
|
||||
outline: none;
|
||||
min-height: 50px;
|
||||
}
|
||||
|
||||
&-send {
|
||||
|
||||
@@ -54,6 +54,7 @@ margin: 10px auto;">
|
||||
|
||||
<el-col :span="24" v-for="i in allDiscussList" :key="i.id">
|
||||
<img v-if="isIcp" src="@/assets/login.png" style="height: 150px;width: 100%" alt=""/>
|
||||
|
||||
<DisscussCard v-else :discuss="i"/>
|
||||
</el-col>
|
||||
|
||||
|
||||
@@ -222,6 +222,8 @@ const captcha = async () => {
|
||||
<el-form-item prop="code" >
|
||||
<input type="text" v-model.trim="phoneForm.code">
|
||||
</el-form-item>
|
||||
<p style="color: red">由于国内短信严格程度在2025年5月连续加强3次,你的验证码有一定概率被运营商拦截</p>
|
||||
<p style="color: red">如果未收到验证码,请联系微信chengzilaoge520 站长进行手动创建</p>
|
||||
</div>
|
||||
</div>
|
||||
<template #footer>
|
||||
|
||||
@@ -103,7 +103,7 @@ export function usePost() {
|
||||
`确认要<strong>${
|
||||
row.state === false ? "停用" : "启用"
|
||||
}</strong><strong style='color:var(--el-color-primary)'>${
|
||||
row.roleName
|
||||
row.postName
|
||||
}</strong>吗?`,
|
||||
"系统提示",
|
||||
{
|
||||
@@ -132,7 +132,7 @@ export function usePost() {
|
||||
loading: false
|
||||
}
|
||||
);
|
||||
message(`已${row.state === false ? "停用" : "启用"}${row.roleName}`, {
|
||||
message(`已${row.state === false ? "停用" : "启用"}${row.postName}`, {
|
||||
type: "success"
|
||||
});
|
||||
})
|
||||
@@ -143,7 +143,7 @@ export function usePost() {
|
||||
|
||||
async function handleDelete(row) {
|
||||
await delPost([row.id]);
|
||||
message(`您删除了角色名称为${row.roleName}的这条数据`, { type: "success" });
|
||||
message(`您删除了岗位名称为${row.postName}的这条数据`, { type: "success" });
|
||||
onSearch();
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ export function delDept(deptId) {
|
||||
return request({
|
||||
url: `/dept`,
|
||||
method: 'delete',
|
||||
params:{id:deptId}
|
||||
params:{ids:deptId}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -59,6 +59,6 @@ export function delMenu(menuId) {
|
||||
return request({
|
||||
url: `/menu`,
|
||||
method: 'delete',
|
||||
params:{id:menuId}
|
||||
params:{ids:menuId}
|
||||
})
|
||||
}
|
||||
81
Yi.RuoYi.Vue3/src/components/SelectDataTag/index.vue
Normal file
81
Yi.RuoYi.Vue3/src/components/SelectDataTag/index.vue
Normal file
@@ -0,0 +1,81 @@
|
||||
<template>
|
||||
<!-- 动态数据下拉选择框 -->
|
||||
<el-select v-model="value" :value-key="servicekey" filterable remote clearable :placeholder="placeholder"
|
||||
:loading="loading" :remote-method="remoteMethod" @change="handleChange"
|
||||
@clear="handleClear">
|
||||
<el-option v-for="item in options" :key="item[servicekey]" :label="item[servicelabel]" :value="item" />
|
||||
</el-select>
|
||||
</template>
|
||||
|
||||
<script setup name="SelectDataTag">
|
||||
import { ref } from 'vue';
|
||||
import request from '@/utils/request.js'
|
||||
|
||||
const props = defineProps({
|
||||
placeholder: {
|
||||
type: String,
|
||||
default: '请输入关键字',
|
||||
},
|
||||
/** 动态服务名称 */
|
||||
servicename: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
/** 指定响应数据的key */
|
||||
servicekey: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
/** 指定响应数据的label */
|
||||
servicelabel: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
/** 记录表格渲染行索引 */
|
||||
index: {
|
||||
type: [String, Number],
|
||||
default: 0,
|
||||
}
|
||||
});
|
||||
|
||||
const emits = defineEmits(["change", "clear"]);
|
||||
|
||||
const list = ref([]);
|
||||
const options = ref([]);
|
||||
const value = ref([]);
|
||||
const loading = ref(false);
|
||||
|
||||
function getSelectDataList(query) {
|
||||
return request({
|
||||
url: '/' + props.servicename + '/select-data-list?keywords=' + query,
|
||||
method: 'get',
|
||||
});
|
||||
}
|
||||
|
||||
function remoteMethod(query) {
|
||||
options.value = [];
|
||||
if (query) {
|
||||
loading.value = true;
|
||||
|
||||
setTimeout(() => {
|
||||
getSelectDataList(query).then(
|
||||
(response) => {
|
||||
list.value = response.data.items;
|
||||
options.value = list.value;
|
||||
|
||||
loading.value = false;
|
||||
}
|
||||
);
|
||||
}, 300);
|
||||
}
|
||||
}
|
||||
|
||||
function handleChange(data) {
|
||||
emits("change", data || [], props.index);
|
||||
}
|
||||
|
||||
function handleClear() {
|
||||
emits("clear");
|
||||
}
|
||||
|
||||
</script>
|
||||
@@ -43,6 +43,8 @@ import ImagePreview from "@/components/ImagePreview"
|
||||
import TreeSelect from '@/components/TreeSelect'
|
||||
// 字典标签组件
|
||||
import DictTag from '@/components/DictTag'
|
||||
// 动态数据下拉选择框组件
|
||||
import SelectDataTag from '@/components/SelectDataTag'
|
||||
|
||||
const app = createApp(App)
|
||||
|
||||
@@ -57,6 +59,7 @@ app.config.globalProperties.selectDictLabel = selectDictLabel
|
||||
app.config.globalProperties.selectDictLabels = selectDictLabels
|
||||
|
||||
// 全局组件挂载
|
||||
app.component('SelectDataTag', SelectDataTag)
|
||||
app.component('DictTag', DictTag)
|
||||
app.component('Pagination', Pagination)
|
||||
app.component('TreeSelect', TreeSelect)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { parseTime } from '@/ruoyi'
|
||||
import { parseTime } from './ruoyi'
|
||||
|
||||
/**
|
||||
* 表格时间格式化
|
||||
|
||||
@@ -230,6 +230,13 @@
|
||||
></el-input>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
</div>
|
||||
|
||||
BIN
readme/edgeone.png
Normal file
BIN
readme/edgeone.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 24 KiB |
Reference in New Issue
Block a user