Implement API security baseline (sys_user, JWT, audit fields, transactions, unique constraints) and Web real login with 401 handling. Document setup and development workflows in root, WmsLite.Api, and WmsLite.Web README files. Co-authored-by: Cursor <cursoragent@cursor.com>
104 lines
8.1 KiB
C#
104 lines
8.1 KiB
C#
using FluentMigrator;
|
|
|
|
namespace WmsLite.Api.Database.Migrations;
|
|
|
|
[Migration(9, "Sys dictionary items for localized labels")]
|
|
public class CreateSysDictItem0009 : Migration
|
|
{
|
|
public override void Up()
|
|
{
|
|
if (!Schema.Table("sys_dict_item").Exists())
|
|
{
|
|
Create.Table("sys_dict_item")
|
|
.WithBaseColumns()
|
|
.WithColumn("category").AsString(128).NotNullable()
|
|
.WithColumn("code").AsString(128).NotNullable()
|
|
.WithColumn("label").AsString(512).NotNullable()
|
|
.WithColumn("sort_order").AsInt32().NotNullable().WithDefaultValue(0)
|
|
.WithColumn("is_enabled").AsBoolean().NotNullable().WithDefaultValue(true);
|
|
}
|
|
|
|
Execute.Sql("""
|
|
CREATE UNIQUE INDEX IF NOT EXISTS uq_sys_dict_item_scope_cat_code
|
|
ON sys_dict_item (tenant_id, owner_code, category, code)
|
|
WHERE is_deleted = FALSE;
|
|
CREATE INDEX IF NOT EXISTS idx_sys_dict_item_tenant_cat
|
|
ON sys_dict_item (tenant_id, owner_code, category)
|
|
WHERE is_deleted = FALSE AND is_enabled = TRUE;
|
|
""");
|
|
|
|
// Platform defaults: tenants merge these with tenant-specific rows (override same category+code).
|
|
Execute.Sql("""
|
|
INSERT INTO sys_dict_item (id, tenant_id, owner_code, category, code, label, sort_order, is_enabled, create_time, create_by, is_deleted)
|
|
VALUES
|
|
(910000000000000001, 'system', 'system', 'OrderStatus', 'draft', '草稿', 10, TRUE, NOW(), 'migration', FALSE),
|
|
(910000000000000002, 'system', 'system', 'OrderStatus', 'pending', '待处理', 20, TRUE, NOW(), 'migration', FALSE),
|
|
(910000000000000003, 'system', 'system', 'OrderStatus', 'completed', '已完成', 30, TRUE, NOW(), 'migration', FALSE),
|
|
(910000000000000004, 'system', 'system', 'OrderStatus', 'cancelled', '已取消', 40, TRUE, NOW(), 'migration', FALSE),
|
|
|
|
(910000000000000011, 'system', 'system', 'InboundOrder.bizType', 'inbound_default', '默认入库', 10, TRUE, NOW(), 'migration', FALSE),
|
|
(910000000000000012, 'system', 'system', 'OutboundOrder.bizType', 'outbound_default', '默认出库', 10, TRUE, NOW(), 'migration', FALSE),
|
|
(910000000000000013, 'system', 'system', 'TransferOrder.bizType', 'transfer_default', '默认移库', 10, TRUE, NOW(), 'migration', FALSE),
|
|
(910000000000000014, 'system', 'system', 'StocktakeOrder.bizType', 'stocktake_default', '默认盘点', 10, TRUE, NOW(), 'migration', FALSE),
|
|
|
|
(910000000000000021, 'system', 'system', 'InventoryKind', 'material', '物料', 10, TRUE, NOW(), 'migration', FALSE),
|
|
(910000000000000022, 'system', 'system', 'InventoryKind', 'emptyContainer', '空容器', 20, TRUE, NOW(), 'migration', FALSE),
|
|
(910000000000000023, 'system', 'system', 'InventoryKind', '1', '物料', 10, TRUE, NOW(), 'migration', FALSE),
|
|
(910000000000000024, 'system', 'system', 'InventoryKind', '2', '空容器', 20, TRUE, NOW(), 'migration', FALSE),
|
|
|
|
(910000000000000031, 'system', 'system', 'InventoryStatus', 'available', '可用', 10, TRUE, NOW(), 'migration', FALSE),
|
|
(910000000000000032, 'system', 'system', 'InventoryStatus', 'pendingInbound', '待入', 20, TRUE, NOW(), 'migration', FALSE),
|
|
(910000000000000033, 'system', 'system', 'InventoryStatus', 'pendingOutbound', '待出', 30, TRUE, NOW(), 'migration', FALSE),
|
|
(910000000000000034, 'system', 'system', 'InventoryStatus', 'frozen', '冻结', 40, TRUE, NOW(), 'migration', FALSE),
|
|
(910000000000000035, 'system', 'system', 'InventoryStatus', '1', '可用', 10, TRUE, NOW(), 'migration', FALSE),
|
|
(910000000000000036, 'system', 'system', 'InventoryStatus', '2', '待入', 20, TRUE, NOW(), 'migration', FALSE),
|
|
(910000000000000037, 'system', 'system', 'InventoryStatus', '3', '待出', 30, TRUE, NOW(), 'migration', FALSE),
|
|
(910000000000000038, 'system', 'system', 'InventoryStatus', '4', '冻结', 40, TRUE, NOW(), 'migration', FALSE),
|
|
|
|
(910000000000000041, 'system', 'system', 'InventoryMovementType', 'pendingInbound', '待入', 10, TRUE, NOW(), 'migration', FALSE),
|
|
(910000000000000042, 'system', 'system', 'InventoryMovementType', 'inboundConfirm', '入库确认', 20, TRUE, NOW(), 'migration', FALSE),
|
|
(910000000000000043, 'system', 'system', 'InventoryMovementType', 'pendingOutbound', '待出', 30, TRUE, NOW(), 'migration', FALSE),
|
|
(910000000000000044, 'system', 'system', 'InventoryMovementType', 'outboundConfirm', '出库确认', 40, TRUE, NOW(), 'migration', FALSE),
|
|
(910000000000000045, 'system', 'system', 'InventoryMovementType', 'freeze', '冻结', 50, TRUE, NOW(), 'migration', FALSE),
|
|
(910000000000000046, 'system', 'system', 'InventoryMovementType', 'unfreeze', '解冻', 60, TRUE, NOW(), 'migration', FALSE),
|
|
(910000000000000047, 'system', 'system', 'InventoryMovementType', 'adjust', '库存调整', 70, TRUE, NOW(), 'migration', FALSE),
|
|
(910000000000000048, 'system', 'system', 'InventoryMovementType', '1', '待入', 10, TRUE, NOW(), 'migration', FALSE),
|
|
(910000000000000049, 'system', 'system', 'InventoryMovementType', '2', '入库确认', 20, TRUE, NOW(), 'migration', FALSE),
|
|
(910000000000000050, 'system', 'system', 'InventoryMovementType', '3', '待出', 30, TRUE, NOW(), 'migration', FALSE),
|
|
(910000000000000051, 'system', 'system', 'InventoryMovementType', '4', '出库确认', 40, TRUE, NOW(), 'migration', FALSE),
|
|
(910000000000000052, 'system', 'system', 'InventoryMovementType', '5', '冻结', 50, TRUE, NOW(), 'migration', FALSE),
|
|
(910000000000000053, 'system', 'system', 'InventoryMovementType', '6', '解冻', 60, TRUE, NOW(), 'migration', FALSE),
|
|
(910000000000000054, 'system', 'system', 'InventoryMovementType', '7', '库存调整', 70, TRUE, NOW(), 'migration', FALSE),
|
|
|
|
(910000000000000061, 'system', 'system', 'OrderLineStatus', 'open', '未结', 10, TRUE, NOW(), 'migration', FALSE),
|
|
(910000000000000062, 'system', 'system', 'OrderLineStatus', 'completed', '已结', 20, TRUE, NOW(), 'migration', FALSE),
|
|
(910000000000000063, 'system', 'system', 'OrderLineStatus', '1', '未结', 10, TRUE, NOW(), 'migration', FALSE),
|
|
(910000000000000064, 'system', 'system', 'OrderLineStatus', '2', '已结', 20, TRUE, NOW(), 'migration', FALSE),
|
|
|
|
(910000000000000071, 'system', 'system', 'LocationStatus', 'empty', '空', 10, TRUE, NOW(), 'migration', FALSE),
|
|
(910000000000000072, 'system', 'system', 'LocationStatus', 'hasStock', '有货', 20, TRUE, NOW(), 'migration', FALSE),
|
|
(910000000000000073, 'system', 'system', 'LocationStatus', 'pendingInbound', '待入', 30, TRUE, NOW(), 'migration', FALSE),
|
|
(910000000000000074, 'system', 'system', 'LocationStatus', 'pendingOutbound', '待出', 40, TRUE, NOW(), 'migration', FALSE),
|
|
(910000000000000075, 'system', 'system', 'LocationStatus', 'disabled', '禁用', 50, TRUE, NOW(), 'migration', FALSE),
|
|
(910000000000000076, 'system', 'system', 'LocationStatus', '1', '空', 10, TRUE, NOW(), 'migration', FALSE),
|
|
(910000000000000077, 'system', 'system', 'LocationStatus', '2', '有货', 20, TRUE, NOW(), 'migration', FALSE),
|
|
(910000000000000078, 'system', 'system', 'LocationStatus', '3', '待入', 30, TRUE, NOW(), 'migration', FALSE),
|
|
(910000000000000079, 'system', 'system', 'LocationStatus', '4', '待出', 40, TRUE, NOW(), 'migration', FALSE),
|
|
(910000000000000080, 'system', 'system', 'LocationStatus', '5', '禁用', 50, TRUE, NOW(), 'migration', FALSE)
|
|
ON CONFLICT (id) DO NOTHING;
|
|
""");
|
|
}
|
|
|
|
public override void Down()
|
|
{
|
|
Execute.Sql("""
|
|
DROP INDEX IF EXISTS idx_sys_dict_item_tenant_cat;
|
|
DROP INDEX IF EXISTS uq_sys_dict_item_scope_cat_code;
|
|
""");
|
|
if (Schema.Table("sys_dict_item").Exists())
|
|
{
|
|
Delete.Table("sys_dict_item");
|
|
}
|
|
}
|
|
}
|