新增了返回video_author字段。
This commit is contained in:
parent
552a1c2323
commit
554e2a7b92
@ -142,6 +142,11 @@ func (r *Article) PutArticle(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if req.VoteNum < 0 {
|
||||||
|
responses.FailWithMessage("票数需大于0", c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// 获取订单数据
|
// 获取订单数据
|
||||||
articleDao := dao.ArticleDao{}
|
articleDao := dao.ArticleDao{}
|
||||||
article, err := articleDao.GetArticleById(articleId)
|
article, err := articleDao.GetArticleById(articleId)
|
||||||
@ -176,6 +181,11 @@ func (r *Article) PutArticle(c *gin.Context) {
|
|||||||
articleData["article_content"] = req.ArticleContent
|
articleData["article_content"] = req.ArticleContent
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 票数
|
||||||
|
if article.VoteNum != req.VoteNum {
|
||||||
|
articleData["vote_num"] = req.VoteNum
|
||||||
|
}
|
||||||
|
|
||||||
// 修改
|
// 修改
|
||||||
if len(articleData) > 0 {
|
if len(articleData) > 0 {
|
||||||
err = articleDao.EditArticleById(tx, articleId, articleData)
|
err = articleDao.EditArticleById(tx, articleId, articleData)
|
||||||
@ -259,6 +269,11 @@ func (r *Article) AddArticle(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if req.VoteNum < 0 {
|
||||||
|
responses.FailWithMessage("票数需大于0", c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// 开始事务
|
// 开始事务
|
||||||
tx := global.Db.Begin()
|
tx := global.Db.Begin()
|
||||||
defer func() {
|
defer func() {
|
||||||
@ -272,7 +287,7 @@ func (r *Article) AddArticle(c *gin.Context) {
|
|||||||
article := &model.Article{
|
article := &model.Article{
|
||||||
ArticleTitle: req.ArticleTitle,
|
ArticleTitle: req.ArticleTitle,
|
||||||
ArticleStatus: req.ArticleStatus,
|
ArticleStatus: req.ArticleStatus,
|
||||||
VoteNum: 0,
|
VoteNum: req.VoteNum,
|
||||||
ArticleContent: req.ArticleContent,
|
ArticleContent: req.ArticleContent,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -142,6 +142,11 @@ func (r *Video) PutVideo(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if req.VoteNum < 0 {
|
||||||
|
responses.FailWithMessage("票数需大于0", c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// 获取订单数据
|
// 获取订单数据
|
||||||
videoDao := dao.VideoDao{}
|
videoDao := dao.VideoDao{}
|
||||||
video, err := videoDao.GetVideoById(videoId)
|
video, err := videoDao.GetVideoById(videoId)
|
||||||
@ -269,6 +274,11 @@ func (r *Video) AddVideo(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if req.VoteNum < 0 {
|
||||||
|
responses.FailWithMessage("票数需大于0", c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// 开始事务
|
// 开始事务
|
||||||
tx := global.Db.Begin()
|
tx := global.Db.Begin()
|
||||||
defer func() {
|
defer func() {
|
||||||
|
|||||||
@ -133,6 +133,12 @@ func (r *ArticleDao) GetArticlePageSearch(req requests.GetArticlePage, page, pag
|
|||||||
// 构建查询条件
|
// 构建查询条件
|
||||||
query := global.Db.Model(&model.Article{})
|
query := global.Db.Model(&model.Article{})
|
||||||
|
|
||||||
|
// 作者
|
||||||
|
query = query.Preload("ArticleAuthor")
|
||||||
|
|
||||||
|
// 作者关联医院
|
||||||
|
query = query.Preload("ArticleAuthor.BaseHospital")
|
||||||
|
|
||||||
// 文章标题
|
// 文章标题
|
||||||
if req.ArticleTitle != "" {
|
if req.ArticleTitle != "" {
|
||||||
query = query.Where("article_title LIKE ?", "%"+req.ArticleTitle+"%")
|
query = query.Where("article_title LIKE ?", "%"+req.ArticleTitle+"%")
|
||||||
|
|||||||
@ -133,6 +133,12 @@ func (r *VideoDao) GetVideoPageSearch(req requests.GetVideoPage, page, pageSize
|
|||||||
// 构建查询条件
|
// 构建查询条件
|
||||||
query := global.Db.Model(&model.Video{})
|
query := global.Db.Model(&model.Video{})
|
||||||
|
|
||||||
|
// 作者
|
||||||
|
query = query.Preload("VideoAuthor")
|
||||||
|
|
||||||
|
// 作者关联医院
|
||||||
|
query = query.Preload("VideoAuthor.BaseHospital")
|
||||||
|
|
||||||
// 文章标题
|
// 文章标题
|
||||||
if req.VideoTitle != "" {
|
if req.VideoTitle != "" {
|
||||||
query = query.Where("video_title LIKE ?", "%"+req.VideoTitle+"%")
|
query = query.Where("video_title LIKE ?", "%"+req.VideoTitle+"%")
|
||||||
|
|||||||
@ -25,6 +25,7 @@ type GetArticlePageOrder struct {
|
|||||||
type PutArticle struct {
|
type PutArticle struct {
|
||||||
ArticleTitle string `json:"article_title" form:"article_title" label:"文章标题" validate:"required"`
|
ArticleTitle string `json:"article_title" form:"article_title" label:"文章标题" validate:"required"`
|
||||||
ArticleStatus int `json:"article_status" form:"article_status" label:"文章状态" validate:"required,oneof=1 2"` // (1:正常 2:禁用)
|
ArticleStatus int `json:"article_status" form:"article_status" label:"文章状态" validate:"required,oneof=1 2"` // (1:正常 2:禁用)
|
||||||
|
VoteNum uint `json:"vote_num" form:"vote_num" label:"票数" validate:"required"`
|
||||||
ArticleContent string `json:"article_content" form:"article_content" label:"文章内容" validate:"required"`
|
ArticleContent string `json:"article_content" form:"article_content" label:"文章内容" validate:"required"`
|
||||||
ArticleAuthor []*PutArticleAuthor `json:"article_author" form:"article_author" label:"作者" validate:"required"`
|
ArticleAuthor []*PutArticleAuthor `json:"article_author" form:"article_author" label:"作者" validate:"required"`
|
||||||
}
|
}
|
||||||
@ -39,6 +40,7 @@ type PutArticleAuthor struct {
|
|||||||
type AddArticle struct {
|
type AddArticle struct {
|
||||||
ArticleTitle string `json:"article_title" form:"article_title" label:"文章标题" validate:"required"`
|
ArticleTitle string `json:"article_title" form:"article_title" label:"文章标题" validate:"required"`
|
||||||
ArticleStatus int `json:"article_status" form:"article_status" label:"文章状态" validate:"required,oneof=1 2"` // (1:正常 2:禁用)
|
ArticleStatus int `json:"article_status" form:"article_status" label:"文章状态" validate:"required,oneof=1 2"` // (1:正常 2:禁用)
|
||||||
|
VoteNum uint `json:"vote_num" form:"vote_num" label:"票数" validate:"required"`
|
||||||
ArticleContent string `json:"article_content" form:"article_content" label:"文章内容" validate:"required"`
|
ArticleContent string `json:"article_content" form:"article_content" label:"文章内容" validate:"required"`
|
||||||
ArticleAuthor []*PutArticleAuthor `json:"article_author" form:"article_author" label:"作者" validate:"required"`
|
ArticleAuthor []*PutArticleAuthor `json:"article_author" form:"article_author" label:"作者" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user