接口对接

This commit is contained in:
2026-04-21 13:31:10 +08:00
parent adb6da1d70
commit 33cb945846
8 changed files with 119 additions and 47 deletions

View File

@@ -95,9 +95,61 @@ func (d *scheduleDao) buildListFilter(ctx context.Context, req *dto.ListSchedule
if !req.EndDate.IsZero() {
model.WhereLTE(entity.ScheduleCols.StartTime, req.EndDate.Format("2006-01-02")+" 23:59:59")
}
// 根据主播名字模糊查询
if req.AnchorName != "" {
anchorIds, _ := d.getAnchorIdsByName(ctx, req.AnchorName)
if len(anchorIds) > 0 {
model.WhereIn(entity.ScheduleCols.AnchorId, anchorIds)
} else {
// 如果没有匹配的主播,返回空结果
model.Where("1=0")
}
}
// 根据直播账号名字模糊查询
if req.AccountName != "" {
accountIds, _ := d.getAccountIdsByName(ctx, req.AccountName)
if len(accountIds) > 0 {
model.WhereIn(entity.ScheduleCols.AccountId, accountIds)
} else {
// 如果没有匹配的账号,返回空结果
model.Where("1=0")
}
}
return model
}
// getAnchorIdsByName 根据主播名字模糊查询获取主播ID列表
func (d *scheduleDao) getAnchorIdsByName(ctx context.Context, name string) ([]interface{}, error) {
r, err := gfdb.DB(ctx).Model(ctx, consts.AnchorTable).
WhereLike("name", "%"+name+"%").
Fields("id").
All()
if err != nil {
return nil, err
}
ids := make([]interface{}, 0)
for _, record := range r {
ids = append(ids, record["id"])
}
return ids, nil
}
// getAccountIdsByName 根据直播账号名字模糊查询获取账号ID列表
func (d *scheduleDao) getAccountIdsByName(ctx context.Context, name string) ([]interface{}, error) {
r, err := gfdb.DB(ctx).Model(ctx, consts.LiveAccountTable).
WhereLike("account_name", "%"+name+"%").
Fields("id").
All()
if err != nil {
return nil, err
}
ids := make([]interface{}, 0)
for _, record := range r {
ids = append(ids, record["id"])
}
return ids, nil
}
// UpdateStatus 更新排班状态
func (d *scheduleDao) UpdateStatus(ctx context.Context, id int64, status int) (rows int64, err error) {
r, err := gfdb.DB(ctx).Model(ctx, consts.ScheduleTable).