diff --git a/Atomx.Admin/Atomx.Admin.Client/Pages/Settings/CurrencyEdit.razor b/Atomx.Admin/Atomx.Admin.Client/Pages/Settings/CurrencyEdit.razor index ca0f11c..ffeef2f 100644 --- a/Atomx.Admin/Atomx.Admin.Client/Pages/Settings/CurrencyEdit.razor +++ b/Atomx.Admin/Atomx.Admin.Client/Pages/Settings/CurrencyEdit.razor @@ -10,8 +10,8 @@ 管理后台 - 系统功能 - 货币管理 + 系统配置 + 货币管理 diff --git a/Atomx.Admin/Atomx.Admin.Client/Pages/Settings/CurrencyList.razor b/Atomx.Admin/Atomx.Admin.Client/Pages/Settings/CurrencyList.razor index 5c7cb95..2bd8ffc 100644 --- a/Atomx.Admin/Atomx.Admin.Client/Pages/Settings/CurrencyList.razor +++ b/Atomx.Admin/Atomx.Admin.Client/Pages/Settings/CurrencyList.razor @@ -70,7 +70,7 @@ - + diff --git a/Atomx.Admin/Atomx.Admin/Controllers/CurrencyController.cs b/Atomx.Admin/Atomx.Admin/Controllers/CurrencyController.cs index b9e8130..bbed55c 100644 --- a/Atomx.Admin/Atomx.Admin/Controllers/CurrencyController.cs +++ b/Atomx.Admin/Atomx.Admin/Controllers/CurrencyController.cs @@ -152,7 +152,7 @@ namespace Atomx.Admin.Controllers // } //} - result.Data = list; + result = result.IsSuccess(list); return new JsonResult(result); } @@ -192,17 +192,22 @@ namespace Atomx.Admin.Controllers var validation = _validator.Validate(model); if (!validation.IsValid) { - result.Message = ModelState.Values.First().Errors[0].ErrorMessage; - result.Success = false; + result = result.IsFail(ModelState.Values.First().Errors[0].ErrorMessage); return new JsonResult(result); } + var data = _dbContext.Currencies.SingleOrDefault(p => p.Id != model.Id && p.CurrencyCode == model.CurrencyCode); + if (data != null) + { + result = result.IsFail("该货币代码数据已经存在,请更换!"); + return new JsonResult(result); + } + if (model.Id.HasValue && model.Id > 0) { - var data = _dbContext.Currencies.SingleOrDefault(p => p.Id == model.Id); + data = _dbContext.Currencies.SingleOrDefault(p => p.Id == model.Id); if (data == null) { - result.Message = "数据不存在,请更换!"; - result.Success = false; + result = result.IsFail("数据不存在,请更换!"); return new JsonResult(result); } @@ -213,27 +218,29 @@ namespace Atomx.Admin.Controllers } else { - var data = new Currency() - { - Name = model.Name, - CurrencyCode = model.CurrencyCode, - DisplayLocale = model.DisplayLocale, - CustomFormatting = model.CustomFormatting, - Rate = (decimal)model.Rate, - DisplayOrder = model.DisplayOrder, - EnableDisplay = model.Enabled, - Symbolic = "", - Enabled = model.Enabled, - Title = model.Name, - EnablePay = true, - CreateTime = DateTime.UtcNow - }; + //var data = new Currency() + //{ + // Name = model.Name, + // CurrencyCode = model.CurrencyCode, + // DisplayLocale = model.DisplayLocale, + // CustomFormatting = model.CustomFormatting, + // Rate = (decimal)model.Rate, + // DisplayOrder = model.DisplayOrder, + // EnableDisplay = model.Enabled, + // Symbolic = "", + // Enabled = model.Enabled, + // Title = model.Name, + // EnablePay = true, + // CreateTime = DateTime.UtcNow + //}; + data = model.Adapt(); + data.CreateTime = DateTime.UtcNow; _dbContext.Currencies.Add(data); _dbContext.SaveChanges(); } - result.Data = true; + result = result.IsSuccess(true); //todo 更新缓存 diff --git a/Atomx.Common/Entities/AppVersion.cs b/Atomx.Common/Entities/AppVersion.cs index 032ef59..3d864d7 100644 --- a/Atomx.Common/Entities/AppVersion.cs +++ b/Atomx.Common/Entities/AppVersion.cs @@ -19,7 +19,7 @@ namespace Atomx.Common.Entities /// /// 归属站点应用ID /// - public long SiteId { get; set; } + public int SiteId { get; set; } /// /// 运行平台 diff --git a/Atomx.Common/Entities/Category.cs b/Atomx.Common/Entities/Category.cs index 0224bfd..2dd07e7 100644 --- a/Atomx.Common/Entities/Category.cs +++ b/Atomx.Common/Entities/Category.cs @@ -19,7 +19,7 @@ namespace Atomx.Common.Entities /// /// 归属站点应用ID /// - public long SiteId { get; set; } + public int SiteId { get; set; } /// /// 分类类型,1内容,2产品,3社区 diff --git a/Atomx.Common/Entities/Channel.cs b/Atomx.Common/Entities/Channel.cs index d8c6637..49459b1 100644 --- a/Atomx.Common/Entities/Channel.cs +++ b/Atomx.Common/Entities/Channel.cs @@ -16,7 +16,7 @@ namespace Atomx.Common.Entities /// /// 站点ID /// - public long SiteId { get; set; } + public int SiteId { get; set; } /// /// 通道类型,例如通知、支付、登录等 diff --git a/Atomx.Common/Entities/Comment.cs b/Atomx.Common/Entities/Comment.cs index ca193ca..b6273bb 100644 --- a/Atomx.Common/Entities/Comment.cs +++ b/Atomx.Common/Entities/Comment.cs @@ -19,7 +19,7 @@ namespace Atomx.Common.Entities /// /// 归属站点应用ID /// - public long SiteId { get; set; } + public int SiteId { get; set; } /// /// 发布评论用户ID diff --git a/Atomx.Common/Entities/Currency.cs b/Atomx.Common/Entities/Currency.cs index 3e9d707..00b2779 100644 --- a/Atomx.Common/Entities/Currency.cs +++ b/Atomx.Common/Entities/Currency.cs @@ -19,7 +19,7 @@ namespace Atomx.Common.Entities /// /// 站点ID /// - public long SiteId { get; set; } + public int SiteId { get; set; } /// /// 货币名称,系统 diff --git a/Atomx.Common/Entities/MessageTemplate.cs b/Atomx.Common/Entities/MessageTemplate.cs index 4589b2e..7e8783f 100644 --- a/Atomx.Common/Entities/MessageTemplate.cs +++ b/Atomx.Common/Entities/MessageTemplate.cs @@ -19,7 +19,7 @@ namespace Atomx.Common.Entities /// /// 站点ID /// - public long SiteId { get; set; } + public int SiteId { get; set; } /// /// 语言编码 diff --git a/Atomx.Common/Entities/Setting.cs b/Atomx.Common/Entities/Setting.cs index 419a6fd..efd2e41 100644 --- a/Atomx.Common/Entities/Setting.cs +++ b/Atomx.Common/Entities/Setting.cs @@ -19,7 +19,7 @@ namespace Atomx.Common.Entities /// /// 归属的网站应用Id /// - public long SiteId { get; set; } + public int SiteId { get; set; } /// /// 配置类型,见 SettingType 枚举 diff --git a/Atomx.Common/Entities/SiteApp.cs b/Atomx.Common/Entities/SiteApp.cs index e970615..4b1082a 100644 --- a/Atomx.Common/Entities/SiteApp.cs +++ b/Atomx.Common/Entities/SiteApp.cs @@ -12,9 +12,9 @@ namespace Atomx.Common.Entities /// /// 数据ID /// - [DatabaseGenerated(DatabaseGeneratedOption.None)] + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] [Key] - public long Id { get; set; } + public int Id { get; set; } /// /// 网站应用类型 diff --git a/Atomx.Common/Entities/UploadFile.cs b/Atomx.Common/Entities/UploadFile.cs index e0f0acc..6e44199 100644 --- a/Atomx.Common/Entities/UploadFile.cs +++ b/Atomx.Common/Entities/UploadFile.cs @@ -16,7 +16,7 @@ namespace Atomx.Common.Entities /// /// 归属站点应用ID /// - public long SiteId { get; set; } + public int SiteId { get; set; } /// /// 文件类型 diff --git a/Atomx.Data/Migrations/20251216011300_0.1.Designer.cs b/Atomx.Data/Migrations/20251223083953_0.1.Designer.cs similarity index 95% rename from Atomx.Data/Migrations/20251216011300_0.1.Designer.cs rename to Atomx.Data/Migrations/20251223083953_0.1.Designer.cs index 5bb4b6b..ffa1a5e 100644 --- a/Atomx.Data/Migrations/20251216011300_0.1.Designer.cs +++ b/Atomx.Data/Migrations/20251223083953_0.1.Designer.cs @@ -12,7 +12,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; namespace Atomx.Data.Migrations { [DbContext(typeof(DataContext))] - [Migration("20251216011300_0.1")] + [Migration("20251223083953_0.1")] partial class _01 { /// @@ -193,8 +193,8 @@ namespace Atomx.Data.Migrations b.Property("Platform") .HasColumnType("integer"); - b.Property("SiteId") - .HasColumnType("bigint"); + b.Property("SiteId") + .HasColumnType("integer"); b.Property("Status") .HasColumnType("integer"); @@ -329,8 +329,8 @@ namespace Atomx.Data.Migrations .IsRequired() .HasColumnType("varchar(100)"); - b.Property("SiteId") - .HasColumnType("bigint"); + b.Property("SiteId") + .HasColumnType("integer"); b.Property("Slug") .IsRequired() @@ -373,8 +373,8 @@ namespace Atomx.Data.Migrations b.Property("Network") .HasColumnType("integer"); - b.Property("SiteId") - .HasColumnType("bigint"); + b.Property("SiteId") + .HasColumnType("integer"); b.Property("Status") .HasColumnType("integer"); @@ -397,8 +397,11 @@ namespace Atomx.Data.Migrations modelBuilder.Entity("Atomx.Common.Entities.Currency", b => { b.Property("Id") + .ValueGeneratedOnAdd() .HasColumnType("integer"); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + b.Property("CreateTime") .HasColumnType("timestamptz"); @@ -433,8 +436,8 @@ namespace Atomx.Data.Migrations b.Property("Rate") .HasColumnType("decimal(16, 4)"); - b.Property("SiteId") - .HasColumnType("bigint"); + b.Property("SiteId") + .HasColumnType("integer"); b.Property("Symbolic") .IsRequired() @@ -681,8 +684,8 @@ namespace Atomx.Data.Migrations .IsRequired() .HasColumnType("varchar(256)"); - b.Property("SiteId") - .HasColumnType("bigint"); + b.Property("SiteId") + .HasColumnType("integer"); b.Property("Title") .IsRequired() @@ -1226,8 +1229,8 @@ namespace Atomx.Data.Migrations .IsRequired() .HasColumnType("varchar(64)"); - b.Property("SiteId") - .HasColumnType("bigint"); + b.Property("SiteId") + .HasColumnType("integer"); b.Property("Type") .HasColumnType("integer"); @@ -1239,8 +1242,11 @@ namespace Atomx.Data.Migrations modelBuilder.Entity("Atomx.Common.Entities.SiteApp", b => { - b.Property("Id") - .HasColumnType("bigint"); + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("CreateTime") .HasColumnType("timestamptz"); @@ -1333,6 +1339,40 @@ namespace Atomx.Data.Migrations b.ToTable("SpecificationAttributeOptions"); }); + modelBuilder.Entity("Atomx.Common.Entities.Tag", b => + { + b.Property("Id") + .HasColumnType("bigint"); + + b.Property("Color") + .IsRequired() + .HasColumnType("varchar(12)"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("CreateTime") + .HasColumnType("timestamptz"); + + b.Property("Enabled") + .HasColumnType("integer"); + + b.Property("Name") + .IsRequired() + .HasColumnType("varchar(64)"); + + b.Property("Slug") + .IsRequired() + .HasColumnType("varchar(128)"); + + b.Property("UpdateTime") + .HasColumnType("timestamptz"); + + b.HasKey("Id"); + + b.ToTable("Tags"); + }); + modelBuilder.Entity("Atomx.Common.Entities.UploadFile", b => { b.Property("Id") @@ -1368,8 +1408,8 @@ namespace Atomx.Data.Migrations .IsRequired() .HasColumnType("varchar(128)"); - b.Property("SiteId") - .HasColumnType("bigint"); + b.Property("SiteId") + .HasColumnType("integer"); b.Property("Size") .HasColumnType("integer"); diff --git a/Atomx.Data/Migrations/20251216011300_0.1.cs b/Atomx.Data/Migrations/20251223083953_0.1.cs similarity index 96% rename from Atomx.Data/Migrations/20251216011300_0.1.cs rename to Atomx.Data/Migrations/20251223083953_0.1.cs index 0273e9d..5f860ac 100644 --- a/Atomx.Data/Migrations/20251216011300_0.1.cs +++ b/Atomx.Data/Migrations/20251223083953_0.1.cs @@ -76,7 +76,7 @@ namespace Atomx.Data.Migrations columns: table => new { Id = table.Column(type: "bigint", nullable: false), - SiteId = table.Column(type: "bigint", nullable: false), + SiteId = table.Column(type: "integer", nullable: false), Platform = table.Column(type: "integer", nullable: false), AppName = table.Column(type: "varchar(64)", nullable: false), Title = table.Column(type: "varchar(64)", nullable: false), @@ -121,7 +121,7 @@ namespace Atomx.Data.Migrations columns: table => new { Id = table.Column(type: "bigint", nullable: false), - SiteId = table.Column(type: "bigint", nullable: false), + SiteId = table.Column(type: "integer", nullable: false), Type = table.Column(type: "integer", nullable: false), ParentId = table.Column(type: "bigint", nullable: false), Name = table.Column(type: "varchar(25)", nullable: false), @@ -150,7 +150,7 @@ namespace Atomx.Data.Migrations columns: table => new { Id = table.Column(type: "integer", nullable: false), - SiteId = table.Column(type: "bigint", nullable: false), + SiteId = table.Column(type: "integer", nullable: false), Type = table.Column(type: "integer", nullable: false), Network = table.Column(type: "integer", nullable: false), Name = table.Column(type: "varchar(20)", nullable: false), @@ -171,8 +171,9 @@ namespace Atomx.Data.Migrations name: "Currencies", columns: table => new { - Id = table.Column(type: "integer", nullable: false), - SiteId = table.Column(type: "bigint", nullable: false), + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + SiteId = table.Column(type: "integer", nullable: false), Name = table.Column(type: "varchar(50)", nullable: false), Title = table.Column(type: "varchar(50)", nullable: false), CurrencyCode = table.Column(type: "varchar(10)", nullable: false), @@ -296,7 +297,7 @@ namespace Atomx.Data.Migrations columns: table => new { Id = table.Column(type: "bigint", nullable: false), - SiteId = table.Column(type: "bigint", nullable: false), + SiteId = table.Column(type: "integer", nullable: false), LanguageId = table.Column(type: "integer", nullable: false), Type = table.Column(type: "integer", nullable: false), Key = table.Column(type: "varchar(64)", nullable: false), @@ -566,7 +567,7 @@ namespace Atomx.Data.Migrations columns: table => new { Id = table.Column(type: "bigint", nullable: false), - SiteId = table.Column(type: "bigint", nullable: false), + SiteId = table.Column(type: "integer", nullable: false), Type = table.Column(type: "integer", nullable: false), Name = table.Column(type: "varchar(64)", nullable: false), Key = table.Column(type: "varchar(64)", nullable: false), @@ -581,7 +582,8 @@ namespace Atomx.Data.Migrations name: "SiteApps", columns: table => new { - Id = table.Column(type: "bigint", nullable: false), + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Type = table.Column(type: "integer", nullable: false), Name = table.Column(type: "varchar(64)", nullable: false), Enabled = table.Column(type: "boolean", nullable: false), @@ -631,12 +633,30 @@ namespace Atomx.Data.Migrations table.PrimaryKey("PK_SpecificationAttributes", x => x.Id); }); + migrationBuilder.CreateTable( + name: "Tags", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false), + Name = table.Column(type: "varchar(64)", nullable: false), + Color = table.Column(type: "varchar(12)", nullable: false), + Slug = table.Column(type: "varchar(128)", nullable: false), + Count = table.Column(type: "integer", nullable: false), + Enabled = table.Column(type: "integer", nullable: false), + CreateTime = table.Column(type: "timestamptz", nullable: false), + UpdateTime = table.Column(type: "timestamptz", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Tags", x => x.Id); + }); + migrationBuilder.CreateTable( name: "UploadFiles", columns: table => new { Id = table.Column(type: "bigint", nullable: false), - SiteId = table.Column(type: "bigint", nullable: false), + SiteId = table.Column(type: "integer", nullable: false), Type = table.Column(type: "integer", nullable: false), Name = table.Column(type: "varchar(64)", nullable: false), Path = table.Column(type: "varchar(128)", nullable: false), @@ -764,6 +784,9 @@ namespace Atomx.Data.Migrations migrationBuilder.DropTable( name: "SpecificationAttributes"); + migrationBuilder.DropTable( + name: "Tags"); + migrationBuilder.DropTable( name: "UploadFiles"); diff --git a/Atomx.Data/Migrations/DataContextModelSnapshot.cs b/Atomx.Data/Migrations/DataContextModelSnapshot.cs index 8a5f1d1..9906456 100644 --- a/Atomx.Data/Migrations/DataContextModelSnapshot.cs +++ b/Atomx.Data/Migrations/DataContextModelSnapshot.cs @@ -190,8 +190,8 @@ namespace Atomx.Data.Migrations b.Property("Platform") .HasColumnType("integer"); - b.Property("SiteId") - .HasColumnType("bigint"); + b.Property("SiteId") + .HasColumnType("integer"); b.Property("Status") .HasColumnType("integer"); @@ -326,8 +326,8 @@ namespace Atomx.Data.Migrations .IsRequired() .HasColumnType("varchar(100)"); - b.Property("SiteId") - .HasColumnType("bigint"); + b.Property("SiteId") + .HasColumnType("integer"); b.Property("Slug") .IsRequired() @@ -370,8 +370,8 @@ namespace Atomx.Data.Migrations b.Property("Network") .HasColumnType("integer"); - b.Property("SiteId") - .HasColumnType("bigint"); + b.Property("SiteId") + .HasColumnType("integer"); b.Property("Status") .HasColumnType("integer"); @@ -394,8 +394,11 @@ namespace Atomx.Data.Migrations modelBuilder.Entity("Atomx.Common.Entities.Currency", b => { b.Property("Id") + .ValueGeneratedOnAdd() .HasColumnType("integer"); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + b.Property("CreateTime") .HasColumnType("timestamptz"); @@ -430,8 +433,8 @@ namespace Atomx.Data.Migrations b.Property("Rate") .HasColumnType("decimal(16, 4)"); - b.Property("SiteId") - .HasColumnType("bigint"); + b.Property("SiteId") + .HasColumnType("integer"); b.Property("Symbolic") .IsRequired() @@ -678,8 +681,8 @@ namespace Atomx.Data.Migrations .IsRequired() .HasColumnType("varchar(256)"); - b.Property("SiteId") - .HasColumnType("bigint"); + b.Property("SiteId") + .HasColumnType("integer"); b.Property("Title") .IsRequired() @@ -1223,8 +1226,8 @@ namespace Atomx.Data.Migrations .IsRequired() .HasColumnType("varchar(64)"); - b.Property("SiteId") - .HasColumnType("bigint"); + b.Property("SiteId") + .HasColumnType("integer"); b.Property("Type") .HasColumnType("integer"); @@ -1236,8 +1239,11 @@ namespace Atomx.Data.Migrations modelBuilder.Entity("Atomx.Common.Entities.SiteApp", b => { - b.Property("Id") - .HasColumnType("bigint"); + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("CreateTime") .HasColumnType("timestamptz"); @@ -1330,6 +1336,40 @@ namespace Atomx.Data.Migrations b.ToTable("SpecificationAttributeOptions"); }); + modelBuilder.Entity("Atomx.Common.Entities.Tag", b => + { + b.Property("Id") + .HasColumnType("bigint"); + + b.Property("Color") + .IsRequired() + .HasColumnType("varchar(12)"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("CreateTime") + .HasColumnType("timestamptz"); + + b.Property("Enabled") + .HasColumnType("integer"); + + b.Property("Name") + .IsRequired() + .HasColumnType("varchar(64)"); + + b.Property("Slug") + .IsRequired() + .HasColumnType("varchar(128)"); + + b.Property("UpdateTime") + .HasColumnType("timestamptz"); + + b.HasKey("Id"); + + b.ToTable("Tags"); + }); + modelBuilder.Entity("Atomx.Common.Entities.UploadFile", b => { b.Property("Id") @@ -1365,8 +1405,8 @@ namespace Atomx.Data.Migrations .IsRequired() .HasColumnType("varchar(128)"); - b.Property("SiteId") - .HasColumnType("bigint"); + b.Property("SiteId") + .HasColumnType("integer"); b.Property("Size") .HasColumnType("integer");