Compare commits

..

50 Commits
stock ... abp

Author SHA1 Message Date
橙子
a50c45f7a3 !102 修正删除部门无效问题
Merge pull request !102 from Po/cherry-pick-1765609320
2025-12-14 04:37:59 +00:00
Po
2bc8837155 修正删除部门无效问题 2025-12-13 07:02:19 +00:00
ccnetcore
8a6e5abf48 fix: 修复token鉴权 2025-12-11 23:32:57 +08:00
ccnetcore
8b191330b8 Revert "fix: 仅从 Query 获取 access_token/refresh_token,简化 OnMessageReceived 逻辑"
This reverts commit 0d2f2cb826.
2025-12-11 23:31:29 +08:00
chenchun
0d2f2cb826 fix: 仅从 Query 获取 access_token/refresh_token,简化 OnMessageReceived 逻辑
- 修改文件:Yi.Abp.Net8/src/Yi.Abp.Web/YiAbpWebModule.cs
- 将 JwtBearerEvents.OnMessageReceived 的上下文参数名改为 messageContext,统一变量名。
- 简化 Token 获取逻辑:只从 request.Query 中读取 access_token 与 refresh_token,移除从 Cookies(Token)和请求头(refresh_token)读取的分支。
2025-12-11 17:41:38 +08:00
chenchun
571df74c43 chore: 在 common.props 添加 SatelliteResourceLanguages=en;zh-CN
在 Yi.Abp.Net8/common.props 中新增 SatelliteResourceLanguages 属性,指定生成卫星资源语言为 en 和 zh-CN,以便打包对应的本地化资源。
2025-12-10 15:53:18 +08:00
chenchun
cefde6848d perf: 去除35MB又臭又大的腾讯云sdk 2025-12-10 15:10:54 +08:00
ccnetcore
551597765c perf: 优化sqlsguar分页查询 2025-12-07 18:50:02 +08:00
chenchun
5eaffe2ec2 feat: 新增更新并发乐观锁配置与支持
- 在 DbConnOptions 新增 EnabledConcurrencyException(bool,默认 false) 配置项。
- 在 SqlSugarRepository 引入 IAbpLazyServiceProvider,通过 IOptions<DbConnOptions> 延迟获取配置。
- UpdateAsync 改为仅当 EnabledConcurrencyException 为 true 且实体实现 IHasConcurrencyStamp 时,使用 ExecuteCommandWithOptLockAsync 并捕获 VersionExceptions 抛出 AbpDbConcurrencyException;否则回退到原有的 UpdateAsync 实现。
- 清理/调整部分 using 引用,新增 Microsoft.Extensions.Options 与 Volo.Abp.DependencyInjection 引用。

注意:默认值为 false,需在配置中显式开启 EnabledConcurrencyException 才会启用乐观并发校验,开启后会改变之前对带版本实体自动使用乐观锁的行为。
2025-11-17 11:19:15 +08:00
chenchun
2ec7b5f4fd fix: 修复软删除时空引用异常
在 SqlSugarRepository.cs 中对 ISoftDelete 分支增加 GetByIdAsync 返回 null 的判断,避免在实体为 null 时继续反射赋值导致 NullReferenceException。若实体不存在,直接返回 false。
2025-11-13 16:49:44 +08:00
chenchun
4521212a90 feat: 新增文件缓存功能
- 在 Yi.Framework.Rbac.Application.Services.FileService 中注入 IMemoryCache,用于缓存文件元数据,减少对仓储的重复读取。
  - 在 Get 方法中通过 key "File:{code}" 缓存 FileCacheItem,设置绝对过期时间为 1 天。
  - 缓存项使用 Mapster 适配为 FileCacheItem,再适配回 FileAggregateRoot(保留现有逻辑判断和路径获取)。
- 新增缓存模型 Yi.Framework.Rbac.Domain.Shared.Caches.FileCacheItem(包含 Id、FileSize、FileName、FilePath、创建/修改信息等)。
- 增加并调整相关 using 引用(Microsoft.Extensions.Caching.Memory、Volo.Abp.Caching、Domain.Shared.Caches)。
- 同时修复了保存多文件时的缩进/空格格式(不影响功能)。
2025-11-06 11:29:21 +08:00
chenchun
94834f45c3 perf: 使用 FileStreamResult 流式返回文件,避免一次性读取到内存
改为 FileStream 并返回 FileStreamResult,减小内存占用并支持大型文件;修正变量名拼写并添加 null-forgiving 标记。
2025-11-06 11:13:50 +08:00
chenchun
22ac150acd fix: 修正 FileAggregateRoot.FilePath 的赋值,保存目录路径而非包含文件名的完整路径 2025-11-06 10:58:33 +08:00
ccnetcore
1cc5f2a14f refactor: 注释掉 Furion 统一结果 API 注册,保留 ABP 默认处理方式 2025-09-27 17:26:13 +08:00
橙子
d9997eeb28 !100 update Yi.Abp.Net8/framework/Yi.Framework.AspNetCore/UnifyResult/Fiters/FriendlyExceptionFilter.cs.
Merge pull request !100 from Gary/N/A
2025-09-22 07:14:02 +00:00
Gary
06e77aa8fd update Yi.Abp.Net8/framework/Yi.Framework.AspNetCore/UnifyResult/Fiters/FriendlyExceptionFilter.cs.
判断是否为模型验证错误,如果是,将errors传回,并打印日志

Signed-off-by: Gary <1511313969@qq.com>
2025-09-22 07:13:46 +00:00
橙子
e9e2228f6e !97 岗位状态修改
Merge pull request !97 from 嗳摸嫫/jun
2025-09-22 07:13:45 +00:00
橙子
d516a381d0 !98 update Yi.Abp.Net8/framework/Yi.Framework.Mapster/YiFrameworkMapsterModule.cs.
Merge pull request !98 from Gary/N/A
2025-09-22 07:13:26 +00:00
Gary
4e792ba976 update Yi.Abp.Net8/framework/Yi.Framework.Mapster/YiFrameworkMapsterModule.cs.
自动扫描所有继承IRegister 的Mapster 配置

Signed-off-by: Gary <1511313969@qq.com>
2025-09-22 02:58:59 +00:00
chenchun
f90d3871fa feat: 启用 Furion 统一返回结果并优化过滤器配置
- 在 `YiAbpWebModule` 中启用 `AddFurionUnifyResultApi` 以支持 Furion 风格的统一 API 返回格式
- 调整 `UnifyResultExtensions`,移除 `AbpExceptionFilter` 和 `AbpNoContentActionFilter`,确保统一结果过滤器优先执行
2025-09-16 11:48:36 +08:00
HW-July
6005b9329d 岗位状态修改 2025-08-25 17:12:18 +08:00
橙子
9d4b3e7d0c update README.md.
Signed-off-by: 橙子 <454313500@qq.com>
2025-07-05 07:50:10 +00:00
chenchun
72795382a1 style: 调整样式 2025-07-02 15:03:16 +08:00
橙子
35cdff2afa update README.md.
Signed-off-by: 橙子 <454313500@qq.com>
2025-07-02 06:04:18 +00:00
橙子
dcf547f513 style: 新增赞助
Signed-off-by: 橙子 <454313500@qq.com>
2025-07-02 06:03:28 +00:00
橙子
8660d45f36 update README.md.
Signed-off-by: 橙子 <454313500@qq.com>
2025-07-02 06:01:51 +00:00
橙子
63dd55e7a4 !95 修正分页导致部门结构显示异常。取消后台分页功能,同菜单结构无需分页。
Merge pull request !95 from Po/N/A
2025-07-02 03:49:56 +00:00
Po
40cd89f90c 修正分页导致部门结构显示异常。取消后台分页功能,同菜单结构无需分页。
Signed-off-by: Po <448443959@qq.com>
2025-07-02 02:50:06 +00:00
ccnetcore
901ccc7314 feat: 处理短信升级问题 2025-06-02 02:40:22 +08:00
ccnetcore
629add1e8a feat: 支持用户限制 2025-06-02 02:12:38 +08:00
chenchun
8b92cd6bed perf: 支持ai转义 2025-05-01 15:58:43 +08:00
chenchun
e63fb71ef6 fix: 支持ai转义功能 2025-05-01 15:58:03 +08:00
chenchun
aa122d2d82 Merge remote-tracking branch 'origin/abp' into abp 2025-05-01 14:55:45 +08:00
chenchun
5d6bfe36d0 logs: 日志调整 2025-05-01 14:55:32 +08:00
橙子
26dadd7dae !92 优化动态下拉框宽度样式,和延迟获取数据
Merge pull request !92 from JiangCY/abp
2025-04-17 07:09:43 +00:00
橙子
520dca6953 !93 update Yi.RuoYi.Vue3/src/utils/index.js.
Merge pull request !93 from fenngmr/fix-utils-parseTime
2025-04-17 07:09:23 +00:00
fenngmr
699f7febe4 update Yi.RuoYi.Vue3/src/utils/index.js.
Signed-off-by: fenngmr <guo_fengxian@163.com>
2025-04-14 08:11:32 +00:00
橙子
87a14ebac1 feat: 社区新增有偿悬赏功能 2025-04-12 23:18:06 +08:00
JiangCYkk
29573342b5 优化动态下拉框宽度样式,和延迟获取数据 2025-04-08 17:27:26 +08:00
橙子
91b216c06e !91 1.处理删除菜单传参错误的问题;
Merge pull request !91 from JiangCY/abp
2025-03-30 03:29:35 +00:00
JiangCYkk
83a6ec1b98 1.处理删除菜单传参错误的问题;
2.处理字典数据新增修改窗口没有提交按钮的问题;
2025-03-28 16:46:05 +08:00
JiangCYkk
c5d636d697 添加动态数据下拉框,可以通过下拉框筛选获取后台数据;
未实现滚动分页;
2025-03-28 16:45:36 +08:00
JiangCYkk
3d704220f3 添加数据库上下文改为 services.Add() 方法,TryAdd() 让后面的 YiRbacDbContext 无法注入,导致数据权限过滤失效了 2025-03-28 16:45:26 +08:00
橙子
b830317608 Merge remote-tracking branch 'origin/abp' into abp 2025-03-23 17:16:37 +08:00
橙子
21ff599a4e fix: 修复更新事件 2025-03-23 17:15:17 +08:00
chenchun
224c2b96e4 feat: 新增模型 2025-03-21 18:25:22 +08:00
chenchun
cbb3510d94 feat: 重构聊天室语义内核 2025-03-21 18:24:59 +08:00
chenchun
0b111852ec fix: 修复点数问题 2025-03-21 15:51:44 +08:00
chenchun
ff8038a616 fix: 修复股市问题 2025-03-21 15:36:22 +08:00
橙子
710ad95eda feat: 支持默认启用redis 2025-03-18 23:13:16 +08:00
73 changed files with 1181 additions and 507 deletions

View File

@@ -7,6 +7,12 @@
[![fork](https://gitee.com/ccnetcore/yi/badge/fork.svg?theme=dark)](https://gitee.com/ccnetcore/Yi) [![fork](https://gitee.com/ccnetcore/yi/badge/fork.svg?theme=dark)](https://gitee.com/ccnetcore/Yi)
[![license](https://img.shields.io/badge/license-MIT-yellow)](https://gitee.com/ccnetcore/Yi) [![license](https://img.shields.io/badge/license-MIT-yellow)](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) | 简体中文 [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) (已上线,欢迎加入) 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
## 🍏 支持: ## 🍏 支持:

View File

@@ -12,6 +12,7 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<SatelliteResourceLanguages>en;zh-CN</SatelliteResourceLanguages>
<LangVersion>latest</LangVersion> <LangVersion>latest</LangVersion>
<Version>1.0.0</Version> <Version>1.0.0</Version>
<NoWarn>$(NoWarn);CS1591;CS8618;CS1998;CS8604;CS8620;CS8600;CS8602</NoWarn> <NoWarn>$(NoWarn);CS1591;CS8618;CS1998;CS8604;CS8620;CS8600;CS8602</NoWarn>

View File

@@ -1,4 +1,4 @@
// MIT 许可证 // MIT 许可证
// //
// 版权 © 2020-present 百小僧, 百签科技(广东)有限公司 和所有贡献者 // 版权 © 2020-present 百小僧, 百签科技(广东)有限公司 和所有贡献者
// //
@@ -17,25 +17,25 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters; using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.DependencyInjection; using Volo.Abp.Validation;
using Yi.Framework.Core.Extensions; using Yi.Framework.Core.Extensions;
namespace Yi.Framework.AspNetCore.UnifyResult.Fiters; namespace Yi.Framework.AspNetCore.UnifyResult.Fiters;
/// <summary> /// <summary>
/// 友好异常拦截器 /// 友好异常拦截器
/// </summary> /// </summary>
public sealed class FriendlyExceptionFilter : IAsyncExceptionFilter public sealed class FriendlyExceptionFilter : IAsyncExceptionFilter
{ {
/// <summary> /// <summary>
/// 异常拦截 /// 异常拦截
/// </summary> /// </summary>
/// <param name="context"></param> /// <param name="context"></param>
/// <returns></returns> /// <returns></returns>
public async Task OnExceptionAsync(ExceptionContext context) public async Task OnExceptionAsync(ExceptionContext context)
{ {
// 排除 WebSocket 请求处理 // 排除 WebSocket 请求处理
if (context.HttpContext.IsWebSocketRequest()) return; if (context.HttpContext.IsWebSocketRequest()) return;
@@ -44,20 +44,23 @@ public sealed class FriendlyExceptionFilter : IAsyncExceptionFilter
// 解析异常信息 // 解析异常信息
var exceptionMetadata = GetExceptionMetadata(context); var exceptionMetadata = GetExceptionMetadata(context);
var unifyResult = context.GetRequiredService<IUnifyResultProvider>();
IUnifyResultProvider unifyResult = context.GetRequiredService<IUnifyResultProvider>();
// 执行规范化异常处理 // 执行规范化异常处理
context.Result = unifyResult.OnException(context, exceptionMetadata); context.Result = unifyResult.OnException(context, exceptionMetadata);
// 创建日志记录器 // 创建日志记录器
var logger = context.HttpContext.RequestServices.GetRequiredService<ILogger<FriendlyExceptionFilter>>(); 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>
/// 获取异常元数据 /// 获取异常元数据
/// </summary> /// </summary>
/// <param name="context"></param> /// <param name="context"></param>
/// <returns></returns> /// <returns></returns>
@@ -74,22 +77,25 @@ public sealed class FriendlyExceptionFilter : IAsyncExceptionFilter
// 判断是否是 ExceptionContext 或者 ActionExecutedContext // 判断是否是 ExceptionContext 或者 ActionExecutedContext
var exception = context is ExceptionContext exContext var exception = context is ExceptionContext exContext
? exContext.Exception ? exContext.Exception
: ( : context is ActionExecutedContext edContext
context is ActionExecutedContext edContext ? edContext.Exception
? edContext.Exception : default;
: default
); if (exception is AbpValidationException validationException)
{
errors = validationException.ValidationErrors;
isValidationException = true;
}
// 判断是否是友好异常 // 判断是否是友好异常
if (exception is UserFriendlyException friendlyException) if (exception is UserFriendlyException friendlyException)
{ {
int statusCode2 = 500; var statusCode2 = 500;
int.TryParse(friendlyException.Code, out statusCode2); int.TryParse(friendlyException.Code, out statusCode2);
isFriendlyException = true; isFriendlyException = true;
errorCode = friendlyException.Code; errorCode = friendlyException.Code;
originErrorCode = friendlyException.Code; originErrorCode = friendlyException.Code;
statusCode = statusCode2==0?403:statusCode2; statusCode = statusCode2 == 0 ? 403 : statusCode2;
isValidationException = false;
errors = friendlyException.Message; errors = friendlyException.Message;
data = friendlyException.Data; data = friendlyException.Data;
} }

View File

@@ -2,6 +2,7 @@
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Swashbuckle.AspNetCore.SwaggerGen; using Swashbuckle.AspNetCore.SwaggerGen;
using Volo.Abp.AspNetCore.Mvc.ExceptionHandling; using Volo.Abp.AspNetCore.Mvc.ExceptionHandling;
using Volo.Abp.AspNetCore.Mvc.Response;
using Yi.Framework.AspNetCore.UnifyResult.Fiters; using Yi.Framework.AspNetCore.UnifyResult.Fiters;
namespace Yi.Framework.AspNetCore.UnifyResult; namespace Yi.Framework.AspNetCore.UnifyResult;
@@ -20,9 +21,10 @@ public static class UnifyResultExtensions
services.AddTransient<FriendlyExceptionFilter>(); services.AddTransient<FriendlyExceptionFilter>();
services.AddMvc(options => 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<SucceededUnifyResultFilter>(99);
options.Filters.AddService<FriendlyExceptionFilter>(100); options.Filters.AddService<FriendlyExceptionFilter>(100);
options.Filters.RemoveAll(x => (x as ServiceFilterAttribute)?.ServiceType == typeof(AbpExceptionFilter));
}); });
return services; return services;
} }

View File

@@ -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; }
}

View File

@@ -11,12 +11,12 @@ namespace Yi.Framework.Ddd.Application
/// <summary> /// <summary>
/// CRUD应用服务基类 - 基础版本 /// CRUD应用服务基类 - 基础版本
/// </summary> /// </summary>
public abstract class YiCrudAppService<TEntity, TEntityDto, TKey> public abstract class YiCrudAppService<TEntity, TEntityDto, TKey>
: YiCrudAppService<TEntity, TEntityDto, TKey, PagedAndSortedResultRequestDto> : YiCrudAppService<TEntity, TEntityDto, TKey, PagedAndSortedResultRequestDto>
where TEntity : class, IEntity<TKey> where TEntity : class, IEntity<TKey>
where TEntityDto : IEntityDto<TKey> where TEntityDto : IEntityDto<TKey>
{ {
protected YiCrudAppService(IRepository<TEntity, TKey> repository) protected YiCrudAppService(IRepository<TEntity, TKey> repository)
: base(repository) : base(repository)
{ {
} }
@@ -30,7 +30,7 @@ namespace Yi.Framework.Ddd.Application
where TEntity : class, IEntity<TKey> where TEntity : class, IEntity<TKey>
where TEntityDto : IEntityDto<TKey> where TEntityDto : IEntityDto<TKey>
{ {
protected YiCrudAppService(IRepository<TEntity, TKey> repository) protected YiCrudAppService(IRepository<TEntity, TKey> repository)
: base(repository) : base(repository)
{ {
} }
@@ -44,7 +44,7 @@ namespace Yi.Framework.Ddd.Application
where TEntity : class, IEntity<TKey> where TEntity : class, IEntity<TKey>
where TEntityDto : IEntityDto<TKey> where TEntityDto : IEntityDto<TKey>
{ {
protected YiCrudAppService(IRepository<TEntity, TKey> repository) protected YiCrudAppService(IRepository<TEntity, TKey> repository)
: base(repository) : base(repository)
{ {
} }
@@ -58,7 +58,7 @@ namespace Yi.Framework.Ddd.Application
where TEntity : class, IEntity<TKey> where TEntity : class, IEntity<TKey>
where TEntityDto : IEntityDto<TKey> where TEntityDto : IEntityDto<TKey>
{ {
protected YiCrudAppService(IRepository<TEntity, TKey> repository) protected YiCrudAppService(IRepository<TEntity, TKey> repository)
: base(repository) : base(repository)
{ {
} }
@@ -78,7 +78,7 @@ namespace Yi.Framework.Ddd.Application
/// </summary> /// </summary>
private const string TempFilePath = "/wwwroot/temp"; private const string TempFilePath = "/wwwroot/temp";
protected YiCrudAppService(IRepository<TEntity, TKey> repository) protected YiCrudAppService(IRepository<TEntity, TKey> repository)
: base(repository) : base(repository)
{ {
} }
@@ -96,7 +96,7 @@ namespace Yi.Framework.Ddd.Application
// 获取并验证实体 // 获取并验证实体
var entity = await GetEntityByIdAsync(id); var entity = await GetEntityByIdAsync(id);
// 检查更新输入 // 检查更新输入
await CheckUpdateInputDtoAsync(entity, input); await CheckUpdateInputDtoAsync(entity, input);
@@ -124,10 +124,10 @@ namespace Yi.Framework.Ddd.Application
{ {
// 检查创建权限 // 检查创建权限
await CheckCreatePolicyAsync(); await CheckCreatePolicyAsync();
// 检查创建输入 // 检查创建输入
await CheckCreateInputDtoAsync(input); await CheckCreateInputDtoAsync(input);
// 映射到实体 // 映射到实体
var entity = await MapToEntityAsync(input); var entity = await MapToEntityAsync(input);
@@ -156,13 +156,13 @@ namespace Yi.Framework.Ddd.Application
public override async Task<PagedResultDto<TGetListOutputDto>> GetListAsync(TGetListInput input) public override async Task<PagedResultDto<TGetListOutputDto>> GetListAsync(TGetListInput input)
{ {
List<TEntity> entities; List<TEntity> entities;
// 根据输入类型决定查询方式 // 根据输入类型决定查询方式
if (input is IPagedResultRequest pagedInput) if (input is IPagedResultRequest pagedInput)
{ {
// 分页查询 // 分页查询
entities = await Repository.GetPagedListAsync( entities = await Repository.GetPagedListAsync(
pagedInput.SkipCount, pagedInput.SkipCount,
pagedInput.MaxResultCount, pagedInput.MaxResultCount,
string.Empty string.Empty
); );
@@ -176,7 +176,23 @@ namespace Yi.Framework.Ddd.Application
// 获取总数并映射结果 // 获取总数并映射结果
var totalCount = await Repository.GetCountAsync(); var totalCount = await Repository.GetCountAsync();
var dtos = await MapToGetListOutputDtosAsync(entities); 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); return new PagedResultDto<TGetListOutputDto>(totalCount, dtos);
} }

View File

@@ -1,7 +1,8 @@
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Modularity; using Volo.Abp.Modularity;
using Volo.Abp.ObjectMapping; using Volo.Abp.ObjectMapping;
using Yi.Framework.Core; using Yi.Framework.Core;
using Mapster;
namespace Yi.Framework.Mapster namespace Yi.Framework.Mapster
{ {
@@ -22,7 +23,8 @@ namespace Yi.Framework.Mapster
public override void ConfigureServices(ServiceConfigurationContext context) public override void ConfigureServices(ServiceConfigurationContext context)
{ {
var services = context.Services; var services = context.Services;
// 扫描并注册所有映射配置
TypeAdapterConfig.GlobalSettings.Scan(AppDomain.CurrentDomain.GetAssemblies());
// 注册Mapster相关服务 // 注册Mapster相关服务
services.AddTransient<IAutoObjectMappingProvider, MapsterAutoObjectMappingProvider>(); services.AddTransient<IAutoObjectMappingProvider, MapsterAutoObjectMappingProvider>();
services.AddTransient<IObjectMapper, MapsterObjectMapper>(); services.AddTransient<IObjectMapper, MapsterObjectMapper>();

View File

@@ -58,5 +58,10 @@ namespace Yi.Framework.SqlSugarCore.Abstractions
/// 是否启用SaaS多租户 /// 是否启用SaaS多租户
/// </summary> /// </summary>
public bool EnabledSaasMultiTenancy { get; set; } = false; public bool EnabledSaasMultiTenancy { get; set; } = false;
/// <summary>
/// 是否开启更新并发乐观锁
/// </summary>
public bool EnabledConcurrencyException { get;set; } = false;
} }
} }

View File

@@ -213,6 +213,10 @@ public class DefaultSqlSugarDbContext : SqlSugarDbContext
{ {
EntityChangeEventHelperService.PublishEntityDeletedEvent(entityInfo.EntityValue); EntityChangeEventHelperService.PublishEntityDeletedEvent(entityInfo.EntityValue);
} }
else
{
EntityChangeEventHelperService.PublishEntityUpdatedEvent(entityInfo.EntityValue);
}
} }
else else
{ {

View File

@@ -1,12 +1,9 @@
using System.Linq; using System.Linq.Expressions;
using System.Linq.Expressions; using Microsoft.Extensions.Options;
using System.Text;
using Microsoft.Extensions.Logging;
using Nito.AsyncEx; using Nito.AsyncEx;
using SqlSugar; using SqlSugar;
using Volo.Abp;
using Volo.Abp.Auditing;
using Volo.Abp.Data; using Volo.Abp.Data;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain.Entities; using Volo.Abp.Domain.Entities;
using Volo.Abp.Domain.Repositories; using Volo.Abp.Domain.Repositories;
using Volo.Abp.Linq; 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() public class SqlSugarRepository<TEntity> : ISqlSugarRepository<TEntity>, IRepository<TEntity> where TEntity : class, IEntity, new()
{ {
[Obsolete("使用GetDbContextAsync()")]
public ISqlSugarClient _Db => AsyncContext.Run(async () => await GetDbContextAsync()); public ISqlSugarClient _Db => AsyncContext.Run(async () => await GetDbContextAsync());
[Obsolete("使用AsQueryable()")]
public ISugarQueryable<TEntity> _DbQueryable => _Db.Queryable<TEntity>(); public ISugarQueryable<TEntity> _DbQueryable => _Db.Queryable<TEntity>();
private readonly ISugarDbContextProvider<ISqlSugarDbContext> _dbContextProvider; private readonly ISugarDbContextProvider<ISqlSugarDbContext> _dbContextProvider;
public IAbpLazyServiceProvider LazyServiceProvider { get; set; }
protected DbConnOptions? Options => LazyServiceProvider?.LazyGetService<IOptions<DbConnOptions>>().Value;
/// <summary> /// <summary>
/// 异步查询执行器 /// 异步查询执行器
/// </summary> /// </summary>
@@ -264,6 +266,7 @@ namespace Yi.Framework.SqlSugarCore.Repositories
if (typeof(ISoftDelete).IsAssignableFrom(typeof(TEntity))) if (typeof(ISoftDelete).IsAssignableFrom(typeof(TEntity)))
{ {
var entity = await GetByIdAsync(id); var entity = await GetByIdAsync(id);
if (entity == null) return false;
//反射赋值 //反射赋值
ReflexHelper.SetModelValue(nameof(ISoftDelete.IsDeleted), true, entity); ReflexHelper.SetModelValue(nameof(ISoftDelete.IsDeleted), true, entity);
return await UpdateAsync(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) 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) 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) 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) 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()) try
.Context.Updateable(updateObj).ExecuteCommandWithOptLockAsync(true); {
return num>0; int num = await (await GetDbSimpleClientAsync())
} .Context.Updateable(updateObj).ExecuteCommandWithOptLockAsync(true);
catch (VersionExceptions ex) return num > 0;
{ }
catch (VersionExceptions ex)
throw new AbpDbConcurrencyException($"{ex.Message}[更新失败ConcurrencyStamp不是最新版本],entityInfo{updateObj}", ex); {
throw new AbpDbConcurrencyException(
$"{ex.Message}[更新失败ConcurrencyStamp不是最新版本],entityInfo{updateObj}", ex);
}
} }
} }
return await (await GetDbSimpleClientAsync()).UpdateAsync(updateObj); return await (await GetDbSimpleClientAsync()).UpdateAsync(updateObj);
} }

View File

@@ -26,7 +26,7 @@ public static class SqlSugarCoreExtensions
ServiceLifetime serviceLifetime = ServiceLifetime.Transient) ServiceLifetime serviceLifetime = ServiceLifetime.Transient)
where TDbContext : class, ISqlSugarDbContextDependencies where TDbContext : class, ISqlSugarDbContextDependencies
{ {
services.TryAdd(new ServiceDescriptor( services.Add(new ServiceDescriptor(
typeof(ISqlSugarDbContextDependencies), typeof(ISqlSugarDbContextDependencies),
typeof(TDbContext), typeof(TDbContext),
serviceLifetime)); serviceLifetime));

View File

@@ -96,6 +96,7 @@ namespace Yi.Framework.Stock.Application.Services
.WhereIF(input.StartTime.HasValue, p => p.RecordTime >= input.StartTime.Value) .WhereIF(input.StartTime.HasValue, p => p.RecordTime >= input.StartTime.Value)
.WhereIF(input.EndTime.HasValue, p => p.RecordTime <= input.EndTime.Value) .WhereIF(input.EndTime.HasValue, p => p.RecordTime <= input.EndTime.Value)
.WhereIF(input.PeriodType.HasValue, p => p.PeriodType == input.PeriodType.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),input.Sorting)
.OrderByIF(string.IsNullOrEmpty(input.Sorting),p=>p.RecordTime); .OrderByIF(string.IsNullOrEmpty(input.Sorting),p=>p.RecordTime);

View File

@@ -52,6 +52,7 @@ namespace Yi.Framework.Stock.Domain.Entities
/// <summary> /// <summary>
/// 新闻内容 /// 新闻内容
/// </summary> /// </summary>
[SugarColumn(ColumnDataType = StaticConfig.CodeFirst_BigString)]
public string Content { get; set; } = string.Empty; public string Content { get; set; } = string.Empty;
/// <summary> /// <summary>

View File

@@ -2,7 +2,7 @@ namespace Yi.Framework.Stock.Domain.Managers.SemanticKernel
{ {
public class SemanticKernelOptions public class SemanticKernelOptions
{ {
public string ModelId { get; set; } public List<string> ModelIds { get; set; }
public string Endpoint { get; set; } public string Endpoint { get; set; }
public string ApiKey { get; set; } public string ApiKey { get; set; }
} }

View File

@@ -211,6 +211,7 @@ namespace Yi.Framework.Stock.Domain.Managers
// 获取最新的价格记录 // 获取最新的价格记录
var latestPriceRecord = await _stockPriceRecordRepository._DbQueryable var latestPriceRecord = await _stockPriceRecordRepository._DbQueryable
.Where(p => p.StockId == stockId) .Where(p => p.StockId == stockId)
.Where(x=>x.RecordTime<=DateTime.Now)
.OrderByDescending(p => p.RecordTime) .OrderByDescending(p => p.RecordTime)
.FirstAsync(); .FirstAsync();

View File

@@ -32,9 +32,10 @@ namespace Yi.Framework.Stock.Domain
#pragma warning disable SKEXP0010 #pragma warning disable SKEXP0010
// 从配置中获取值 // 从配置中获取值
var options = semanticKernelSection.Get<SemanticKernelOptions>(); var options = semanticKernelSection.Get<SemanticKernelOptions>();
//股市优先使用第一个ai模型
services.AddKernel() services.AddKernel()
.AddOpenAIChatCompletion( .AddOpenAIChatCompletion(
modelId: options.ModelId, modelId: options.ModelIds.FirstOrDefault(),
endpoint: new Uri(options.Endpoint), endpoint: new Uri(options.Endpoint),
apiKey: options.ApiKey); apiKey: options.ApiKey);
#pragma warning restore SKEXP0010 #pragma warning restore SKEXP0010

View File

@@ -5,8 +5,10 @@ namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Discuss
/// <summary> /// <summary>
/// Discuss输入创建对象 /// Discuss输入创建对象
/// </summary> /// </summary>
public class DiscussCreateInputVo public class DiscussCreateInput
{ {
public DiscussTypeEnum DiscussType { get; set; }
public string Title { get; set; } public string Title { get; set; }
public string? Types { get; set; } public string? Types { get; set; }
public string? Introduction { get; set; } public string? Introduction { get; set; }
@@ -41,5 +43,29 @@ namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Discuss
/// 角色 /// 角色
/// </summary> /// </summary>
public List<string>? PermissionRoleCodes { get; set; } = new List<string>(); 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; }
} }
} }

View File

@@ -32,6 +32,8 @@ namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Discuss
//是否置顶默认false //是否置顶默认false
public bool IsTop { get; set; } public bool IsTop { get; set; }
public DiscussTypeEnum DiscussType { get; set; }
public DiscussPermissionTypeEnum PermissionType { get; set; } public DiscussPermissionTypeEnum PermissionType { get; set; }
//是否禁止默认false //是否禁止默认false
public bool IsBan { get; set; } public bool IsBan { get; set; }

View File

@@ -24,7 +24,10 @@ namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Discuss
public Guid PlateId { get; set; } public Guid PlateId { get; set; }
//是否置顶默认false //是否置顶默认false
public bool IsTop { get; set; } public bool IsTop { get; set; }
/// <summary>
/// 主题类型
/// </summary>
public DiscussTypeEnum DiscussType { get; set; }
/// <summary> /// <summary>
/// 封面 /// 封面
/// </summary> /// </summary>
@@ -50,6 +53,7 @@ namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Discuss
public bool HasPermission { get;internal set; } public bool HasPermission { get;internal set; }
public DiscussRewardGetOutputDto? RewardData { get; set; }
/// <summary> /// <summary>
/// 设置权限 /// 设置权限
/// </summary> /// </summary>

View File

@@ -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; }
}

View File

@@ -2,7 +2,7 @@ using Yi.Framework.Bbs.Domain.Shared.Enums;
namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Discuss namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Discuss
{ {
public class DiscussUpdateInputVo public class DiscussUpdateInput
{ {
public string Title { get; set; } public string Title { get; set; }
public string? Types { get; set; } public string? Types { get; set; }

View File

@@ -6,7 +6,7 @@ namespace Yi.Framework.Bbs.Application.Contracts.IServices
/// <summary> /// <summary>
/// Discuss服务抽象 /// Discuss服务抽象
/// </summary> /// </summary>
public interface IDiscussService : IYiCrudAppService<DiscussGetOutputDto, DiscussGetListOutputDto, Guid, DiscussGetListInputVo, DiscussCreateInputVo, DiscussUpdateInputVo> public interface IDiscussService : IYiCrudAppService<DiscussGetOutputDto, DiscussGetListOutputDto, Guid, DiscussGetListInputVo, DiscussCreateInput, DiscussUpdateInput>
{ {
} }
} }

View File

@@ -8,7 +8,7 @@ namespace Yi.Framework.Bbs.Application.Services
{ {
public class BbsUserInfoService : ApplicationService, IBbsUserInfoService public class BbsUserInfoService : ApplicationService, IBbsUserInfoService
{ {
private BbsUserManager _bbsUserManager; private readonly BbsUserManager _bbsUserManager;
public BbsUserInfoService(BbsUserManager bbsUserManager) public BbsUserInfoService(BbsUserManager bbsUserManager)
{ {
_bbsUserManager = bbsUserManager; _bbsUserManager = bbsUserManager;

View File

@@ -2,8 +2,10 @@
using Volo.Abp; using Volo.Abp;
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
using Volo.Abp.Uow; using Volo.Abp.Uow;
using Volo.Abp.Users;
using Yi.Framework.Bbs.Application.Contracts.Dtos.Argee; using Yi.Framework.Bbs.Application.Contracts.Dtos.Argee;
using Yi.Framework.Bbs.Domain.Entities.Forum; using Yi.Framework.Bbs.Domain.Entities.Forum;
using Yi.Framework.Bbs.Domain.Managers;
using Yi.Framework.SqlSugarCore.Abstractions; using Yi.Framework.SqlSugarCore.Abstractions;
namespace Yi.Framework.Bbs.Application.Services.Forum namespace Yi.Framework.Bbs.Application.Services.Forum
@@ -13,12 +15,13 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
/// </summary> /// </summary>
public class AgreeService : ApplicationService, IApplicationService 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; _repository = repository;
_discssRepository = discssRepository; _discssRepository = discssRepository;
_bbsUserManager = bbsUserManager;
} }
private readonly BbsUserManager _bbsUserManager;
private ISqlSugarRepository<AgreeEntity> _repository { get; set; } private ISqlSugarRepository<AgreeEntity> _repository { get; set; }
private ISqlSugarRepository<DiscussAggregateRoot> _discssRepository { get; set; } private ISqlSugarRepository<DiscussAggregateRoot> _discssRepository { get; set; }
@@ -26,17 +29,17 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
/// <summary> /// <summary>
/// 点赞,返回true为点赞+1返回false为点赞-1 /// 点赞,返回true为点赞+1返回false为点赞-1
/// Todo: 可放入领域层 /// Todo: 可放入领域层,但是没必要,这个项目太简单了
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
[Authorize] [Authorize]
public async Task<AgreeDto> PostOperateAsync(Guid discussId) 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); var entity = await _repository.GetFirstAsync(x => x.DiscussId == discussId && x.CreatorId == CurrentUser.Id);
//判断是否已经点赞过 //判断是否已经点赞过
if (entity is null) if (entity is null)
{ {
//没点赞过,添加记录即可,,修改总点赞数量 //没点赞过,添加记录即可,,修改总点赞数量
await _repository.InsertAsync(new AgreeEntity(discussId)); await _repository.InsertAsync(new AgreeEntity(discussId));
var discussEntity = await _discssRepository.GetByIdAsync(discussId); var discussEntity = await _discssRepository.GetByIdAsync(discussId);

View File

@@ -1,28 +1,20 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Text; using System.Text;
using Mapster; using Mapster;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
using SqlSugar; using SqlSugar;
using Volo.Abp;
using Volo.Abp.Application.Dtos; 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.Article;
using Yi.Framework.Bbs.Application.Contracts.Dtos.Plate;
using Yi.Framework.Bbs.Application.Contracts.IServices; using Yi.Framework.Bbs.Application.Contracts.IServices;
using Yi.Framework.Bbs.Domain.Entities.Forum; using Yi.Framework.Bbs.Domain.Entities.Forum;
using Yi.Framework.Bbs.Domain.Managers; using Yi.Framework.Bbs.Domain.Managers;
using Yi.Framework.Bbs.Domain.Repositories; using Yi.Framework.Bbs.Domain.Repositories;
using Yi.Framework.Bbs.Domain.Shared.Consts; using Yi.Framework.Bbs.Domain.Shared.Consts;
using Yi.Framework.Bbs.Domain.Shared.Model; using Yi.Framework.Bbs.Domain.Shared.Model;
using Yi.Framework.Core.Extensions;
using Yi.Framework.Ddd.Application; using Yi.Framework.Ddd.Application;
using Yi.Framework.Rbac.Domain.Authorization; using Yi.Framework.Rbac.Domain.Authorization;
using Yi.Framework.Rbac.Domain.Extensions;
using Yi.Framework.Rbac.Domain.Shared.Consts;
using Yi.Framework.SqlSugarCore.Abstractions; using Yi.Framework.SqlSugarCore.Abstractions;
namespace Yi.Framework.Bbs.Application.Services.Forum namespace Yi.Framework.Bbs.Application.Services.Forum
@@ -36,19 +28,16 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
{ {
public ArticleService(IArticleRepository articleRepository, public ArticleService(IArticleRepository articleRepository,
ISqlSugarRepository<DiscussAggregateRoot> discussRepository, ISqlSugarRepository<DiscussAggregateRoot> discussRepository,
IDiscussService discussService,
ForumManager forumManager) : base(articleRepository) ForumManager forumManager) : base(articleRepository)
{ {
_articleRepository = articleRepository; _articleRepository = articleRepository;
_discussRepository = discussRepository; _discussRepository = discussRepository;
_discussService = discussService;
_forumManager = forumManager; _forumManager = forumManager;
} }
private ForumManager _forumManager; private readonly ForumManager _forumManager;
private IArticleRepository _articleRepository; private readonly IArticleRepository _articleRepository;
private ISqlSugarRepository<DiscussAggregateRoot> _discussRepository; private readonly ISqlSugarRepository<DiscussAggregateRoot> _discussRepository;
private IDiscussService _discussService;
public override async Task<PagedResultDto<ArticleGetListOutputDto>> GetListAsync(ArticleGetListInputVo input) public override async Task<PagedResultDto<ArticleGetListOutputDto>> GetListAsync(ArticleGetListInputVo input)
{ {
@@ -123,7 +112,7 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
/// <exception cref="UserFriendlyException"></exception> /// <exception cref="UserFriendlyException"></exception>
[Permission("bbs:article:add")] [Permission("bbs:article:add")]
[Authorize] [Authorize]
public async override Task<ArticleGetOutputDto> CreateAsync(ArticleCreateInputVo input) public override async Task<ArticleGetOutputDto> CreateAsync(ArticleCreateInputVo input)
{ {
await VerifyPermissionAsync(input.DiscussId); await VerifyPermissionAsync(input.DiscussId);
return await base.CreateAsync(input); return await base.CreateAsync(input);

View File

@@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Mvc;
using SqlSugar; using SqlSugar;
using Volo.Abp; using Volo.Abp;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
using Volo.Abp.Users;
using Yi.Framework.Bbs.Application.Contracts.Dtos.BbsUser; using Yi.Framework.Bbs.Application.Contracts.Dtos.BbsUser;
using Yi.Framework.Bbs.Application.Contracts.Dtos.Comment; using Yi.Framework.Bbs.Application.Contracts.Dtos.Comment;
using Yi.Framework.Bbs.Application.Contracts.IServices; using Yi.Framework.Bbs.Application.Contracts.IServices;
@@ -34,14 +35,11 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
_repository = CommentRepository; _repository = CommentRepository;
_bbsUserManager = bbsUserManager; _bbsUserManager = bbsUserManager;
} }
private ForumManager _forumManager { get; set; } private ForumManager _forumManager { get; set; }
private ISqlSugarRepository<DiscussAggregateRoot> _discussRepository { get; set; } private ISqlSugarRepository<DiscussAggregateRoot> _discussRepository { get; set; }
private IDiscussService _discussService { get; set; } private IDiscussService _discussService { get; set; }
/// <summary> /// <summary>
/// 获取改主题下的评论,结构为二维列表,该查询无分页 /// 获取改主题下的评论,结构为二维列表,该查询无分页
/// </summary> /// </summary>
@@ -127,7 +125,7 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
{ {
throw new UserFriendlyException("评论不能为空"); throw new UserFriendlyException("评论不能为空");
} }
await _bbsUserManager.VerifyUserLimitAsync(CurrentUser.GetId());
var discuess = await _discussRepository.GetFirstAsync(x => x.Id == input.DiscussId); var discuess = await _discussRepository.GetFirstAsync(x => x.Id == input.DiscussId);
if (discuess is null) if (discuess is null)
{ {

View File

@@ -3,7 +3,6 @@ using Mapster;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using SqlSugar; using SqlSugar;
using TencentCloud.Pds.V20210701.Models;
using Volo.Abp; using Volo.Abp;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
using Volo.Abp.EventBus.Local; using Volo.Abp.EventBus.Local;
@@ -33,17 +32,19 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
/// Discuss应用服务实现,用于参数校验、领域服务业务组合、日志记录、事务处理、账户信息 /// Discuss应用服务实现,用于参数校验、领域服务业务组合、日志记录、事务处理、账户信息
/// </summary> /// </summary>
public class DiscussService : YiCrudAppService<DiscussAggregateRoot, DiscussGetOutputDto, DiscussGetListOutputDto, public class DiscussService : YiCrudAppService<DiscussAggregateRoot, DiscussGetOutputDto, DiscussGetListOutputDto,
Guid, DiscussGetListInputVo, DiscussCreateInputVo, DiscussUpdateInputVo>, Guid, DiscussGetListInputVo, DiscussCreateInput, DiscussUpdateInput>,
IDiscussService IDiscussService
{ {
private ISqlSugarRepository<DiscussTopEntity> _discussTopRepository; private ISqlSugarRepository<DiscussTopEntity> _discussTopRepository;
private ISqlSugarRepository<AgreeEntity> _agreeRepository; private ISqlSugarRepository<AgreeEntity> _agreeRepository;
private BbsUserManager _bbsUserManager; private BbsUserManager _bbsUserManager;
private IDiscussLableRepository _discussLableRepository; private IDiscussLableRepository _discussLableRepository;
public DiscussService(BbsUserManager bbsUserManager, ForumManager forumManager, public DiscussService(BbsUserManager bbsUserManager, ForumManager forumManager,
ISqlSugarRepository<DiscussTopEntity> discussTopRepository, ISqlSugarRepository<DiscussTopEntity> discussTopRepository,
ISqlSugarRepository<PlateAggregateRoot> plateEntityRepository, ILocalEventBus localEventBus, ISqlSugarRepository<PlateAggregateRoot> plateEntityRepository, ILocalEventBus localEventBus,
ISqlSugarRepository<AgreeEntity> agreeRepository, IDiscussLableRepository discussLableRepository) : base(forumManager._discussRepository) ISqlSugarRepository<AgreeEntity> agreeRepository, IDiscussLableRepository discussLableRepository) : base(
forumManager._discussRepository)
{ {
_forumManager = forumManager; _forumManager = forumManager;
_plateEntityRepository = plateEntityRepository; _plateEntityRepository = plateEntityRepository;
@@ -59,13 +60,13 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
private ISqlSugarRepository<PlateAggregateRoot> _plateEntityRepository { get; set; } private ISqlSugarRepository<PlateAggregateRoot> _plateEntityRepository { get; set; }
/// <summary> /// <summary>
/// 单查 /// 单查
/// </summary> /// </summary>
/// <param name="id"></param> /// <param name="id"></param>
/// <returns></returns> /// <returns></returns>
public async override Task<DiscussGetOutputDto> GetAsync(Guid id) public override async Task<DiscussGetOutputDto> GetAsync(Guid id)
{ {
//查询主题发布 浏览主题 事件,浏览数+1 //查询主题发布 浏览主题 事件,浏览数+1
var output = await _forumManager._discussRepository._DbQueryable var output = await _forumManager._discussRepository._DbQueryable
@@ -98,32 +99,44 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
}, true) }, true)
.FirstAsync(discuss => discuss.Id == id); .FirstAsync(discuss => discuss.Id == id);
if (output is null) if (output is null)
{ {
throw new UserFriendlyException("该主题不存在", "404"); 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 = 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) if (CurrentUser.Id is not null)
{ {
output.IsAgree = agreeCreatorList.Contains(CurrentUser.Id); output.IsAgree = agreeCreatorList.Contains(CurrentUser.Id);
} }
//组装标签 //组装标签
var lableDic=await _discussLableRepository.GetDiscussLableCacheMapAsync(); var lableDic = await _discussLableRepository.GetDiscussLableCacheMapAsync();
foreach (var lableId in output.DiscussLableIds) 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>()); 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(); output.SetNoPermission();
} }
@@ -131,11 +144,12 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
{ {
output.SetPassPermission(); output.SetPassPermission();
} }
await _localEventBus.PublishAsync(new SeeDiscussEventArgs await _localEventBus.PublishAsync(new SeeDiscussEventArgs
{ DiscussId = output.Id, OldSeeNum = output.SeeNum }); { DiscussId = output.Id, OldSeeNum = output.SeeNum });
return output; return output;
} }
/// <summary> /// <summary>
/// 查询 /// 查询
/// </summary> /// </summary>
@@ -159,7 +173,8 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
// .OrderByIF(input.Type == QueryDiscussTypeEnum.New, // .OrderByIF(input.Type == QueryDiscussTypeEnum.New,
// @"COALESCE(discuss.LastModificationTime, discuss.CreationTime) DESC") // @"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.Host, discuss => discuss.SeeNum, OrderByType.Desc)
.OrderByIF(input.Type == QueryDiscussTypeEnum.Suggest, discuss => discuss.AgreeNum, OrderByType.Desc) .OrderByIF(input.Type == QueryDiscussTypeEnum.Suggest, discuss => discuss.AgreeNum, OrderByType.Desc)
.Select((discuss, user, info) => new DiscussGetListOutputDto .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()) (await _agreeRepository._DbQueryable.Where(x => discussId.Contains(x.DiscussId)).ToListAsync())
.GroupBy(x => x.DiscussId) .GroupBy(x => x.DiscussId)
.ToDictionary(x => x.Key, y => y.Select(y => y.CreatorId).ToList()); .ToDictionary(x => x.Key, y => y.Select(y => y.CreatorId).ToList());
var levelCacheDic= await _bbsUserManager.GetLevelCacheMapAsync(); var levelCacheDic = await _bbsUserManager.GetLevelCacheMapAsync();
var lableDic=await _discussLableRepository.GetDiscussLableCacheMapAsync(); var lableDic = await _discussLableRepository.GetDiscussLableCacheMapAsync();
//组装等级、是否点赞赋值、标签 //组装等级、是否点赞赋值、标签
items?.ForEach(x => items?.ForEach(x =>
{ {
@@ -198,20 +213,19 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
if (CurrentUser.Id is not null) if (CurrentUser.Id is not null)
{ {
//默认fasle //默认fasle
if (agreeDic.TryGetValue(x.Id,out var userIds)) if (agreeDic.TryGetValue(x.Id, out var userIds))
{ {
x.IsAgree = userIds.Contains(CurrentUser.Id); x.IsAgree = userIds.Contains(CurrentUser.Id);
} }
} }
foreach (var lableId in x.DiscussLableIds) 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>()); x.Lables.Add(item.Adapt<DiscussLableGetOutputDto>());
} }
} }
}); });
return new PagedResultDto<DiscussGetListOutputDto>(total, items); return new PagedResultDto<DiscussGetListOutputDto>(total, items);
} }
@@ -253,15 +267,15 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
} }
}, true) }, true)
.ToListAsync(); .ToListAsync();
var levelCacheDic= await _bbsUserManager.GetLevelCacheMapAsync(); var levelCacheDic = await _bbsUserManager.GetLevelCacheMapAsync();
var lableDic=await _discussLableRepository.GetDiscussLableCacheMapAsync(); var lableDic = await _discussLableRepository.GetDiscussLableCacheMapAsync();
output?.ForEach(x => 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) 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>()); x.Lables.Add(item.Adapt<DiscussLableGetOutputDto>());
} }
@@ -277,7 +291,7 @@ namespace Yi.Framework.Bbs.Application.Services.Forum
/// <returns></returns> /// <returns></returns>
[Permission("bbs:discuss:add")] [Permission("bbs:discuss:add")]
[Authorize] [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); var plate = await _plateEntityRepository.FindAsync(x => x.Id == input.PlateId);
if (plate is null) 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); return await MapToGetOutputDtoAsync(entity);
} }
/// <summary>
public override Task<DiscussGetOutputDto> UpdateAsync(Guid id, DiscussUpdateInputVo input) /// 设置悬赏主题已解决
/// </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);
} }
} }
} }

View File

@@ -0,0 +1,17 @@
namespace Yi.Framework.Bbs.Domain.Shared.Enums;
/// <summary>
/// 主题类型
/// </summary>
public enum DiscussTypeEnum
{
/// <summary>
/// 文章
/// </summary>
Article = 0,
/// <summary>
/// 悬赏
/// </summary>
Reward=1
}

View File

@@ -39,6 +39,11 @@ namespace Yi.Framework.Bbs.Domain.Entities.Forum
public string? Introduction { get; set; } public string? Introduction { get; set; }
public int AgreeNum { get; set; } public int AgreeNum { get; set; }
public int SeeNum { get; set; } public int SeeNum { get; set; }
/// <summary>
/// 主题类型
/// </summary>
public DiscussTypeEnum DiscussType { get; set; }
/// <summary> /// <summary>
/// 封面 /// 封面
/// </summary> /// </summary>

View File

@@ -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;
}
}

View File

@@ -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.Domain.Entities.Events;
using Volo.Abp.EventBus; using Volo.Abp.EventBus;
using Volo.Abp.EventBus.Local; using Volo.Abp.EventBus.Local;

View File

@@ -13,25 +13,49 @@ namespace Yi.Framework.Bbs.Domain.Managers
public class BbsUserManager : DomainService public class BbsUserManager : DomainService
{ {
public ISqlSugarRepository<UserAggregateRoot> _userRepository; public ISqlSugarRepository<UserAggregateRoot> _userRepository;
public ISqlSugarRepository<BbsUserExtraInfoEntity> _bbsUserInfoRepository;
// public Dictionary<int, LevelCacheItem> _levelCacheDic; private readonly LevelManager _levelManager;
private LevelManager _levelManager;
public BbsUserManager(ISqlSugarRepository<UserAggregateRoot> userRepository, public BbsUserManager(ISqlSugarRepository<UserAggregateRoot> userRepository,
ISqlSugarRepository<BbsUserExtraInfoEntity> bbsUserInfoRepository, ISqlSugarRepository<BbsUserExtraInfoEntity> bbsUserInfoRepository,
LevelManager levelManager LevelManager levelManager
) )
{ {
_userRepository = userRepository; _userRepository = userRepository;
_bbsUserInfoRepository = bbsUserInfoRepository;
_levelManager = levelManager; _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() public async Task<Dictionary<int, LevelCacheItem>> GetLevelCacheMapAsync()
{ {
return await _levelManager.GetCacheMapAsync(); return await _levelManager.GetCacheMapAsync();
} }
/// <summary>
/// 获取bbs用户信息
/// </summary>
/// <param name="userId"></param>
/// <returns></returns>
public async Task<BbsUserInfoDto?> GetBbsUserInfoAsync(Guid userId) public async Task<BbsUserInfoDto?> GetBbsUserInfoAsync(Guid userId)
{ {
var userInfo = await _userRepository._DbQueryable var userInfo = await _userRepository._DbQueryable
@@ -50,7 +74,7 @@ namespace Yi.Framework.Bbs.Domain.Managers
}, true) }, true)
.FirstAsync(user => user.Id == userId); .FirstAsync(user => user.Id == userId);
var levelCacheDic= await GetLevelCacheMapAsync(); var levelCacheDic = await GetLevelCacheMapAsync();
userInfo.LevelName = levelCacheDic[userInfo.Level].Name; userInfo.LevelName = levelCacheDic[userInfo.Level].Name;
return userInfo; return userInfo;
} }
@@ -73,8 +97,8 @@ namespace Yi.Framework.Bbs.Domain.Managers
DiscussNumber = info.DiscussNumber DiscussNumber = info.DiscussNumber
}, true) }, true)
.ToListAsync(); .ToListAsync();
var levelCacheDic= await GetLevelCacheMapAsync(); var levelCacheDic = await GetLevelCacheMapAsync();
userInfos?.ForEach(userInfo => userInfo.LevelName =levelCacheDic[userInfo.Level].Name); userInfos?.ForEach(userInfo => userInfo.LevelName = levelCacheDic[userInfo.Level].Name);
return userInfos ?? new List<BbsUserInfoDto>(); return userInfos ?? new List<BbsUserInfoDto>();
} }

View File

@@ -21,21 +21,30 @@ namespace Yi.Framework.Bbs.Domain.Managers
public readonly ISqlSugarRepository<PlateAggregateRoot, Guid> _plateEntityRepository; public readonly ISqlSugarRepository<PlateAggregateRoot, Guid> _plateEntityRepository;
public readonly ISqlSugarRepository<CommentAggregateRoot, Guid> _commentRepository; public readonly ISqlSugarRepository<CommentAggregateRoot, Guid> _commentRepository;
public readonly ISqlSugarRepository<ArticleAggregateRoot, Guid> _articleRepository; 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; _discussRepository = discussRepository;
_plateEntityRepository = plateEntityRepository; _plateEntityRepository = plateEntityRepository;
_commentRepository = commentRepository; _commentRepository = commentRepository;
_articleRepository = articleRepository; _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.CreationTime = DateTime.Now;
entity.AgreeNum = 0; entity.AgreeNum = 0;
entity.SeeNum = 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) public async Task<CommentAggregateRoot> CreateCommentAsync(Guid discussId, Guid parentId, Guid rootId, string content)

View File

@@ -37,10 +37,10 @@ namespace Yi.Framework.Bbs.Domain.Managers
/// <returns></returns> /// <returns></returns>
public async Task<Dictionary<int, LevelCacheItem>> GetCacheMapAsync() 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) var cacheItem = ((await _repository.GetListAsync())
.OrderByDescending(x => x.CurrentLevel).ToList() .OrderByDescending(x => x.CurrentLevel))
.Adapt<List<LevelCacheItem>>(); .Adapt<List<LevelCacheItem>>();
return cacheItem; return cacheItem;
}); });

View File

@@ -23,7 +23,7 @@ namespace Yi.Framework.ChatHub.Application.Services
/// <param name="chatContext"></param> /// <param name="chatContext"></param>
/// <returns></returns> /// <returns></returns>
[Authorize] [Authorize]
[HttpPost("ai-chat/chat/{model}")] [HttpPost("ai-chat/chat/{*model}")]
public async Task ChatAsync([FromRoute]string model, [FromBody] List<AiChatContextDto> chatContext) public async Task ChatAsync([FromRoute]string model, [FromBody] List<AiChatContextDto> chatContext)
{ {
const int maxChar = 10; const int maxChar = 10;

View File

@@ -1,6 +1,9 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Net; using System.Net;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.ChatCompletion;
using Microsoft.SemanticKernel.Connectors.OpenAI;
// using OpenAI; // using OpenAI;
// using OpenAI.Managers; // using OpenAI.Managers;
// using OpenAI.ObjectModels; // using OpenAI.ObjectModels;
@@ -14,61 +17,50 @@ namespace Yi.Framework.ChatHub.Domain.Managers
{ {
public class AiManager : ISingletonDependency public class AiManager : ISingletonDependency
{ {
public AiManager(IOptions<AiOptions> options) private readonly Kernel _kernel;
public AiManager(Kernel kernel)
{ {
// this.OpenAIService = new OpenAIService(new OpenAiOptions() _kernel = kernel;
// {
// ApiKey = options.Value.ApiKey,
// BaseDomain = options.Value.BaseDomain
// });
} }
// 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重构"); if (aiChatContextDtos.Count == 0)
yield break; {
// if (aiChatContextDtos.Count == 0) yield return null;
// { }
// yield return null; var openSettings = new OpenAIPromptExecutionSettings()
// } {
// MaxTokens =1000
// List<ChatMessage> messages = aiChatContextDtos.Select(x => };
// {
// if (x.AnswererType == AnswererTypeEnum.Ai) var chatCompletionService = this._kernel.GetRequiredService<IChatCompletionService>(model);
// {
// return ChatMessage.FromSystem(x.Message); var history =new ChatHistory();
// } foreach (var aiChatContextDto in aiChatContextDtos)
// else {
// { if (aiChatContextDto.AnswererType==AnswererTypeEnum.Ai)
// return ChatMessage.FromUser(x.Message); {
// } history.AddSystemMessage(aiChatContextDto.Message);
// }).ToList(); }
// var completionResult = OpenAIService.ChatCompletion.CreateCompletionAsStream(new ChatCompletionCreateRequest else if(aiChatContextDto.AnswererType==AnswererTypeEnum.User)
// { {
// Messages = messages, history.AddUserMessage(aiChatContextDto.Message);
// Model =model }
// }); }
//
// HttpStatusCode? error = null; var results = chatCompletionService.GetStreamingChatMessageContentsAsync(
// await foreach (var result in completionResult) chatHistory: history,
// { executionSettings: openSettings,
// if (result.Successful) kernel: _kernel);
// { if (results is null)
// yield return result.Choices.FirstOrDefault()?.Message.Content ?? null; {
// } yield return null;
// else }
// { await foreach (var result in results)
// error = result.HttpStatusCode; {
// break; yield return result.Content;
// } }
//
// }
// if (error == HttpStatusCode.PaymentRequired)
// {
// yield return "余额不足,请联系站长充值";
//
// }
} }
} }
} }

View File

@@ -8,7 +8,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Volo.Abp.AspNetCore.SignalR" Version="$(AbpVersion)" /> <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.Ddd.Domain" Version="$(AbpVersion)" />
<PackageReference Include="Volo.Abp.Caching" Version="$(AbpVersion)" /> <PackageReference Include="Volo.Abp.Caching" Version="$(AbpVersion)" />
<ProjectReference Include="..\..\..\framework\Yi.Framework.Caching.FreeRedis\Yi.Framework.Caching.FreeRedis.csproj" /> <ProjectReference Include="..\..\..\framework\Yi.Framework.Caching.FreeRedis\Yi.Framework.Caching.FreeRedis.csproj" />

View File

@@ -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.Caching.FreeRedis;
using Yi.Framework.ChatHub.Domain.Shared; using Yi.Framework.ChatHub.Domain.Shared;
using Yi.Framework.Core.Options;
namespace Yi.Framework.ChatHub.Domain namespace Yi.Framework.ChatHub.Domain
@@ -13,9 +17,27 @@ namespace Yi.Framework.ChatHub.Domain
)] )]
public class YiFrameworkChatHubDomainModule : AbpModule 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
} }
} }
} }

View File

@@ -6,8 +6,10 @@ using System.Threading.Tasks;
using Mapster; using Mapster;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Caching.Memory;
using Volo.Abp; using Volo.Abp;
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
using Volo.Abp.Caching;
using Volo.Abp.Domain.Repositories; using Volo.Abp.Domain.Repositories;
using Volo.Abp.Guids; using Volo.Abp.Guids;
using Yi.Framework.Core.Enums; 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.Application.Contracts.IServices;
using Yi.Framework.Rbac.Domain.Entities; using Yi.Framework.Rbac.Domain.Entities;
using Yi.Framework.Rbac.Domain.Managers; using Yi.Framework.Rbac.Domain.Managers;
using Yi.Framework.Rbac.Domain.Shared.Caches;
namespace Yi.Framework.Rbac.Application.Services namespace Yi.Framework.Rbac.Application.Services
{ {
@@ -23,11 +26,13 @@ namespace Yi.Framework.Rbac.Application.Services
{ {
private readonly IRepository<FileAggregateRoot> _repository; private readonly IRepository<FileAggregateRoot> _repository;
private readonly FileManager _fileManager; 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; _repository = repository;
_fileManager = fileManager; _fileManager = fileManager;
_memoryCache = memoryCache;
} }
/// <summary> /// <summary>
@@ -37,14 +42,22 @@ namespace Yi.Framework.Rbac.Application.Services
[Route("file/{code}/{isThumbnail?}")] [Route("file/{code}/{isThumbnail?}")]
public async Task<IActionResult> Get([FromRoute] Guid code, [FromRoute] bool? 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); var path = file?.GetQueryFileSavePath(isThumbnail);
if (path is null || !File.Exists(path)) if (path is null || !File.Exists(path))
{ {
return new NotFoundResult(); 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> /// <summary>
@@ -57,12 +70,13 @@ namespace Yi.Framework.Rbac.Application.Services
for (int i = 0; i < file.Count; i++) for (int i = 0; i < file.Count; i++)
{ {
var entity= entities[i]; var entity = entities[i];
using (var steam = file[i].OpenReadStream()) using (var steam = file[i].OpenReadStream())
{ {
await _fileManager.SaveFileAsync(entity,steam); await _fileManager.SaveFileAsync(entity, steam);
} }
} }
return entities.Adapt<List<FileGetListOutputDto>>(); return entities.Adapt<List<FileGetListOutputDto>>();
} }
} }

View File

@@ -3,7 +3,6 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using Microsoft.VisualBasic; using Microsoft.VisualBasic;
using TencentCloud.Mna.V20210119.Models;
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
using Volo.Abp.Caching; using Volo.Abp.Caching;
using Volo.Abp.DependencyInjection; using Volo.Abp.DependencyInjection;

View File

@@ -51,7 +51,7 @@ namespace Yi.Framework.Rbac.Application.Services.System
.WhereIF(!string.IsNullOrEmpty(input.DeptName), u => u.DeptName.Contains(input.DeptName!)) .WhereIF(!string.IsNullOrEmpty(input.DeptName), u => u.DeptName.Contains(input.DeptName!))
.WhereIF(input.State is not null, u => u.State == input.State) .WhereIF(input.State is not null, u => u.State == input.State)
.OrderBy(u => u.OrderNum, OrderByType.Asc) .OrderBy(u => u.OrderNum, OrderByType.Asc)
.ToPageListAsync(input.SkipCount, input.MaxResultCount, total); .ToListAsync();
return new PagedResultDto<DeptGetListOutputDto> return new PagedResultDto<DeptGetListOutputDto>
{ {
Items = await MapToGetListOutputDtosAsync(entities), Items = await MapToGetListOutputDtosAsync(entities),

View File

@@ -1,3 +1,4 @@
using Microsoft.AspNetCore.Mvc;
using SqlSugar; using SqlSugar;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
using Yi.Framework.Ddd.Application; using Yi.Framework.Ddd.Application;
@@ -54,5 +55,25 @@ namespace Yi.Framework.Rbac.Application.Services.System
throw new UserFriendlyException(RoleConst.Exist); 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);
}
} }
} }

View File

@@ -1,6 +1,5 @@
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using SqlSugar; using SqlSugar;
using TencentCloud.Tcr.V20190924.Models;
using Volo.Abp; using Volo.Abp;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
using Volo.Abp.Caching; using Volo.Abp.Caching;

View File

@@ -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; }
}

View File

@@ -34,8 +34,7 @@ namespace Yi.Framework.Rbac.Domain.Entities
var type = GetFileType(); var type = GetFileType();
var savePath = GetSaveFilePath(); var savePath = GetSaveFilePath();
var filePath = Path.Combine(savePath, this.FileName); this.FilePath = savePath;
this.FilePath = filePath;
} }
/// <summary> /// <summary>

View File

@@ -1,59 +1,59 @@
using System; // using System;
using System.Collections.Generic; // using System.Collections.Generic;
using System.Linq; // using System.Linq;
using System.Text; // using System.Text;
using System.Threading.Tasks; // using System.Threading.Tasks;
using TencentCloud.Common.Profile; // using TencentCloud.Common.Profile;
using TencentCloud.Common; // using TencentCloud.Common;
using TencentCloud.Sms.V20210111.Models; // using TencentCloud.Sms.V20210111.Models;
using TencentCloud.Sms.V20210111; // using TencentCloud.Sms.V20210111;
using Volo.Abp.Domain.Services; // using Volo.Abp.Domain.Services;
using Microsoft.Extensions.Logging; // using Microsoft.Extensions.Logging;
//
namespace Yi.Framework.Rbac.Domain.Managers // namespace Yi.Framework.Rbac.Domain.Managers
{ // {
public class TencentCloudManager : DomainService // public class TencentCloudManager : DomainService
{ // {
private ILogger<TencentCloudManager> _logger; // private ILogger<TencentCloudManager> _logger;
public TencentCloudManager(ILogger<TencentCloudManager> logger) // public TencentCloudManager(ILogger<TencentCloudManager> logger)
{ // {
_logger= logger; // _logger= logger;
} // }
//
public async Task SendSmsAsync() // public async Task SendSmsAsync()
{ // {
//
try // try
{ // {
// 实例化一个认证对象,入参需要传入腾讯云账户 SecretId 和 SecretKey此处还需注意密钥对的保密 // // 实例化一个认证对象,入参需要传入腾讯云账户 SecretId 和 SecretKey此处还需注意密钥对的保密
// 代码泄露可能会导致 SecretId 和 SecretKey 泄露并威胁账号下所有资源的安全性。以下代码示例仅供参考建议采用更安全的方式来使用密钥请参见https://cloud.tencent.com/document/product/1278/85305 // // 代码泄露可能会导致 SecretId 和 SecretKey 泄露并威胁账号下所有资源的安全性。以下代码示例仅供参考建议采用更安全的方式来使用密钥请参见https://cloud.tencent.com/document/product/1278/85305
// 密钥可前往官网控制台 https://console.cloud.tencent.com/cam/capi 进行获取 // // 密钥可前往官网控制台 https://console.cloud.tencent.com/cam/capi 进行获取
Credential cred = new Credential // Credential cred = new Credential
{ // {
SecretId = "SecretId", // SecretId = "SecretId",
SecretKey = "SecretKey" // SecretKey = "SecretKey"
}; // };
// 实例化一个client选项可选的没有特殊需求可以跳过 // // 实例化一个client选项可选的没有特殊需求可以跳过
ClientProfile clientProfile = new ClientProfile(); // ClientProfile clientProfile = new ClientProfile();
// 实例化一个http选项可选的没有特殊需求可以跳过 // // 实例化一个http选项可选的没有特殊需求可以跳过
HttpProfile httpProfile = new HttpProfile(); // HttpProfile httpProfile = new HttpProfile();
httpProfile.Endpoint = ("sms.tencentcloudapi.com"); // httpProfile.Endpoint = ("sms.tencentcloudapi.com");
clientProfile.HttpProfile = httpProfile; // clientProfile.HttpProfile = httpProfile;
//
// 实例化要请求产品的client对象,clientProfile是可选的 // // 实例化要请求产品的client对象,clientProfile是可选的
SmsClient client = new SmsClient(cred, "", clientProfile); // SmsClient client = new SmsClient(cred, "", clientProfile);
// 实例化一个请求对象,每个接口都会对应一个request对象 // // 实例化一个请求对象,每个接口都会对应一个request对象
SendSmsRequest req = new SendSmsRequest(); // SendSmsRequest req = new SendSmsRequest();
//
// 返回的resp是一个SendSmsResponse的实例与请求对象对应 // // 返回的resp是一个SendSmsResponse的实例与请求对象对应
SendSmsResponse resp = await client.SendSms(req); // SendSmsResponse resp = await client.SendSms(req);
// 输出json格式的字符串回包 // // 输出json格式的字符串回包
_logger.LogInformation("腾讯云Sms返回"+AbstractModel.ToJsonString(resp)); // _logger.LogInformation("腾讯云Sms返回"+AbstractModel.ToJsonString(resp));
} // }
catch (Exception e) // catch (Exception e)
{ // {
_logger.LogError(e,e.ToString()); // _logger.LogError(e,e.ToString());
} // }
} // }
} // }
} // }

View File

@@ -8,7 +8,7 @@
<PackageReference Include="IPTools.China" Version="1.6.0" /> <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" /> <PackageReference Include="UAParser" Version="3.1.47" />

View File

@@ -1,5 +1,6 @@
using Medallion.Threading; using Medallion.Threading;
using Medallion.Threading.Redis; using Medallion.Threading.Redis;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using StackExchange.Redis; using StackExchange.Redis;
using Volo.Abp.AspNetCore.SignalR; using Volo.Abp.AspNetCore.SignalR;
@@ -42,14 +43,18 @@ namespace Yi.Framework.Rbac.Domain
//配置阿里云短信 //配置阿里云短信
Configure<AliyunOptions>(configuration.GetSection(nameof(AliyunOptions))); Configure<AliyunOptions>(configuration.GetSection(nameof(AliyunOptions)));
//分布式锁 //分布式锁,需要redis
context.Services.AddSingleton<IDistributedLockProvider>(sp => if (configuration.GetSection("Redis").GetValue<bool>("IsEnabled"))
{ {
var connection = ConnectionMultiplexer context.Services.AddSingleton<IDistributedLockProvider>(sp =>
.Connect(configuration["Redis:Configuration"]); {
return new var connection = ConnectionMultiplexer
RedisDistributedSynchronizationProvider(connection.GetDatabase()); .Connect(configuration["Redis:Configuration"]);
}); return new
RedisDistributedSynchronizationProvider(connection.GetDatabase());
});
}
} }
} }
} }

View File

@@ -185,12 +185,12 @@ namespace Yi.Abp.Application.Services
/// <summary> /// <summary>
/// 分布式送abp版本abp套了一层娃。但是纯粹鸡肋不建议使用这个 /// 分布式送abp版本abp套了一层娃。但是纯粹鸡肋不建议使用这个
/// </summary> /// </summary>
public IAbpDistributedLock AbpDistributedLock { get; set; } public IAbpDistributedLock AbpDistributedLock => LazyServiceProvider.LazyGetService<IAbpDistributedLock>();
/// <summary> /// <summary>
/// 分布式锁推荐使用版本yyds分布式锁永远的神 /// 分布式锁推荐使用版本yyds分布式锁永远的神
/// </summary> /// </summary>
public IDistributedLockProvider DistributedLock { get; set; } public IDistributedLockProvider DistributedLock => LazyServiceProvider.LazyGetService<IDistributedLockProvider>();
/// <summary> /// <summary>
/// 分布式锁 /// 分布式锁

View File

@@ -4,15 +4,17 @@ using Yi.Abp.Web;
//创建日志,可使用{SourceContext}记录 //创建日志,可使用{SourceContext}记录
Log.Logger = new LoggerConfiguration() Log.Logger = new LoggerConfiguration()
.MinimumLevel.Debug() //由于后端处理请求中,前端请求已经结束,此类日志可不记录
.MinimumLevel.Override("Microsoft", LogEventLevel.Information) .Filter.ByExcluding(log =>log.Exception?.GetType() == typeof(TaskCanceledException)||log.MessageTemplate.Text.Contains("\"message\": \"A task was canceled.\""))
.MinimumLevel.Override("Microsoft.AspNetCore.Hosting.Diagnostics", LogEventLevel.Error) .MinimumLevel.Debug()
.MinimumLevel.Override("Quartz", LogEventLevel.Warning) .MinimumLevel.Override("Microsoft", LogEventLevel.Information)
.Enrich.FromLogContext() .MinimumLevel.Override("Microsoft.AspNetCore.Hosting.Diagnostics", LogEventLevel.Error)
.WriteTo.Async(c => c.File("logs/all/log-.txt", rollingInterval: RollingInterval.Day, restrictedToMinimumLevel: LogEventLevel.Debug)) .MinimumLevel.Override("Quartz", LogEventLevel.Warning)
.WriteTo.Async(c => c.File("logs/error/errorlog-.txt", rollingInterval: RollingInterval.Day, restrictedToMinimumLevel: LogEventLevel.Error)) .Enrich.FromLogContext()
.WriteTo.Async(c => c.Console()) .WriteTo.Async(c => c.File("logs/all/log-.txt", rollingInterval: RollingInterval.Day, restrictedToMinimumLevel: LogEventLevel.Debug))
.CreateLogger(); .WriteTo.Async(c => c.File("logs/error/errorlog-.txt", rollingInterval: RollingInterval.Day, restrictedToMinimumLevel: LogEventLevel.Error))
.WriteTo.Async(c => c.Console())
.CreateLogger();
try try
{ {

View File

@@ -39,6 +39,7 @@ using Yi.Framework.AspNetCore.Authentication.OAuth.Gitee;
using Yi.Framework.AspNetCore.Authentication.OAuth.QQ; using Yi.Framework.AspNetCore.Authentication.OAuth.QQ;
using Yi.Framework.AspNetCore.Microsoft.AspNetCore.Builder; using Yi.Framework.AspNetCore.Microsoft.AspNetCore.Builder;
using Yi.Framework.AspNetCore.Microsoft.Extensions.DependencyInjection; using Yi.Framework.AspNetCore.Microsoft.Extensions.DependencyInjection;
using Yi.Framework.AspNetCore.UnifyResult;
using Yi.Framework.BackgroundWorkers.Hangfire; using Yi.Framework.BackgroundWorkers.Hangfire;
using Yi.Framework.Bbs.Application; using Yi.Framework.Bbs.Application;
using Yi.Framework.Bbs.Application.Extensions; using Yi.Framework.Bbs.Application.Extensions;
@@ -130,6 +131,7 @@ namespace Yi.Abp.Web
}); });
//采用furion格式的规范化api默认不开启使用abp优雅的方式 //采用furion格式的规范化api默认不开启使用abp优雅的方式
//前置需要将管道工作单元前加上app.Properties.Add("_AbpExceptionHandlingMiddleware_Added",false);
//你没看错。。。 //你没看错。。。
//service.AddFurionUnifyResultApi(); //service.AddFurionUnifyResultApi();
@@ -204,7 +206,7 @@ namespace Yi.Abp.Web
var redisConfiguration = configuration["Redis:Configuration"]; var redisConfiguration = configuration["Redis:Configuration"];
context.Services.AddHangfire(config=> context.Services.AddHangfire(config=>
{ {
bool.TryParse( configuration["Redis:IsEnabled"], out var redisEnabled); var redisEnabled=configuration.GetSection("Redis").GetValue<bool>("IsEnabled");
if (redisEnabled) if (redisEnabled)
{ {
var jobDb=configuration.GetSection("Redis").GetValue<int>("JobDb"); var jobDb=configuration.GetSection("Redis").GetValue<int>("JobDb");
@@ -278,19 +280,19 @@ namespace Yi.Abp.Web
}; };
options.Events = new JwtBearerEvents options.Events = new JwtBearerEvents
{ {
OnMessageReceived = context => OnMessageReceived = messageContext =>
{ {
//优先Query中获取再去cookies中获取 //优先Query中获取再去cookies中获取
var accessToken = context.Request.Query["access_token"]; var accessToken = messageContext.Request.Query["access_token"];
if (!string.IsNullOrEmpty(accessToken)) if (!string.IsNullOrEmpty(accessToken))
{ {
context.Token = accessToken; messageContext.Token = accessToken;
} }
else 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 options.Events = new JwtBearerEvents
{ {
OnMessageReceived = context => OnMessageReceived = messageContext =>
{ {
var refresh_token = context.Request.Headers["refresh_token"]; var headerRefreshToken = messageContext.Request.Headers["refresh_token"];
if (!string.IsNullOrEmpty(refresh_token)) if (!string.IsNullOrEmpty(headerRefreshToken))
{ {
context.Token = refresh_token; messageContext.Token = headerRefreshToken;
return Task.CompletedTask; return Task.CompletedTask;
} }
var refreshToken = context.Request.Query["refresh_token"]; var queryRefreshToken = messageContext.Request.Query["refresh_token"];
if (!string.IsNullOrEmpty(refreshToken)) if (!string.IsNullOrEmpty(queryRefreshToken))
{ {
context.Token = refreshToken; messageContext.Token = queryRefreshToken;
} }
return Task.CompletedTask; return Task.CompletedTask;
@@ -393,8 +395,7 @@ namespace Yi.Abp.Web
app.UseDefaultFiles(); app.UseDefaultFiles();
app.UseDirectoryBrowser("/api/app/wwwroot"); app.UseDirectoryBrowser("/api/app/wwwroot");
//app.Properties.Add("_AbpExceptionHandlingMiddleware_Added",false);
// app.Properties.Add("_AbpExceptionHandlingMiddleware_Added",false);
//工作单元 //工作单元
app.UseUnitOfWork(); app.UseUnitOfWork();

View File

@@ -40,7 +40,8 @@
"EnabledDbSeed": true, "EnabledDbSeed": true,
"EnableUnderLine": false, // 启用驼峰转下划线 "EnableUnderLine": false, // 启用驼峰转下划线
//SAAS多租户 //SAAS多租户
"EnabledSaasMultiTenancy": true "EnabledSaasMultiTenancy": true,
"EnabledConcurrencyException": false
//读写分离地址 //读写分离地址
//"ReadUrl": [ //"ReadUrl": [
// "DataSource=[xxxx]", //Sqlite // "DataSource=[xxxx]", //Sqlite
@@ -103,18 +104,10 @@
//开启定时数据库备份 //开启定时数据库备份
"EnableDataBaseBackup": false "EnableDataBaseBackup": false
}, },
//OpenAi
"AiOptions": {
"ApiKey": "",
"BaseDomain": ""
},
//语义内核 //语义内核
"SemanticKernel": { "SemanticKernel": {
"ModelId": "gpt-4o", "ModelIds": ["gpt-4o"],
"Endpoint": "https://xxx.com/v1", "Endpoint": "https://xxx.com/v1",
"ApiKey": "sk-xxxxxx" "ApiKey": "sk-xxxxxx"
} }

View File

@@ -22,6 +22,7 @@
- 一天24小时下来整体价格变化的趋势应该比较连贯可以部分小时的价格大幅度变化 - 一天24小时下来整体价格变化的趋势应该比较连贯可以部分小时的价格大幅度变化
- 变化幅度可以大一些,为了更吸引用户 - 变化幅度可以大一些,为了更吸引用户
- 可能下跌,可能上涨 - 可能下跌,可能上涨
- 最低价值为1,最高价为100 - 最低价格为5,最高价为100如果小于等于5就固定一直是5如果大于等于100要即时的修正扣减
- 可能出现暴跌或者暴涨一天直接减少或增加百分之50
请确保数据格式正确,以便系统能够自动处理。 请确保数据格式正确,以便系统能够自动处理。

View File

@@ -1,6 +1,4 @@
基于以下最近的新闻背景,预测趋势生成一条其他新闻 生成一条有趣并通俗易懂的新闻
{{newsContext}}
包含以下要素: 包含以下要素:
1. 新闻标题:吸引人且简短,涉及不同行业 1. 新闻标题:吸引人且简短,涉及不同行业
@@ -14,6 +12,5 @@
- 内容应当暗示可能对不同行业公司产生某种影响(积极或消极),不能太过于明显 - 内容应当暗示可能对不同行业公司产生某种影响(积极或消极),不能太过于明显
- 行业焦点可以包括娱乐、科技、金融、医疗、食品等多个领域 - 行业焦点可以包括娱乐、科技、金融、医疗、食品等多个领域
- 新闻有很小的概率造假,如果是造假的,新闻来源就得来自小的工作室 - 新闻有很小的概率造假,如果是造假的,新闻来源就得来自小的工作室
- 不要一直重复着一个公司、一个行业的新闻 - 不要一直重复着一个公司、一个行业、一个事件的新闻
- 可以加一些很离谱的元素增加新闻的趣味性
- 只需生成一次即可 - 只需生成一次即可

View File

@@ -1,7 +1,5 @@
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Shouldly; using Shouldly;
using TencentCloud.Ame.V20190916.Models;
using TencentCloud.Tiw.V20190919.Models;
using Volo.Abp.Domain.Repositories; using Volo.Abp.Domain.Repositories;
using Xunit; using Xunit;
using Yi.Framework.Rbac.Application.Contracts.Dtos.User; using Yi.Framework.Rbac.Application.Contracts.Dtos.User;

View File

@@ -1,5 +1,12 @@
import request from "@/config/axios/service"; import request from "@/config/axios/service";
export function setResolve(discussId) {
return request({
url: `/discuss/reward/resolve/${discussId}`,
method: "put"
});
}
export function getList(data) { export function getList(data) {
return request({ return request({
url: "/discuss", url: "/discuss",

View File

@@ -35,7 +35,8 @@ export function getStockPriceRecords(stockId, startTime, endTime, periodType = '
StockId: stockId, StockId: stockId,
StartTime: startTime, StartTime: startTime,
EndTime: endTime, EndTime: endTime,
PeriodType: periodType PeriodType: periodType,
MaxResultCount : 100
} }
}); });
} }

View 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>

View File

@@ -1,13 +1,15 @@
<template> <template>
<el-badge class="box-card"> <el-badge class="box-card">
<el-card shadow="never" :style="{ 'border-color': discuss.color }" <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"> <div class="card-header">
<AvatarInfo :userInfo="discuss.user" /> <AvatarInfo :userInfo="discuss.user" />
</div> </div>
<div style="display: flex; <div style="display: flex;
justify-content: space-between;"> justify-content: space-between;">
<div> <div>
<div v-if="discuss.isBan" class="item item-title"> <div v-if="discuss.isBan" class="item item-title">
<el-link size="100" :underline="false" style="color: #f56c6c">{{ <el-link size="100" :underline="false" style="color: #f56c6c">{{
@@ -42,10 +44,11 @@
<div class="item item-bottom"> <div class="item item-bottom">
<div class="tag-list"> <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-if="discuss.title!=''&& 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.lables.length>0" v-for="item in discuss.lables" :key="item.id">{{item.name}}</el-tag>
</div> </div>
<el-space :size="10" :spacer="spacer"> <el-space :size="10" :spacer="spacer">
<div class="item-description"> <div class="item-description">
@@ -86,7 +89,9 @@ const discuss = reactive({
isAgree: false, isAgree: false,
cover: "", cover: "",
isBan: false, isBan: false,
lables:[] lables:[],
permissionRoleCodes:[],
discussType:""
}); });
const router = useRouter(); const router = useRouter();
const spacer = h(ElDivider, { direction: "vertical" }); const spacer = h(ElDivider, { direction: "vertical" });
@@ -132,6 +137,7 @@ onMounted(() => {
discuss.cover = props.discuss.cover; discuss.cover = props.discuss.cover;
discuss.lables=props.discuss.lables; discuss.lables=props.discuss.lables;
discuss.permissionRoleCodes=props.discuss.permissionRoleCodes; discuss.permissionRoleCodes=props.discuss.permissionRoleCodes;
discuss.discussType=props.discuss.discussType;
}); });
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
@@ -207,4 +213,41 @@ onMounted(() => {
:deep(.el-card__body) { :deep(.el-card__body) {
padding: 10px 20px; 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> </style>

View File

@@ -14,7 +14,7 @@
<el-menu-item index="2" @click="enterStart" <el-menu-item index="2" @click="enterStart"
>开始</el-menu-item> >开始</el-menu-item>
<el-menu-item index="3" @click="enterTemp" style="color: red;font-weight: bolder;font-size: large;" <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 index="4" @click="enterShop"
>商城</el-menu-item> >商城</el-menu-item>
<!-- <el-sub-menu index="4">--> <!-- <el-sub-menu index="4">-->
@@ -234,7 +234,7 @@ const enterStart = () => {
} }
const enterTemp=()=>{ const enterTemp=()=>{
router.push("/stock"); router.push("/discuss/24cc0526-86e7-aabf-e091-3a0f83c3e604/false");
} }
const enterShop=()=>{ const enterShop=()=>{
router.push("/shop"); router.push("/shop");

View File

@@ -3,7 +3,7 @@
<el-row :gutter="20" class="top-div"> <el-row :gutter="20" class="top-div">
<el-col :span="5"> <el-col :span="5">
<el-row class="art-info-left"> <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"> <InfoCard header="文章信息" text="展开" hideDivider="true" :isPadding="false" style="padding: 10px">
<template #content> <template #content>
<el-button <el-button
@@ -35,6 +35,35 @@
</template> </template>
</InfoCard> </InfoCard>
</el-col> </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"> <el-col :span="24">
<InfoCard :items="authorList" :isPadding="false" header="作者分享" height="410" text="更多" style="padding:0 20px"> <InfoCard :items="authorList" :isPadding="false" header="作者分享" height="410" text="更多" style="padding:0 20px">
<template #item="temp"> <template #item="temp">
@@ -42,13 +71,6 @@
</template> </template>
</InfoCard> </InfoCard>
</el-col> </el-col>
<!-- <el-col :span="24">-->
<!-- <InfoCard :items="items" header="内容推荐" text="更多">-->
<!-- <template #item="temp">-->
<!-- <AvatarInfo />-->
<!-- </template>-->
<!-- </InfoCard>-->
<!-- </el-col>-->
</el-row> </el-row>
</el-col> </el-col>
@@ -56,16 +78,15 @@
<el-row class="left-div"> <el-row class="left-div">
<el-col :span="24"> <el-col :span="24">
<Breadcrumb :breadcrumbsList="breadcrumbsList" class="breadcrumb"/> <Breadcrumb :breadcrumbsList="breadcrumbsList" class="breadcrumb"/>
<!-- {{ discuss.user }} -->
<AvatarInfo <AvatarInfo
:size="50" :size="50"
:showWatching="true" :showWatching="true"
:time="discuss.creationTime" :time="discuss.creationTime"
:userInfo="discuss.user" :userInfo="discuss.user"
></AvatarInfo> ></AvatarInfo>
<!-- :userInfo="{nick:'qwe'} -->
<h2> <DiscussTypeLable style="margin-right: 8px;height: 35px;" v-model="discuss.discussType" /> {{ discuss.title }}</h2>
<h2>{{ discuss.title }}</h2>
<h5 class="subtitle">{{ discuss.introduction }}</h5> <h5 class="subtitle">{{ discuss.introduction }}</h5>
<el-image <el-image
:preview-src-list="[getUrl(discuss.cover)]" :preview-src-list="[getUrl(discuss.cover)]"
@@ -73,7 +94,14 @@
:src="getUrl(discuss.cover)" :src="getUrl(discuss.cover)"
style="width: 150px; height: 150px" 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-divider/>
<el-skeleton :rows="10" animated v-if="discuss.content==undefined" />
<ArticleContentInfo <ArticleContentInfo
:code="discuss.content ?? ''" :code="discuss.content ?? ''"
></ArticleContentInfo> ></ArticleContentInfo>
@@ -111,11 +139,21 @@
<el-button <el-button
type="primary" type="primary"
size="default" size="default"
v-if="isEditTheme && isArticleUser" v-if="isEditTheme && isArticleUser&&discuss.discussType=='Article'"
@click="updateHander(route.params.discussId)" @click="updateHander(route.params.discussId)"
>编辑 >编辑
</el-button </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 <el-button
style="margin-left: 1rem" style="margin-left: 1rem"
type="danger" type="danger"
@@ -165,19 +203,7 @@
<ThemeData :themeData="temp"/> <ThemeData :themeData="temp"/>
</template> </template>
</InfoCard> </InfoCard>
<!-- <InfoCard :items="items" header="其他" text="更多">-->
<!-- <template #item="temp">-->
<!-- <AvatarInfo />-->
<!-- </template>-->
<!-- </InfoCard>-->
</el-col> </el-col>
<!-- <el-col :span="24">-->
<!-- <InfoCard :items="items" header="其他" text="更多">-->
<!-- <template #item="temp">-->
<!-- <AvatarInfo />-->
<!-- </template>-->
<!-- </InfoCard>-->
<!-- </el-col>-->
</el-row> </el-row>
</el-col> </el-col>
</el-row> </el-row>
@@ -193,7 +219,8 @@ import BottomInfo from "@/components/BottomInfo.vue";
import TreeArticleInfo from "@/components/TreeArticleInfo.vue"; import TreeArticleInfo from "@/components/TreeArticleInfo.vue";
import {useRoute, useRouter} from "vue-router"; import {useRoute, useRouter} from "vue-router";
import AgreeInfo from "@/components/AgreeInfo.vue"; 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 { import {
all as articleall, all as articleall,
del as articleDel, 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) => { const updateHander = (discussId) => {
//跳转路由 //跳转路由

View File

@@ -12,8 +12,7 @@
<el-radio-group v-model="radio"> <el-radio-group v-model="radio">
<el-radio-button label="discuss" :disabled="artType !== 'discuss'" <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 label="article" :disabled="artType !== 'article'"
>文章 >文章
</el-radio-button </el-radio-button
@@ -28,132 +27,161 @@
> >
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<el-form-item label="权限:" v-if="radio == 'discuss'">
<el-radio-group v-model="perRadio"> <el-form-item label="主题类型:" v-if="radio == 'discuss'">
<el-radio-button label="Public">公开</el-radio-button> <el-radio-group v-model="editForm.discussType">
<el-radio-button label="Role">所选角色可见</el-radio-button> <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-radio-group>
</el-form-item> </el-form-item>
<el-form-item <el-form-item label="悬赏金额:" v-if="editForm.discussType == 'Reward'">
label="可见角色:" <div class="reward-div">
v-if="radio == 'discuss' && perRadio == 'Role'" <p style="color: red">通过悬赏主题发布问题双方达成一致并解决问题后建议有偿提供RMB给解决人员</p>
> <p style="color: red">社区只提供解决问题平台不参与任何交易请自行联系</p>
<el-input-tag <div>
v-model="editForm.permissionRoleCodes" <span>最少RMB</span>
placeholder="请输入角色code" <el-input-number style="margin-right: 40px;" v-model="editForm.rewardData.minValue" :min="10">
aria-label="按下回车可选择多个" </el-input-number>
/>
</el-form-item>
<el-form-item <span>最多RMB</span>
v-if="radio == 'article'" <el-input-number v-model="editForm.rewardData.maxValue" :min="10">
label="子文章名称:" </el-input-number>
prop="name" </div>
>
<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>
<!-- 文件弹框 --> </el-form-item>
<div> <el-form-item label="联系方式:" v-if="editForm.discussType == 'Reward'">
<input <el-input v-model="editForm.rewardData.contact" placeholder="输入你的联系方式(例如微信号/QQ号" />
v-show="false" </el-form-item>
ref="fileRef"
type="file" <el-form-item label="权限:" v-if="radio == 'discuss'">
multiple <el-radio-group v-model="perRadio">
@change="getFile" <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> </div>
<!-- 文件弹框 -->
<div>
<input
v-show="false"
ref="fileRef"
type="file"
multiple
@change="getFile"
/>
</div>
</div>
</template> </template>
<script setup> <script setup>
import MavonEdit from "@/components/MavonEdit.vue"; import MavonEdit from "@/components/MavonEdit.vue";
@@ -187,7 +215,6 @@ const codeStyle = "atom-one-dark";
// 用于禁用判断 // 用于禁用判断
const artType = ref(route.query.artType); const artType = ref(route.query.artType);
//封面完整显示的url //封面完整显示的url
const fileUploadUrl = `${import.meta.env.VITE_APP_BASEAPI}/file`; const fileUploadUrl = `${import.meta.env.VITE_APP_BASEAPI}/file`;
//封面的url //封面的url
@@ -200,7 +227,7 @@ const selectLabelList = ref([]);
//远程下拉框查询文章标签 //远程下拉框查询文章标签
const remoteMethod = async (query) => { const remoteMethod = async (query) => {
labelLoading.value = true labelLoading.value = true
const {data} = await getLableAllList({name:query}); const {data} = await getLableAllList({name: query});
labelLoading.value = false labelLoading.value = false
labelListData.value = data.items; labelListData.value = data.items;
} }
@@ -218,12 +245,19 @@ const getUrl = computed(() => {
//整个页面上的表单 //整个页面上的表单
const editForm = reactive({ const editForm = reactive({
discussType: "Article",
title: "", title: "",
introduction: "", introduction: "",
content: "", content: "",
name: "", name: "",
permissionRoleCodes: [], permissionRoleCodes: [],
discussLableIds:[] discussLableIds: [],
rewardData: {
minValue: 10,
maxValue: 200,
contact:""
}
}); });
//组装主题内容: 需要更新主题信息 //组装主题内容: 需要更新主题信息
@@ -252,7 +286,8 @@ const submit = async (formEl) => {
if (valid) { if (valid) {
//dicuss主题处理 //dicuss主题处理
if (radio.value == "discuss") { 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.title = editForm.title;
discuss.introduction = editForm.introduction; discuss.introduction = editForm.introduction;
discuss.content = editForm.content; discuss.content = editForm.content;
@@ -260,7 +295,22 @@ const submit = async (formEl) => {
discuss.cover = dialogImageUrl.value; discuss.cover = dialogImageUrl.value;
discuss.permissionType = perRadio.value; discuss.permissionType = perRadio.value;
discuss.permissionRoleCodes = editForm.permissionRoleCodes; 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") { if (route.query.operType == "create") {
const response = await discussAdd(discuss); const response = await discussAdd(discuss);
@@ -273,7 +323,7 @@ const submit = async (formEl) => {
} }
//主题更新 //主题更新
else if (route.query.operType == "update") { 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); await discussUpdate(route.query.discussId, discuss);
ElMessage({ ElMessage({
@@ -341,13 +391,13 @@ const loadDiscuss = async () => {
editForm.content = res.content; editForm.content = res.content;
editForm.title = res.title; editForm.title = res.title;
editForm.introduction = res.introduction; editForm.introduction = res.introduction;
editForm.discussLableIds=res.discussLableIds; editForm.discussLableIds = res.discussLableIds;
editForm.permissionRoleCodes = res.permissionRoleCodes; editForm.permissionRoleCodes = res.permissionRoleCodes;
//编辑状态,已选择的就是全部 //编辑状态,已选择的就是全部
labelListData.value=res.lables; labelListData.value = res.lables;
selectLabelList.value=res.lables; selectLabelList.value = res.lables;
discuss.plateId = res.plateId; discuss.plateId = res.plateId;
dialogImageUrl.value = res.cover; dialogImageUrl.value = res.cover;
perRadio.value = res.permissionType; perRadio.value = res.permissionType;
@@ -412,6 +462,11 @@ const getFile = async (e) => {
width: 40%; width: 40%;
} }
.reward-div {
display: flex;
flex-direction: column;
}
.body-div { .body-div {
position: relative; position: relative;
min-height: 1000px; min-height: 1000px;

View File

@@ -43,13 +43,15 @@ const inputListDataStore = ref([
{key: "ai@gpt-4o-mini", name: "ChatGpt聊天", titleName: "ChatGpt-全能神!综合能力最强!", logo: "openAi.png", value: ""}, {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@claude-3-7-sonnet", 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-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@Qwen/QwQ-32B-Preview", name: "QWen聊天", titleName: "国产阿里千问通义", logo: "qwenAi.png", value: ""},
{key: "ai@deepseek-ai/deepseek-r1", name: "DeepSeek思索", titleName: "满血DeepSeek-思索模式", logo: "deepSeekAi.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聊天临时存储 //AI聊天临时存储
const sendAiChatContext = ref([]); const sendAiChatContext = ref([]);
@@ -57,6 +59,14 @@ var timer = null;
let codeCopyDic = []; 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 () => { onMounted(async () => {
if (!isLogin.value) { if (!isLogin.value) {
@@ -92,7 +102,12 @@ onMounted(async () => {
//在线用户列表 //在线用户列表
chatStore.setUserList((await getChatUserList()).data); chatStore.setUserList((await getChatUserList()).data);
startCountTip(); startCountTip();
// 添加全局鼠标事件监听
document.addEventListener('mousemove', handleMouseMove);
document.addEventListener('mouseup', handleMouseUp);
}) })
onUnmounted(() => { onUnmounted(() => {
if (timer != null) { if (timer != null) {
clearInterval(timer) clearInterval(timer)
@@ -100,8 +115,57 @@ onUnmounted(() => {
if (timerTip != null) { if (timerTip != null) {
clearInterval(timerTip) 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(() => { const currentMsgContext = computed(() => {
@@ -366,7 +430,7 @@ const toMarkDownHtml = (text) => {
const codeHandler = (code, language) => { const codeHandler = (code, language) => {
const codeIndex = parseInt(Date.now() + "") + Math.floor(Math.random() * 10000000); const codeIndex = parseInt(Date.now() + "") + Math.floor(Math.random() * 10000000);
//console.log(codeIndex,"codeIndex"); //console.log(codeIndex,"codeIndex");
// 格式化第一行是右侧language和 复制 按钮; // 格式化第一行是右侧language和 "复制" 按钮;
if (code) { if (code) {
const navCode = navHandler(code) const navCode = navHandler(code)
try { try {
@@ -440,9 +504,9 @@ const clickCopyEvent = async function (event) {
<template> <template>
<div style="position: absolute; top: 0;left: 0;" v-show="isShowTipNumber>0"> <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:官方学习交流群每次发送消息消耗 1 钱钱</p>
<p>tip:点击聊天窗口右上角X可退出</p> <p>tip:点击聊天窗口右上角"X"可退出</p>
<p>tip:多人同时在聊天室时左侧可显示其他成员</p> <p>tip:多人同时在聊天室时左侧可显示其他成员</p>
<p>tip:当前支持多种AI模式由于接口收费原因还请各位手下留情</p> <p>tip:当前支持多种AI模式由于接口收费原因还请各位手下留情</p>
@@ -473,7 +537,7 @@ const clickCopyEvent = async function (event) {
</ul> </ul>
</div> </div>
<div class="middle"> <div class="middle" :style="{ width: middleWidth + 'px' }">
<div class="header"> <div class="header">
<div class="header-div"> <div class="header-div">
<div class="search"> <div class="search">
@@ -515,7 +579,10 @@ const clickCopyEvent = async function (event) {
</div> </div>
</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">
<div class="header-left">{{ currentHeaderName }} <span class="clear-msg" v-show="selectIsAi()" <div class="header-left">{{ currentHeaderName }} <span class="clear-msg" v-show="selectIsAi()"
@click="clearAiMsg">点击此处清空当前对话</span> @click="clearAiMsg">点击此处清空当前对话</span>
@@ -536,7 +603,7 @@ const clickCopyEvent = async function (event) {
</div> </div>
</div> </div>
<div class="content"> <div class="content" :style="{ height: contentHeight + 'px' }">
<div v-for="(item, i) in currentMsgContext" :key="i"> <div v-for="(item, i) in currentMsgContext" :key="i">
@@ -563,7 +630,11 @@ const clickCopyEvent = async function (event) {
</div> </div>
</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"> <div class="bottom-tool">
<ul class="ul-left"> <ul class="ul-left">
@@ -609,8 +680,35 @@ ul {
height: 790px; height: 790px;
width: 1400px; width: 1400px;
display: flex; display: flex;
justify-content: center; justify-content: flex-start;
box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.2); 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 { .select-user-item {
@@ -621,6 +719,7 @@ ul {
background-color: #2a2a2a; background-color: #2a2a2a;
width: 70px; width: 70px;
padding: 46px 10px 0 10px; padding: 46px 10px 0 10px;
flex-shrink: 0;
.icon { .icon {
background-color: burlywood; background-color: burlywood;
@@ -637,6 +736,7 @@ ul {
.middle { .middle {
background-color: #dadbdc; background-color: #dadbdc;
width: 380px; width: 380px;
flex-shrink: 0;
.header { .header {
height: 75px; height: 75px;
@@ -646,13 +746,13 @@ ul {
.header-div { .header-div {
background-color: #F7F7F7; background-color: #F7F7F7;
height: 30px; height: 30px;
width: 338px; width: 90%;
margin: auto; margin: auto;
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
.search { .search {
width: 300px; width: 85%;
height: 100%; height: 100%;
background-color: #E2E2E2; background-color: #E2E2E2;
border-radius: 5px; border-radius: 5px;
@@ -756,7 +856,9 @@ ul {
.right { .right {
background-color: #f5f5f5; background-color: #f5f5f5;
width: 950px; flex-grow: 1;
display: flex;
flex-direction: column;
.header { .header {
height: 75px; height: 75px;
@@ -764,6 +866,7 @@ ul {
border: 1px solid #e7e7e7; border: 1px solid #e7e7e7;
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
flex-shrink: 0;
.header-left { .header-left {
padding: 25px; padding: 25px;
@@ -801,21 +904,24 @@ ul {
.content { .content {
overflow-y: auto; overflow-y: auto;
/* 只启用垂直方向滚动条 */ /* 只启用垂直方向滚动条 */
height: 535px;
padding: 20px 40px; padding: 20px 40px;
flex-grow: 1;
} }
.bottom { .bottom {
height: calc(100% - 610px);
background: #f7f7f7; background: #f7f7f7;
border-top: 1.5px solid #e7e7e7; border-top: 1.5px solid #e7e7e7;
padding: 15px 35px; padding: 15px 35px;
display: flex;
flex-direction: column;
min-height: 150px;
&-tool { &-tool {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
height: 22px; height: 22px;
margin-bottom: 5px;
.ul-left { .ul-left {
display: flex; display: flex;
@@ -851,7 +957,7 @@ ul {
&-input { &-input {
font-family: "Microsoft YaHei", sans-serif; font-family: "Microsoft YaHei", sans-serif;
height: 70px; flex-grow: 1;
width: 100%; width: 100%;
overflow-y: auto; overflow-y: auto;
padding: 10px 0; padding: 10px 0;
@@ -860,6 +966,7 @@ ul {
border: none; border: none;
resize: none; resize: none;
outline: none; outline: none;
min-height: 50px;
} }
&-send { &-send {

View File

@@ -54,6 +54,7 @@ margin: 10px auto;">
<el-col :span="24" v-for="i in allDiscussList" :key="i.id"> <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=""/> <img v-if="isIcp" src="@/assets/login.png" style="height: 150px;width: 100%" alt=""/>
<DisscussCard v-else :discuss="i"/> <DisscussCard v-else :discuss="i"/>
</el-col> </el-col>

View File

@@ -222,6 +222,8 @@ const captcha = async () => {
<el-form-item prop="code" > <el-form-item prop="code" >
<input type="text" v-model.trim="phoneForm.code"> <input type="text" v-model.trim="phoneForm.code">
</el-form-item> </el-form-item>
<p style="color: red">由于国内短信严格程度在2025年5月连续加强3次你的验证码有一定概率被运营商拦截</p>
<p style="color: red">如果未收到验证码请联系微信chengzilaoge520 站长进行手动创建</p>
</div> </div>
</div> </div>
<template #footer> <template #footer>

View File

@@ -103,7 +103,7 @@ export function usePost() {
`确认要<strong>${ `确认要<strong>${
row.state === false ? "停用" : "启用" row.state === false ? "停用" : "启用"
}</strong><strong style='color:var(--el-color-primary)'>${ }</strong><strong style='color:var(--el-color-primary)'>${
row.roleName row.postName
}</strong>吗?`, }</strong>吗?`,
"系统提示", "系统提示",
{ {
@@ -132,7 +132,7 @@ export function usePost() {
loading: false loading: false
} }
); );
message(`${row.state === false ? "停用" : "启用"}${row.roleName}`, { message(`${row.state === false ? "停用" : "启用"}${row.postName}`, {
type: "success" type: "success"
}); });
}) })
@@ -143,7 +143,7 @@ export function usePost() {
async function handleDelete(row) { async function handleDelete(row) {
await delPost([row.id]); await delPost([row.id]);
message(`您删除了角色名称为${row.roleName}的这条数据`, { type: "success" }); message(`您删除了岗位名称为${row.postName}的这条数据`, { type: "success" });
onSearch(); onSearch();
} }

View File

@@ -50,7 +50,7 @@ export function delDept(deptId) {
return request({ return request({
url: `/dept`, url: `/dept`,
method: 'delete', method: 'delete',
params:{id:deptId} params:{ids:deptId}
}) })
} }

View File

@@ -59,6 +59,6 @@ export function delMenu(menuId) {
return request({ return request({
url: `/menu`, url: `/menu`,
method: 'delete', method: 'delete',
params:{id:menuId} params:{ids:menuId}
}) })
} }

View 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>

View File

@@ -43,6 +43,8 @@ import ImagePreview from "@/components/ImagePreview"
import TreeSelect from '@/components/TreeSelect' import TreeSelect from '@/components/TreeSelect'
// 字典标签组件 // 字典标签组件
import DictTag from '@/components/DictTag' import DictTag from '@/components/DictTag'
// 动态数据下拉选择框组件
import SelectDataTag from '@/components/SelectDataTag'
const app = createApp(App) const app = createApp(App)
@@ -57,6 +59,7 @@ app.config.globalProperties.selectDictLabel = selectDictLabel
app.config.globalProperties.selectDictLabels = selectDictLabels app.config.globalProperties.selectDictLabels = selectDictLabels
// 全局组件挂载 // 全局组件挂载
app.component('SelectDataTag', SelectDataTag)
app.component('DictTag', DictTag) app.component('DictTag', DictTag)
app.component('Pagination', Pagination) app.component('Pagination', Pagination)
app.component('TreeSelect', TreeSelect) app.component('TreeSelect', TreeSelect)

View File

@@ -1,4 +1,4 @@
import { parseTime } from '@/ruoyi' import { parseTime } from './ruoyi'
/** /**
* 表格时间格式化 * 表格时间格式化

View File

@@ -230,6 +230,13 @@
></el-input> ></el-input>
</el-form-item> </el-form-item>
</el-form> </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> </el-dialog>
</div> </div>

BIN
readme/edgeone.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB