You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
715 B
Go

package repository
import (
"online_code/client"
"online_code/models/entity"
"online_code/models/param"
)
type submitService struct{}
func SubmitService() *submitService {
return &submitService{}
}
func (submitService) GetList(p param.GetSubmitList) (records []entity.SubmitBasic, count int64, err error) {
tx := client.MySQL.Scopes(page(p.Current, p.Size))
if p.ProblemIdentity != "" {
tx = tx.Where("problem_identity = ?", p.ProblemIdentity)
}
if p.UserIdentity != "" {
tx = tx.Where("user_identity = ?", p.UserIdentity)
}
if p.Status != 0 && p.Status != 1 && p.Status != 2 {
tx = tx.Where("status = ?", p.Status)
}
err = tx.Offset(-1).Limit(-1).Count(&count).Find(&records).Error
return
}