router.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. Supplier(boxcost)
  19. // 供应商价格管理
  20. SupplierPrice(boxcost)
  21. // 包装管理
  22. Pack(boxcost)
  23. // 生产计划管理
  24. ProductPlan(boxcost)
  25. // 单据管理
  26. Bill(boxcost)
  27. BillProduce(boxcost)
  28. //设置
  29. Setting(boxcost)
  30. // 签名管理
  31. Signature(boxcost)
  32. // 统计报表
  33. Report(boxcost)
  34. }
  35. func Logger() gin.HandlerFunc {
  36. return func(c *gin.Context) {
  37. // 开始时间
  38. // start := time.Now()
  39. // 处理请求
  40. c.Next()
  41. // 结束时间
  42. // end := time.Now()
  43. //执行时间
  44. // latency := end.Sub(start)
  45. path := c.Request.URL.Path
  46. clientIP := c.ClientIP()
  47. // method := c.Request.Method
  48. // statusCode := c.Writer.Status()
  49. out := fmt.Sprintf("%15s=> %s", clientIP, path)
  50. fmt.Println(out)
  51. }
  52. }