fix: 修复缺少渠道表时商务列表失败并补充接口实测
This commit is contained in:
@@ -32,14 +32,21 @@ type Account struct {
|
||||
RejectReason string
|
||||
AuthorityID uint
|
||||
CreatedAt, UpdatedAt time.Time
|
||||
PromoteCount, BindCount int64
|
||||
PromoteCount *int64
|
||||
BindCount int64
|
||||
}
|
||||
|
||||
type AccountCounts struct {
|
||||
// 无渠道表时为 nil,避免将未接入数据误报为真实零渠道。
|
||||
PromoteCount *int64
|
||||
BindCount int64
|
||||
}
|
||||
|
||||
// UserScope 表示商务树可见范围,与框架部门权限相互独立。
|
||||
type UserScope struct {
|
||||
All, Empty, IncludeSelf bool
|
||||
SelfID uint
|
||||
DescendantPath string
|
||||
All, Empty, IncludeSelf, OnlySelf bool
|
||||
SelfID uint
|
||||
DescendantPath string
|
||||
}
|
||||
|
||||
type AccountFilter struct {
|
||||
@@ -84,7 +91,7 @@ type AccountRepo interface {
|
||||
Create(context.Context, *Account) error
|
||||
Update(context.Context, *Account) error
|
||||
AuthorityForLevel(context.Context, int) (uint, error)
|
||||
DirectCounts(context.Context, []uint) (map[uint][2]int64, error)
|
||||
DirectCounts(context.Context, []uint) (map[uint]AccountCounts, error)
|
||||
}
|
||||
|
||||
type AccountUsecase struct{ repo AccountRepo }
|
||||
@@ -141,7 +148,7 @@ func (uc *AccountUsecase) List(ctx context.Context, filter AccountFilter, option
|
||||
return nil, 0, err
|
||||
}
|
||||
for _, row := range rows {
|
||||
row.PromoteCount, row.BindCount = counts[row.ID][0], counts[row.ID][1]
|
||||
row.PromoteCount, row.BindCount = counts[row.ID].PromoteCount, counts[row.ID].BindCount
|
||||
}
|
||||
return rows, total, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user