router.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. func Logger() gin.HandlerFunc {
  38. return func(c *gin.Context) {
  39. // 开始时间
  40. // start := time.Now()
  41. // 处理请求
  42. c.Next()
  43. // 结束时间
  44. // end := time.Now()
  45. //执行时间
  46. // latency := end.Sub(start)
  47. path := c.Request.URL.Path
  48. clientIP := c.ClientIP()
  49. // method := c.Request.Method
  50. // statusCode := c.Writer.Status()
  51. out := fmt.Sprintf("%15s=> %s", clientIP, path)
  52. fmt.Println(out)
  53. }
  54. }