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}) }