WIP: Full restruct, seprate service and api
Signed-off-by: Asai Neko <sugar@sne.moe>
This commit is contained in:
8
api/auth/handler.go
Normal file
8
api/auth/handler.go
Normal file
@@ -0,0 +1,8 @@
|
||||
package auth
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func ApiHandler(r *gin.RouterGroup) {
|
||||
}
|
||||
11
api/event/handler.go
Normal file
11
api/event/handler.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package event
|
||||
|
||||
import (
|
||||
"nixcn-cms/middleware"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func ApiHandler(r *gin.RouterGroup) {
|
||||
r.Use(middleware.ApiVersionCheck(), middleware.JWTAuth(), middleware.Permission(10))
|
||||
}
|
||||
17
api/handler.go
Normal file
17
api/handler.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"nixcn-cms/api/auth"
|
||||
"nixcn-cms/api/event"
|
||||
"nixcn-cms/api/kyc"
|
||||
"nixcn-cms/api/user"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func Handler(r *gin.RouterGroup) {
|
||||
auth.ApiHandler(r.Group("/auth"))
|
||||
user.ApiHandler(r.Group("/user"))
|
||||
event.ApiHandler(r.Group("/event"))
|
||||
kyc.ApiHandler(r.Group("/kyc"))
|
||||
}
|
||||
11
api/kyc/handler.go
Normal file
11
api/kyc/handler.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package kyc
|
||||
|
||||
import (
|
||||
"nixcn-cms/middleware"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func ApiHandler(r *gin.RouterGroup) {
|
||||
r.Use(middleware.ApiVersionCheck(), middleware.JWTAuth(), middleware.Permission(10))
|
||||
}
|
||||
6
api/user/create.go
Normal file
6
api/user/create.go
Normal file
@@ -0,0 +1,6 @@
|
||||
package user
|
||||
|
||||
import "github.com/gin-gonic/gin"
|
||||
|
||||
func (self *UserHandler) Create(c *gin.Context) {
|
||||
}
|
||||
7
api/user/full.go
Normal file
7
api/user/full.go
Normal file
@@ -0,0 +1,7 @@
|
||||
package user
|
||||
|
||||
import "github.com/gin-gonic/gin"
|
||||
|
||||
func (self *UserHandler) Full(c *gin.Context) {
|
||||
|
||||
}
|
||||
24
api/user/handler.go
Normal file
24
api/user/handler.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"nixcn-cms/middleware"
|
||||
"nixcn-cms/service"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type UserHandler struct {
|
||||
svc service.UserService
|
||||
}
|
||||
|
||||
func ApiHandler(r *gin.RouterGroup) {
|
||||
userSvc := service.NewUserService()
|
||||
userHandler := &UserHandler{userSvc}
|
||||
|
||||
r.Use(middleware.ApiVersionCheck(), middleware.JWTAuth(), middleware.Permission(5))
|
||||
r.GET("/info", userHandler.Info)
|
||||
r.PATCH("/update", userHandler.Update)
|
||||
r.GET("/list", middleware.Permission(20), userHandler.List)
|
||||
r.POST("/full", middleware.Permission(40), userHandler.Full)
|
||||
r.POST("/create", middleware.Permission(50), userHandler.Create)
|
||||
}
|
||||
6
api/user/info.go
Normal file
6
api/user/info.go
Normal file
@@ -0,0 +1,6 @@
|
||||
package user
|
||||
|
||||
import "github.com/gin-gonic/gin"
|
||||
|
||||
func (self *UserHandler) Info(c *gin.Context) {
|
||||
}
|
||||
7
api/user/list.go
Normal file
7
api/user/list.go
Normal file
@@ -0,0 +1,7 @@
|
||||
package user
|
||||
|
||||
import "github.com/gin-gonic/gin"
|
||||
|
||||
func (self *UserHandler) List(c *gin.Context) {
|
||||
|
||||
}
|
||||
7
api/user/update.go
Normal file
7
api/user/update.go
Normal file
@@ -0,0 +1,7 @@
|
||||
package user
|
||||
|
||||
import "github.com/gin-gonic/gin"
|
||||
|
||||
func (self *UserHandler) Update(c *gin.Context) {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user