package server import ( "enterprise/common/config" "enterprise/server/controller" "github.com/gin-gonic/gin" ) func initRoutge(engine *gin.Engine) { qyweixin := new(controller.QyWeixin) staff := new(controller.Staff) base := new(controller.Base) checkin := new(controller.StaffCheckin) apiGroup := engine.Group("/api") noTokenGroup := engine.Group("/api") group := engine.Group("/").Use(base.Recovery).Use(base.Before) apiGroup.Use(base.Recovery).Use(base.Before).Use(base.Token) noTokenGroup.Use(base.Recovery).Use(base.Before) noTokenGroup.Any("/qyweixin/approve/:cid", qyweixin.Approve) noTokenGroup.Any("/qyweixin/pay/:cid", qyweixin.Pay) noTokenGroup.Any("/qyweixin/handle/refund", qyweixin.HandleRefund) group.GET("/staff/salary", staff.Salary) group.GET("/staff/sync/salary", staff.SyncStaffSalary) apiGroup.GET("/checkin", checkin.List) apiGroup.DELETE("/checkin", checkin.Delete) apiGroup.Any("/checkin/sync", checkin.Sync) noTokenGroup.POST("/login", staff.Login) engine.LoadHTMLGlob("conf/template/*") } func Start() error { cfg := config.GetConfig() engine := gin.New() initRoutge(engine) return engine.Run(cfg.Server.Address) }