material.go 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. package routers
  2. import (
  3. "zhiyuan/controllers/admin"
  4. adminBid "zhiyuan/controllers/admin/material/bid"
  5. adminPick "zhiyuan/controllers/admin/material/pick"
  6. "zhiyuan/controllers/material"
  7. "zhiyuan/controllers/material/bid"
  8. "zhiyuan/controllers/material/pick"
  9. "zhiyuan/controllers/material/pkg"
  10. "zhiyuan/middlewares"
  11. "zhiyuan/models"
  12. "zhiyuan/models/calc"
  13. "zhiyuan/pkg/db"
  14. "github.com/gin-gonic/gin"
  15. )
  16. func InitMaterialRouters(r *gin.Engine, router *gin.RouterGroup) {
  17. staticPath := "public/material/"
  18. r.Static("/material/static", staticPath+"static")
  19. r.StaticFile("/material", staticPath+"index.html")
  20. r.StaticFile("/material/favicon.ico", staticPath+"favicon.ico")
  21. calcStaticPath := "public/calc/"
  22. r.Static("/calc/static", calcStaticPath+"static")
  23. r.StaticFile("/calc", calcStaticPath+"index.html")
  24. r.StaticFile("/calc/favicon.ico", calcStaticPath+"favicon.ico")
  25. router = router.Group("/material")
  26. router.POST("/login", material.Login)
  27. router.GET("/items", material.ItemList)
  28. router.GET("/pkgs/:id", pkg.PkgInfo)
  29. router.Use(middlewares.Auth("material"))
  30. {
  31. router.GET("/item_types", material.TypeList)
  32. router.GET("/brands", material.BrandList)
  33. router.GET("/pkgs", pkg.PkgList)
  34. router.GET("/params", admin.ParamList)
  35. router.GET("/picks/:id", pick.PickInfo)
  36. router.GET("/picks", pick.PickList)
  37. router.POST("/pick/orders", pick.OrderAdd)
  38. router.GET("/pick/orders", pick.OrderList)
  39. router.PUT("/pick/orders/:id", pick.OrderEdit)
  40. router.GET("/pick/orders/:id/export", adminPick.OrderExport)
  41. router.GET("/pick/orders/:id", pick.OrderInfo)
  42. router.GET("/bids", bid.BidList)
  43. router.GET("/bid/outline", bid.BidOutline)
  44. router.POST("/bid/outline_calc", bid.BidOutlineCalc)
  45. router.GET("/bid/detail", bid.BidDetail)
  46. router.GET("/bid/orders", bid.OrderList)
  47. router.GET("/bid/export", adminBid.BidExport)
  48. router.POST("/bid/orders", bid.OrderAdd)
  49. router.DELETE("/bid/orders/:id", bid.OrderDel)
  50. router.PUT("/bid/orders/:id", bid.OrderEdit)
  51. router.GET("/bid/orders/:id", bid.OrderInfo)
  52. router.POST("/bid/detail_calc", bid.BidDetailCalc)
  53. router.POST("/bid/detail_calc_toilet", bid.BidDetailCalcToilet)
  54. router.GET("/bid/orders/:id/export", adminBid.OrderExport)
  55. router.PUT("/password", material.Password)
  56. router.GET("/info", material.Info)
  57. router.POST("/logout", material.Logout)
  58. router.GET("/regions", admin.RegionList)
  59. router.POST("/calcs", material.CalcList)
  60. router.POST("/calc/:id", material.CalcInfo)
  61. router.POST("/calc", material.Calc)
  62. router.POST("/type/:id", func(c *gin.Context) {
  63. db.ModelOne(db.Type(calc.ProductType{}), c)
  64. })
  65. router.POST("/products", func(c *gin.Context) {
  66. db.ModelList(db.Type(struct {
  67. calc.Product
  68. Property string `json:"property" label:"属性" prop:"select:false"`
  69. Details string `json:"details" label:"产品详情" prop:"select:false"`
  70. }{}), map[string]interface{}{}, c)
  71. })
  72. router.POST("/orders", func(c *gin.Context) {
  73. db.ModelList(db.Type(calc.Order{}), map[string]interface{}{
  74. "adminId": c.GetInt("adminID"),
  75. }, c)
  76. })
  77. router.POST("/order/:id", material.OrderInfo)
  78. router.POST("/order/edit/:id", material.OrderEdit)
  79. router.POST("/order/del/:id", func(c *gin.Context) {
  80. db.ModelDel(db.Type(calc.Order{}), c)
  81. })
  82. router.POST("/calcfiles", func(c *gin.Context) {
  83. db.ModelList(db.Type(calc.File{}), map[string]interface{}{}, c)
  84. })
  85. router.GET("/order/:id/export/:fid", admin.OrderExport)
  86. router.POST("/upgradepkgs", func(c *gin.Context) {
  87. db.ModelList(db.Type(models.UpgradePkg{}), map[string]interface{}{
  88. "state": 1,
  89. }, c)
  90. })
  91. router.POST("/upgradepkg/:id", func(c *gin.Context) {
  92. db.ModelOne(db.Type(models.UpgradePkg{}), c)
  93. })
  94. router.POST("/upgradeitems", func(c *gin.Context) {
  95. db.ModelList(db.Type(models.UpgradeItem{}), map[string]interface{}{
  96. "state": 1,
  97. }, c)
  98. })
  99. }
  100. }