refactor(account): 移除卡类型字段、优化账号列表查询和权限检查
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 6m18s
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 6m18s
- 移除 IoT 卡和号卡的 card_type 字段(数据库迁移) - 优化账号列表查询,支持按店铺和企业筛选 - 账号响应增加店铺名称和企业名称字段 - 实现批量加载店铺和企业名称,避免 N+1 查询 - 更新权限检查中间件,完善权限验证逻辑 - 更新相关测试用例,确保功能正确性
This commit is contained in:
@@ -27,9 +27,9 @@ func TestDeviceImportHandler_ProcessBatch_AllOrNothingValidation(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
shopID := uint(100)
|
||||
platformCard := &model.IotCard{ICCID: "89860012345670001001", CardType: "data_card", CarrierID: 1, Status: 1, ShopID: nil}
|
||||
platformCard2 := &model.IotCard{ICCID: "89860012345670001003", CardType: "data_card", CarrierID: 1, Status: 1, ShopID: nil}
|
||||
shopCard := &model.IotCard{ICCID: "89860012345670001002", CardType: "data_card", CarrierID: 1, Status: 1, ShopID: &shopID}
|
||||
platformCard := &model.IotCard{ICCID: "89860012345670001001", CarrierID: 1, Status: 1, ShopID: nil}
|
||||
platformCard2 := &model.IotCard{ICCID: "89860012345670001003", CarrierID: 1, Status: 1, ShopID: nil}
|
||||
shopCard := &model.IotCard{ICCID: "89860012345670001002", CarrierID: 1, Status: 1, ShopID: &shopID}
|
||||
require.NoError(t, cardStore.Create(ctx, platformCard))
|
||||
require.NoError(t, cardStore.Create(ctx, platformCard2))
|
||||
require.NoError(t, cardStore.Create(ctx, shopCard))
|
||||
@@ -119,8 +119,8 @@ func TestDeviceImportHandler_ProcessBatch_AllOrNothingValidation(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("多张卡全部可用-成功", func(t *testing.T) {
|
||||
newCard1 := &model.IotCard{ICCID: "89860012345670001010", CardType: "data_card", CarrierID: 1, Status: 1, ShopID: nil}
|
||||
newCard2 := &model.IotCard{ICCID: "89860012345670001011", CardType: "data_card", CarrierID: 1, Status: 1, ShopID: nil}
|
||||
newCard1 := &model.IotCard{ICCID: "89860012345670001010", CarrierID: 1, Status: 1, ShopID: nil}
|
||||
newCard2 := &model.IotCard{ICCID: "89860012345670001011", CarrierID: 1, Status: 1, ShopID: nil}
|
||||
require.NoError(t, cardStore.Create(ctx, newCard1))
|
||||
require.NoError(t, cardStore.Create(ctx, newCard2))
|
||||
|
||||
@@ -159,9 +159,9 @@ func TestDeviceImportHandler_ProcessImport_AllOrNothing(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
shopID := uint(200)
|
||||
platformCard1 := &model.IotCard{ICCID: "89860012345680001001", CardType: "data_card", CarrierID: 1, Status: 1, ShopID: nil}
|
||||
platformCard2 := &model.IotCard{ICCID: "89860012345680001002", CardType: "data_card", CarrierID: 1, Status: 1, ShopID: nil}
|
||||
shopCard := &model.IotCard{ICCID: "89860012345680001003", CardType: "data_card", CarrierID: 1, Status: 1, ShopID: &shopID}
|
||||
platformCard1 := &model.IotCard{ICCID: "89860012345680001001", CarrierID: 1, Status: 1, ShopID: nil}
|
||||
platformCard2 := &model.IotCard{ICCID: "89860012345680001002", CarrierID: 1, Status: 1, ShopID: nil}
|
||||
shopCard := &model.IotCard{ICCID: "89860012345680001003", CarrierID: 1, Status: 1, ShopID: &shopID}
|
||||
require.NoError(t, cardStore.Create(ctx, platformCard1))
|
||||
require.NoError(t, cardStore.Create(ctx, platformCard2))
|
||||
require.NoError(t, cardStore.Create(ctx, shopCard))
|
||||
|
||||
@@ -54,7 +54,6 @@ func TestIotCardImportHandler_ProcessImport(t *testing.T) {
|
||||
t.Run("跳过已存在的ICCID", func(t *testing.T) {
|
||||
existingCard := &model.IotCard{
|
||||
ICCID: "89860012345678906001",
|
||||
CardType: "data_card",
|
||||
CarrierID: 1,
|
||||
Status: 1,
|
||||
}
|
||||
@@ -108,7 +107,6 @@ func TestIotCardImportHandler_ProcessImport(t *testing.T) {
|
||||
t.Run("混合场景-成功跳过和失败", func(t *testing.T) {
|
||||
existingCard := &model.IotCard{
|
||||
ICCID: "89860012345678908001",
|
||||
CardType: "data_card",
|
||||
CarrierID: 1,
|
||||
Status: 1,
|
||||
}
|
||||
@@ -166,7 +164,6 @@ func TestIotCardImportHandler_ProcessBatch(t *testing.T) {
|
||||
t.Run("验证行号和MSISDN正确记录", func(t *testing.T) {
|
||||
existingCard := &model.IotCard{
|
||||
ICCID: "89860012345678909002",
|
||||
CardType: "data_card",
|
||||
CarrierID: 1,
|
||||
Status: 1,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user