🎨 优化文章相关接口
This commit is contained in:
@@ -7,13 +7,13 @@ import (
|
|||||||
type Article struct {
|
type Article struct {
|
||||||
global.GVA_MODEL
|
global.GVA_MODEL
|
||||||
Title string `json:"title" gorm:"comment:文章标题"`
|
Title string `json:"title" gorm:"comment:文章标题"`
|
||||||
Desc string `json:"desc" gorm:"comment:文章描述"`
|
Desc string `json:"desc" gorm:"comment:文章描述;type:longtext"`
|
||||||
Content string `json:"content" gorm:"comment:文章内容;type:longtext"`
|
Content string `json:"content" gorm:"comment:文章内容;type:longtext"`
|
||||||
CoverImg string `json:"coverImg" gorm:"comment:文章封面图"`
|
CoverImg string `json:"coverImg" gorm:"comment:文章封面图"`
|
||||||
TeacherId int `json:"teacherId" gorm:"comment:讲师ID"`
|
TeacherId int `json:"teacherId" gorm:"comment:讲师ID"`
|
||||||
TeacherName string `json:"teacherName" gorm:"comment:讲师名称"`
|
TeacherName string `json:"teacherName" gorm:"comment:讲师名称"`
|
||||||
Price int64 `json:"price" gorm:"comment:文章价格(单位为分)"`
|
Price int64 `json:"price" gorm:"comment:文章价格(单位为分)"`
|
||||||
IsFree int `json:"isFree" gorm:"comment:是否免费;default:0"` // 是否免费 0-否 1-是
|
IsFree *int `json:"isFree" gorm:"comment:是否免费;default:0"` // 是否免费 0-否 1-是
|
||||||
// 分类ID
|
// 分类ID
|
||||||
CategoryId int `json:"categoryId" gorm:"comment:分类ID"`
|
CategoryId int `json:"categoryId" gorm:"comment:分类ID"`
|
||||||
Status int `json:"status" gorm:"comment:状态 1-已发布 2-待审核 3-审核不通过;default:2"` // 状态 0-草稿 1-已发布 2-待审核 3-审核不通过
|
Status int `json:"status" gorm:"comment:状态 1-已发布 2-待审核 3-审核不通过;default:2"` // 状态 0-草稿 1-已发布 2-待审核 3-审核不通过
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
package vo
|
package vo
|
||||||
|
|
||||||
import "git.echol.cn/loser/lckt/model/app/vo"
|
import (
|
||||||
|
"git.echol.cn/loser/lckt/model/app/vo"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
type ArticleListVo struct {
|
type ArticleListVo struct {
|
||||||
ID int `json:"id" gorm:"comment:文章ID"`
|
ID int `json:"id" gorm:"comment:文章ID"`
|
||||||
@@ -13,6 +16,7 @@ type ArticleListVo struct {
|
|||||||
TeacherName string `json:"teacherName" gorm:"comment:讲师名称"`
|
TeacherName string `json:"teacherName" gorm:"comment:讲师名称"`
|
||||||
TeacherAvatar string `json:"teacherAvatar" gorm:"comment:讲师头像"`
|
TeacherAvatar string `json:"teacherAvatar" gorm:"comment:讲师头像"`
|
||||||
IsFree int `json:"isFree" gorm:"comment:是否免费;default:0"` // 是否免费 0-否 1-是
|
IsFree int `json:"isFree" gorm:"comment:是否免费;default:0"` // 是否免费 0-否 1-是
|
||||||
|
CreatedAt time.Time `json:"createdAt" gorm:"comment:创建时间"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ArticleVo struct {
|
type ArticleVo struct {
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ func (ArticleService) UpdateArticle(req article.Article) (err error) {
|
|||||||
err = global.GVA_DB.Model(&article.Article{}).Where("id = ?", req.ID).Updates(&req).Error
|
err = global.GVA_DB.Model(&article.Article{}).Where("id = ?", req.ID).Updates(&req).Error
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ArticleService) GetArticle(id string) (article article.Article, err error) {
|
func (ArticleService) GetArticle(id string) (article article.Article, err error) {
|
||||||
err = global.GVA_DB.Where("id = ?", id).First(&article).Error
|
err = global.GVA_DB.Where("id = ?", id).First(&article).Error
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user