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.

144 lines
5.3 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.

// ============================================================================
// 【文件说明】HwWeb.cs - 官网页面实体类
// ============================================================================
// 这个实体类对应数据库表 hw_web用于存储官网页面配置信息。
//
// 【数据库表结构】
// hw_web 表字段:
// - web_id: 主键ID自增
// - web_json: JSON格式的页面配置
// - web_json_string: JSON字符串格式
// - web_code: 页面编码(业务主键)
// - is_delete: 逻辑删除标记
// - web_json_english: 英文版JSON配置
// - create_by, create_time, update_by, update_time, remark: 继承自基类
// ============================================================================
namespace Admin.NET.Plugin.HwPortal;
/// <summary>
/// 官网页面实体类。
/// <para>
/// 【C# 语法知识点 - 类继承】
/// public class HwWeb : HwPortalBaseEntity
/// HwWeb 继承自 HwPortalBaseEntity自动获得 CreateBy、CreateTime 等公共字段。
///
/// 对比 Java
/// Java 的继承语法完全一样:
/// public class HwWeb extends HwPortalBaseEntity { ... }
/// </para>
/// <para>
/// 【ORM 映射说明】
/// [SugarTable("hw_web")] 告诉 SqlSugar ORM这个类映射到数据库的 hw_web 表。
///
/// 对比 Java MyBatis/JPA
/// JPA: @Table(name = "hw_web")
/// MyBatis: 在 XML 中配置 &lt;table tableName="hw_web"&gt;
/// </para>
/// </summary>
[SugarTable("hw_web")]
// 【C# 语法知识点 - 特性Attribute
// [SugarTable("hw_web")] 是 SqlSugar ORM 的特性,用于指定数据库表名。
// 如果不写SqlSugar 会默认用类名HwWeb作为表名。
// 但数据库表名通常是 snake_casehw_web所以需要显式指定。
public class HwWeb : HwPortalBaseEntity
{
/// <summary>
/// 页面主键ID。
/// <para>
/// 【C# 语法知识点 - 可空值类型 long?】
/// long? 表示"可空的长整型",等价于 Nullable&lt;long&gt;。
///
/// 为什么用可空类型?
/// 1. 新增记录时ID 还没生成(数据库自增),此时是 null
/// 2. 查询时,某些关联查询可能返回 null
/// 3. 和前端交互时,空值更明确
///
/// 对比 Java
/// Java 的 Long 本身就是引用类型,可以为 null
/// private Long webId;
///
/// C# 的 long 是值类型,不能为 null所以用 long? 来支持 null。
/// </para>
/// </summary>
[SugarColumn(ColumnName = "web_id", IsPrimaryKey = true, IsIdentity = true)]
// 【SugarColumn 特性参数说明】
// ColumnName = "web_id":映射到数据库列 web_id
// IsPrimaryKey = true标记为主键
// IsIdentity = true标记为自增列数据库自动生成值
//
// 对比 Java JPA
// @Id
// @GeneratedValue(strategy = GenerationType.IDENTITY)
// @Column(name = "web_id")
// private Long webId;
public long? WebId { get; set; }
/// <summary>
/// JSON格式的页面配置。
/// <para>
/// 【业务说明】
/// 这个字段存储页面配置的 JSON 数据,前端解析后渲染页面。
/// 例如:导航菜单、轮播图、内容区块等配置。
/// </para>
/// </summary>
[SugarColumn(ColumnName = "web_json")]
public string WebJson { get; set; }
/// <summary>
/// JSON字符串格式。
/// </summary>
[SugarColumn(ColumnName = "web_json_string")]
public string WebJsonString { get; set; }
/// <summary>
/// 页面编码(业务主键)。
/// <para>
/// 【业务主键 vs 技术主键】
/// - 技术主键web_id数据库自增无业务含义
/// - 业务主键web_code有业务含义如 "home_page"、"about_us"
///
/// 为什么需要两个主键?
/// 1. 技术主键保证数据库性能(自增整数比字符串索引快)
/// 2. 业务主键方便开发和运维(看到 web_code 就知道是哪个页面)
/// 3. 业务主键可以跨环境保持一致(开发/测试/生产)
/// </para>
/// </summary>
[SugarColumn(ColumnName = "web_code")]
public long? WebCode { get; set; }
/// <summary>
/// 逻辑删除标记。
/// <para>
/// 【逻辑删除 vs 物理删除】
/// - 物理删除DELETE FROM table WHERE id = ?,数据真的没了
/// - 逻辑删除UPDATE table SET is_delete = '1' WHERE id = ?,数据还在,只是标记为删除
///
/// 为什么用逻辑删除?
/// 1. 数据可恢复:误删后可以恢复
/// 2. 审计需求:保留删除记录
/// 3. 关联数据:其他表可能引用这条数据
///
/// 这里的值:
/// - "0":正常
/// - "1":已删除
///
/// 对比 Java 若依:
/// 若依框架也使用逻辑删除,字段通常是 del_flag。
/// </para>
/// </summary>
[SugarColumn(ColumnName = "is_delete")]
public string IsDelete { get; set; }
/// <summary>
/// 英文版JSON配置。
/// <para>
/// 【国际化支持】
/// 这个字段存储英文版页面配置,用于多语言网站。
/// 用户切换语言时,前端读取不同的 JSON 配置。
/// </para>
/// </summary>
[SugarColumn(ColumnName = "web_json_english")]
public string WebJsonEnglish { get; set; }
}