企业授权增强与资产列表扩展
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 8m9s
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 8m9s
- 企业卡授权唯一约束:新增 DB 迁移(000154),卡级部分唯一索引防止同一张卡被多个企业同时持有,Service 层新增跨企业冲突检测 - 单卡列表新增 network_status 过滤参数 - 单卡/设备列表新增 asset_status、asset_status_name、generation 响应字段 - 单卡/设备列表新增企业维度过滤(authorized_enterprise_id、is_authorized_to_enterprise)及响应中企业授权信息(批量加载,无 N+1) - 主钱包流水/退款列表新增 asset_identifier 精确过滤参数 - 企业卡授权/收回接口升级为三模式(list/range/filter),企业设备授权/收回升级为双模式(list/filter) - 升级 sonic v1.14.2 → v1.15.2 以兼容 Go 1.26 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -155,3 +155,27 @@ func (s *EnterpriseStore) GetByIDs(ctx context.Context, ids []uint) ([]*model.En
|
||||
}
|
||||
return enterprises, nil
|
||||
}
|
||||
|
||||
// GetNameMapByIDs 批量查询企业名称映射(不受数据权限过滤)
|
||||
// 专用于列表响应中回填企业名称,企业 ID 来自已过滤的授权记录,无需二次权限限制
|
||||
func (s *EnterpriseStore) GetNameMapByIDs(ctx context.Context, ids []uint) (map[uint]string, error) {
|
||||
if len(ids) == 0 {
|
||||
return make(map[uint]string), nil
|
||||
}
|
||||
var rows []struct {
|
||||
ID uint
|
||||
EnterpriseName string
|
||||
}
|
||||
err := s.db.WithContext(ctx).Model(&model.Enterprise{}).
|
||||
Select("id, enterprise_name").
|
||||
Where("id IN ? AND deleted_at IS NULL", ids).
|
||||
Scan(&rows).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := make(map[uint]string, len(rows))
|
||||
for _, r := range rows {
|
||||
result[r.ID] = r.EnterpriseName
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user