package reward import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/log" ) type RecordResponse struct { Records []*models.RewardOperateRecordShow Total int64 PageSize int Page int } func GetRewardRecordList(opts *models.RewardRecordListOpts) (*RecordResponse, error) { var l models.RewardRecordShowList var n int64 var err error if opts.IsAdmin { l, n, err = models.GetAdminRewardRecordShowList(opts) } else { l, n, err = models.GetRewardRecordShowList(opts) } if err != nil { log.Error("GetRewardRecordList error. %v", err) return nil, err } if len(l) == 0 { return &RecordResponse{Records: make([]*models.RewardOperateRecordShow, 0), Total: n, Page: opts.Page, PageSize: opts.PageSize}, nil } return &RecordResponse{Records: l, Total: n, Page: opts.Page, PageSize: opts.PageSize}, nil } func handleRecordResponse(opts *models.RewardRecordListOpts, list models.RewardRecordShowList) { if opts.IsAdmin { for _, v := range list { v.UserName = opts.UserName } } else { for _, v := range list { if v.Cloudbrain != nil { v.Cloudbrain.AiCenter = "" } } } }