v3.5.8和v3.5.9版本更新
CI / verify (pull_request) Waiting to run

This commit is contained in:
2026-08-25 09:20:32 +08:00
parent 7304c7a8e1
commit 5935024ea8
101 changed files with 7640 additions and 5364 deletions
@@ -0,0 +1,3 @@
-- v3.5.9: HQ 账号列表显示列 / 顺序偏好
ALTER TABLE `hq_account`
ADD COLUMN `list_column_prefs` JSON NULL;
@@ -0,0 +1,15 @@
-- v3.5.8 补丁:删除门店分类权限(可对已执行过 migrate-hq-permissions-v358.sql 的库单独跑)
-- 城市门店服务可新增分类,不可删除
INSERT IGNORE INTO `hq_role_permission` (`admin_role`, `permission_key`, `created_at`)
SELECT `admin_role`, 'store_categories_delete', NOW(3)
FROM `hq_role_permission`
WHERE `permission_key` = 'store_categories'
AND `admin_role` <> 'CITY_STORE_SERVICE';
INSERT IGNORE INTO `hq_account_permission` (`hq_account_id`, `permission_key`, `effect`, `created_at`)
SELECT p.`hq_account_id`, 'store_categories_delete', p.`effect`, NOW(3)
FROM `hq_account_permission` p
INNER JOIN `hq_account` a ON a.`id` = p.`hq_account_id`
WHERE p.`permission_key` = 'store_categories'
AND a.`admin_role` <> 'CITY_STORE_SERVICE';
@@ -0,0 +1,71 @@
-- v3.5.8: HQ 权限追加/撤销、城市门店服务、账号城市范围
ALTER TABLE `hq_account`
MODIFY COLUMN `admin_role` ENUM(
'SUPER_ADMIN',
'OPS',
'FINANCE',
'CUSTOMER_SERVICE',
'CITY_STORE_SERVICE'
) NOT NULL DEFAULT 'OPS';
ALTER TABLE `hq_role_permission`
MODIFY COLUMN `admin_role` ENUM(
'SUPER_ADMIN',
'OPS',
'FINANCE',
'CUSTOMER_SERVICE',
'CITY_STORE_SERVICE'
) NOT NULL;
ALTER TABLE `hq_account_permission`
ADD COLUMN `effect` ENUM('GRANT', 'DENY') NOT NULL DEFAULT 'GRANT' AFTER `permission_key`;
CREATE TABLE IF NOT EXISTS `hq_account_city` (
`hq_account_id` BIGINT UNSIGNED NOT NULL,
`city_id` BIGINT UNSIGNED NOT NULL,
`created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
PRIMARY KEY (`hq_account_id`, `city_id`),
INDEX `hq_account_city_city_id_idx` (`city_id`),
CONSTRAINT `hq_account_city_hq_account_id_fkey`
FOREIGN KEY (`hq_account_id`) REFERENCES `hq_account` (`id`) ON DELETE CASCADE,
CONSTRAINT `hq_account_city_city_id_fkey`
FOREIGN KEY (`city_id`) REFERENCES `common_city` (`id`) ON DELETE CASCADE
) DEFAULT CHARSET = utf8mb4;
-- 存量 stores 拆键:补齐审核/评价/分类/账户/资源,保持与拆分前菜单一致
INSERT IGNORE INTO `hq_role_permission` (`admin_role`, `permission_key`, `created_at`)
SELECT `admin_role`, 'store_audits', NOW(3) FROM `hq_role_permission` WHERE `permission_key` = 'stores';
INSERT IGNORE INTO `hq_role_permission` (`admin_role`, `permission_key`, `created_at`)
SELECT `admin_role`, 'store_ratings', NOW(3) FROM `hq_role_permission` WHERE `permission_key` = 'stores';
INSERT IGNORE INTO `hq_role_permission` (`admin_role`, `permission_key`, `created_at`)
SELECT `admin_role`, 'store_categories', NOW(3) FROM `hq_role_permission` WHERE `permission_key` = 'stores';
INSERT IGNORE INTO `hq_role_permission` (`admin_role`, `permission_key`, `created_at`)
SELECT `admin_role`, 'store_accounts', NOW(3) FROM `hq_role_permission` WHERE `permission_key` = 'stores';
INSERT IGNORE INTO `hq_role_permission` (`admin_role`, `permission_key`, `created_at`)
SELECT `admin_role`, 'store_media', NOW(3) FROM `hq_role_permission` WHERE `permission_key` = 'stores';
INSERT IGNORE INTO `hq_account_permission` (`hq_account_id`, `permission_key`, `effect`, `created_at`)
SELECT `hq_account_id`, 'store_audits', `effect`, NOW(3) FROM `hq_account_permission` WHERE `permission_key` = 'stores';
INSERT IGNORE INTO `hq_account_permission` (`hq_account_id`, `permission_key`, `effect`, `created_at`)
SELECT `hq_account_id`, 'store_ratings', `effect`, NOW(3) FROM `hq_account_permission` WHERE `permission_key` = 'stores';
INSERT IGNORE INTO `hq_account_permission` (`hq_account_id`, `permission_key`, `effect`, `created_at`)
SELECT `hq_account_id`, 'store_categories', `effect`, NOW(3) FROM `hq_account_permission` WHERE `permission_key` = 'stores';
INSERT IGNORE INTO `hq_account_permission` (`hq_account_id`, `permission_key`, `effect`, `created_at`)
SELECT `hq_account_id`, 'store_accounts', `effect`, NOW(3) FROM `hq_account_permission` WHERE `permission_key` = 'stores';
INSERT IGNORE INTO `hq_account_permission` (`hq_account_id`, `permission_key`, `effect`, `created_at`)
SELECT `hq_account_id`, 'store_media', `effect`, NOW(3) FROM `hq_account_permission` WHERE `permission_key` = 'stores';
-- 删除分类:有分类权限的角色/账号补齐,城市门店服务除外(可新增、不可删除)
INSERT IGNORE INTO `hq_role_permission` (`admin_role`, `permission_key`, `created_at`)
SELECT `admin_role`, 'store_categories_delete', NOW(3)
FROM `hq_role_permission`
WHERE `permission_key` = 'store_categories'
AND `admin_role` <> 'CITY_STORE_SERVICE';
INSERT IGNORE INTO `hq_account_permission` (`hq_account_id`, `permission_key`, `effect`, `created_at`)
SELECT p.`hq_account_id`, 'store_categories_delete', p.`effect`, NOW(3)
FROM `hq_account_permission` p
INNER JOIN `hq_account` a ON a.`id` = p.`hq_account_id`
WHERE p.`permission_key` = 'store_categories'
AND a.`admin_role` <> 'CITY_STORE_SERVICE';
+27 -3
View File
@@ -263,6 +263,12 @@ enum HqAdminRole {
OPS
FINANCE
CUSTOMER_SERVICE
CITY_STORE_SERVICE
}
enum HqPermissionEffect {
GRANT
DENY
}
enum PartnerBillStatus {
@@ -1031,6 +1037,7 @@ model CommonCity {
partnerAccounts PartnerAccount[] @relation("PartnerAccountCity")
stores Store[]
orders Order[]
hqAccountCities HqAccountCity[]
@@map("common_city")
}
@@ -1244,10 +1251,13 @@ model HqAccount {
wxUnionId String? @map("wx_union_id") @db.VarChar(64)
status AccountStatus @default(ACTIVE)
lastLoginAt DateTime? @map("last_login_at") @db.DateTime(3)
/// HQ 各列表的显示列与顺序(按 listKey)
listColumnPrefs Json? @map("list_column_prefs")
createdAt DateTime @default(now()) @map("created_at") @db.DateTime(3)
updatedAt DateTime @updatedAt @map("updated_at") @db.DateTime(3)
permissions HqAccountPermission[]
cities HqAccountCity[]
testWhitelistPhones CommonTestWhitelistPhone[] @relation("TestWhitelistCreatedBy")
@@map("hq_account")
@@ -1263,9 +1273,10 @@ model HqRolePermission {
}
model HqAccountPermission {
hqAccountId BigInt @map("hq_account_id") @db.UnsignedBigInt
permissionKey String @map("permission_key") @db.VarChar(64)
createdAt DateTime @default(now()) @map("created_at") @db.DateTime(3)
hqAccountId BigInt @map("hq_account_id") @db.UnsignedBigInt
permissionKey String @map("permission_key") @db.VarChar(64)
effect HqPermissionEffect @default(GRANT)
createdAt DateTime @default(now()) @map("created_at") @db.DateTime(3)
hqAccount HqAccount @relation(fields: [hqAccountId], references: [id], onDelete: Cascade)
@@ -1273,6 +1284,19 @@ model HqAccountPermission {
@@map("hq_account_permission")
}
model HqAccountCity {
hqAccountId BigInt @map("hq_account_id") @db.UnsignedBigInt
cityId BigInt @map("city_id") @db.UnsignedBigInt
createdAt DateTime @default(now()) @map("created_at") @db.DateTime(3)
hqAccount HqAccount @relation(fields: [hqAccountId], references: [id], onDelete: Cascade)
city CommonCity @relation(fields: [cityId], references: [id], onDelete: Cascade)
@@id([hqAccountId, cityId])
@@index([cityId])
@@map("hq_account_city")
}
// ─── USER ─────────────────────────────────────────────
model User {