Some checks failed
Build docker and publish / linux (1.24.5) (push) Failing after 40s
feat(pay): 添加支付API基础结构 feat(miniapp): 创建支付测试小程序页面与配置 feat(wechatpay): 配置微信支付参数与证书 fix(guild): 修复成员列表查询条件 docs: 更新代码规范文档与需求文档 style: 统一前后端枚举显示与注释格式 refactor(admin): 重构用户奖励发放接口参数处理 test(title): 添加称号效果参数验证测试
49 lines
1.2 KiB
Go
49 lines
1.2 KiB
Go
package activity
|
||
|
||
import (
|
||
"context"
|
||
|
||
"bindbox-game/internal/repository/mysql/model"
|
||
)
|
||
|
||
// ListActivities 查询活动列表(支持名称、分类、Boss、状态过滤与分页)
|
||
// 参数: in 列表查询输入
|
||
// 返回: 活动集合、总数与错误
|
||
func (s *service) ListActivities(ctx context.Context, in ListActivitiesInput) (items []*model.Activities, total int64, err error) {
|
||
q := s.readDB.Activities.WithContext(ctx).ReadDB()
|
||
|
||
if in.Name != "" {
|
||
q = q.Where(s.readDB.Activities.Name.Like("%" + in.Name + "%"))
|
||
}
|
||
if in.CategoryID != 0 {
|
||
q = q.Where(s.readDB.Activities.ActivityCategoryID.Eq(in.CategoryID))
|
||
}
|
||
if in.IsBoss != nil {
|
||
q = q.Where(s.readDB.Activities.IsBoss.Eq(*in.IsBoss))
|
||
}
|
||
if in.Status != nil {
|
||
q = q.Where(s.readDB.Activities.Status.Eq(*in.Status))
|
||
}
|
||
|
||
total, err = q.Count()
|
||
if err != nil {
|
||
return nil, 0, err
|
||
}
|
||
|
||
if in.Page <= 0 {
|
||
in.Page = 1
|
||
}
|
||
if in.PageSize <= 0 {
|
||
in.PageSize = 20
|
||
}
|
||
if in.PageSize > 100 {
|
||
in.PageSize = 100
|
||
}
|
||
|
||
items, err = q.Order(s.readDB.Activities.ID.Desc()).Offset((in.Page - 1) * in.PageSize).Limit(in.PageSize).Find()
|
||
if err != nil {
|
||
return nil, 0, err
|
||
}
|
||
return items, total, nil
|
||
}
|