package routers import ( "zhiyuan/controllers/admin" adminBid "zhiyuan/controllers/admin/material/bid" adminPick "zhiyuan/controllers/admin/material/pick" "zhiyuan/controllers/material" "zhiyuan/controllers/material/bid" "zhiyuan/controllers/material/pick" "zhiyuan/controllers/material/pkg" "zhiyuan/middlewares" "zhiyuan/models" "zhiyuan/models/calc" "zhiyuan/pkg/db" "github.com/gin-gonic/gin" ) func InitMaterialRouters(r *gin.Engine, router *gin.RouterGroup) { staticPath := "public/material/" r.Static("/material/static", staticPath+"static") r.StaticFile("/material", staticPath+"index.html") r.StaticFile("/material/favicon.ico", staticPath+"favicon.ico") calcStaticPath := "public/calc/" r.Static("/calc/static", calcStaticPath+"static") r.StaticFile("/calc", calcStaticPath+"index.html") r.StaticFile("/calc/favicon.ico", calcStaticPath+"favicon.ico") router = router.Group("/material") router.POST("/login", material.Login) router.GET("/items", material.ItemList) router.GET("/pkgs/:id", pkg.PkgInfo) router.Use(middlewares.Auth("material")) { router.GET("/item_types", material.TypeList) router.GET("/brands", material.BrandList) router.GET("/pkgs", pkg.PkgList) router.GET("/params", admin.ParamList) router.GET("/picks/:id", pick.PickInfo) router.GET("/picks", pick.PickList) router.POST("/pick/orders", pick.OrderAdd) router.GET("/pick/orders", pick.OrderList) router.PUT("/pick/orders/:id", pick.OrderEdit) router.GET("/pick/orders/:id/export", adminPick.OrderExport) router.GET("/pick/orders/:id", pick.OrderInfo) router.GET("/bids", bid.BidList) router.GET("/bid/outline", bid.BidOutline) router.POST("/bid/outline_calc", bid.BidOutlineCalc) router.GET("/bid/detail", bid.BidDetail) router.GET("/bid/orders", bid.OrderList) router.GET("/bid/export", adminBid.BidExport) router.POST("/bid/orders", bid.OrderAdd) router.DELETE("/bid/orders/:id", bid.OrderDel) router.PUT("/bid/orders/:id", bid.OrderEdit) router.GET("/bid/orders/:id", bid.OrderInfo) router.POST("/bid/detail_calc", bid.BidDetailCalc) router.POST("/bid/detail_calc_toilet", bid.BidDetailCalcToilet) router.GET("/bid/orders/:id/export", adminBid.OrderExport) router.PUT("/password", material.Password) router.GET("/info", material.Info) router.POST("/logout", material.Logout) router.GET("/regions", admin.RegionList) router.POST("/calcs", material.CalcList) router.POST("/calc/:id", material.CalcInfo) router.POST("/calc", material.Calc) router.POST("/type/:id", func(c *gin.Context) { db.ModelOne(db.Type(calc.ProductType{}), c) }) router.POST("/products", func(c *gin.Context) { db.ModelList(db.Type(struct { calc.Product Property string `json:"property" label:"属性" prop:"select:false"` Details string `json:"details" label:"产品详情" prop:"select:false"` }{}), map[string]interface{}{}, c) }) router.POST("/orders", func(c *gin.Context) { db.ModelList(db.Type(calc.Order{}), map[string]interface{}{ "adminId": c.GetInt("adminID"), }, c) }) router.POST("/order/:id", material.OrderInfo) router.POST("/order/edit/:id", material.OrderEdit) router.POST("/order/del/:id", func(c *gin.Context) { db.ModelDel(db.Type(calc.Order{}), c) }) router.POST("/calcfiles", func(c *gin.Context) { db.ModelList(db.Type(calc.File{}), map[string]interface{}{}, c) }) router.GET("/order/:id/export/:fid", admin.OrderExport) router.POST("/upgradepkgs", func(c *gin.Context) { db.ModelList(db.Type(models.UpgradePkg{}), map[string]interface{}{ "state": 1, }, c) }) router.POST("/upgradepkg/:id", func(c *gin.Context) { db.ModelOne(db.Type(models.UpgradePkg{}), c) }) router.POST("/upgradeitems", func(c *gin.Context) { db.ModelList(db.Type(models.UpgradeItem{}), map[string]interface{}{ "state": 1, }, c) }) } }