123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- 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)
- boxcost.GET("/removeSyncBill", RemovePlanSyncBill)
- boxcost.GET("/callback", callback)
- boxcost.POSTJWT("/diffUpdatePlanTest", DiffUpdatePlanTest)
- boxcost.POSTJWT("/diffUpdateProduceTest", DiffUpdateProduceTest)
-
- boxcost.GETJWT("/bill/history/list", BillHistoryList)
- boxcost.GETJWT("/plan/history/list", PlanHistoryList)
- boxcost.GETJWT("/bill/history/detail/:id", GetBillHistory)
- boxcost.GETJWT("/plan/history/detail/:id", GetPlanHistory)
- boxcost.POSTJWT("/download/plan/track", DownloadPlanTrack)
- PlanTrack(boxcost)
-
- 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)
-
- Summary(boxcost)
-
- boxcost.POSTJWT("/plan/add/component/:id", AddCompnonet)
- boxcost.POSTJWT("/plan/delete/component/:id/:componentId", DeleteCompnonet)
- boxcost.POSTJWT("/plan/update/component/:id/:componentId", UpdateCompnonet)
- boxcost.POSTJWT("/plan/add/stages", AddStage)
- boxcost.POSTJWT("/plan/update/stages", UpdateStages)
- boxcost.POSTJWT("/plan/delete/stage", DeleteStage)
- boxcost.POSTJWT("/plan/update/fileds", UpdatePlanfileds)
- 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)
- }
- }
|