Compare commits
3 Commits
4142b621c3
...
dbf77c7d50
| Author | SHA1 | Date | |
|---|---|---|---|
| dbf77c7d50 | |||
| 94799ee189 | |||
| eb1a677612 |
129
CommunityMessage_TestData.sql
Normal file
129
CommunityMessage_TestData.sql
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
-- =====================================================
|
||||||
|
-- CommunityMessage 社区预置消息表 - 20条模拟测试数据
|
||||||
|
-- 生成时间: 2026-06-12
|
||||||
|
-- =====================================================
|
||||||
|
|
||||||
|
INSERT INTO [dbo].[CommunityMessage]
|
||||||
|
([Id], [Status], [IsDeleted], [CreatedBy], [CreatedAt], [UpdatedBy], [UpdatedAt],
|
||||||
|
[JournalId], [UserId], [UserJournalId], [JournalTaskId], [JournalTaskAnswerId],
|
||||||
|
[Content], [ImageUrl], [SortOrder], [IsActive], [Type], [LikeCount], [IsFeatured])
|
||||||
|
VALUES
|
||||||
|
-- 1. 文章类型 - 期刊导读
|
||||||
|
(1916234567890001, 1, 0, N'系统管理员', '2026-05-01 09:00:00', NULL, NULL,
|
||||||
|
1001, 5001, 8001, 3001, 6001,
|
||||||
|
N'本期期刊聚焦人工智能在教育领域的创新应用,欢迎各位读者踊跃讨论。',
|
||||||
|
NULL, 1, 1, 1, 42, 1),
|
||||||
|
|
||||||
|
-- 2. 引用类型 - 名人名言
|
||||||
|
(1916234567890002, 1, 0, N'编辑小王', '2026-05-02 10:30:00', NULL, NULL,
|
||||||
|
1001, 5002, 8002, 3001, 6002,
|
||||||
|
N'"教育不是灌输,而是点燃火焰。" —— 苏格拉底',
|
||||||
|
NULL, 2, 1, 2, 88, 1),
|
||||||
|
|
||||||
|
-- 3. 公告类型 - 活动通知
|
||||||
|
(1916234567890003, 1, 0, N'系统管理员', '2026-05-03 14:00:00', N'系统管理员', '2026-05-03 15:00:00',
|
||||||
|
1001, 5003, 8003, 3002, 6003,
|
||||||
|
N'【活动通知】第十二期线上读书分享会将于本周六晚8点举行,主题为"科技与人文的对话",欢迎大家报名参加!',
|
||||||
|
N'/uploads/images/activity_notice_202605.png', 1, 1, 3, 156, 1),
|
||||||
|
|
||||||
|
-- 4. 文章类型 - 读者投稿
|
||||||
|
(1916234567890004, 1, 0, N'读者张三', '2026-05-04 08:15:00', NULL, NULL,
|
||||||
|
1002, 5004, 8004, 3003, 6004,
|
||||||
|
N'阅读了本期的深度报道《数字时代的阅读习惯变迁》,深有感触。作为一个从纸质书时代走过来的人,既感慨科技带来的便利,也怀念翻页时的触感。',
|
||||||
|
NULL, 3, 1, 1, 35, 0),
|
||||||
|
|
||||||
|
-- 5. 引用类型 - 期刊摘录
|
||||||
|
(1916234567890005, 1, 0, N'编辑小李', '2026-05-05 11:20:00', NULL, NULL,
|
||||||
|
1002, 5005, 8005, 3003, 6005,
|
||||||
|
N'摘自本期特稿:"在信息爆炸的时代,深度阅读能力正在成为一种稀缺的核心竞争力。"',
|
||||||
|
N'/uploads/images/quote_bg_01.png', 4, 1, 2, 67, 1),
|
||||||
|
|
||||||
|
-- 6. 文章类型 - 互动讨论
|
||||||
|
(1916234567890006, 1, 0, N'读者李四', '2026-05-06 16:45:00', NULL, NULL,
|
||||||
|
1001, 5006, 8006, 3001, 6006,
|
||||||
|
N'关于本期讨论话题"AI是否会取代教师",我认为技术只是工具,教育的本质是人与人之间灵魂的碰撞,这是机器无法替代的。',
|
||||||
|
NULL, 5, 1, 1, 92, 1),
|
||||||
|
|
||||||
|
-- 7. 公告类型 - 系统维护
|
||||||
|
(1916234567890007, 1, 0, N'系统管理员', '2026-05-07 09:00:00', N'系统管理员', '2026-05-07 09:30:00',
|
||||||
|
1001, 5001, 8001, 3001, 6001,
|
||||||
|
N'【系统公告】平台将于5月10日凌晨2:00-5:00进行系统升级维护,届时服务将短暂中断,请各位读者提前保存阅读进度。',
|
||||||
|
NULL, 1, 1, 3, 23, 0),
|
||||||
|
|
||||||
|
-- 8. 文章类型 - 编辑寄语
|
||||||
|
(1916234567890008, 1, 0, N'主编老陈', '2026-05-08 07:30:00', NULL, NULL,
|
||||||
|
1003, 5007, 8007, 3004, 6007,
|
||||||
|
N'新一期杂志如期而至。本期我们特别策划了"青年创作者专栏",收录了十位90后作家的原创作品,期待听到你们的声音。',
|
||||||
|
N'/uploads/images/editor_letter_05.jpg', 1, 1, 1, 210, 1),
|
||||||
|
|
||||||
|
-- 9. 引用类型 - 读者金句
|
||||||
|
(1916234567890009, 1, 0, N'读者王五', '2026-05-09 20:10:00', NULL, NULL,
|
||||||
|
1002, 5008, 8008, 3003, 6008,
|
||||||
|
N'"每一本杂志都是一扇窗,让我们看到不同的人生风景。" 感谢社区里每一位分享者。',
|
||||||
|
NULL, 6, 1, 2, 54, 0),
|
||||||
|
|
||||||
|
-- 10. 文章类型 - 话题互动
|
||||||
|
(1916234567890010, 1, 0, N'读者赵六', '2026-05-10 13:55:00', NULL, NULL,
|
||||||
|
1003, 5009, 8009, 3004, 6009,
|
||||||
|
N'看完"城市记忆"系列第三篇,想起了小时候胡同里的叫卖声和邻居家的饭菜香。城市化进程中,我们该如何留住这些温暖的记忆?',
|
||||||
|
N'/uploads/images/city_memory_03.jpg', 7, 1, 1, 78, 1),
|
||||||
|
|
||||||
|
-- 11. 公告类型 - 征稿启事
|
||||||
|
(1916234567890011, 1, 0, N'编辑小王', '2026-05-11 10:00:00', N'编辑小王', '2026-05-12 08:00:00',
|
||||||
|
1003, 5010, 8010, 3005, 6010,
|
||||||
|
N'【征稿启事】第十三期"我的阅读故事"主题征稿正式启动!征稿时间:5月11日-6月11日,优秀作品将刊登在杂志特辑中,期待您的来稿。',
|
||||||
|
N'/uploads/images/call_for_papers_2026.png', 2, 1, 3, 189, 1),
|
||||||
|
|
||||||
|
-- 12. 文章类型 - 读书笔记
|
||||||
|
(1916234567890012, 1, 0, N'读者孙七', '2026-05-12 19:30:00', NULL, NULL,
|
||||||
|
1001, 5011, 8011, 3001, 6011,
|
||||||
|
N'本期推荐的三本书我都读完了,最喜欢《思考,快与慢》。作者对直觉思维和理性思维的分析让人醍醐灌顶,强烈推荐给所有社区朋友。',
|
||||||
|
NULL, 8, 1, 1, 45, 0),
|
||||||
|
|
||||||
|
-- 13. 引用类型 - 经典回顾
|
||||||
|
(1916234567890013, 1, 0, N'编辑小李', '2026-05-13 15:00:00', NULL, NULL,
|
||||||
|
1002, 5002, 8002, 3003, 6012,
|
||||||
|
N'回顾创刊号寄语:"我们相信,好的内容值得被慢慢品味。在这个快节奏的时代,让我们一起做慢阅读的实践者。"',
|
||||||
|
N'/uploads/images/anniversary_retro.png', 3, 1, 2, 134, 1),
|
||||||
|
|
||||||
|
-- 14. 文章类型 - 作者互动
|
||||||
|
(1916234567890014, 1, 0, N'作者林清', '2026-05-14 21:45:00', NULL, NULL,
|
||||||
|
1003, 5012, 8012, 3004, 6013,
|
||||||
|
N'感谢大家对《城市记忆》系列的支持和反馈!每一条评论我都认真阅读了。你们的共鸣是我继续创作的最大动力,下一篇将聚焦"消失的声音"。',
|
||||||
|
NULL, 9, 1, 1, 167, 1),
|
||||||
|
|
||||||
|
-- 15. 公告类型 - 获奖公告
|
||||||
|
(1916234567890015, 1, 0, N'系统管理员', '2026-05-15 12:00:00', N'系统管理员', '2026-05-15 14:00:00',
|
||||||
|
1001, 5001, 8001, 3002, 6001,
|
||||||
|
N'【获奖公告】第十一期"最佳读者评论"评选结果揭晓!恭喜读者@书香满园、@夜读人、@思考者三位获得本期精选评论奖,奖品将于一周内寄送。',
|
||||||
|
N'/uploads/images/award_11.jpg', 4, 1, 3, 302, 1),
|
||||||
|
|
||||||
|
-- 16. 文章类型 - 生活随笔
|
||||||
|
(1916234567890016, 1, 0, N'读者周八', '2026-05-16 07:00:00', NULL, NULL,
|
||||||
|
1002, 5013, 8013, 3003, 6014,
|
||||||
|
N'清晨六点,一杯咖啡,一本杂志。这已经成了我三年来雷打不动的习惯。今天的这篇关于极简生活的文章,正好呼应了我最近的生活理念——少即是多。',
|
||||||
|
N'/uploads/images/morning_read.jpg', 10, 1, 1, 29, 0),
|
||||||
|
|
||||||
|
-- 17. 引用类型 - 编辑精选
|
||||||
|
(1916234567890017, 1, 0, N'主编老陈', '2026-05-17 16:30:00', NULL, NULL,
|
||||||
|
1003, 5007, 8007, 3004, 6015,
|
||||||
|
N'本期编辑精选语录:"真正的知识不在于拥有多少信息,而在于能用多少方式去理解世界。" —— 选自专栏文章《认知的边界》',
|
||||||
|
NULL, 5, 1, 2, 95, 1),
|
||||||
|
|
||||||
|
-- 18. 文章类型 - 问题探讨
|
||||||
|
(1916234567890018, 1, 0, N'读者吴九', '2026-05-18 22:15:00', NULL, NULL,
|
||||||
|
1001, 5014, 8014, 3001, 6016,
|
||||||
|
N'想请教大家,本期提到的"元宇宙图书馆"概念,你们觉得在技术层面还有多远?VR阅读体验是否真的能超越传统阅读?期待和大家探讨。',
|
||||||
|
NULL, 11, 1, 1, 61, 0),
|
||||||
|
|
||||||
|
-- 19. 公告类型 - 订阅优惠
|
||||||
|
(1916234567890019, 1, 0, N'系统管理员', '2026-05-19 09:30:00', NULL, NULL,
|
||||||
|
1002, 5003, 8003, 3002, 6003,
|
||||||
|
N'【限时优惠】杂志年度订阅特惠活动开启!5月20日-5月31日期间订阅全年杂志享7折优惠,老用户续费额外赠送限量版精装合集一本。',
|
||||||
|
N'/uploads/images/subscription_promo_2026.png', 6, 1, 3, 278, 0),
|
||||||
|
|
||||||
|
-- 20. 文章类型 - 社区感言
|
||||||
|
(1916234567890020, 1, 0, N'读者郑十', '2026-05-20 18:00:00', NULL, NULL,
|
||||||
|
1003, 5015, 8015, 3004, 6017,
|
||||||
|
N'加入这个阅读社区整整一年了,从最初的潜水到现在的积极互动,在这里认识了很多志同道合的朋友。感谢平台的用心运营,让我们一起在文字中找到归属。',
|
||||||
|
N'/uploads/images/community_anniversary.jpg', 12, 1, 1, 445, 1);
|
||||||
45
QYZH.InteractiveMagazine.IService/IAiBasePromptService.cs
Normal file
45
QYZH.InteractiveMagazine.IService/IAiBasePromptService.cs
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
using QYZH.InteractiveMagazine.Models.Dto;
|
||||||
|
using QYZH.InteractiveMagazine.Models.Entity;
|
||||||
|
|
||||||
|
namespace QYZH.InteractiveMagazine.IService;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// AIPrompt配置服务接口
|
||||||
|
/// </summary>
|
||||||
|
public interface IAiBasePromptService : IBaseService<AiBasePrompt>
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 创建Prompt配置
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="input">Prompt配置输入</param>
|
||||||
|
/// <returns>创建的Prompt配置信息</returns>
|
||||||
|
Task<AiBasePromptOutput> CreateAsync(AiBasePromptInput input);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新Prompt配置
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">Prompt配置ID</param>
|
||||||
|
/// <param name="input">Prompt配置输入</param>
|
||||||
|
/// <returns>更新后的Prompt配置信息</returns>
|
||||||
|
Task<AiBasePromptOutput> UpdateAsync(long id, AiBasePromptInput input);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除Prompt配置(软删除)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">Prompt配置ID</param>
|
||||||
|
Task DeleteAsync(long id);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 根据ID获取Prompt配置
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">Prompt配置ID</param>
|
||||||
|
/// <returns>Prompt配置信息</returns>
|
||||||
|
Task<AiBasePromptOutput> GetByIdAsync(long id);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 分页查询Prompt配置列表
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="input">查询条件</param>
|
||||||
|
/// <returns>分页结果</returns>
|
||||||
|
Task<PageListModel<AiBasePromptOutput>> GetListAsync(AiBasePromptQueryInput input);
|
||||||
|
}
|
||||||
116
QYZH.InteractiveMagazine.Models/Dto/Ai/AiBasePromptDto.cs
Normal file
116
QYZH.InteractiveMagazine.Models/Dto/Ai/AiBasePromptDto.cs
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
using QYZH.InteractiveMagazine.Models.Dto;
|
||||||
|
|
||||||
|
namespace QYZH.InteractiveMagazine.Models.Dto;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// AIPrompt配置创建/更新输入
|
||||||
|
/// </summary>
|
||||||
|
public class AiBasePromptInput
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 配置标识(如:DEFAULT, READING, COMPREHENSION)
|
||||||
|
/// </summary>
|
||||||
|
public string PromptKey { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 配置名称(如:默认Prompt、阅读理解专用)
|
||||||
|
/// </summary>
|
||||||
|
public string PromptName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Prompt模板内容
|
||||||
|
/// </summary>
|
||||||
|
public string PromptTemplate { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 配置说明
|
||||||
|
/// </summary>
|
||||||
|
public string? Description { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 优先级(数值越小优先级越高)
|
||||||
|
/// </summary>
|
||||||
|
public int Priority { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否为默认模板
|
||||||
|
/// </summary>
|
||||||
|
public bool IsDefault { get; set; } = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// AIPrompt配置输出
|
||||||
|
/// </summary>
|
||||||
|
public class AiBasePromptOutput
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 主键ID
|
||||||
|
/// </summary>
|
||||||
|
public long Id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 配置标识
|
||||||
|
/// </summary>
|
||||||
|
public string PromptKey { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 配置名称
|
||||||
|
/// </summary>
|
||||||
|
public string PromptName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Prompt模板内容
|
||||||
|
/// </summary>
|
||||||
|
public string PromptTemplate { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 配置说明
|
||||||
|
/// </summary>
|
||||||
|
public string? Description { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 优先级
|
||||||
|
/// </summary>
|
||||||
|
public int Priority { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否为默认模板
|
||||||
|
/// </summary>
|
||||||
|
public bool IsDefault { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 创建人
|
||||||
|
/// </summary>
|
||||||
|
public string? CreatedBy { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 创建时间
|
||||||
|
/// </summary>
|
||||||
|
public DateTime CreatedAt { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新人
|
||||||
|
/// </summary>
|
||||||
|
public string? UpdatedBy { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新时间
|
||||||
|
/// </summary>
|
||||||
|
public DateTime? UpdatedAt { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// AIPrompt配置分页查询输入
|
||||||
|
/// </summary>
|
||||||
|
public class AiBasePromptQueryInput : PageQueryModel
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 配置标识(精确匹配)
|
||||||
|
/// </summary>
|
||||||
|
public string? PromptKey { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 配置名称(模糊查询)
|
||||||
|
/// </summary>
|
||||||
|
public string? PromptName { get; set; }
|
||||||
|
}
|
||||||
@ -86,7 +86,7 @@ public class UserJournalItemOutput
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 期刊标题
|
/// 期刊标题
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string JournalTitle { get; set; } = string.Empty;
|
public string Name { get; set; } = string.Empty;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 期刊封面
|
/// 期刊封面
|
||||||
|
|||||||
@ -6,7 +6,7 @@ namespace QYZH.InteractiveMagazine.Models.Entity
|
|||||||
///<summary>
|
///<summary>
|
||||||
///点赞记录表
|
///点赞记录表
|
||||||
///</summary>
|
///</summary>
|
||||||
[SugarTable("MessageLike")]
|
[SugarTable("CommunityMessageLike")]
|
||||||
public partial class CommunityMessageLike : SqlSugarBaseEntity
|
public partial class CommunityMessageLike : SqlSugarBaseEntity
|
||||||
{
|
{
|
||||||
public CommunityMessageLike()
|
public CommunityMessageLike()
|
||||||
|
|||||||
@ -6,7 +6,7 @@ namespace QYZH.InteractiveMagazine.Models.Entity
|
|||||||
///<summary>
|
///<summary>
|
||||||
///固定模板言论表
|
///固定模板言论表
|
||||||
///</summary>
|
///</summary>
|
||||||
[SugarTable("TemplateSentence")]
|
[SugarTable("CommunityTemplateSentence")]
|
||||||
public partial class CommunityTemplateSentence : SqlSugarBaseEntity
|
public partial class CommunityTemplateSentence : SqlSugarBaseEntity
|
||||||
{
|
{
|
||||||
public CommunityTemplateSentence(){
|
public CommunityTemplateSentence(){
|
||||||
|
|||||||
@ -92,8 +92,6 @@ namespace QYZH.InteractiveMagazine.Models.Entity
|
|||||||
public string PdfPreviewUrl { get; set; }
|
public string PdfPreviewUrl { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public string Title { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Desc:下载书籍页码点阵码PDF文件名称
|
/// Desc:下载书籍页码点阵码PDF文件名称
|
||||||
/// Default:
|
/// Default:
|
||||||
|
|||||||
@ -152,5 +152,33 @@ namespace QYZH.InteractiveMagazine.Models.Entity
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string CustomPrompt {get;set;}
|
public string CustomPrompt {get;set;}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Desc:理解力评分
|
||||||
|
/// Default:0
|
||||||
|
/// Nullable:False
|
||||||
|
/// </summary>
|
||||||
|
public float Comprehension {get;set;}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Desc:判断力评分
|
||||||
|
/// Default:0
|
||||||
|
/// Nullable:False
|
||||||
|
/// </summary>
|
||||||
|
public float Judgment {get;set;}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Desc:表达力评分
|
||||||
|
/// Default:0
|
||||||
|
/// Nullable:False
|
||||||
|
/// </summary>
|
||||||
|
public float Expression {get;set;}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Desc:说服力评分
|
||||||
|
/// Default:0
|
||||||
|
/// Nullable:False
|
||||||
|
/// </summary>
|
||||||
|
public float Persuasiveness {get;set;}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,216 @@
|
|||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace QYZH.InteractiveMagazine.Models.Entity
|
||||||
|
{
|
||||||
|
///<summary>
|
||||||
|
///杂志任务用户作答记录;
|
||||||
|
///</summary>
|
||||||
|
[SugarTable("JournalPageTaskUserAnswer")]
|
||||||
|
public partial class JournalPageTaskUserAnswer : SqlSugarBaseEntity
|
||||||
|
{
|
||||||
|
public JournalPageTaskUserAnswer(){
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Desc:书id
|
||||||
|
/// Default:
|
||||||
|
/// Nullable:False
|
||||||
|
/// </summary>
|
||||||
|
public long JournalId {get;set;}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Desc:书页id
|
||||||
|
/// Default:
|
||||||
|
/// Nullable:False
|
||||||
|
/// </summary>
|
||||||
|
public long JournalPageId {get;set;}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Desc:任务id
|
||||||
|
/// Default:
|
||||||
|
/// Nullable:False
|
||||||
|
/// </summary>
|
||||||
|
public long JournalPageTaskId {get;set;}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Desc:任务分组id
|
||||||
|
/// Default:
|
||||||
|
/// Nullable:False
|
||||||
|
/// </summary>
|
||||||
|
public long JournalPageTaskGroupId {get;set;}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Desc:用户id
|
||||||
|
/// Default:
|
||||||
|
/// Nullable:False
|
||||||
|
/// </summary>
|
||||||
|
public long UserId {get;set;}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Desc:作答结果
|
||||||
|
/// Default:
|
||||||
|
/// Nullable:True
|
||||||
|
/// </summary>
|
||||||
|
public string Result {get;set;}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Desc:积分
|
||||||
|
/// Default:0
|
||||||
|
/// Nullable:False
|
||||||
|
/// </summary>
|
||||||
|
public float Points {get;set;}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Desc:成长值
|
||||||
|
/// Default:0
|
||||||
|
/// Nullable:False
|
||||||
|
/// </summary>
|
||||||
|
public float GrowthPoints {get;set;}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Desc:题目作答图片地址
|
||||||
|
/// Default:
|
||||||
|
/// Nullable:True
|
||||||
|
/// </summary>
|
||||||
|
public string QuestionAnswerUrl {get;set;}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Desc:答案图片地址
|
||||||
|
/// Default:
|
||||||
|
/// Nullable:True
|
||||||
|
/// </summary>
|
||||||
|
public string AnswerUrl {get;set;}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Desc:页面作答图片地址
|
||||||
|
/// Default:
|
||||||
|
/// Nullable:True
|
||||||
|
/// </summary>
|
||||||
|
public string PageAnswerUrl {get;set;}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Desc:乐观锁
|
||||||
|
/// Default:
|
||||||
|
/// Nullable:False
|
||||||
|
/// </summary>
|
||||||
|
public int Revision {get;set;}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Desc:作答状态
|
||||||
|
/// Default:
|
||||||
|
/// Nullable:False
|
||||||
|
/// </summary>
|
||||||
|
public int AnswerStatus {get;set;}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Desc:作答开始时间
|
||||||
|
/// Default:
|
||||||
|
/// Nullable:True
|
||||||
|
/// </summary>
|
||||||
|
public DateTime AnswerStartTime {get;set;}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Desc:作答结束时间
|
||||||
|
/// Default:
|
||||||
|
/// Nullable:True
|
||||||
|
/// </summary>
|
||||||
|
public DateTime AnswerEndTime {get;set;}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Desc:作答耗时(秒)
|
||||||
|
/// Default:0
|
||||||
|
/// Nullable:False
|
||||||
|
/// </summary>
|
||||||
|
public int AnswerSeconds {get;set;}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Desc:图像识别结果
|
||||||
|
/// Default:
|
||||||
|
/// Nullable:False
|
||||||
|
/// </summary>
|
||||||
|
public int ImageRecognition {get;set;}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Desc:书页序号
|
||||||
|
/// Default:
|
||||||
|
/// Nullable:False
|
||||||
|
/// </summary>
|
||||||
|
public int JournalPageNum {get;set;}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Desc:修改次数
|
||||||
|
/// Default:
|
||||||
|
/// Nullable:False
|
||||||
|
/// </summary>
|
||||||
|
public int Modify {get;set;}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Desc:最后标签id
|
||||||
|
/// Default:
|
||||||
|
/// Nullable:False
|
||||||
|
/// </summary>
|
||||||
|
public long LastTag {get;set;}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Desc:点读书页序号
|
||||||
|
/// Default:
|
||||||
|
/// Nullable:False
|
||||||
|
/// </summary>
|
||||||
|
public int DotPageNum {get;set;}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Desc:页面结果图片地址
|
||||||
|
/// Default:
|
||||||
|
/// Nullable:True
|
||||||
|
/// </summary>
|
||||||
|
public string PageResultUrl {get;set;}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Desc:题型
|
||||||
|
/// Default:
|
||||||
|
/// Nullable:True
|
||||||
|
/// </summary>
|
||||||
|
public string Type {get;set;}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Desc:点读书页编号
|
||||||
|
/// Default:
|
||||||
|
/// Nullable:True
|
||||||
|
/// </summary>
|
||||||
|
public string DotPageNo {get;set;}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Desc:页面作答点读图片地址
|
||||||
|
/// Default:
|
||||||
|
/// Nullable:True
|
||||||
|
/// </summary>
|
||||||
|
public string PageAnswerDotUrl {get;set;}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Desc:中断次数
|
||||||
|
/// Default:0
|
||||||
|
/// Nullable:False
|
||||||
|
/// </summary>
|
||||||
|
public int BreakCount {get;set;}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Desc:中断时间记录
|
||||||
|
/// Default:
|
||||||
|
/// Nullable:True
|
||||||
|
/// </summary>
|
||||||
|
public string BreakTimes {get;set;}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Desc:作业状态
|
||||||
|
/// Default:
|
||||||
|
/// Nullable:True
|
||||||
|
/// </summary>
|
||||||
|
public string AssignmentStatus {get;set;}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
254
QYZH.InteractiveMagazine.Service/AiBasePromptService.cs
Normal file
254
QYZH.InteractiveMagazine.Service/AiBasePromptService.cs
Normal file
@ -0,0 +1,254 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using QYZH.InteractiveMagazine.IService;
|
||||||
|
using QYZH.InteractiveMagazine.Models.Common;
|
||||||
|
using QYZH.InteractiveMagazine.Models.Dto;
|
||||||
|
using QYZH.InteractiveMagazine.Models.Entity;
|
||||||
|
using QYZH.InteractiveMagazine.Repository;
|
||||||
|
using SqlSugar;
|
||||||
|
|
||||||
|
namespace QYZH.InteractiveMagazine.Service;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// AIPrompt配置服务实现
|
||||||
|
/// </summary>
|
||||||
|
public class AiBasePromptService(
|
||||||
|
BaseRepository<AiBasePrompt> promptRepository,
|
||||||
|
ILogger<AiBasePromptService> logger) : BaseRepository<AiBasePrompt>, IAiBasePromptService
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 创建Prompt配置
|
||||||
|
/// </summary>
|
||||||
|
public async Task<AiBasePromptOutput> CreateAsync(AiBasePromptInput input)
|
||||||
|
{
|
||||||
|
logger.LogInformation("正在创建Prompt配置,PromptKey: {PromptKey}", input.PromptKey);
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(input.PromptKey))
|
||||||
|
{
|
||||||
|
throw new BusinessException("配置标识不能为空", 400);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(input.PromptName))
|
||||||
|
{
|
||||||
|
throw new BusinessException("配置名称不能为空", 400);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(input.PromptTemplate))
|
||||||
|
{
|
||||||
|
throw new BusinessException("Prompt模板内容不能为空", 400);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查PromptKey是否已存在
|
||||||
|
var exists = await promptRepository.IsAnyAsync(p => p.PromptKey == input.PromptKey.Trim());
|
||||||
|
if (exists)
|
||||||
|
{
|
||||||
|
throw new BusinessException($"配置标识 '{input.PromptKey.Trim()}' 已存在", 400);
|
||||||
|
}
|
||||||
|
|
||||||
|
var entity = new AiBasePrompt
|
||||||
|
{
|
||||||
|
PromptKey = input.PromptKey.Trim(),
|
||||||
|
PromptName = input.PromptName.Trim(),
|
||||||
|
PromptTemplate = input.PromptTemplate,
|
||||||
|
Description = input.Description,
|
||||||
|
Priority = input.Priority,
|
||||||
|
IsDefault = input.IsDefault,
|
||||||
|
CreatedBy = "System",
|
||||||
|
UpdatedBy = "System",
|
||||||
|
CreatedAt = DateTime.Now,
|
||||||
|
UpdatedAt = DateTime.Now,
|
||||||
|
IsDeleted = false
|
||||||
|
};
|
||||||
|
|
||||||
|
var result = await promptRepository.InsertAsync(entity);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
logger.LogError("Prompt配置创建失败,PromptKey: {PromptKey}", input.PromptKey);
|
||||||
|
throw new BusinessException("创建Prompt配置失败", 500);
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.LogInformation("Prompt配置创建成功,PromptKey: {PromptKey}, ID: {Id}", input.PromptKey, entity.Id);
|
||||||
|
|
||||||
|
return new AiBasePromptOutput
|
||||||
|
{
|
||||||
|
Id = entity.Id,
|
||||||
|
PromptKey = entity.PromptKey,
|
||||||
|
PromptName = entity.PromptName,
|
||||||
|
PromptTemplate = entity.PromptTemplate,
|
||||||
|
Description = entity.Description,
|
||||||
|
Priority = entity.Priority,
|
||||||
|
IsDefault = entity.IsDefault,
|
||||||
|
CreatedBy = entity.CreatedBy,
|
||||||
|
CreatedAt = entity.CreatedAt,
|
||||||
|
UpdatedBy = entity.UpdatedBy,
|
||||||
|
UpdatedAt = entity.UpdatedAt
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新Prompt配置
|
||||||
|
/// </summary>
|
||||||
|
public async Task<AiBasePromptOutput> UpdateAsync(long id, AiBasePromptInput input)
|
||||||
|
{
|
||||||
|
logger.LogInformation("正在更新Prompt配置,ID: {Id}", id);
|
||||||
|
|
||||||
|
var entity = await promptRepository.GetByIdAsync(id);
|
||||||
|
if (entity == null)
|
||||||
|
{
|
||||||
|
logger.LogWarning("未找到要更新的Prompt配置,ID: {Id}", id);
|
||||||
|
throw new BusinessException("Prompt配置不存在", 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(input.PromptKey))
|
||||||
|
{
|
||||||
|
throw new BusinessException("配置标识不能为空", 400);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(input.PromptName))
|
||||||
|
{
|
||||||
|
throw new BusinessException("配置名称不能为空", 400);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(input.PromptTemplate))
|
||||||
|
{
|
||||||
|
throw new BusinessException("Prompt模板内容不能为空", 400);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查PromptKey是否被其他记录占用
|
||||||
|
var exists = await promptRepository.IsAnyAsync(p => p.PromptKey == input.PromptKey.Trim() && p.Id != id);
|
||||||
|
if (exists)
|
||||||
|
{
|
||||||
|
throw new BusinessException($"配置标识 '{input.PromptKey.Trim()}' 已被其他配置使用", 400);
|
||||||
|
}
|
||||||
|
|
||||||
|
entity.PromptKey = input.PromptKey.Trim();
|
||||||
|
entity.PromptName = input.PromptName.Trim();
|
||||||
|
entity.PromptTemplate = input.PromptTemplate;
|
||||||
|
entity.Description = input.Description;
|
||||||
|
entity.Priority = input.Priority;
|
||||||
|
entity.IsDefault = input.IsDefault;
|
||||||
|
entity.UpdatedBy = "System";
|
||||||
|
entity.UpdatedAt = DateTime.Now;
|
||||||
|
|
||||||
|
var result = await promptRepository.UpdateAsync(entity);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
logger.LogError("Prompt配置更新失败,ID: {Id}", id);
|
||||||
|
throw new BusinessException("更新Prompt配置失败", 500);
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.LogInformation("Prompt配置更新成功,ID: {Id}", id);
|
||||||
|
|
||||||
|
return new AiBasePromptOutput
|
||||||
|
{
|
||||||
|
Id = entity.Id,
|
||||||
|
PromptKey = entity.PromptKey,
|
||||||
|
PromptName = entity.PromptName,
|
||||||
|
PromptTemplate = entity.PromptTemplate,
|
||||||
|
Description = entity.Description,
|
||||||
|
Priority = entity.Priority,
|
||||||
|
IsDefault = entity.IsDefault,
|
||||||
|
CreatedBy = entity.CreatedBy,
|
||||||
|
CreatedAt = entity.CreatedAt,
|
||||||
|
UpdatedBy = entity.UpdatedBy,
|
||||||
|
UpdatedAt = entity.UpdatedAt
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除Prompt配置(软删除)
|
||||||
|
/// </summary>
|
||||||
|
public async Task DeleteAsync(long id)
|
||||||
|
{
|
||||||
|
logger.LogInformation("正在删除Prompt配置,ID: {Id}", id);
|
||||||
|
|
||||||
|
var entity = await promptRepository.GetByIdAsync(id);
|
||||||
|
if (entity == null)
|
||||||
|
{
|
||||||
|
logger.LogWarning("未找到要删除的Prompt配置,ID: {Id}", id);
|
||||||
|
throw new BusinessException("Prompt配置不存在", 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
var result = await promptRepository.DeleteByIdAsync(id);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
logger.LogError("Prompt配置删除失败,ID: {Id}", id);
|
||||||
|
throw new BusinessException("删除Prompt配置失败", 500);
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.LogInformation("Prompt配置删除成功,ID: {Id}", id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 根据ID获取Prompt配置
|
||||||
|
/// </summary>
|
||||||
|
public async Task<AiBasePromptOutput> GetByIdAsync(long id)
|
||||||
|
{
|
||||||
|
logger.LogInformation("正在获取Prompt配置信息,ID: {Id}", id);
|
||||||
|
|
||||||
|
var entity = await promptRepository.GetByIdAsync(id);
|
||||||
|
if (entity == null)
|
||||||
|
{
|
||||||
|
logger.LogWarning("未找到Prompt配置,ID: {Id}", id);
|
||||||
|
throw new BusinessException("Prompt配置不存在", 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new AiBasePromptOutput
|
||||||
|
{
|
||||||
|
Id = entity.Id,
|
||||||
|
PromptKey = entity.PromptKey,
|
||||||
|
PromptName = entity.PromptName,
|
||||||
|
PromptTemplate = entity.PromptTemplate,
|
||||||
|
Description = entity.Description,
|
||||||
|
Priority = entity.Priority,
|
||||||
|
IsDefault = entity.IsDefault,
|
||||||
|
CreatedBy = entity.CreatedBy,
|
||||||
|
CreatedAt = entity.CreatedAt,
|
||||||
|
UpdatedBy = entity.UpdatedBy,
|
||||||
|
UpdatedAt = entity.UpdatedAt
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 分页查询Prompt配置列表
|
||||||
|
/// </summary>
|
||||||
|
public async Task<PageListModel<AiBasePromptOutput>> GetListAsync(AiBasePromptQueryInput input)
|
||||||
|
{
|
||||||
|
logger.LogInformation("正在查询Prompt配置列表,页码: {PageIndex}, 每页条数: {PageSize}", input.PageIndex, input.PageSize);
|
||||||
|
|
||||||
|
if (input.PageIndex <= 0)
|
||||||
|
{
|
||||||
|
throw new BusinessException("页码必须大于0", 400);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (input.PageSize <= 0 || input.PageSize > 100)
|
||||||
|
{
|
||||||
|
throw new BusinessException("每页条数必须在1-100之间", 400);
|
||||||
|
}
|
||||||
|
|
||||||
|
RefAsync<int> totalNumber = 0;
|
||||||
|
var pageResult = await promptRepository.Queryable()
|
||||||
|
.WhereIF(!string.IsNullOrWhiteSpace(input.PromptKey), p => p.PromptKey == input.PromptKey)
|
||||||
|
.WhereIF(!string.IsNullOrWhiteSpace(input.PromptName), p => p.PromptName.Contains(input.PromptName))
|
||||||
|
.OrderBy(p => p.Priority)
|
||||||
|
.OrderByDescending(p => p.CreatedAt)
|
||||||
|
.ToPageListAsync(input.PageIndex, input.PageSize, totalNumber);
|
||||||
|
|
||||||
|
var result = pageResult.Select(p => new AiBasePromptOutput
|
||||||
|
{
|
||||||
|
Id = p.Id,
|
||||||
|
PromptKey = p.PromptKey,
|
||||||
|
PromptName = p.PromptName,
|
||||||
|
PromptTemplate = p.PromptTemplate,
|
||||||
|
Description = p.Description,
|
||||||
|
Priority = p.Priority,
|
||||||
|
IsDefault = p.IsDefault,
|
||||||
|
CreatedBy = p.CreatedBy,
|
||||||
|
CreatedAt = p.CreatedAt,
|
||||||
|
UpdatedBy = p.UpdatedBy,
|
||||||
|
UpdatedAt = p.UpdatedAt
|
||||||
|
}).ToList();
|
||||||
|
|
||||||
|
return new PageListModel<AiBasePromptOutput>(result, input.PageIndex, input.PageSize, totalNumber);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -105,7 +105,6 @@ public class JournalService(BaseRepository<JournalPage> JournalPageRepository,
|
|||||||
Journal.Width = input.Width;
|
Journal.Width = input.Width;
|
||||||
Journal.Height = input.Height;
|
Journal.Height = input.Height;
|
||||||
Journal.Name = input.Name;
|
Journal.Name = input.Name;
|
||||||
Journal.Title = input.Title;
|
|
||||||
|
|
||||||
var res = await UseTranAsync(async () =>
|
var res = await UseTranAsync(async () =>
|
||||||
{
|
{
|
||||||
|
|||||||
@ -157,7 +157,7 @@ public class UsersService(
|
|||||||
{
|
{
|
||||||
if (journalDict.TryGetValue(item.JournalId, out var journal))
|
if (journalDict.TryGetValue(item.JournalId, out var journal))
|
||||||
{
|
{
|
||||||
item.JournalTitle = journal.Title;
|
item.Name = journal.Name;
|
||||||
item.CoverImageUrl = journal.Cover;
|
item.CoverImageUrl = journal.Cover;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -236,7 +236,7 @@ public class WeChatAuthService(
|
|||||||
|
|
||||||
// 校验 WxUser 是否存在
|
// 校验 WxUser 是否存在
|
||||||
var wxUser = await wxUserRepository.Context.Queryable<WxUser>()
|
var wxUser = await wxUserRepository.Context.Queryable<WxUser>()
|
||||||
.Where(w => w.Id == wxUserId )
|
.Where(w => w.Id == wxUserId)
|
||||||
.FirstAsync();
|
.FirstAsync();
|
||||||
|
|
||||||
if (wxUser == null)
|
if (wxUser == null)
|
||||||
@ -260,11 +260,10 @@ public class WeChatAuthService(
|
|||||||
UpdatedAt = DateTime.Now
|
UpdatedAt = DateTime.Now
|
||||||
};
|
};
|
||||||
|
|
||||||
var userId = await wxUserRepository.Context.Insertable(newUser).ExecuteReturnIdentityAsync();
|
await wxUserRepository.Context.Insertable(newUser).ExecuteReturnIdentityAsync();
|
||||||
newUser.Id = userId;
|
|
||||||
|
|
||||||
logger.LogInformation("新用户创建成功,UserId: {UserId}, WxUserId: {WxUserId}, Name: {Name}",
|
logger.LogInformation("新用户创建成功,UserId: {UserId}, WxUserId: {WxUserId}, Name: {Name}",
|
||||||
userId, wxUserId, input.Name);
|
newUser.Id, wxUserId, input.Name);
|
||||||
|
|
||||||
// 为新用户创建默认宠物
|
// 为新用户创建默认宠物
|
||||||
try { await petService.CreateDefaultPetAsync(newUser.Id); }
|
try { await petService.CreateDefaultPetAsync(newUser.Id); }
|
||||||
|
|||||||
@ -0,0 +1,151 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using QYZH.InteractiveMagazine.IService;
|
||||||
|
using QYZH.InteractiveMagazine.Models.Common;
|
||||||
|
using QYZH.InteractiveMagazine.Models.Dto;
|
||||||
|
using QYZH.InteractiveMagazine.Models.Enum;
|
||||||
|
|
||||||
|
namespace QYZH.InteractiveMagazine.WebApi.Controllers;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// AIPrompt配置管理控制器
|
||||||
|
/// </summary>
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
[ApiController]
|
||||||
|
[ApiExplorerSettings(GroupName = nameof(ApiVersionEnum.Platform))]
|
||||||
|
public class AiBasePromptController : BaseController
|
||||||
|
{
|
||||||
|
private readonly IAiBasePromptService _aiBasePromptService;
|
||||||
|
private readonly ILogger<AiBasePromptController> _logger;
|
||||||
|
|
||||||
|
public AiBasePromptController(IAiBasePromptService aiBasePromptService, ILogger<AiBasePromptController> logger)
|
||||||
|
{
|
||||||
|
_aiBasePromptService = aiBasePromptService;
|
||||||
|
_logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 创建Prompt配置
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="input">Prompt配置信息</param>
|
||||||
|
/// <returns>创建的Prompt配置信息</returns>
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<BaseResponse<AiBasePromptOutput>> CreateAsync([FromBody] AiBasePromptInput input)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var result = await _aiBasePromptService.CreateAsync(input);
|
||||||
|
return Success(result, "创建Prompt配置成功");
|
||||||
|
}
|
||||||
|
catch (BusinessException ex)
|
||||||
|
{
|
||||||
|
_logger.LogWarning(ex, "创建Prompt配置业务异常: {Message}", ex.Message);
|
||||||
|
return BaseResponse<AiBasePromptOutput>.Fail(ex.Message);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "创建Prompt配置系统异常,参数:{Input}", input);
|
||||||
|
return BaseResponse<AiBasePromptOutput>.Fail("创建Prompt配置失败,请稍后重试");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新Prompt配置
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">Prompt配置ID</param>
|
||||||
|
/// <param name="input">Prompt配置信息</param>
|
||||||
|
/// <returns>更新后的Prompt配置信息</returns>
|
||||||
|
[HttpPut("{id}")]
|
||||||
|
public async Task<BaseResponse<AiBasePromptOutput>> UpdateAsync(long id, [FromBody] AiBasePromptInput input)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var result = await _aiBasePromptService.UpdateAsync(id, input);
|
||||||
|
return Success(result, "更新Prompt配置成功");
|
||||||
|
}
|
||||||
|
catch (BusinessException ex)
|
||||||
|
{
|
||||||
|
_logger.LogWarning(ex, "更新Prompt配置业务异常: {Message}", ex.Message);
|
||||||
|
return BaseResponse<AiBasePromptOutput>.Fail(ex.Message);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "更新Prompt配置系统异常,ID:{Id},参数:{Input}", id, input);
|
||||||
|
return BaseResponse<AiBasePromptOutput>.Fail("更新Prompt配置失败,请稍后重试");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除Prompt配置
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">Prompt配置ID</param>
|
||||||
|
/// <returns>操作结果</returns>
|
||||||
|
[HttpDelete("{id}")]
|
||||||
|
public async Task<BaseResponse<object>> DeleteAsync(long id)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await _aiBasePromptService.DeleteAsync(id);
|
||||||
|
return Success(new object(), "删除Prompt配置成功");
|
||||||
|
}
|
||||||
|
catch (BusinessException ex)
|
||||||
|
{
|
||||||
|
_logger.LogWarning(ex, "删除Prompt配置业务异常: {Message}", ex.Message);
|
||||||
|
return BaseResponse<object>.Fail(ex.Message);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "删除Prompt配置系统异常,ID:{Id}", id);
|
||||||
|
return BaseResponse<object>.Fail("删除Prompt配置失败,请稍后重试");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 根据ID获取Prompt配置
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">Prompt配置ID</param>
|
||||||
|
/// <returns>Prompt配置信息</returns>
|
||||||
|
[HttpGet("{id}")]
|
||||||
|
public async Task<BaseResponse<AiBasePromptOutput>> GetByIdAsync(long id)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var result = await _aiBasePromptService.GetByIdAsync(id);
|
||||||
|
return Success(result);
|
||||||
|
}
|
||||||
|
catch (BusinessException ex)
|
||||||
|
{
|
||||||
|
_logger.LogWarning(ex, "获取Prompt配置业务异常: {Message}", ex.Message);
|
||||||
|
return BaseResponse<AiBasePromptOutput>.Fail(ex.Message);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "获取Prompt配置系统异常,ID:{Id}", id);
|
||||||
|
return BaseResponse<AiBasePromptOutput>.Fail("获取Prompt配置信息失败,请稍后重试");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 分页查询Prompt配置列表
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="input">查询条件</param>
|
||||||
|
/// <returns>分页结果</returns>
|
||||||
|
[HttpPost("list")]
|
||||||
|
public async Task<BaseResponse<PageListModel<AiBasePromptOutput>>> GetListAsync([FromBody] AiBasePromptQueryInput input)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var result = await _aiBasePromptService.GetListAsync(input);
|
||||||
|
return Success(result);
|
||||||
|
}
|
||||||
|
catch (BusinessException ex)
|
||||||
|
{
|
||||||
|
_logger.LogWarning(ex, "查询Prompt配置列表业务异常: {Message}", ex.Message);
|
||||||
|
return BaseResponse<PageListModel<AiBasePromptOutput>>.Fail(ex.Message);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "查询Prompt配置列表系统异常,参数:{Input}", input);
|
||||||
|
return BaseResponse<PageListModel<AiBasePromptOutput>>.Fail("查询Prompt配置列表失败,请稍后重试");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user