1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- package api
- import (
- "fmt"
- "github.com/gin-gonic/gin"
- )
- // RegRouters 注册路由
- func RegRouters(svc *Service) {
- boxcost := svc.NewGinRouter("/" + svc.Conf.Name)
- boxcost.group.Use(Logger())
- boxcost.GET("/printr", Printr)
- // 材料管理
- Material(boxcost)
- // 工艺管理
- Craft(boxcost)
- // 工序管理
- Process(boxcost)
- // 供应商管理
- Supplier(boxcost)
- // 供应商价格管理
- SupplierPrice(boxcost)
- // 包装管理
- Pack(boxcost)
- // 生产计划管理
- ProductPlan(boxcost)
- // 单据管理
- Bill(boxcost)
- //设置
- Setting(boxcost)
- }
- func Logger() gin.HandlerFunc {
- return func(c *gin.Context) {
- // 开始时间
- // start := time.Now()
- // 处理请求
- c.Next()
- // 结束时间
- // end := time.Now()
- //执行时间
- // latency := end.Sub(start)
- path := c.Request.URL.Path
- clientIP := c.ClientIP()
- // method := c.Request.Method
- // statusCode := c.Writer.Status()
- out := fmt.Sprintf("%15s=> %s", clientIP, path)
- fmt.Println(out)
- }
- }
|