12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- package api
- import (
- "box-cost/db/repo"
- "fmt"
- "github.com/gin-gonic/gin"
- )
- func RegRouters(svc *Service) {
- boxcost := svc.NewGinRouter("/" + svc.Conf.Name)
- boxcost.group.Use(Logger())
-
- boxcost.POST("/save/policy", ServiceObsUploadPolicy)
- boxcost.GET("/printr", Printr)
-
-
-
- Material(boxcost)
-
- Craft(boxcost)
-
- Supplier(boxcost)
-
- SupplierPrice(boxcost)
-
- Pack(boxcost)
-
- ProductPlan(boxcost)
-
- Bill(boxcost)
-
- BillProduce(boxcost)
-
- BillProduct(boxcost)
-
- Setting(boxcost)
-
- Signature(boxcost)
-
- Report(boxcost)
-
- Product(boxcost)
- boxcost.GET("/apk/version", func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
- out, err := repo.RepoPageSearch(apictx.CreateRepoCtx(), &repo.PageSearchOptions{
- CollectName: "versions",
- Page: 1,
- Size: 10,
- Sort: repo.Map{"releaseDate": -1},
- })
- c.JSON(200, out.List)
- return nil, err
- })
- }
- func Logger() gin.HandlerFunc {
- return func(c *gin.Context) {
-
-
-
- c.Next()
-
-
-
-
- path := c.Request.URL.Path
- clientIP := c.ClientIP()
-
-
- out := fmt.Sprintf("%15s=> %s", clientIP, path)
- fmt.Println(out)
- }
- }
|