This commit is contained in:
@@ -19,6 +19,7 @@ type ListDeviceRequest struct {
|
||||
CreatedAtStart *time.Time `json:"created_at_start" query:"created_at_start" description:"创建时间起始"`
|
||||
CreatedAtEnd *time.Time `json:"created_at_end" query:"created_at_end" description:"创建时间结束"`
|
||||
HasActivePackage *bool `json:"has_active_package" query:"has_active_package" description:"是否有生效中的套餐(true:有生效中主套餐, false:无生效中主套餐)"`
|
||||
Keyword string `json:"keyword" query:"keyword" validate:"omitempty,max=100" maxLength:"100" description:"关键字搜索,匹配虚拟号或IMEI(模糊查询,与virtual_no/imei独立)"`
|
||||
}
|
||||
|
||||
type DeviceResponse struct {
|
||||
|
||||
@@ -90,6 +90,9 @@ func (s *Service) List(ctx context.Context, req *dto.ListDeviceRequest) (*dto.Li
|
||||
if req.IMEI != "" {
|
||||
filters["imei"] = req.IMEI
|
||||
}
|
||||
if req.Keyword != "" {
|
||||
filters["keyword"] = req.Keyword
|
||||
}
|
||||
if req.DeviceName != "" {
|
||||
filters["device_name"] = req.DeviceName
|
||||
}
|
||||
|
||||
@@ -134,6 +134,9 @@ func (s *DeviceStore) applyDeviceFilters(query *gorm.DB, filters map[string]any)
|
||||
if imei, ok := filters["imei"].(string); ok && imei != "" {
|
||||
query = query.Where("imei LIKE ?", "%"+imei+"%")
|
||||
}
|
||||
if keyword, ok := filters["keyword"].(string); ok && keyword != "" {
|
||||
query = query.Where("virtual_no LIKE ? OR imei LIKE ?", "%"+keyword+"%", "%"+keyword+"%")
|
||||
}
|
||||
if virtualNoStart, ok := filters["virtual_no_start"].(string); ok && virtualNoStart != "" {
|
||||
query = query.Where("virtual_no >= ?", virtualNoStart)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user