更新数据库

This commit is contained in:
yxw
2025-12-23 18:39:39 +08:00
parent 3c4144335f
commit a1516490d2
15 changed files with 187 additions and 77 deletions

View File

@@ -10,8 +10,8 @@
<Breadcrumb>
<Breadcrumb>
<BreadcrumbItem Href="/">管理后台</BreadcrumbItem>
<BreadcrumbItem Href="/admin/list">系统功能</BreadcrumbItem>
<BreadcrumbItem>货币管理</BreadcrumbItem>
<BreadcrumbItem Href="/admin/list">系统配置</BreadcrumbItem>
<BreadcrumbItem Href="/currency/list">货币管理</BreadcrumbItem>
</Breadcrumb>
</Breadcrumb>
<ChildContent>

View File

@@ -70,7 +70,7 @@
<ChildContent>
<Table DataSource="PagingList.Items" PageSize="100" HidePagination="true">
<Selection CheckStrictly />
<PropertyColumn Property="c => c.Name" Title="语言" />
<PropertyColumn Property="c => c.Name" Title="名称" />
<PropertyColumn Property="c => c.CurrencyCode" Title="货币代码" />
<PropertyColumn Property="c => c.Rate" Title="汇率" />
<PropertyColumn Property="c => c.PrimaryCurrency" Title="默认货币">

View File

@@ -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<Currency>();
data.CreateTime = DateTime.UtcNow;
_dbContext.Currencies.Add(data);
_dbContext.SaveChanges();
}
result.Data = true;
result = result.IsSuccess(true);
//todo 更新缓存

View File

@@ -19,7 +19,7 @@ namespace Atomx.Common.Entities
/// <summary>
/// 归属站点应用ID
/// </summary>
public long SiteId { get; set; }
public int SiteId { get; set; }
/// <summary>
/// 运行平台

View File

@@ -19,7 +19,7 @@ namespace Atomx.Common.Entities
/// <summary>
/// 归属站点应用ID
/// </summary>
public long SiteId { get; set; }
public int SiteId { get; set; }
/// <summary>
/// 分类类型,1内容2产品3社区

View File

@@ -16,7 +16,7 @@ namespace Atomx.Common.Entities
/// <summary>
/// 站点ID
/// </summary>
public long SiteId { get; set; }
public int SiteId { get; set; }
/// <summary>
/// 通道类型,例如通知、支付、登录等

View File

@@ -19,7 +19,7 @@ namespace Atomx.Common.Entities
/// <summary>
/// 归属站点应用ID
/// </summary>
public long SiteId { get; set; }
public int SiteId { get; set; }
/// <summary>
/// 发布评论用户ID

View File

@@ -19,7 +19,7 @@ namespace Atomx.Common.Entities
/// <summary>
/// 站点ID
/// </summary>
public long SiteId { get; set; }
public int SiteId { get; set; }
/// <summary>
/// 货币名称,系统

View File

@@ -19,7 +19,7 @@ namespace Atomx.Common.Entities
/// <summary>
/// 站点ID
/// </summary>
public long SiteId { get; set; }
public int SiteId { get; set; }
/// <summary>
/// 语言编码

View File

@@ -19,7 +19,7 @@ namespace Atomx.Common.Entities
/// <summary>
/// 归属的网站应用Id
/// </summary>
public long SiteId { get; set; }
public int SiteId { get; set; }
/// <summary>
/// 配置类型,见 SettingType 枚举

View File

@@ -12,9 +12,9 @@ namespace Atomx.Common.Entities
/// <summary>
/// 数据ID
/// </summary>
[DatabaseGenerated(DatabaseGeneratedOption.None)]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[Key]
public long Id { get; set; }
public int Id { get; set; }
/// <summary>
/// 网站应用类型

View File

@@ -16,7 +16,7 @@ namespace Atomx.Common.Entities
/// <summary>
/// 归属站点应用ID
/// </summary>
public long SiteId { get; set; }
public int SiteId { get; set; }
/// <summary>
/// 文件类型

View File

@@ -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
{
/// <inheritdoc />
@@ -193,8 +193,8 @@ namespace Atomx.Data.Migrations
b.Property<int>("Platform")
.HasColumnType("integer");
b.Property<long>("SiteId")
.HasColumnType("bigint");
b.Property<int>("SiteId")
.HasColumnType("integer");
b.Property<int>("Status")
.HasColumnType("integer");
@@ -329,8 +329,8 @@ namespace Atomx.Data.Migrations
.IsRequired()
.HasColumnType("varchar(100)");
b.Property<long>("SiteId")
.HasColumnType("bigint");
b.Property<int>("SiteId")
.HasColumnType("integer");
b.Property<string>("Slug")
.IsRequired()
@@ -373,8 +373,8 @@ namespace Atomx.Data.Migrations
b.Property<int>("Network")
.HasColumnType("integer");
b.Property<long>("SiteId")
.HasColumnType("bigint");
b.Property<int>("SiteId")
.HasColumnType("integer");
b.Property<int>("Status")
.HasColumnType("integer");
@@ -397,8 +397,11 @@ namespace Atomx.Data.Migrations
modelBuilder.Entity("Atomx.Common.Entities.Currency", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<DateTime>("CreateTime")
.HasColumnType("timestamptz");
@@ -433,8 +436,8 @@ namespace Atomx.Data.Migrations
b.Property<decimal>("Rate")
.HasColumnType("decimal(16, 4)");
b.Property<long>("SiteId")
.HasColumnType("bigint");
b.Property<int>("SiteId")
.HasColumnType("integer");
b.Property<string>("Symbolic")
.IsRequired()
@@ -681,8 +684,8 @@ namespace Atomx.Data.Migrations
.IsRequired()
.HasColumnType("varchar(256)");
b.Property<long>("SiteId")
.HasColumnType("bigint");
b.Property<int>("SiteId")
.HasColumnType("integer");
b.Property<string>("Title")
.IsRequired()
@@ -1226,8 +1229,8 @@ namespace Atomx.Data.Migrations
.IsRequired()
.HasColumnType("varchar(64)");
b.Property<long>("SiteId")
.HasColumnType("bigint");
b.Property<int>("SiteId")
.HasColumnType("integer");
b.Property<int>("Type")
.HasColumnType("integer");
@@ -1239,8 +1242,11 @@ namespace Atomx.Data.Migrations
modelBuilder.Entity("Atomx.Common.Entities.SiteApp", b =>
{
b.Property<long>("Id")
.HasColumnType("bigint");
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<DateTime>("CreateTime")
.HasColumnType("timestamptz");
@@ -1333,6 +1339,40 @@ namespace Atomx.Data.Migrations
b.ToTable("SpecificationAttributeOptions");
});
modelBuilder.Entity("Atomx.Common.Entities.Tag", b =>
{
b.Property<long>("Id")
.HasColumnType("bigint");
b.Property<string>("Color")
.IsRequired()
.HasColumnType("varchar(12)");
b.Property<int>("Count")
.HasColumnType("integer");
b.Property<DateTime>("CreateTime")
.HasColumnType("timestamptz");
b.Property<int>("Enabled")
.HasColumnType("integer");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("varchar(64)");
b.Property<string>("Slug")
.IsRequired()
.HasColumnType("varchar(128)");
b.Property<DateTime?>("UpdateTime")
.HasColumnType("timestamptz");
b.HasKey("Id");
b.ToTable("Tags");
});
modelBuilder.Entity("Atomx.Common.Entities.UploadFile", b =>
{
b.Property<long>("Id")
@@ -1368,8 +1408,8 @@ namespace Atomx.Data.Migrations
.IsRequired()
.HasColumnType("varchar(128)");
b.Property<long>("SiteId")
.HasColumnType("bigint");
b.Property<int>("SiteId")
.HasColumnType("integer");
b.Property<int>("Size")
.HasColumnType("integer");

View File

@@ -76,7 +76,7 @@ namespace Atomx.Data.Migrations
columns: table => new
{
Id = table.Column<long>(type: "bigint", nullable: false),
SiteId = table.Column<long>(type: "bigint", nullable: false),
SiteId = table.Column<int>(type: "integer", nullable: false),
Platform = table.Column<int>(type: "integer", nullable: false),
AppName = table.Column<string>(type: "varchar(64)", nullable: false),
Title = table.Column<string>(type: "varchar(64)", nullable: false),
@@ -121,7 +121,7 @@ namespace Atomx.Data.Migrations
columns: table => new
{
Id = table.Column<long>(type: "bigint", nullable: false),
SiteId = table.Column<long>(type: "bigint", nullable: false),
SiteId = table.Column<int>(type: "integer", nullable: false),
Type = table.Column<int>(type: "integer", nullable: false),
ParentId = table.Column<long>(type: "bigint", nullable: false),
Name = table.Column<string>(type: "varchar(25)", nullable: false),
@@ -150,7 +150,7 @@ namespace Atomx.Data.Migrations
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false),
SiteId = table.Column<long>(type: "bigint", nullable: false),
SiteId = table.Column<int>(type: "integer", nullable: false),
Type = table.Column<int>(type: "integer", nullable: false),
Network = table.Column<int>(type: "integer", nullable: false),
Name = table.Column<string>(type: "varchar(20)", nullable: false),
@@ -171,8 +171,9 @@ namespace Atomx.Data.Migrations
name: "Currencies",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false),
SiteId = table.Column<long>(type: "bigint", nullable: false),
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
SiteId = table.Column<int>(type: "integer", nullable: false),
Name = table.Column<string>(type: "varchar(50)", nullable: false),
Title = table.Column<string>(type: "varchar(50)", nullable: false),
CurrencyCode = table.Column<string>(type: "varchar(10)", nullable: false),
@@ -296,7 +297,7 @@ namespace Atomx.Data.Migrations
columns: table => new
{
Id = table.Column<long>(type: "bigint", nullable: false),
SiteId = table.Column<long>(type: "bigint", nullable: false),
SiteId = table.Column<int>(type: "integer", nullable: false),
LanguageId = table.Column<int>(type: "integer", nullable: false),
Type = table.Column<int>(type: "integer", nullable: false),
Key = table.Column<string>(type: "varchar(64)", nullable: false),
@@ -566,7 +567,7 @@ namespace Atomx.Data.Migrations
columns: table => new
{
Id = table.Column<long>(type: "bigint", nullable: false),
SiteId = table.Column<long>(type: "bigint", nullable: false),
SiteId = table.Column<int>(type: "integer", nullable: false),
Type = table.Column<int>(type: "integer", nullable: false),
Name = table.Column<string>(type: "varchar(64)", nullable: false),
Key = table.Column<string>(type: "varchar(64)", nullable: false),
@@ -581,7 +582,8 @@ namespace Atomx.Data.Migrations
name: "SiteApps",
columns: table => new
{
Id = table.Column<long>(type: "bigint", nullable: false),
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Type = table.Column<int>(type: "integer", nullable: false),
Name = table.Column<string>(type: "varchar(64)", nullable: false),
Enabled = table.Column<bool>(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<long>(type: "bigint", nullable: false),
Name = table.Column<string>(type: "varchar(64)", nullable: false),
Color = table.Column<string>(type: "varchar(12)", nullable: false),
Slug = table.Column<string>(type: "varchar(128)", nullable: false),
Count = table.Column<int>(type: "integer", nullable: false),
Enabled = table.Column<int>(type: "integer", nullable: false),
CreateTime = table.Column<DateTime>(type: "timestamptz", nullable: false),
UpdateTime = table.Column<DateTime>(type: "timestamptz", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Tags", x => x.Id);
});
migrationBuilder.CreateTable(
name: "UploadFiles",
columns: table => new
{
Id = table.Column<long>(type: "bigint", nullable: false),
SiteId = table.Column<long>(type: "bigint", nullable: false),
SiteId = table.Column<int>(type: "integer", nullable: false),
Type = table.Column<int>(type: "integer", nullable: false),
Name = table.Column<string>(type: "varchar(64)", nullable: false),
Path = table.Column<string>(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");

View File

@@ -190,8 +190,8 @@ namespace Atomx.Data.Migrations
b.Property<int>("Platform")
.HasColumnType("integer");
b.Property<long>("SiteId")
.HasColumnType("bigint");
b.Property<int>("SiteId")
.HasColumnType("integer");
b.Property<int>("Status")
.HasColumnType("integer");
@@ -326,8 +326,8 @@ namespace Atomx.Data.Migrations
.IsRequired()
.HasColumnType("varchar(100)");
b.Property<long>("SiteId")
.HasColumnType("bigint");
b.Property<int>("SiteId")
.HasColumnType("integer");
b.Property<string>("Slug")
.IsRequired()
@@ -370,8 +370,8 @@ namespace Atomx.Data.Migrations
b.Property<int>("Network")
.HasColumnType("integer");
b.Property<long>("SiteId")
.HasColumnType("bigint");
b.Property<int>("SiteId")
.HasColumnType("integer");
b.Property<int>("Status")
.HasColumnType("integer");
@@ -394,8 +394,11 @@ namespace Atomx.Data.Migrations
modelBuilder.Entity("Atomx.Common.Entities.Currency", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<DateTime>("CreateTime")
.HasColumnType("timestamptz");
@@ -430,8 +433,8 @@ namespace Atomx.Data.Migrations
b.Property<decimal>("Rate")
.HasColumnType("decimal(16, 4)");
b.Property<long>("SiteId")
.HasColumnType("bigint");
b.Property<int>("SiteId")
.HasColumnType("integer");
b.Property<string>("Symbolic")
.IsRequired()
@@ -678,8 +681,8 @@ namespace Atomx.Data.Migrations
.IsRequired()
.HasColumnType("varchar(256)");
b.Property<long>("SiteId")
.HasColumnType("bigint");
b.Property<int>("SiteId")
.HasColumnType("integer");
b.Property<string>("Title")
.IsRequired()
@@ -1223,8 +1226,8 @@ namespace Atomx.Data.Migrations
.IsRequired()
.HasColumnType("varchar(64)");
b.Property<long>("SiteId")
.HasColumnType("bigint");
b.Property<int>("SiteId")
.HasColumnType("integer");
b.Property<int>("Type")
.HasColumnType("integer");
@@ -1236,8 +1239,11 @@ namespace Atomx.Data.Migrations
modelBuilder.Entity("Atomx.Common.Entities.SiteApp", b =>
{
b.Property<long>("Id")
.HasColumnType("bigint");
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<DateTime>("CreateTime")
.HasColumnType("timestamptz");
@@ -1330,6 +1336,40 @@ namespace Atomx.Data.Migrations
b.ToTable("SpecificationAttributeOptions");
});
modelBuilder.Entity("Atomx.Common.Entities.Tag", b =>
{
b.Property<long>("Id")
.HasColumnType("bigint");
b.Property<string>("Color")
.IsRequired()
.HasColumnType("varchar(12)");
b.Property<int>("Count")
.HasColumnType("integer");
b.Property<DateTime>("CreateTime")
.HasColumnType("timestamptz");
b.Property<int>("Enabled")
.HasColumnType("integer");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("varchar(64)");
b.Property<string>("Slug")
.IsRequired()
.HasColumnType("varchar(128)");
b.Property<DateTime?>("UpdateTime")
.HasColumnType("timestamptz");
b.HasKey("Id");
b.ToTable("Tags");
});
modelBuilder.Entity("Atomx.Common.Entities.UploadFile", b =>
{
b.Property<long>("Id")
@@ -1365,8 +1405,8 @@ namespace Atomx.Data.Migrations
.IsRequired()
.HasColumnType("varchar(128)");
b.Property<long>("SiteId")
.HasColumnType("bigint");
b.Property<int>("SiteId")
.HasColumnType("integer");
b.Property<int>("Size")
.HasColumnType("integer");