Initial project import
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
namespace MiaoJiZhang.Domain.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// 后台可配置内容(决策:App 名称等品牌位后台配置;性格 Prompt/文案/表情包后台管理)。
|
||||
/// 统一 key-value + 版本号,客户端按版本增量拉取。
|
||||
/// </summary>
|
||||
public class AppConfig
|
||||
{
|
||||
public long Id { get; set; }
|
||||
/// <summary>如 brand.app_name / brand.logo_url / llm.model / limit.daily_ai_messages</summary>
|
||||
public string Key { get; set; } = null!;
|
||||
public string Value { get; set; } = null!;
|
||||
public int Version { get; set; }
|
||||
public DateTime UpdatedAt { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>AI 性格库(后台管理,Prompt 可调不发版)</summary>
|
||||
public class AiPersona
|
||||
{
|
||||
public long Id { get; set; }
|
||||
/// <summary>如 sassy_cat / gentle / strict / meme</summary>
|
||||
public string Key { get; set; } = null!;
|
||||
public string Name { get; set; } = null!;
|
||||
public string Description { get; set; } = null!;
|
||||
public string SampleLine { get; set; } = null!;
|
||||
/// <summary>系统提示词模板,支持 {avatar_tic} 等占位符</summary>
|
||||
public string PromptTemplate { get; set; } = null!;
|
||||
public int Version { get; set; }
|
||||
public bool IsEnabled { get; set; } = true;
|
||||
}
|
||||
|
||||
/// <summary>AI 形象库(后台管理;口癖跟随形象——决策 20)</summary>
|
||||
public class AiAvatar
|
||||
{
|
||||
public long Id { get; set; }
|
||||
/// <summary>cat / dog / robot ...</summary>
|
||||
public string Key { get; set; } = null!;
|
||||
public string DefaultName { get; set; } = null!;
|
||||
/// <summary>口癖后缀,如 喵 / 汪 / 空字符串</summary>
|
||||
public string SpeechTic { get; set; } = "";
|
||||
public string? ImageUrl { get; set; }
|
||||
public bool IsEnabled { get; set; } = true;
|
||||
}
|
||||
|
||||
/// <summary>表情包库(后台管理)</summary>
|
||||
public class Sticker
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public string Key { get; set; } = null!;
|
||||
public string Label { get; set; } = null!;
|
||||
public string? ImageUrl { get; set; }
|
||||
/// <summary>分组:ai_exclusive / classic ...</summary>
|
||||
public string GroupKey { get; set; } = "classic";
|
||||
/// <summary>触发场景标签,逗号分隔:over_budget,salary,forgive</summary>
|
||||
public string? TriggerTags { get; set; }
|
||||
public bool IsEnabled { get; set; } = true;
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
using MiaoJiZhang.Domain.Enums;
|
||||
|
||||
namespace MiaoJiZhang.Domain.Entities;
|
||||
|
||||
/// <summary>账本(支持多账本/共享账本)</summary>
|
||||
public class Ledger
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public long OwnerId { get; set; }
|
||||
public User Owner { get; set; } = null!;
|
||||
public string Name { get; set; } = null!;
|
||||
public string IconKey { get; set; } = "wallet";
|
||||
public bool IsDefault { get; set; }
|
||||
public DateTime CreatedAt { get; set; }
|
||||
|
||||
public List<Transaction> Transactions { get; set; } = [];
|
||||
public List<Budget> Budgets { get; set; } = [];
|
||||
}
|
||||
|
||||
/// <summary>分类(系统默认分类 UserId 为 null;用户自定义分类挂 UserId)</summary>
|
||||
public class Category
|
||||
{
|
||||
public long Id { get; set; }
|
||||
/// <summary>null = 系统默认分类(后台可管理)</summary>
|
||||
public long? UserId { get; set; }
|
||||
public TransactionType Type { get; set; }
|
||||
public string Name { get; set; } = null!;
|
||||
public string IconKey { get; set; } = "tag";
|
||||
public string ColorKey { get; set; } = "mint";
|
||||
public int SortOrder { get; set; }
|
||||
public bool IsDeleted { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>账单</summary>
|
||||
public class Transaction
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public long LedgerId { get; set; }
|
||||
public Ledger Ledger { get; set; } = null!;
|
||||
public long UserId { get; set; }
|
||||
public long CategoryId { get; set; }
|
||||
public Category Category { get; set; } = null!;
|
||||
|
||||
public TransactionType Type { get; set; }
|
||||
public decimal Amount { get; set; }
|
||||
public string? Note { get; set; }
|
||||
public string? PaymentMethod { get; set; }
|
||||
public DateTime OccurredAt { get; set; }
|
||||
|
||||
// ---- AI 来源追溯(决策:可核对、可撤销) ----
|
||||
public TransactionSource Source { get; set; } = TransactionSource.Manual;
|
||||
/// <summary>AI 记账时用户的原话(追溯用)</summary>
|
||||
public string? SourceText { get; set; }
|
||||
/// <summary>关联的聊天消息 Id(追溯用)</summary>
|
||||
public long? SourceChatMessageId { get; set; }
|
||||
public string? ClientRequestId { get; set; }
|
||||
|
||||
// ---- 软删除(决策:直接入账 + 可撤销) ----
|
||||
public bool IsDeleted { get; set; }
|
||||
public DateTime? DeletedAt { get; set; }
|
||||
|
||||
public DateTime CreatedAt { get; set; }
|
||||
public DateTime UpdatedAt { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>预算(CategoryId 为 null 表示总预算)</summary>
|
||||
public class Budget
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public long LedgerId { get; set; }
|
||||
public Ledger Ledger { get; set; } = null!;
|
||||
public long UserId { get; set; }
|
||||
/// <summary>null = 月度总预算</summary>
|
||||
public long? CategoryId { get; set; }
|
||||
/// <summary>格式 yyyyMM;0 表示长期生效模板</summary>
|
||||
public int Period { get; set; }
|
||||
public decimal Amount { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>AI 聊天消息</summary>
|
||||
public class ChatMessage
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public long UserId { get; set; }
|
||||
public ChatRole Role { get; set; }
|
||||
public ChatMessageType Type { get; set; }
|
||||
/// <summary>文本内容 / 表情包 key / 卡片 JSON</summary>
|
||||
public string Content { get; set; } = null!;
|
||||
/// <summary>该消息产生的账单 Id(BillCard 类型)</summary>
|
||||
public long? TransactionId { get; set; }
|
||||
public DateTime CreatedAt { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
using MiaoJiZhang.Domain.Enums;
|
||||
|
||||
namespace MiaoJiZhang.Domain.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// 用户。当前仅用户名+密码注册登录;
|
||||
/// Email/Phone/微信等字段为预留(决策 2026-07-18),暂不启用。
|
||||
/// </summary>
|
||||
public class User
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public string Username { get; set; } = null!;
|
||||
public string PasswordHash { get; set; } = null!;
|
||||
public string? Nickname { get; set; }
|
||||
public string? AvatarUrl { get; set; }
|
||||
|
||||
// ---- 预留:快捷登录(暂不启用,仅建表占位) ----
|
||||
public string? Email { get; set; }
|
||||
public bool EmailVerified { get; set; }
|
||||
public string? Phone { get; set; }
|
||||
public bool PhoneVerified { get; set; }
|
||||
public string? WeChatOpenId { get; set; }
|
||||
public string? WeChatUnionId { get; set; }
|
||||
public string? AppleUserId { get; set; }
|
||||
|
||||
// ---- 模式与 AI 伙伴设置 ----
|
||||
public AppMode AppMode { get; set; } = AppMode.Normal;
|
||||
public AiCompanionSetting? AiCompanion { get; set; }
|
||||
|
||||
public bool IsBanned { get; set; }
|
||||
public int AuthVersion { get; set; }
|
||||
public int AiChatLimit { get; set; } = 50;
|
||||
public AiQuotaPeriod AiChatPeriod { get; set; } = AiQuotaPeriod.Day;
|
||||
public int AiChatUsed { get; set; }
|
||||
public DateTime AiChatWindowStartedAt { get; set; }
|
||||
public DateTime? AccountClosureRequestedAt { get; set; }
|
||||
public DateTime? AccountClosureScheduledAt { get; set; }
|
||||
public DateTime CreatedAt { get; set; }
|
||||
public DateTime? LastLoginAt { get; set; }
|
||||
|
||||
public List<Ledger> Ledgers { get; set; } = [];
|
||||
public List<UserFeaturePermission> FeaturePermissions { get; set; } = [];
|
||||
}
|
||||
|
||||
/// <summary>AI 伙伴设置(形象/昵称/性格/滑杆),1:1 User</summary>
|
||||
public class UserFeaturePermission
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public long UserId { get; set; }
|
||||
public User User { get; set; } = null!;
|
||||
public string PermissionKey { get; set; } = null!;
|
||||
public bool IsEnabled { get; set; }
|
||||
public DateTime CreatedAt { get; set; }
|
||||
public DateTime UpdatedAt { get; set; }
|
||||
}
|
||||
|
||||
public class AiCompanionSetting
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public long UserId { get; set; }
|
||||
public User User { get; set; } = null!;
|
||||
|
||||
/// <summary>形象 key:cat / dog / robot(后台形象库可扩展)</summary>
|
||||
public string AvatarKey { get; set; } = "cat";
|
||||
/// <summary>用户给 AI 起的名字;空则用形象默认名</summary>
|
||||
public string? CustomName { get; set; }
|
||||
/// <summary>性格 key,对应后台性格库</summary>
|
||||
public string PersonaKey { get; set; } = "sassy_cat";
|
||||
|
||||
/// <summary>吐槽力度 0-100</summary>
|
||||
public int RoastLevel { get; set; } = 60;
|
||||
/// <summary>表情包频率 0-100</summary>
|
||||
public int StickerFrequency { get; set; } = 70;
|
||||
/// <summary>主动提醒频率 0-100(映射:关/每周/每天/实时)</summary>
|
||||
public int ProactiveLevel { get; set; } = 40;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
namespace MiaoJiZhang.Domain.Enums;
|
||||
|
||||
public enum AiQuotaPeriod
|
||||
{
|
||||
Day = 0,
|
||||
Week = 1,
|
||||
Month = 2,
|
||||
}
|
||||
|
||||
/// <summary>App 模式(决策:双模式)</summary>
|
||||
public enum AppMode
|
||||
{
|
||||
/// <summary>普通记账模式</summary>
|
||||
Normal = 0,
|
||||
/// <summary>全 AI 模式</summary>
|
||||
AiFirst = 1,
|
||||
}
|
||||
|
||||
/// <summary>账单类型</summary>
|
||||
public enum TransactionType
|
||||
{
|
||||
Expense = 0,
|
||||
Income = 1,
|
||||
Transfer = 2,
|
||||
}
|
||||
|
||||
/// <summary>账单来源(决策:AI 记账可追溯)</summary>
|
||||
public enum TransactionSource
|
||||
{
|
||||
Manual = 0,
|
||||
AiChat = 1,
|
||||
Voice = 2,
|
||||
ReceiptOcr = 3,
|
||||
Screenshot = 4,
|
||||
Accessibility = 5,
|
||||
Notification = 6,
|
||||
RecognitionAi = 7,
|
||||
LocalOcr = 8,
|
||||
}
|
||||
|
||||
public static class TransactionSourceRules
|
||||
{
|
||||
public static readonly TransactionSource[] AiAssisted =
|
||||
[
|
||||
TransactionSource.AiChat,
|
||||
TransactionSource.Voice,
|
||||
TransactionSource.ReceiptOcr,
|
||||
TransactionSource.Screenshot,
|
||||
TransactionSource.RecognitionAi,
|
||||
];
|
||||
|
||||
public static bool IsAiAssisted(this TransactionSource source) =>
|
||||
source is TransactionSource.AiChat
|
||||
or TransactionSource.Voice
|
||||
or TransactionSource.ReceiptOcr
|
||||
or TransactionSource.Screenshot
|
||||
or TransactionSource.RecognitionAi;
|
||||
}
|
||||
|
||||
/// <summary>聊天消息角色</summary>
|
||||
public enum ChatRole
|
||||
{
|
||||
User = 0,
|
||||
Assistant = 1,
|
||||
System = 2,
|
||||
}
|
||||
|
||||
/// <summary>聊天消息类型</summary>
|
||||
public enum ChatMessageType
|
||||
{
|
||||
Text = 0,
|
||||
Sticker = 1,
|
||||
BillCard = 2,
|
||||
ReportCard = 3,
|
||||
ContextBoundary = 4,
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user