init: 初始化 web_hgdjb_server 项目

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-11-07 10:47:32 +08:00
co-authored by Claude Opus 4.7
commit f13d33af4d
707 changed files with 147705 additions and 0 deletions
+17
View File
@@ -0,0 +1,17 @@
package router
import (
"videoweb/web/api/web_announcement"
"github.com/gin-gonic/gin"
)
func announcementRouter(router *gin.RouterGroup) {
group := router.Group("/announcement")
{
group.POST("/list", web_announcement.AnnouncementList)
group.POST("/add", web_announcement.AnnouncementAdd)
group.POST("/del", web_announcement.AnnouncementDel)
group.POST("/update", web_announcement.AnnouncementUpdate)
}
}
+23
View File
@@ -0,0 +1,23 @@
package router
import (
webanalytics "videoweb/web/api/web_analytics"
"videoweb/web/api/web_cfg"
"github.com/gin-gonic/gin"
)
func syscfgRouter(router *gin.RouterGroup) {
system := router.Group("/syscfg")
{
system.GET("/get", web_cfg.GetCfg)
system.POST("/update", web_cfg.UpdateCfg)
system.POST("/appkey", web_cfg.SetAppKey)
}
stat := router.Group("/stat")
{
stat.GET("/analytics", webanalytics.GetAnalyticsStat)
stat.GET("/daily/analytics", webanalytics.GetAnalyticsDailyStat)
}
}
+15
View File
@@ -0,0 +1,15 @@
package router
import (
"videoweb/web/api/web_card"
"github.com/gin-gonic/gin"
)
func cardRouter(router *gin.RouterGroup) {
card := router.Group("/card")
{
card.POST("/order/list", web_card.GetOrders)
card.POST("/order/district/sync", web_card.SyncDistrictCode)
}
}
+14
View File
@@ -0,0 +1,14 @@
package router
import (
"videoweb/web/api/web_coin"
"github.com/gin-gonic/gin"
)
func coinRouter(router *gin.RouterGroup) {
coin := router.Group("/coin")
{
coin.POST("/trans", web_coin.GetCoinTrans)
}
}
+19
View File
@@ -0,0 +1,19 @@
package router
import (
"videoweb/web/api/web_commend"
"github.com/gin-gonic/gin"
)
func commentRouter(router *gin.RouterGroup) {
group := router.Group("/post")
{
group.POST("/comment/list", web_commend.SearchManyCommend)
group.POST("/comment/replay", web_commend.ReplayPostComment)
group.POST("/comment/del", web_commend.DelCommend)
group.POST("/comment/user/del", web_commend.DelUserCommend)
group.POST("/comment/reviewBatch", web_commend.ReviewCommendBatch)
group.POST("/comment/review", web_commend.ReviewComment)
}
}
+15
View File
@@ -0,0 +1,15 @@
package router
import (
"videoweb/web/api/web_contactus"
"github.com/gin-gonic/gin"
)
func contactUsRouter(router *gin.RouterGroup) {
group := router.Group("/contactus")
{
group.GET("/list", web_contactus.List)
group.POST("/handle", web_contactus.Handle)
}
}
+17
View File
@@ -0,0 +1,17 @@
package router
import (
"videoweb/web/api/web_detailnav"
"github.com/gin-gonic/gin"
)
func detailNavRouter(router *gin.RouterGroup) {
group := router.Group("/detailnav")
{
group.POST("/list", web_detailnav.DetailNavList)
group.POST("/add", web_detailnav.DetailNavAdd)
group.POST("/del", web_detailnav.DetailNavDel)
group.POST("/update", web_detailnav.DetailNavUpdate)
}
}
+15
View File
@@ -0,0 +1,15 @@
package router
import (
"videoweb/web/api/web_feedback"
"github.com/gin-gonic/gin"
)
func feedbackRouter(router *gin.RouterGroup) {
group := router.Group("/feedback")
{
group.GET("/list", web_feedback.List)
group.POST("/handle", web_feedback.Handle)
}
}
+16
View File
@@ -0,0 +1,16 @@
package router
import (
"videoweb/web/api/web_file"
"github.com/gin-gonic/gin"
)
func fileRouter(router *gin.RouterGroup) {
// 文件上传
file := router.Group("/file")
{
file.POST("/uploadImg", web_file.UploadImage)
file.POST("/uploadImgs", web_file.UploadImages)
}
}
+121
View File
@@ -0,0 +1,121 @@
package router
import (
"fmt"
"net/http"
"videoweb/pub/common/errors"
"videoweb/pub/common/log"
"videoweb/pub/common/useragent"
"videoweb/web/middleware/auth"
"videoweb/web/middleware/cors"
"videoweb/web/middleware/ipblacklist"
"videoweb/web/middleware/limitHandler"
"videoweb/web/webg"
swaggerFiles "github.com/swaggo/files"
ginSwagger "github.com/swaggo/gin-swagger"
"github.com/DeanThompson/ginpprof"
"github.com/gin-gonic/gin"
_ "videoweb/web/docs"
)
func Init() (engine *gin.Engine) {
// 设置启动模式
switch webg.Conf.RunMod {
case "dev":
gin.SetMode(gin.DebugMode)
case "test":
gin.SetMode(gin.TestMode)
case "prod":
gin.SetMode(gin.ReleaseMode)
default:
gin.SetMode(gin.DebugMode)
}
// 初始化gin引擎
engine = gin.Default()
engine.HandleMethodNotAllowed = true
engine.MaxMultipartMemory = 60 << 20
engine.NoMethod(noMethod)
engine.NoRoute(noRoute)
// 注册中间件
registeMiddleware(engine)
wbVideoDataRouter(engine)
registerRouter(engine)
log.Info("setGinSwaggerxxxxx")
if webg.Conf.RunMod != "prod" {
log.Info("setGinSwagger")
setGinSwagger(engine)
log.Info("setGinSwagger end")
}
// 是否开启监控服务
if webg.Conf.Pprof {
ginpprof.Wrap(engine)
}
return
}
func noMethod(c *gin.Context) {
c.JSON(http.StatusMethodNotAllowed, errors.MakeWithMsg(errors.MethodNotFound, "MethodNotFound"))
}
func noRoute(c *gin.Context) {
c.JSON(http.StatusNotFound, errors.MakeWithMsg(errors.ApiNotFound, "ApiNotFound"))
}
func registeMiddleware(engine *gin.Engine) {
engine.Use(gin.Recovery())
engine.Use(cors.Cors(&cors.Options{
Origin: nil, // "*"
Methods: []string{http.MethodGet, http.MethodPost, http.MethodPut, http.MethodHead, http.MethodDelete},
AllowedHeaders: []string{"Content-Length", "Content-Type", "Authorization", "X-User-Agent", useragent.SDKCommonHeader},
ExposedHeaders: []string{"Content-Disposition", "Refresh-Authorization"},
OptionsSuccessStatus: http.StatusOK,
}))
engine.Use(ipblacklist.IpBlackListMiddleware)
engine.Use(auth.Auth)
engine.Use(limitHandler.LoginLimit)
engine.Use(auth.OperateLog)
}
// 设置swag 接口信息
func setGinSwagger(router *gin.Engine) {
url := ginSwagger.URL(fmt.Sprintf("http://%s:%s/swagger/doc.json", webg.Conf.Host, webg.Conf.ListenAddr))
router.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler, url))
}
func registerRouter(router *gin.Engine) {
rootRouter := router.Group("/api/web")
{
MainWebRouter(rootRouter)
syscfgRouter(rootRouter)
fileRouter(rootRouter)
videoRouter(rootRouter)
richTextContent(rootRouter)
commentRouter(rootRouter)
ipBlackRouter(rootRouter)
detailNavRouter(rootRouter)
announcementRouter(rootRouter)
cardRouter(rootRouter)
coinRouter(rootRouter)
rechargePackageRouter(rootRouter)
userRouter(rootRouter)
translationRouter(rootRouter)
mediaResourceRouter(rootRouter)
playletRouter(rootRouter)
homeBannerRouter(rootRouter)
homeConfigRouter(rootRouter)
feedbackRouter(rootRouter)
contactUsRouter(rootRouter)
}
// 第三方回调路由(免鉴权,挂在 engine 上而非 /api/web 分组)
thirdRouter(router)
}
+17
View File
@@ -0,0 +1,17 @@
package router
import (
"videoweb/web/api/web_homebanner"
"github.com/gin-gonic/gin"
)
func homeBannerRouter(router *gin.RouterGroup) {
group := router.Group("/home/banner")
{
group.GET("/list", web_homebanner.List)
group.POST("/add", web_homebanner.Add)
group.POST("/update", web_homebanner.Update)
group.POST("/del", web_homebanner.Del)
}
}
+17
View File
@@ -0,0 +1,17 @@
package router
import (
"videoweb/web/api/web_homeconfig"
"github.com/gin-gonic/gin"
)
func homeConfigRouter(router *gin.RouterGroup) {
group := router.Group("/home/config")
{
group.GET("/list", web_homeconfig.List)
group.POST("/add", web_homeconfig.Add)
group.POST("/update", web_homeconfig.Update)
group.POST("/del", web_homeconfig.Del)
}
}
+16
View File
@@ -0,0 +1,16 @@
package router
import (
"github.com/gin-gonic/gin"
"videoweb/web/api/web_ipblack"
)
func ipBlackRouter(router *gin.RouterGroup) {
// 文件上传
group := router.Group("/ipblack")
{
group.POST("/list", web_ipblack.IpBlackList)
group.POST("/add", web_ipblack.IpBlackAdd)
group.POST("/del", web_ipblack.IpBlackDel)
}
}
+19
View File
@@ -0,0 +1,19 @@
package router
import (
"videoweb/web/api/web_mediaresource"
"github.com/gin-gonic/gin"
)
func mediaResourceRouter(router *gin.RouterGroup) {
group := router.Group("/resource")
{
group.GET("/list", web_mediaresource.ResourceList)
group.GET("/jh/list", web_mediaresource.ResourceJHList)
group.GET("/jh/chapters", web_mediaresource.ResourceJHChapters)
group.POST("/jh/import", web_mediaresource.ResourceJHImport)
group.GET("/chapters", web_mediaresource.ResourceChapters)
group.POST("/import", web_mediaresource.ResourceImport)
}
}
+53
View File
@@ -0,0 +1,53 @@
package router
import (
"videoweb/web/api/web_playlet"
"github.com/gin-gonic/gin"
)
func playletRouter(router *gin.RouterGroup) {
group := router.Group("/playlet")
{
group.GET("/home-config/topic/options", web_playlet.HomeConfigTopicOptions)
group.GET("/list", web_playlet.List)
group.GET("/sales", web_playlet.Sales)
group.POST("/add", web_playlet.Add)
group.POST("/update", web_playlet.Update)
group.POST("/del", web_playlet.Del)
group.POST("/status/set", web_playlet.SetStatus)
group.POST("/online-at/fill", web_playlet.FillOnlineAt)
group.POST("/recommend/set", web_playlet.SetRecommend)
group.POST("/featured/set", web_playlet.SetFeatured)
group.POST("/operate-type/set", web_playlet.SetOperateType)
group.POST("/banner/set", web_playlet.SetBanner)
group.POST("/theme/set", web_playlet.SetTheme)
group.POST("/tag/set", web_playlet.SetTag)
group.POST("/category/set", web_playlet.SetCategory)
group.POST("/like/virtual/set", web_playlet.SetVirtualLike)
group.POST("/pay-type/set", web_playlet.SetPayType)
group.POST("/watermark/reset", web_playlet.ResetWatermark)
group.POST("/slug/sync", web_playlet.SyncSlug)
group.GET("/chapter/list", web_playlet.ChapterList)
group.POST("/chapter/add", web_playlet.ChapterAdd)
group.POST("/chapter/update", web_playlet.ChapterUpdate)
group.POST("/chapter/del", web_playlet.ChapterDel)
group.POST("/chapter/status/fill", web_playlet.ChapterFillStatus)
group.POST("/chapter/status/set", web_playlet.ChapterSetStatus)
group.POST("/chapter/pay-type/set", web_playlet.ChapterSetPayType)
group.POST("/chapter/sync", web_playlet.ChapterSync)
group.GET("/theme/list", web_playlet.ThemeList)
group.GET("/topic-group/list", web_playlet.TopicGroupList)
group.POST("/topic-group/add", web_playlet.TopicGroupAdd)
group.POST("/topic-group/update", web_playlet.TopicGroupUpdate)
group.POST("/topic-group/del", web_playlet.TopicGroupDel)
group.POST("/theme/add", web_playlet.ThemeAdd)
group.POST("/theme/update", web_playlet.ThemeUpdate)
group.POST("/theme/recommend/set", web_playlet.SetThemeRecommend)
group.POST("/theme/del", web_playlet.ThemeDel)
group.GET("/tag/list", web_playlet.TagList)
group.POST("/tag/add", web_playlet.TagAdd)
group.POST("/tag/update", web_playlet.TagUpdate)
group.POST("/tag/del", web_playlet.TagDel)
}
}
+19
View File
@@ -0,0 +1,19 @@
package router
import (
"videoweb/web/api/web_rechargepackage"
"github.com/gin-gonic/gin"
)
func rechargePackageRouter(router *gin.RouterGroup) {
group := router.Group("/recharge/package")
{
group.POST("/list", web_rechargepackage.List)
group.POST("/vip/list", web_rechargepackage.VipList)
group.POST("/add", web_rechargepackage.Add)
group.POST("/update", web_rechargepackage.Update)
group.POST("/del", web_rechargepackage.Delete)
group.POST("/status/set", web_rechargepackage.SetStatus)
}
}
+17
View File
@@ -0,0 +1,17 @@
package router
import (
"github.com/gin-gonic/gin"
"videoweb/web/api/web_richtextcontent"
)
func richTextContent(router *gin.RouterGroup) {
// 文件上传
file := router.Group("/richtextcontent")
{
file.POST("/list", web_richtextcontent.List)
file.POST("/add", web_richtextcontent.Add)
file.POST("/del", web_richtextcontent.Del)
file.POST("/update", web_richtextcontent.Update)
}
}
+42
View File
@@ -0,0 +1,42 @@
package router
import (
"videoweb/web/api/web_acc"
"github.com/gin-gonic/gin"
)
// 主后台路由
func MainWebRouter(router *gin.RouterGroup) {
login := router.Group("/login")
{
login.POST("/acc", web_acc.AccLogin)
login.POST("/bind", web_acc.BindQurl)
login.POST("/slogin", web_acc.SLogin)
}
role := router.Group("/role")
{
role.GET("/list", web_acc.RoleGetList)
role.POST("/add", web_acc.RoleAdd)
role.POST("/del", web_acc.RoleDel)
role.GET("/getinfo", web_acc.RoleGetInfo)
role.POST("/up", web_acc.RoleUp)
role.POST("/enable", web_acc.RoleEnable)
role.POST("/drop", web_acc.RoleGetDrop)
role.GET("/getauth", web_acc.RoleGetAuth)
role.POST("/upauth", web_acc.RoleUpAuth)
}
acc := router.Group("/acc")
{
acc.GET("/list", web_acc.AccGetList)
acc.POST("/add", web_acc.AccAdd)
acc.POST("/del", web_acc.AccDel)
acc.GET("/getinfo", web_acc.AccGetInfo)
acc.POST("/up", web_acc.AccUp)
acc.GET("/getstatus", web_acc.AccGetStatus)
acc.POST("/savestatus", web_acc.AccSaveStatus)
acc.POST("/ops", web_acc.GetAccOpRecords)
acc.POST("/uppwd", web_acc.AccUpdatePwd)
}
}
+14
View File
@@ -0,0 +1,14 @@
package router
import (
"videoweb/web/api/web_recharge"
"github.com/gin-gonic/gin"
)
func thirdRouter(r *gin.Engine) {
thirdGroup := r.Group("/api/web/third")
{
thirdGroup.POST("/newpaycenter/recharge/callback", web_recharge.NewPayCenterRchgCallBack)
}
}
+24
View File
@@ -0,0 +1,24 @@
package router
import (
"videoweb/web/api/web_translation"
"github.com/gin-gonic/gin"
)
func translationRouter(router *gin.RouterGroup) {
translation := router.Group("/translation")
{
translation.POST("/list", web_translation.GetTranslation)
translation.POST("/update", web_translation.UpdateOnetTranslation)
translation.POST("/del", web_translation.DelOnetTranslation)
translation.POST("/add", web_translation.AddOnetTranslation)
}
translationcategory := router.Group("/translationcategory")
{
translationcategory.POST("/list", web_translation.GetTranslationCategory)
translationcategory.POST("/update", web_translation.UpdateOnetTranslationCategory)
translationcategory.POST("/del", web_translation.DelOnetTranslationCategory)
translationcategory.POST("/add", web_translation.AddOnetTranslationCategory)
}
}
+18
View File
@@ -0,0 +1,18 @@
package router
import (
"videoweb/web/api/web_user"
"github.com/gin-gonic/gin"
)
func userRouter(router *gin.RouterGroup) {
user := router.Group("/user")
{
user.POST("/list", web_user.GetUserList)
user.POST("/update", web_user.UpdateUser)
user.POST("/giftcoin", web_user.GiftCoin)
user.POST("/vip/update", web_user.UpdateVip)
user.POST("/resetPassword", web_user.ResetPassword)
}
}
+58
View File
@@ -0,0 +1,58 @@
package router
import (
"videoweb/web/api/web_video"
"github.com/gin-gonic/gin"
)
func videoRouter(router *gin.RouterGroup) {
advitise := router.Group("/videoinfo")
{
advitise.POST("/list", web_video.GetVideoInfo)
advitise.POST("/update", web_video.UpdateOneVideoInfo)
advitise.POST("/del", web_video.DelOneVideoInfo)
advitise.POST("/sync", web_video.SyncVideoInfo)
advitise.POST("/addcoll", web_video.AddOneVideoCollection)
advitise.POST("/setFakeWatchTimes", web_video.SetVideoFakeWatchTimes)
advitise.POST("/category/set", web_video.SetCategory)
advitise.POST("/transcode", web_video.TranscodeVideo)
advitise.POST("/slug/sync", web_video.SyncSlug)
}
videocategory := router.Group("/videocategory")
{
videocategory.POST("/list", web_video.GetVideoCategory)
videocategory.POST("/update", web_video.UpdateOneVideoCategory)
videocategory.POST("/del", web_video.DelOneVideoCategory)
videocategory.POST("/add", web_video.AddOneVideoCategory)
}
videotag := router.Group("/videotag")
{
videotag.POST("/list", web_video.GetVideoTagInfo)
videotag.POST("/update", web_video.UpdateOneVideoTagInfo)
videotag.POST("/del", web_video.DelOneVideoTagInfo)
videotag.POST("/add", web_video.AddOneVideoTagInfo)
}
videocreater := router.Group("/videocreater")
{
videocreater.POST("/list", web_video.GetVideoCreater)
videocreater.POST("/update", web_video.UpdateOneVideoCreater)
videocreater.POST("/del", web_video.DelOneVideoCreater)
videocreater.POST("/add", web_video.AddOneVideoCreater)
}
videoTopic := router.Group("/videotopic")
{
videoTopic.POST("/list", web_video.GetVideoTopic)
videoTopic.POST("/update", web_video.UpdateOneVideoTopic)
videoTopic.POST("/del", web_video.DelOneVideoTopic)
videoTopic.POST("/add", web_video.AddOneVideoTopic)
}
router.GET("/m3u8/*key", web_video.Play)
router.GET("/transm3u8/*key", web_video.TranscodeM3u8)
router.GET("/enkey", web_video.Enkey)
router.GET("/newenkey", web_video.NewEnkey)
router.GET("/lsjenkey", web_video.LsjEnkey)
router.GET("/videotag/hottag", web_video.GetVideoPlayData)
}
+20
View File
@@ -0,0 +1,20 @@
package router
import (
"videoweb/web/api/web_recharge"
"videoweb/web/api/web_video"
"videoweb/web/middleware/apilimitHandler"
"github.com/gin-gonic/gin"
)
func wbVideoDataRouter(r *gin.Engine) {
limiter := apilimitHandler.NewRouteHourlyLimiter(100)
router := r.Group("/wbapi/sgdjweb")
{
router.Use(limiter.Middleware())
//router.GET("/hottag", web_video.GetHotTagByPlayData)
router.GET("/ipstat", web_video.GetIpStatData)
router.GET("/recharge/summary", web_recharge.RechargeSummary)
}
}