router.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. //加工单据
  30. BillProduce(boxcost)
  31. //成品采购
  32. BillProduct(boxcost)
  33. //设置
  34. Setting(boxcost)
  35. // 签名管理
  36. Signature(boxcost)
  37. // 统计报表
  38. Report(boxcost)
  39. // 成品采购管理
  40. Product(boxcost)
  41. }
  42. func Logger() gin.HandlerFunc {
  43. return func(c *gin.Context) {
  44. // 开始时间
  45. // start := time.Now()
  46. // 处理请求
  47. c.Next()
  48. // 结束时间
  49. // end := time.Now()
  50. //执行时间
  51. // latency := end.Sub(start)
  52. path := c.Request.URL.Path
  53. clientIP := c.ClientIP()
  54. // method := c.Request.Method
  55. // statusCode := c.Writer.Status()
  56. out := fmt.Sprintf("%15s=> %s", clientIP, path)
  57. fmt.Println(out)
  58. }
  59. }