using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations.Schema; using Volo.Abp.Domain.Entities.Auditing; namespace KonSoft.Admin.Entities; public class Product( Guid id, string name, string code, decimal price, string description, string type, Guid? parentId, string status = "在售", int order = 0) : FullAuditedAggregateRoot(id) { /// /// 分类名称 /// public string Name { get; private set; } = name; /// /// 商品编码 /// public string Code { get; private set; } = code; /// /// 商品价格 /// public decimal Price { get; private set; } = price; /// /// 商品描述 /// public string Description { get; private set; } = description; /// /// 分类类型(大类或小类) /// public string Type { get; private set; } = type; /// /// 父分类ID /// public Guid? ParentId { get; private set; } = parentId; /// /// 商品状态(在售/下架等) /// public string Status { get; private set; } = status; /// /// 排序字段 /// public int Order { get; private set; } = order; [NotMapped] public List Children { get; set; } = new(); /// /// 修改商品信息 /// public void Update(string name, string code, decimal price, string description, int order) { Name = name; Code = code; Price = price; Description = description; Order = order; } /// /// 修改商品分类 /// public void ChangeCategory(string type, Guid? parentId) { Type = type; ParentId = parentId; } /// /// 上架商品 /// public void PutOnSale() { Status = "在售"; } /// /// 下架商品 /// public void TakeOffSale() { Status = "下架"; } /// /// 修改价格 /// public void ChangePrice(decimal newPrice) { Price = newPrice; } }