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:
@@ -23,9 +23,9 @@ func TestIotCard_ListStandalone(t *testing.T) {
|
||||
env := integ.NewIntegrationTestEnv(t)
|
||||
|
||||
cards := []*model.IotCard{
|
||||
{ICCID: "TEST0012345678901001", CardType: "data_card", CarrierID: 1, Status: 1},
|
||||
{ICCID: "TEST0012345678901002", CardType: "data_card", CarrierID: 1, Status: 1},
|
||||
{ICCID: "TEST0012345678901003", CardType: "data_card", CarrierID: 2, Status: 2},
|
||||
{ICCID: "TEST0012345678901001", CarrierID: 1, Status: 1},
|
||||
{ICCID: "TEST0012345678901002", CarrierID: 1, Status: 1},
|
||||
{ICCID: "TEST0012345678901003", CarrierID: 2, Status: 2},
|
||||
}
|
||||
for _, card := range cards {
|
||||
require.NoError(t, env.TX.Create(card).Error)
|
||||
@@ -424,8 +424,8 @@ func TestIotCard_CarrierRedundantFields(t *testing.T) {
|
||||
CarrierID: carrier.ID,
|
||||
CarrierType: carrier.CarrierType,
|
||||
CarrierName: carrier.CarrierName,
|
||||
CardType: "data_card",
|
||||
Status: 1,
|
||||
|
||||
Status: 1,
|
||||
}
|
||||
require.NoError(t, env.TX.Create(card).Error)
|
||||
|
||||
@@ -485,12 +485,12 @@ func TestIotCard_GetByICCID(t *testing.T) {
|
||||
|
||||
testICCID := fmt.Sprintf("8986%016d", time.Now().UnixNano()%10000000000000000)
|
||||
card := &model.IotCard{
|
||||
ICCID: testICCID,
|
||||
CarrierID: carrier.ID,
|
||||
CarrierType: carrier.CarrierType,
|
||||
CarrierName: carrier.CarrierName,
|
||||
MSISDN: "13800000001",
|
||||
CardType: "physical",
|
||||
ICCID: testICCID,
|
||||
CarrierID: carrier.ID,
|
||||
CarrierType: carrier.CarrierType,
|
||||
CarrierName: carrier.CarrierName,
|
||||
MSISDN: "13800000001",
|
||||
|
||||
CardCategory: "normal",
|
||||
CostPrice: 1000,
|
||||
DistributePrice: 1500,
|
||||
@@ -557,9 +557,9 @@ func TestIotCard_BatchSetSeriesBinding(t *testing.T) {
|
||||
// 创建测试卡(归属于该店铺)
|
||||
timestamp := time.Now().Unix() % 1000000
|
||||
cards := []*model.IotCard{
|
||||
{ICCID: fmt.Sprintf("TEST%06d001", timestamp), CardType: "data_card", CarrierID: 1, Status: 1, ShopID: &shop.ID},
|
||||
{ICCID: fmt.Sprintf("TEST%06d002", timestamp), CardType: "data_card", CarrierID: 1, Status: 1, ShopID: &shop.ID},
|
||||
{ICCID: fmt.Sprintf("TEST%06d003", timestamp), CardType: "data_card", CarrierID: 1, Status: 1, ShopID: &shop.ID},
|
||||
{ICCID: fmt.Sprintf("TEST%06d001", timestamp), CarrierID: 1, Status: 1, ShopID: &shop.ID},
|
||||
{ICCID: fmt.Sprintf("TEST%06d002", timestamp), CarrierID: 1, Status: 1, ShopID: &shop.ID},
|
||||
{ICCID: fmt.Sprintf("TEST%06d003", timestamp), CarrierID: 1, Status: 1, ShopID: &shop.ID},
|
||||
}
|
||||
for _, card := range cards {
|
||||
require.NoError(t, env.TX.Create(card).Error)
|
||||
@@ -694,8 +694,8 @@ func TestIotCard_BatchSetSeriesBinding(t *testing.T) {
|
||||
// 创建另一个店铺和卡
|
||||
otherShop := env.CreateTestShop("其他店铺", 1, nil)
|
||||
otherCard := &model.IotCard{
|
||||
ICCID: fmt.Sprintf("OTH%010d", time.Now().Unix()%10000000000),
|
||||
CardType: "data_card",
|
||||
ICCID: fmt.Sprintf("OTH%010d", time.Now().Unix()%10000000000),
|
||||
|
||||
CarrierID: 1,
|
||||
Status: 1,
|
||||
ShopID: &otherShop.ID,
|
||||
@@ -726,8 +726,8 @@ func TestIotCard_BatchSetSeriesBinding(t *testing.T) {
|
||||
// 创建另一个店铺和卡
|
||||
anotherShop := env.CreateTestShop("另一个店铺", 1, nil)
|
||||
anotherCard := &model.IotCard{
|
||||
ICCID: fmt.Sprintf("ADM%010d", time.Now().Unix()%10000000000),
|
||||
CardType: "data_card",
|
||||
ICCID: fmt.Sprintf("ADM%010d", time.Now().Unix()%10000000000),
|
||||
|
||||
CarrierID: 1,
|
||||
Status: 1,
|
||||
ShopID: &anotherShop.ID,
|
||||
|
||||
Reference in New Issue
Block a user