🎨 优化文章相关接口

This commit is contained in:
2025-07-25 23:02:57 +08:00
parent bb2a68fb61
commit 7951f77f47
3 changed files with 12 additions and 10 deletions

View File

@@ -249,13 +249,13 @@ wechat:
pay-list:
- type: wxpay
alias-name: wxpay-1
app-id: 1
mch-id: 1
app-id: wx3d21df18d7f8f9fc
mch-id: 1646874753
v3-key: 1a3sd8561d5179Df152D4789aD38wG9s
cert-path: 1
key-path: 1
notify-url: 1
serial-no: 1
cert-path: /resource/cert/apiclient_cert.pem
key-path: /resource/cert/apiclient_key.pem
notify-url: http://lckt.hnlc5588.cn/app_order/notify
serial-no: 59A891FB403EC7A1CF2090DB9C8EC704BD43B101
- type: wxpay2
alias-name: wxpay-2
app-id: 2

View File

@@ -5,7 +5,9 @@ import api "git.echol.cn/loser/lckt/api/v1"
type RouterGroup struct {
UserRouter
BannerRouter
OrderRouter
}
var userApi = api.ApiGroupApp.AppApiGroup.AppUserApi
var bannerApi = api.ApiGroupApp.AppApiGroup.BannerApi
var orderApi = api.ApiGroupApp.AppApiGroup.OrderApi

View File

@@ -75,13 +75,13 @@ func (s ArticleService) APPGetArticleList(pageInfo request.GetList) (list []vo.A
return
}
func (s ArticleService) APPGetArticle(id string, userId uint) (article vo.ArticleVo, err error) {
func (s ArticleService) APPGetArticle(id string, userId uint) (article *vo.ArticleVo, err error) {
err = global.GVA_DB.Table("article").Where("id = ?", id).First(&article).Error
if err != nil {
global.GVA_LOG.Error("获取文章失败", zap.Error(err))
return
}
article.IsBuy = 1 // 设置为已购买
article.IsBuy = 1
global.GVA_DB.Table("app_user").Select("avatar").Where("id = ?", article.TeacherId).Scan(&article.TeacherAvatar)
@@ -89,10 +89,10 @@ func (s ArticleService) APPGetArticle(id string, userId uint) (article vo.Articl
if article.IsFree == 0 {
// 如果不是免费文章,判断用户是否购买过
var count int64
err = global.GVA_DB.Model(&app.Order{}).Where("article_id = ? AND user_id = ?", id, userId).Count(&count).Error
err = global.GVA_DB.Model(&app.Order{}).Where("article_id = ? AND user_id = ? AND status = 2", id, userId).Count(&count).Error
if err != nil {
global.GVA_LOG.Error("查询用户购买记录失败", zap.Error(err))
return
return nil, err
}
if count == 0 {
// 用户没有购买过隐藏Content