router.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. package api
  2. import (
  3. "fmt"
  4. "github.com/gin-gonic/gin"
  5. )
  6. // RegRouters 注册路由
  7. func RegRouters(svc *Service) {
  8. boxcost := svc.NewGinRouter("/" + svc.Conf.Name)
  9. boxcost.group.Use(Logger())
  10. //数据存储
  11. boxcost.POST("/save/policy", ServiceObsUploadPolicy)
  12. boxcost.GET("/printr", Printr)
  13. // 材料管理
  14. Material(boxcost)
  15. // 工艺管理
  16. Craft(boxcost)
  17. // 工序管理
  18. Process(boxcost)
  19. // 供应商管理
  20. Supplier(boxcost)
  21. // 供应商价格管理
  22. SupplierPrice(boxcost)
  23. // 包装管理
  24. Pack(boxcost)
  25. // 生产计划管理
  26. ProductPlan(boxcost)
  27. // 单据管理
  28. Bill(boxcost)
  29. BillProduce(boxcost)
  30. //设置
  31. Setting(boxcost)
  32. }
  33. func Logger() gin.HandlerFunc {
  34. return func(c *gin.Context) {
  35. // 开始时间
  36. // start := time.Now()
  37. // 处理请求
  38. c.Next()
  39. // 结束时间
  40. // end := time.Now()
  41. //执行时间
  42. // latency := end.Sub(start)
  43. path := c.Request.URL.Path
  44. clientIP := c.ClientIP()
  45. // method := c.Request.Method
  46. // statusCode := c.Writer.Status()
  47. out := fmt.Sprintf("%15s=> %s", clientIP, path)
  48. fmt.Println(out)
  49. }
  50. }