You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

98 lines
4.0 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

// ============================================================================
// 【文件说明】HwPortalBaseEntity.cs - 门户模块实体基类
// ============================================================================
// 这个文件定义了所有门户实体的"公共字段基类"。
// 在 Java Spring Boot 项目中,你可能会用 @MappedSuperclass 注解一个 BaseEntity
// 然后让其他实体类继承它。这里的概念完全一样!
// ============================================================================
namespace Admin.NET.Plugin.HwPortal;
/// <summary>
/// 门户模块实体基类。
/// <para>
/// 【C# 语法知识点 - abstract 关键字】
/// abstract 表示"抽象类",和 Java 的 abstract class 含义完全一致:
/// - 不能直接 new 实例化,只能被继承
/// - 可以包含抽象方法(没有实现体)和具体方法(有实现体)
/// - 子类必须实现所有抽象成员
/// </para>
/// <para>
/// 【与 Java Spring Boot 的对比】
/// Java: @MappedSuperclass public class BaseEntity { ... }
/// C#: public abstract class HwPortalBaseEntity { ... }
/// 两者目的相同:把公共字段抽取到父类,避免每个实体都重复定义 create_by、create_time 等字段。
/// </para>
/// </summary>
public abstract class HwPortalBaseEntity
{
/// <summary>
/// 创建人。
/// <para>
/// 【C# 语法知识点 - 属性Property
/// public string CreateBy { get; set; } 是 C# 的"自动属性"语法。
/// 编译器会自动生成一个私有的后备字段backing field和 get/set 方法。
///
/// 对比 Java
/// Java 需要手写:
/// private String createBy;
/// public String getCreateBy() { return createBy; }
/// public void setCreateBy(String createBy) { this.createBy = createBy; }
///
/// C# 只需要一行:
/// public string CreateBy { get; set; }
///
/// 这就是 C# 的"语法糖"——让代码更简洁,编译器帮你生成繁琐的部分。
/// </para>
/// </summary>
[SugarColumn(ColumnName = "create_by")]
// 【C# 语法知识点 - 特性Attribute
// [SugarColumn(...)] 是 SqlSugar ORM 的特性,用于映射数据库列名。
// 特性相当于 Java 的注解Annotation写法是方括号 [] 而不是 @。
//
// Java 写法:@Column(name = "create_by")
// C# 写法:[SugarColumn(ColumnName = "create_by")]
//
// 这里为什么要写 ColumnName = "create_by"
// 因为 C# 的命名规范是 PascalCase首字母大写但数据库列名是 snake_case小写+下划线)。
// 如果不指定映射SqlSugar 会默认把 CreateBy 映射成 CreateBy 列(大写开头),
// 这在 MySQLLinux 环境,区分大小写)下会报错"列不存在"。
public string CreateBy { get; set; }
/// <summary>
/// 创建时间。
/// <para>
/// 【C# 语法知识点 - 可空值类型 DateTime?】
/// DateTime 是值类型struct不能为 null。
/// 但数据库里的 create_time 可能是 NULL比如老数据没填
///
/// DateTime? 是"可空 DateTime",等价于 Nullable&lt;DateTime&gt;。
/// 它可以是具体的日期时间,也可以是 null。
///
/// 对比 Java
/// Java 的 Date 本身就是引用类型,可以直接 null。
/// C# 把日期作为值类型是为了性能,但这就需要 Nullable&lt;T&gt; 来支持 null。
/// </para>
/// </summary>
[SugarColumn(ColumnName = "create_time")]
public DateTime? CreateTime { get; set; }
/// <summary>
/// 更新人。
/// </summary>
[SugarColumn(ColumnName = "update_by")]
public string UpdateBy { get; set; }
/// <summary>
/// 更新时间。
/// </summary>
[SugarColumn(ColumnName = "update_time")]
public DateTime? UpdateTime { get; set; }
/// <summary>
/// 备注信息。
/// </summary>
[SugarColumn(ColumnName = "remark")]
public string Remark { get; set; }
}