online_code/repository/submit.go
2022-06-02 16:21:42 +08:00

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
}