feat(设备列表): 新增 has_active_package 查询条件

- DTO ListDeviceRequest 增加 HasActivePackage *bool 字段(query/json: has_active_package)
- Service List 方法将 HasActivePackage 透传至 filters["has_active_package"]
- Store applyDeviceFilters 新增 applyHasActivePackageFilter:
  true  → EXISTS 子查询(生效中主套餐)
  false → NOT EXISTS 子查询
  均限制 master_usage_id IS NULL、deleted_at IS NULL,状态使用 constants.PackageUsageStatusActive

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-19 12:04:23 +08:00
parent ca939ff617
commit 5e7e68cce7
3 changed files with 24 additions and 2 deletions

View File

@@ -124,6 +124,9 @@ func (s *Service) List(ctx context.Context, req *dto.ListDeviceRequest) (*dto.Li
if req.SeriesID != nil {
filters["series_id"] = *req.SeriesID
}
if req.HasActivePackage != nil {
filters["has_active_package"] = *req.HasActivePackage
}
devices, total, err := s.deviceStore.List(ctx, opts, filters)
if err != nil {