sunpengfei
2025-08-07 a8b475881959d4a88d821951a615f03e7d0d1725
FlexJobApi.Core/Entities/Users/UserInfo.cs
@@ -1,5 +1,6 @@
using Furion.DatabaseAccessor;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
@@ -12,7 +13,7 @@
    /// <summary>
    /// 用户信息
    /// </summary>
    public class UserInfo : CommonEntity, IEntitySeedData<UserInfo>
    public class UserInfo : CommonEntity, IEntitySeedData<UserInfo>, IEntityTypeBuilder<UserInfo>
    {
        public UserInfo()
        {
@@ -74,9 +75,9 @@
        public List<UserInfoDepartment> UserInfoDepartments { get; set; }
        /// <summary>
        /// 身份Id
        /// 身份编号
        /// </summary>
        public Guid? PersonalIdentityId { get; set; }
        public string PersonalIdentityCode { get; set; }
        /// <summary>
        /// 身份
@@ -84,9 +85,9 @@
        public DictionaryData PersonalIdentity { get; set; }
        /// <summary>
        /// 学历Id
        /// 学历编号
        /// </summary>
        public Guid? EducationalBackgroundId { get; set; }
        public string EducationalBackgroundCode { get; set; }
        /// <summary>
        /// 学历
@@ -94,9 +95,9 @@
        public DictionaryData EducationalBackground { get; set; }
        /// <summary>
        /// 常驻省份Id
        /// 常驻省份编号
        /// </summary>
        public Guid? ProvinceId { get; set; }
        public string ProvinceCode { get; set; }
        /// <summary>
        /// 常驻省份
@@ -104,9 +105,9 @@
        public DictionaryData Province { get; set; }
        /// <summary>
        /// 常驻城市Id
        /// 常驻城市编号
        /// </summary>
        public Guid? CityId { get; set; }
        public string CityCode { get; set; }
        /// <summary>
        /// 常驻城市
@@ -163,6 +164,34 @@
        /// </summary>
        public EnumUserInfoStatus Status { get; set; }
        public void Configure(EntityTypeBuilder<UserInfo> entityBuilder, DbContext dbContext, Type dbContextLocator)
        {
            entityBuilder
                .HasOne(it => it.PersonalIdentity)
                .WithMany()
                .HasForeignKey(it => it.PersonalIdentityCode)
                .HasPrincipalKey(it => it.Code)
                .OnDelete(DeleteBehavior.Restrict);
            entityBuilder
                .HasOne(it => it.EducationalBackground)
                .WithMany()
                .HasForeignKey(it => it.EducationalBackgroundCode)
                .HasPrincipalKey(it => it.Code)
                .OnDelete(DeleteBehavior.Restrict);
            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);
        }
        public IEnumerable<UserInfo> HasData(DbContext dbContext, Type dbContextLocator)
        {
            return new List<UserInfo>