🎨 新增获取已购课程接口&
This commit is contained in:
@@ -165,3 +165,28 @@ func (ArticleApi) GetMyArticleList(ctx *gin.Context) {
|
||||
}
|
||||
r.OkWithDetailed(gin.H{"list": list, "total": total}, "查询成功", ctx)
|
||||
}
|
||||
|
||||
// GetBuyList 获取用户购买的文章列表
|
||||
func (ArticleApi) GetBuyList(ctx *gin.Context) {
|
||||
var p request.GetList
|
||||
if err := ctx.ShouldBind(&p); err != nil {
|
||||
r.FailWithMessage(err.Error(), ctx)
|
||||
global.GVA_LOG.Error("参数有误!", zap.Error(err))
|
||||
return
|
||||
}
|
||||
|
||||
userId := user_jwt.GetUserID(ctx)
|
||||
if userId == 0 {
|
||||
r.FailWithMessage("用户未登录", ctx)
|
||||
return
|
||||
}
|
||||
p.UserId = userId // 设置当前用户ID
|
||||
|
||||
list, total, err := articleService.GetBuyList(p)
|
||||
if err != nil {
|
||||
global.GVA_LOG.Error("查询失败!", zap.Error(err))
|
||||
r.FailWithMessage("查询失败:"+err.Error(), ctx)
|
||||
return
|
||||
}
|
||||
r.OkWithDetailed(gin.H{"list": list, "total": total}, "查询成功", ctx)
|
||||
}
|
||||
|
Reference in New Issue
Block a user