diff --git a/internal/model/dto/iot_card_dto.go b/internal/model/dto/iot_card_dto.go index 63795ef..9367a7e 100644 --- a/internal/model/dto/iot_card_dto.go +++ b/internal/model/dto/iot_card_dto.go @@ -18,6 +18,7 @@ type ListStandaloneIotCardRequest struct { IsReplaced *bool `json:"is_replaced" query:"is_replaced" description:"是否有换卡记录 (true:有换卡记录, false:无换卡记录)"` ICCIDStart string `json:"iccid_start" query:"iccid_start" validate:"omitempty,max=20" maxLength:"20" description:"ICCID起始号"` ICCIDEnd string `json:"iccid_end" query:"iccid_end" validate:"omitempty,max=20" maxLength:"20" description:"ICCID结束号"` + CarrierName string `json:"carrier_name" query:"carrier_name" validate:"omitempty,max=100" maxLength:"100" description:"运营商名称(模糊查询)"` } type StandaloneIotCardResponse struct { diff --git a/internal/service/iot_card/service.go b/internal/service/iot_card/service.go index 267d6ac..1e8706a 100644 --- a/internal/service/iot_card/service.go +++ b/internal/service/iot_card/service.go @@ -148,6 +148,9 @@ func (s *Service) ListStandalone(ctx context.Context, req *dto.ListStandaloneIot if req.SeriesID != nil { filters["series_id"] = *req.SeriesID } + if req.CarrierName != "" { + filters["carrier_name"] = req.CarrierName + } // 代理用户注入 subordinate_shop_ids,让 Store 层走并行查询路径 // 避免 PG 对 shop_id IN (...) + ORDER BY 选择全表扫描 diff --git a/internal/store/postgres/iot_card_store.go b/internal/store/postgres/iot_card_store.go index cae194c..71c9ee2 100644 --- a/internal/store/postgres/iot_card_store.go +++ b/internal/store/postgres/iot_card_store.go @@ -736,6 +736,9 @@ func (s *IotCardStore) applyStandaloneFilters(ctx context.Context, query *gorm.D if seriesID, ok := filters["series_id"].(uint); ok && seriesID > 0 { query = query.Where("series_id = ?", seriesID) } + if carrierName, ok := filters["carrier_name"].(string); ok && carrierName != "" { + query = query.Where("carrier_name LIKE ?", "%"+carrierName+"%") + } return query }