附近小店
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 

73 linhas
2.0 KiB

  1. package router
  2. import (
  3. "applet/app/cfg"
  4. "applet/app/hdl"
  5. "applet/app/mw"
  6. _ "applet/docs"
  7. "github.com/gin-gonic/gin"
  8. )
  9. // 初始化路由
  10. // 1
  11. func Init() *gin.Engine {
  12. // debug, release, test 项目阶段
  13. mode := "release"
  14. if cfg.Debug {
  15. mode = "debug"
  16. }
  17. gin.SetMode(mode)
  18. //创建一个新的启动器
  19. r := gin.New()
  20. r.Use(mw.ChangeHeader)
  21. // 是否打印访问日志, 在非正式环境都打印
  22. if mode != "release" {
  23. r.Use(gin.Logger())
  24. }
  25. r.Use(gin.Recovery())
  26. r.GET("/favicon.ico", func(c *gin.Context) {
  27. c.Status(204)
  28. })
  29. r.NoRoute(func(c *gin.Context) {
  30. c.JSON(404, gin.H{"code": 404, "msg": "page not found", "data": []struct{}{}})
  31. })
  32. r.NoMethod(func(c *gin.Context) {
  33. c.JSON(405, gin.H{"code": 405, "msg": "method not allowed", "data": []struct{}{}})
  34. })
  35. r.Use(mw.Cors)
  36. routeCommunityTeam(r.Group("/api/v1/communityTeam"))
  37. return r
  38. }
  39. func routeCommunityTeam(r *gin.RouterGroup) {
  40. r.Use(mw.DB) // 下面接口再根据mid 获取数据库名
  41. r.Use(mw.CheckBody) //body参数转换
  42. r.Use(mw.CheckSign) //签名校验
  43. r.Use(mw.Checker)
  44. r.GET("/cate", hdl.Cate)
  45. r.GET("/bank/store/cate", hdl.BankStoreCate)
  46. r.POST("/bank/store/list", hdl.BankStore)
  47. r.POST("/store", hdl.Store)
  48. // 用户授权后调用的接口
  49. r.Use(mw.AuthJWT)
  50. r.POST("/store/addLike", hdl.StoreAddLike)
  51. r.POST("/store/cancelLike", hdl.StoreCancelLike)
  52. r.POST("/goods", hdl.Goods)
  53. r.POST("/goods/sku", hdl.GoodsSku)
  54. r.POST("/goods/coupon", hdl.GoodsCoupon)
  55. r.POST("/order/total", hdl.OrderTotal)
  56. r.POST("/order/create", hdl.OrderCreate)
  57. r.POST("/order/cancel", hdl.OrderCancel)
  58. r.POST("/order/coupon", hdl.OrderCoupon)
  59. r.POST("/order/list", hdl.OrderList)
  60. r.POST("/order/detail", hdl.OrderDetail)
  61. r.GET("/order/cate", hdl.OrderCate)
  62. r.POST("/pay/:payMethod/:orderType", hdl.Pay)
  63. r.POST("/store/order/list", hdl.StoreOrderList)
  64. r.POST("/store/order/detail", hdl.StoreOrderDetail)
  65. r.POST("/store/order/confirm", hdl.StoreOrderConfirm)
  66. r.GET("/store/order/cate", hdl.StoreOrderCate)
  67. }