Developer.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. using System.ComponentModel.DataAnnotations;
  2. using System.ComponentModel.DataAnnotations.Schema;
  3. using Domain.Entities.Developers.ValueObject;
  4. using Domain.Entities.Members;
  5. namespace Domain.Entities.Developers;
  6. /// <summary>
  7. /// 개발자 포털 가입 법인 정보 (Member 1:1).
  8. /// API 키 사용 회사의 회사정보 + 본인인증/승인 상태 메타.
  9. /// </summary>
  10. public class Developer
  11. {
  12. [ForeignKey(nameof(MemberID))]
  13. public virtual Member? Member { get; private set; }
  14. [Key]
  15. public int ID { get; private set; }
  16. public int MemberID { get; private set; }
  17. public string CompanyName { get; private set; } = default!;
  18. public string BusinessNumber { get; private set; } = default!;
  19. public string CeoName { get; private set; } = default!;
  20. public string ContactName { get; private set; } = default!;
  21. public string ContactPhone { get; private set; } = default!;
  22. public KycStatus KycStatus { get; private set; } = KycStatus.None;
  23. public string? KycCi { get; private set; }
  24. public string? KycDi { get; private set; }
  25. public DateTime? KycVerifiedAt { get; private set; }
  26. public DeveloperApprovalStatus ApprovalStatus { get; private set; } = DeveloperApprovalStatus.Pending;
  27. public string? ApprovalReason { get; private set; }
  28. public DateTime? ApprovedAt { get; private set; }
  29. public string? ApprovedByAdminID { get; private set; }
  30. public DateTime CreatedAt { get; private set; } = DateTime.UtcNow;
  31. public DateTime? UpdatedAt { get; private set; }
  32. private Developer() { }
  33. public static Developer Create(
  34. int memberID,
  35. string companyName,
  36. string businessNumber,
  37. string ceoName,
  38. string contactName,
  39. string contactPhone
  40. ) {
  41. if (string.IsNullOrWhiteSpace(companyName))
  42. {
  43. throw new ArgumentException("Company name is required.", nameof(companyName));
  44. }
  45. if (string.IsNullOrWhiteSpace(businessNumber))
  46. {
  47. throw new ArgumentException("Business number is required.", nameof(businessNumber));
  48. }
  49. if (string.IsNullOrWhiteSpace(ceoName))
  50. {
  51. throw new ArgumentException("CEO name is required.", nameof(ceoName));
  52. }
  53. if (string.IsNullOrWhiteSpace(contactName))
  54. {
  55. throw new ArgumentException("Contact name is required.", nameof(contactName));
  56. }
  57. if (string.IsNullOrWhiteSpace(contactPhone))
  58. {
  59. throw new ArgumentException("Contact phone is required.", nameof(contactPhone));
  60. }
  61. return new Developer
  62. {
  63. MemberID = memberID,
  64. CompanyName = companyName,
  65. BusinessNumber = businessNumber,
  66. CeoName = ceoName,
  67. ContactName = contactName,
  68. ContactPhone = contactPhone
  69. };
  70. }
  71. public void UpdateCompanyInfo(
  72. string companyName,
  73. string businessNumber,
  74. string ceoName,
  75. string contactName,
  76. string contactPhone
  77. ) {
  78. CompanyName = companyName;
  79. BusinessNumber = businessNumber;
  80. CeoName = ceoName;
  81. ContactName = contactName;
  82. ContactPhone = contactPhone;
  83. UpdatedAt = DateTime.UtcNow;
  84. }
  85. public void MarkKycPending()
  86. {
  87. KycStatus = KycStatus.Pending;
  88. UpdatedAt = DateTime.UtcNow;
  89. }
  90. public void MarkKycVerified(string? ci, string? di)
  91. {
  92. KycStatus = KycStatus.Verified;
  93. KycCi = ci;
  94. KycDi = di;
  95. KycVerifiedAt = DateTime.UtcNow;
  96. UpdatedAt = DateTime.UtcNow;
  97. }
  98. public void MarkKycRejected()
  99. {
  100. KycStatus = KycStatus.Rejected;
  101. UpdatedAt = DateTime.UtcNow;
  102. }
  103. public void Approve(string adminID)
  104. {
  105. ApprovalStatus = DeveloperApprovalStatus.Approved;
  106. ApprovalReason = null;
  107. ApprovedAt = DateTime.UtcNow;
  108. ApprovedByAdminID = adminID;
  109. UpdatedAt = DateTime.UtcNow;
  110. }
  111. public void Reject(string adminID, string? reason)
  112. {
  113. ApprovalStatus = DeveloperApprovalStatus.Rejected;
  114. ApprovalReason = reason;
  115. ApprovedAt = DateTime.UtcNow;
  116. ApprovedByAdminID = adminID;
  117. UpdatedAt = DateTime.UtcNow;
  118. }
  119. public void Suspend(string adminID, string? reason)
  120. {
  121. ApprovalStatus = DeveloperApprovalStatus.Suspended;
  122. ApprovalReason = reason;
  123. ApprovedByAdminID = adminID;
  124. UpdatedAt = DateTime.UtcNow;
  125. }
  126. }