🎨 新增获取提交列表接口
This commit is contained in:
28
repository/submit.go
Normal file
28
repository/submit.go
Normal file
@@ -0,0 +1,28 @@
|
||||
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
|
||||
}
|
Reference in New Issue
Block a user