You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.3 KiB

package serve
import (
"moredoc/biz"
"moredoc/middleware/auth"
"moredoc/model"
"github.com/gin-gonic/gin"
"go.uber.org/zap"
)
// RegisterGinRouter 注册gin路由
func RegisterGinRouter(app *gin.Engine, dbModel *model.DBModel, logger *zap.Logger, auth *auth.Auth) (err error) {
attachmentAPIService := biz.NewAttachmentAPIService(dbModel, logger)
app.GET("/favicon.ico", attachmentAPIService.Favicon)
app.GET("/static/images/logo.png", attachmentAPIService.Logo)
app.GET("/sitemap.xml", func(ctx *gin.Context) {
ctx.File("./sitemap/sitemap.xml")
})
app.GET("/view/page/:hash/:page", attachmentAPIService.ViewDocumentPages)
app.GET("/view/cover/:hash", attachmentAPIService.ViewDocumentCover)
app.GET("/download/:jwt", attachmentAPIService.DownloadDocument)
checkPermissionGroup := app.Group("/api/v1/upload")
checkPermissionGroup.Use(auth.AuthGin())
{
checkPermissionGroup.POST("avatar", attachmentAPIService.UploadAvatar)
checkPermissionGroup.POST("config", attachmentAPIService.UploadConfig)
checkPermissionGroup.POST("banner", attachmentAPIService.UploadBanner)
checkPermissionGroup.POST("document", attachmentAPIService.UploadDocument)
checkPermissionGroup.POST("category", attachmentAPIService.UploadCategory)
checkPermissionGroup.POST("article", attachmentAPIService.UploadArticle)
}
return
}