新增运营商名称模糊搜索

This commit is contained in:
2026-04-21 11:24:47 +08:00
parent e573a82120
commit 1b21d4dafa
3 changed files with 7 additions and 0 deletions

View File

@@ -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 {

View File

@@ -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 选择全表扫描

View File

@@ -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
}