接口对接

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

@@ -85,11 +85,17 @@ func (d *anchorDao) buildListFilter(ctx context.Context, req *dto.ListAnchorReq)
WhereOrLike(entity.AnchorCols.Phone, "%"+req.Keyword+"%").
WhereOrLike(entity.AnchorCols.Code, "%"+req.Keyword+"%")
}
model.Where(entity.AnchorCols.Name, req.Name)
model.Where(entity.AnchorCols.Phone, req.Phone)
model.Where(entity.AnchorCols.Code, req.Code)
if !g.IsEmpty(req.Name) {
model.WhereLike(entity.AnchorCols.Name, "%"+req.Name+"%")
}
if !g.IsEmpty(req.Phone) {
model.WhereLike(entity.AnchorCols.Phone, "%"+req.Phone+"%")
}
if !g.IsEmpty(req.Code) {
model.WhereLike(entity.AnchorCols.Code, "%"+req.Code+"%")
}
if req.Status != nil {
model.Where(entity.AnchorCols.Status, *req.Status)
model.Where("status = ?", *req.Status)
}
model.OmitEmptyWhere()
return model

View File

@@ -85,11 +85,17 @@ func (d *liveAccountDao) buildListFilter(ctx context.Context, req *dto.ListLiveA
WhereOrLike(entity.LiveAccountCols.AccountName, "%"+req.Keyword+"%").
WhereOrLike(entity.LiveAccountCols.AccountId, "%"+req.Keyword+"%")
}
model.Where(entity.LiveAccountCols.Platform, req.Platform)
model.Where(entity.LiveAccountCols.AccountName, req.AccountName)
model.Where(entity.LiveAccountCols.AccountId, req.AccountId)
if !g.IsEmpty(req.Platform) {
model.WhereLike(entity.LiveAccountCols.Platform, "%"+req.Platform+"%")
}
if !g.IsEmpty(req.AccountName) {
model.WhereLike(entity.LiveAccountCols.AccountName, "%"+req.AccountName+"%")
}
if !g.IsEmpty(req.AccountId) {
model.WhereLike(entity.LiveAccountCols.AccountId, "%"+req.AccountId+"%")
}
if req.Status != nil {
model.Where(entity.LiveAccountCols.Status, *req.Status)
model.Where("status = ?", *req.Status)
}
model.OmitEmptyWhere()
return model

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).