2022-05-26 00:39:39 +08:00
|
|
|
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
|
|
|
|
}
|
2022-06-02 16:21:08 +08:00
|
|
|
|
2022-05-26 00:39:39 +08:00
|
|
|
// 返回结果
|
2022-06-02 16:21:08 +08:00
|
|
|
core.R(ctx).OkDataPage(count, core.PageData{Current: p.Current, Size: p.Size, Total: count, Records: records})
|
2022-05-26 00:39:39 +08:00
|
|
|
}
|