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.

32 lines
707 B
Go

package api
import (
"github.com/gin-gonic/gin"
"online_code/core"
"online_code/models/param"
"online_code/repository"
)
type problemApi struct{}
func ProblemApi() *problemApi {
return &problemApi{}
}
func (problemApi) GetProbleList(ctx *gin.Context) {
var p param.GetProblemList
if err := ctx.ShouldBind(&p); err != nil {
core.R(ctx).FailWithMessage("参数错误: " + err.Error())
return
}
records, count, err := repository.ProblemService().GetList(p)
if err != nil {
core.R(ctx).FailWithMessage("获取题目列表失败: " + err.Error())
return
}
// 返回结果
core.R(ctx).OkDataPage(count, core.PageData{Current: p.Current, Size: p.Size, Total: count, Records: records})
}