router.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. // boxcost.GET("/genData", GenData)
  14. // boxcost.GET("/searchData", SearchData)
  15. // 材料管理
  16. Material(boxcost)
  17. // 工艺管理
  18. Craft(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. Signature(boxcost)
  34. // 统计报表
  35. Report(boxcost)
  36. // 工序管理
  37. Process(boxcost)
  38. }
  39. func Logger() gin.HandlerFunc {
  40. return func(c *gin.Context) {
  41. // 开始时间
  42. // start := time.Now()
  43. // 处理请求
  44. c.Next()
  45. // 结束时间
  46. // end := time.Now()
  47. //执行时间
  48. // latency := end.Sub(start)
  49. path := c.Request.URL.Path
  50. clientIP := c.ClientIP()
  51. // method := c.Request.Method
  52. // statusCode := c.Writer.Status()
  53. out := fmt.Sprintf("%15s=> %s", clientIP, path)
  54. fmt.Println(out)
  55. }
  56. }