Config.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422
  1. namespace Domain.Entities.Common;
  2. public sealed class Config
  3. {
  4. public int ID { get; private set; }
  5. public DateTime LastUpdatedAt { get; private set; } = DateTime.UtcNow;
  6. public byte[] RowVersion { get; private set; } = [];
  7. public BasicConfig Basic { get; private set; } = new();
  8. public ImagesConfig Images { get; private set; } = new();
  9. public MetaConfig Meta { get; private set; } = new();
  10. public CompanyConfig Company { get; private set; } = new();
  11. public AccountConfig Account { get; private set; } = new();
  12. public EmailTemplateConfig EmailTemplate { get; private set; } = new();
  13. public ExternalApiConfig External { get; private set; } = new();
  14. public CryptoConfig Crypto { get; private set; } = new();
  15. public AttendanceConfig Attendance { get; private set; } = new();
  16. public SignupRewardConfig SignupReward { get; private set; } = new();
  17. public RewardConfig Reward { get; private set; } = new();
  18. public ChatExpConfig ChatExp { get; private set; } = new();
  19. public PaperConfig Paper { get; private set; } = new();
  20. private Config() { }
  21. public static Config Create()
  22. {
  23. return new();
  24. }
  25. public void Update(
  26. BasicConfig basic,
  27. ImagesConfig images,
  28. MetaConfig meta,
  29. CompanyConfig company,
  30. AccountConfig account,
  31. EmailTemplateConfig emailTemplate,
  32. ExternalApiConfig external,
  33. CryptoConfig crypto,
  34. AttendanceConfig attendance,
  35. SignupRewardConfig signupReward
  36. ) {
  37. Basic = basic ?? throw new ArgumentNullException(nameof(basic));
  38. Images = images ?? throw new ArgumentNullException(nameof(images));
  39. Meta = meta ?? throw new ArgumentNullException(nameof(meta));
  40. Company = company ?? throw new ArgumentNullException(nameof(company));
  41. Account = account ?? throw new ArgumentNullException(nameof(account));
  42. EmailTemplate = emailTemplate ?? throw new ArgumentNullException(nameof(emailTemplate));
  43. External = external ?? throw new ArgumentNullException(nameof(external));
  44. Crypto = crypto ?? throw new ArgumentNullException(nameof(crypto));
  45. Attendance = attendance ?? throw new ArgumentNullException(nameof(attendance));
  46. SignupReward = signupReward ?? throw new ArgumentNullException(nameof(signupReward));
  47. LastUpdatedAt = DateTime.UtcNow;
  48. }
  49. public void UpdateChatExp(ChatExpConfig chatExp)
  50. {
  51. ChatExp = chatExp ?? throw new ArgumentNullException(nameof(chatExp));
  52. LastUpdatedAt = DateTime.UtcNow;
  53. }
  54. public void UpdateReward(RewardConfig reward)
  55. {
  56. Reward = reward ?? throw new ArgumentNullException(nameof(reward));
  57. LastUpdatedAt = DateTime.UtcNow;
  58. }
  59. public void UpdatePaper(PaperConfig paper)
  60. {
  61. Paper = paper ?? throw new ArgumentNullException(nameof(paper));
  62. LastUpdatedAt = DateTime.UtcNow;
  63. }
  64. }
  65. #region Owned Groups
  66. // ==================================================
  67. // 기본 정보 (Basic)
  68. // ==================================================
  69. public sealed class BasicConfig
  70. {
  71. public string? SiteName { get; set; }
  72. public string? SiteURL { get; set; }
  73. public string? RootID { get; set; }
  74. public string? FromEmail { get; set; }
  75. public string? FromName { get; set; }
  76. public string? SmtpServer { get; set; }
  77. public int? SmtpPort { get; set; }
  78. public bool SmtpEnableSSL { get; set; }
  79. public string? SmtpUsername { get; set; }
  80. public string? SmtpPassword { get; set; }
  81. public string? AdminWhiteIPList { get; set; }
  82. public string? FrontWhiteIPList { get; set; }
  83. public string? BlockAlertTitle { get; set; }
  84. public string? BlockAlertContent { get; set; }
  85. public bool IsMaintenance { get; set; } = false;
  86. public string? MaintenanceContent { get; set; }
  87. /// <summary>쪽지 일일 발송 제한 (사용자 1인당 / 시스템 쪽지 제외). 0 = 발송 차단</summary>
  88. public int NoteDailySendLimit { get; set; } = 3;
  89. }
  90. // ==================================================
  91. // 기본 이미지 (Images)
  92. // ==================================================
  93. public sealed class ImagesConfig
  94. {
  95. public string? Favicon { get; set; }
  96. public string? LogoSquare { get; set; }
  97. public string? LogoHorizontal { get; set; }
  98. public string? OgDefault { get; set; }
  99. public string? TwitterImage { get; set; }
  100. public string? AppleTouchIcon { get; set; }
  101. public string? AppIcon_192 { get; set; }
  102. public string? AppIcon_512 { get; set; }
  103. }
  104. // ==================================================
  105. // 메타 태그 (Meta)
  106. // ==================================================
  107. public sealed class MetaConfig
  108. {
  109. public string? Keywords { get; set; }
  110. public string? Description { get; set; }
  111. public string? Author { get; set; }
  112. public string? Viewport { get; set; }
  113. public string? ApplicationName { get; set; }
  114. public string? Generator { get; set; }
  115. public string? Robots { get; set; }
  116. public string? Adds { get; set; }
  117. }
  118. // ==================================================
  119. // 회사 정보 (Company)
  120. // ==================================================
  121. public sealed class CompanyConfig
  122. {
  123. public string? Name { get; set; }
  124. public string? RegNo { get; set; }
  125. public string? Address { get; set; }
  126. public string? ZipCode { get; set; }
  127. public string? Owner { get; set; }
  128. public string? Tel { get; set; }
  129. public string? Fax { get; set; }
  130. public string? RetailSaleNo { get; set; }
  131. public string? AddedSaleNo { get; set; }
  132. public string? Hosting { get; set; }
  133. public string? AdminName { get; set; }
  134. public string? AdminEmail { get; set; }
  135. public string? SiteUrl { get; set; }
  136. public string? BankCode { get; set; }
  137. public string? BankOwner { get; set; }
  138. public string? BankNumber { get; set; }
  139. }
  140. // ==================================================
  141. // 회원가입 설정 (Account)
  142. // ==================================================
  143. public sealed class AccountConfig
  144. {
  145. // 회원 가입 시
  146. public bool IsRegisterBlock { get; set; } = false;
  147. public bool IsRegisterEmailAuth { get; set; } = false;
  148. public ushort? PasswordMinLength { get; set; }
  149. public ushort? PasswordUppercaseLength { get; set; }
  150. public ushort? PasswordNumbersLength { get; set; }
  151. public ushort? PasswordSpecialcharsLength { get; set; }
  152. public string? DeniedEmailList { get; set; }
  153. public string? DeniedNameList { get; set; }
  154. // 회원 수정 시 — 프로필(닉네임·한마디·이미지) 기본 90일 쿨다운 (변경권 아이템으로 우회 — Wave 3 P3)
  155. public ushort? ChangeEmailDay { get; set; }
  156. public ushort? ChangeNameDay { get; set; } = 90;
  157. public ushort? ChangeSummaryDay { get; set; }
  158. public ushort? ChangeIntroDay { get; set; } = 90;
  159. public ushort? ChangeThumbDay { get; set; } = 90;
  160. public ushort? ChangePasswordDay { get; set; }
  161. // 로그인 시
  162. public bool IsLoginEmailVerifiedOnly { get; set; } = false;
  163. public ushort? MaxLoginTryCount { get; set; }
  164. public ushort? MaxLoginTryLimitSecond { get; set; }
  165. }
  166. // ==================================================
  167. // 알림 발송 양식 - 이메일 (EmailTemplate)
  168. // ==================================================
  169. public sealed class EmailTemplateConfig
  170. {
  171. public string? RegisterEmailFormTitle { get; set; }
  172. public string? RegisterEmailFormContent { get; set; }
  173. public string? RegistrationEmailFormTitle { get; set; }
  174. public string? RegistrationEmailFormContent { get; set; }
  175. public string? ResetPasswordEmailFormTitle { get; set; }
  176. public string? ResetPasswordEmailFormContent { get; set; }
  177. public string? ChangedPasswordEmailFormTitle { get; set; }
  178. public string? ChangedPasswordEmailFormContent { get; set; }
  179. public string? WithdrawEmailFormTitle { get; set; }
  180. public string? WithdrawEmailFormContent { get; set; }
  181. public string? WithdrawVerifyEmailFormTitle { get; set; }
  182. public string? WithdrawVerifyEmailFormContent { get; set; }
  183. public string? EmailVerifyFormTitle { get; set; }
  184. public string? EmailVerifyFormContent { get; set; }
  185. public string? ChangedEmailFormTitle { get; set; }
  186. public string? ChangedEmailFormContent { get; set; }
  187. }
  188. // ==================================================
  189. // 외부 API 설정 (External)
  190. // ==================================================
  191. public sealed class ExternalApiConfig
  192. {
  193. /** YouTube **/
  194. public string? YouTubeApiKeyEnc { get; set; }
  195. public string? YouTubeApiName { get; set; }
  196. /** 구글 **/
  197. public string? GoogleClientId { get; set; }
  198. public string? GoogleClientSecretEnc { get; set; }
  199. public string? GoogleAppId { get; set; }
  200. /** 토스페이먼츠 **/
  201. /// <summary>Toss 결제 환경 (test / live)</summary>
  202. public string? TossPayMode { get; set; }
  203. /// <summary>Toss Test Client Key (암호화 저장 권장)</summary>
  204. public string? TossTestClientKeyEnc { get; set; }
  205. /// <summary>Toss Test Secret Key (암호화 저장 권장)</summary>
  206. public string? TossTestSecretKeyEnc { get; set; }
  207. /// <summary>Toss Live Client Key (암호화 저장 권장)</summary>
  208. public string? TossLiveClientKeyEnc { get; set; }
  209. /// <summary>Toss Live Secret Key (암호화 저장 권장)</summary>
  210. public string? TossLiveSecretKeyEnc { get; set; }
  211. }
  212. // ==================================================
  213. // 코인/시세 설정 (Crypto)
  214. // ==================================================
  215. public sealed class CryptoConfig
  216. {
  217. public int TickerRefreshSeconds { get; set; } = 5;
  218. public decimal SurgeThreshold { get; set; } = 5.0m;
  219. public decimal PlungeThreshold { get; set; } = -5.0m;
  220. public int MainPageCoinCount { get; set; } = 10;
  221. }
  222. // ==================================================
  223. // 채팅 경험치/리더보드 설정 (ChatExp)
  224. // 관리자: /Channel/Exp 페이지에서 편집
  225. // ==================================================
  226. public sealed class ChatExpConfig
  227. {
  228. /// <summary>채팅 1건당 지급 XP</summary>
  229. public int ChatXpPerMessage { get; set; } = 1;
  230. /// <summary>후원 N POINT당 1 XP (기본 1000 = 1,000원당 1XP)</summary>
  231. public int DonationXpPerAmount { get; set; } = 1000;
  232. /// <summary>방송 세션당 채팅 XP 상한 (후원 XP는 무제한)</summary>
  233. public int ChatXpSessionLimit { get; set; } = 50;
  234. /// <summary>XP 적립 최소 글자수</summary>
  235. public int MinContentLength { get; set; } = 2;
  236. /// <summary>채팅 쿨다운(초) — 기존 RateLimit 재정의</summary>
  237. public int RateLimitSec { get; set; } = 2;
  238. /// <summary>리더보드 표시 인원 (Top N)</summary>
  239. public int LeaderboardSize { get; set; } = 50;
  240. /// <summary>크라운 뱃지 부여 Top N</summary>
  241. public int CrownTopN { get; set; } = 3;
  242. /// <summary>watch 페이지에서 리더보드 기능 노출</summary>
  243. public bool UxShowLeaderboard { get; set; } = true;
  244. /// <summary>watch 페이지 채팅창 상단에 "내 XP" 뱃지 노출</summary>
  245. public bool UxShowMyXpBadge { get; set; } = true;
  246. }
  247. // ==================================================
  248. // 출석 설정 (Attendance)
  249. // ==================================================
  250. public sealed class AttendanceConfig
  251. {
  252. /// <summary>출석 기능 활성화</summary>
  253. public bool IsEnabled { get; set; } = false;
  254. /// <summary>기본 경험치</summary>
  255. public int BaseExp { get; set; } = 0;
  256. /// <summary>기본 포인트</summary>
  257. public int BasePoint { get; set; } = 0;
  258. /// <summary>연속 출석 가중치 사용</summary>
  259. public bool UseStreakBonus { get; set; } = false;
  260. /// <summary>연속 출석 1일당 추가 경험치</summary>
  261. public int StreakBonusPerDay { get; set; } = 0;
  262. /// <summary>연속 출석 1일당 추가 포인트</summary>
  263. public int StreakBonusPointPerDay { get; set; } = 0;
  264. /// <summary>가중치 최대 적용 일수</summary>
  265. public int StreakBonusMaxDays { get; set; } = 0;
  266. /// <summary>순위 보상 사용</summary>
  267. public bool UseRankBonus { get; set; } = false;
  268. /// <summary>순위별 보상 설정 (JSON) [{"rank":1,"exp":100,"point":50},...]</summary>
  269. public string? RankBonusConfig { get; set; }
  270. }
  271. // ==================================================
  272. // 가입 축하 보상 설정 (SignupReward)
  273. // 신규 회원 최초 가입 시 1회 지급. 멱등: WalletTransaction RefID "signup:{memberID}"
  274. // ==================================================
  275. public sealed class SignupRewardConfig
  276. {
  277. /// <summary>가입 축하 보상 활성화</summary>
  278. public bool Enabled { get; set; } = false;
  279. /// <summary>지급 코인(무상, Airdrop 파티션)</summary>
  280. public int CoinAmount { get; set; } = 0;
  281. /// <summary>지급 캐시(유상 취급, Adjusted 파티션). 기본 0</summary>
  282. public int CashAmount { get; set; } = 0;
  283. /// <summary>지급 경험치(XP)</summary>
  284. public int ExpAmount { get; set; } = 0;
  285. }
  286. // ==================================================
  287. // 보상 엔진 설정 (Reward) — d3 §③ / M2. ActivityTokenConfig 를 대체·통합.
  288. // RewardService 가 단일 지급 관문에서 참조하는 XP/토큰 수치 + 액션별 일일 캡.
  289. // 캡 필드는 0 = 무제한. XP=경험치(MemberStats.Exp), Point=토큰(Wallet Reward 파티션).
  290. // ==================================================
  291. public sealed class RewardConfig
  292. {
  293. /// <summary>게시글 1건 작성 시 지급 경험치 (0 = 미지급)</summary>
  294. public int PostExp { get; set; } = 0;
  295. /// <summary>게시글 1건 작성 시 지급 토큰 (0 = 미지급)</summary>
  296. public int PostPoint { get; set; } = 0;
  297. /// <summary>댓글 1건 작성 시 지급 경험치 (0 = 미지급)</summary>
  298. public int CommentExp { get; set; } = 0;
  299. /// <summary>댓글 1건 작성 시 지급 토큰 (0 = 미지급)</summary>
  300. public int CommentPoint { get; set; } = 0;
  301. /// <summary>추천(좋아요)을 누른 회원에게 지급 경험치 (0 = 미지급)</summary>
  302. public int LikeGivenExp { get; set; } = 0;
  303. /// <summary>추천(좋아요)을 받은 글 작성자에게 지급 토큰 (0 = 미지급)</summary>
  304. public int LikeReceivedPoint { get; set; } = 0;
  305. /// <summary>보상 지급 최소 게시글 길이 (미만이면 미지급, 0 = 제한 없음)</summary>
  306. public int MinPostLength { get; set; } = 0;
  307. /// <summary>보상 지급 최소 댓글 길이 (미만이면 미지급, 0 = 제한 없음)</summary>
  308. public int MinCommentLength { get; set; } = 0;
  309. /// <summary>신규 가입 후 보상 유예 기간(일) — 가입 N일 이내 회원은 활동 보상 미지급 (어뷰징 방지, 0 = 유예 없음)</summary>
  310. public int NewMemberHoldDays { get; set; } = 0;
  311. // ---- 액션별 일일 캡 (0 = 무제한) ----
  312. /// <summary>게시글 보상 일일 횟수 상한</summary>
  313. public int PostDailyCount { get; set; } = 0;
  314. /// <summary>게시글 보상 일일 경험치 상한</summary>
  315. public int PostDailyExp { get; set; } = 0;
  316. /// <summary>게시글 보상 일일 토큰 상한</summary>
  317. public int PostDailyPoint { get; set; } = 0;
  318. /// <summary>댓글 보상 일일 횟수 상한</summary>
  319. public int CommentDailyCount { get; set; } = 0;
  320. /// <summary>댓글 보상 일일 경험치 상한</summary>
  321. public int CommentDailyExp { get; set; } = 0;
  322. /// <summary>댓글 보상 일일 토큰 상한</summary>
  323. public int CommentDailyPoint { get; set; } = 0;
  324. /// <summary>추천(누른 쪽) 보상 일일 횟수 상한</summary>
  325. public int LikeGivenDailyCount { get; set; } = 0;
  326. /// <summary>추천(누른 쪽) 보상 일일 경험치 상한</summary>
  327. public int LikeGivenDailyExp { get; set; } = 0;
  328. /// <summary>추천(받은 쪽) 보상 일일 횟수 상한</summary>
  329. public int LikeReceivedDailyCount { get; set; } = 0;
  330. /// <summary>추천(받은 쪽) 보상 일일 토큰 상한</summary>
  331. public int LikeReceivedDailyPoint { get; set; } = 0;
  332. /// <summary>채팅 보상 일일 횟수 상한</summary>
  333. public int ChatDailyCount { get; set; } = 0;
  334. /// <summary>채팅 보상 일일 경험치 상한</summary>
  335. public int ChatDailyExp { get; set; } = 0;
  336. // ---- 응원(Cheer) 설정 (D3 M4) ----
  337. /// <summary>응원 플랫폼 수수료율(%) — fee = floor(amount × CheerFeePercent/100). 기본 20 (Twitch Bits 참고)</summary>
  338. public int CheerFeePercent { get; set; } = 20;
  339. /// <summary>1회 응원 최소 금액 (미만이면 거부). 기본 100</summary>
  340. public int CheerMinAmount { get; set; } = 100;
  341. /// <summary>한 회원이 하루에 보낼 수 있는 응원 총액 상한 (0 = 무제한). 자전 응원 어뷰징 방지</summary>
  342. public int CheerDailyMax { get; set; } = 0;
  343. }
  344. // ==================================================
  345. // 모의투자 설정 (Paper) — Admin /Config, d4 §④
  346. // ==================================================
  347. public sealed class PaperConfig
  348. {
  349. /// <summary>모의투자 노출/주문 토글</summary>
  350. public bool Enabled { get; set; } = true;
  351. /// <summary>매매 수수료 Bp (기본 15 = 0.15%; 토큰 sink)</summary>
  352. public int FeeRateBp { get; set; } = 15;
  353. /// <summary>매도 거래세 Bp (기본 18; 토큰 sink)</summary>
  354. public int TaxRateBp { get; set; } = 18;
  355. /// <summary>최소 입금 토큰</summary>
  356. public int MinDeposit { get; set; } = 10000;
  357. /// <summary>계좌 최대 보유 토큰 (0 = 무제한)</summary>
  358. public int MaxHolding { get; set; } = 0;
  359. /// <summary>출금 시 수익분 소각 Bp (0 = 꺼둠, 인플레 밸브)</summary>
  360. public int WithdrawProfitBurnBp { get; set; } = 0;
  361. /// <summary>1주문 상한 Bp (기본 3000 = Equity 30%)</summary>
  362. public int OrderMaxPctBp { get; set; } = 3000;
  363. /// <summary>리더보드 등재 최소 체결 수</summary>
  364. public int MinFillsForRank { get; set; } = 3;
  365. }
  366. #endregion