init: web_hgcg_server 初始化提交

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-10-27 16:44:55 +08:00
co-authored by Claude Opus 4.7
commit 189556e702
627 changed files with 126228 additions and 0 deletions
+112
View File
@@ -0,0 +1,112 @@
package home
import (
"fmt"
"net/http"
"strconv"
"videoweb/app/api/proto"
"videoweb/app/service/configser"
"videoweb/app/service/translationser"
"videoweb/pub/common"
"videoweb/pub/common/log"
"videoweb/pub/common/srvdef"
"videoweb/pub/models/richtextcontentmod"
"github.com/gin-gonic/gin"
"go.mongodb.org/mongo-driver/bson"
)
// VideoTagApi 标签搜索
// @Tags 标签搜索
// @Summary 标签搜索
// @Description 标签搜索
// @Accept json
// @Produce json
// @Param param body string true "参数列表"
// @Success 200 {object} proto.HomeHtmlData "成功"
// @Failure 400 {string} string "获取失败的返回结果"
// @Security ApiKeyAuth
// @Router /richtext/:id [get]
func RichtextApi(c *gin.Context) {
data := proto.RichTextHtmlData{
Path: c.Request.URL.Path,
Translations: translationser.GetTranslationData(),
BottonTranslations: translationser.GetTranslationBottomList(),
Config: configser.GetConfigInfo(),
Advitise: configser.GetAdvitise(),
}
richtextStr := c.Param("id")
richtextId, err := strconv.ParseInt(richtextStr, 10, 64)
if err != nil || richtextId < 1 {
common.ServerJSON(c, srvdef.NotFound, "")
return
}
richtextDate, serr := richtextData(c, richtextId)
if serr != nil {
common.ServerJSON(c, serr.Code, "richtext param error")
return
}
data.CompletePath = fmt.Sprintf("/richtext/%d", richtextId)
data.RichTextInfo = richtextDate
common.JSONWriterCache(c, srvdef.Success, data)
}
// PageNotFound 404
// @Tags 404
// @Summary 404
// @Description 404
// @Accept json
// @Produce json
// @Param param body string true "参数列表"
// @Success 200 {string} string "成功"
// @Failure 400 {string} string "获取失败的返回结果"
// @Security ApiKeyAuth
func PageNotFound(c *gin.Context) {
data := proto.NotFoundHtmlData{
Path: c.Request.URL.Path,
Translations: translationser.GetTranslationData(),
BottonTranslations: translationser.GetTranslationBottomList(),
Config: configser.GetConfigInfo(),
Advitise: configser.GetAdvitise(),
}
data.CompletePath = c.Request.URL.Path
c.JSON(http.StatusOK, data)
//common.ServerJSON(c, srvdef.Success, data)
//c.HTML(404, "404", gin.H{
// "data": data,
//})
}
func UrlRedirect(c *gin.Context) {
data := proto.UrlRedirectData{
Path: c.Request.URL.Path,
CompletePath: c.Request.URL.Path,
Translations: translationser.GetTranslationData(),
BottonTranslations: translationser.GetTranslationBottomList(),
Config: configser.GetConfigInfo(),
Advitise: configser.GetAdvitise(),
}
url := c.Query("url")
data.UrlRedirect = url
common.ServerJSON(c, srvdef.Success, data)
}
func richtextData(ctx *gin.Context, richtextId int64) (proto.RichTextInfo, *srvdef.SrvErr) {
filter := bson.M{
richtextcontentmod.FN.RichTextContentModel.Id: richtextId,
}
richtextInfo, serr := richtextcontentmod.FindOneRichTextContentModelModel(ctx, filter)
if serr != nil {
log.Error("richtextData", log.Any("filter", filter), log.E(serr))
return proto.RichTextInfo{}, serr
}
return proto.RichTextInfo{
Id: richtextInfo.Id,
Title: richtextInfo.Title,
Content: richtextInfo.Content,
Desc: richtextInfo.Desc,
SeoInfo: richtextInfo.SeoInfo,
}, nil
}