From a8b475881959d4a88d821951a615f03e7d0d1725 Mon Sep 17 00:00:00 2001
From: sunpengfei <i@angelzzz.com>
Date: 星期四, 07 八月 2025 13:28:30 +0800
Subject: [PATCH] feat:字典优化

---
 FlexJobApi.Core/Entities/Users/Enterprise.cs |   41 +++++++++++++++++++++++++++++++++--------
 1 files changed, 33 insertions(+), 8 deletions(-)

diff --git a/FlexJobApi.Core/Entities/Users/Enterprise.cs b/FlexJobApi.Core/Entities/Users/Enterprise.cs
index 035e637..65ac6ef 100644
--- a/FlexJobApi.Core/Entities/Users/Enterprise.cs
+++ b/FlexJobApi.Core/Entities/Users/Enterprise.cs
@@ -1,4 +1,7 @@
-锘縰sing System;
+锘縰sing Furion.DatabaseAccessor;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Metadata.Builders;
+using System;
 using System.Collections.Generic;
 using System.ComponentModel.DataAnnotations;
 using System.Linq;
@@ -10,7 +13,7 @@
     /// <summary>
     /// 浼佷笟
     /// </summary>
-    public class Enterprise : CommonEntity
+    public class Enterprise : CommonEntity, IEntityTypeBuilder<Enterprise>
     {
         public Enterprise()
         {
@@ -29,9 +32,9 @@
         public EnterpriseAuth EnterpriseAuth { get; set; }
 
         /// <summary>
-        /// 鎵�鍦ㄧ渷浠絀d
+        /// 鎵�鍦ㄧ渷浠界紪鍙�
         /// </summary>
-        public Guid? ProvinceId { get; set; }
+        public string ProvinceCode { get; set; }
 
         /// <summary>
         /// 鎵�鍦ㄧ渷浠�
@@ -39,9 +42,9 @@
         public DictionaryData Province { get; set; }
 
         /// <summary>
-        /// 鎵�鍦ㄥ煄甯侷d
+        /// 鎵�鍦ㄥ煄甯傜紪鍙�
         /// </summary>
-        public Guid? CityId { get; set; }
+        public string CityCode { get; set; }
 
         /// <summary>
         /// 鎵�鍦ㄥ煄甯�
@@ -49,9 +52,9 @@
         public DictionaryData City { get; set; }
 
         /// <summary>
-        /// 鎵�灞炶涓欼d
+        /// 鎵�灞炶涓氱紪鍙�
         /// </summary>
-        public Guid? IndustryTypeId { get; set; }
+        public string IndustryTypeCode { get; set; }
 
         /// <summary>
         /// 鎵�灞炶涓�
@@ -145,5 +148,27 @@
         /// 鐢ㄦ埛淇℃伅
         /// </summary>
         public List<UserInfo> UserInfos { get; set; }
+
+        public void Configure(EntityTypeBuilder<Enterprise> entityBuilder, DbContext dbContext, Type dbContextLocator)
+        {
+            entityBuilder
+                .HasOne(it => it.Province)
+                .WithMany()
+                .HasForeignKey(it => it.ProvinceCode)
+                .HasPrincipalKey(it => it.Code)
+                .OnDelete(DeleteBehavior.Restrict);
+            entityBuilder
+                .HasOne(it => it.City)
+                .WithMany()
+                .HasForeignKey(it => it.CityCode)
+                .HasPrincipalKey(it => it.Code)
+                .OnDelete(DeleteBehavior.Restrict);
+            entityBuilder
+                .HasOne(it => it.IndustryType)
+                .WithMany()
+                .HasForeignKey(it => it.IndustryTypeCode)
+                .HasPrincipalKey(it => it.Code)
+                .OnDelete(DeleteBehavior.Restrict);
+        }
     }
 }

--
Gitblit v1.9.1