liujiandao
2023-09-18 40eb578f79a0f0dcf0bbfa2c267478d159f0f58c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package router
 
import (
    "net/http"
    "wms/conf"
    "wms/controllers"
    _ "wms/docs"
    "wms/middleware"
 
    "github.com/gin-gonic/gin"
    swaggerFiles "github.com/swaggo/files"
    ginSwagger "github.com/swaggo/gin-swagger"
)
 
func NewRouter() *gin.Engine {
    r := gin.Default()
    r.Use(middleware.Cors())
 
    r.StaticFS(conf.LocalConf.StorePath, http.Dir(conf.LocalConf.StorePath)) // 为用户头像和文件提供静态地址
    r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
 
    urlPrefix := "/api-wms/v1"
 
    // 组织管理
    departmentController := new(controllers.DepartmentController)
    organizeAPI := r.Group(urlPrefix + "/organize")
    {
        organizeAPI.GET("department", departmentController.List)          // 获取部门列表
        organizeAPI.POST("department", departmentController.Add)          // 新增部门
        organizeAPI.PUT("department/:id", departmentController.Update)    // 修改部门
        organizeAPI.DELETE("department/:id", departmentController.Delete) // 删除部门
    }
 
    // 公司管理
    companyController := new(controllers.CompanyController)
    companyAPI := r.Group(urlPrefix + "/company")
    {
        companyAPI.GET("company", companyController.List)          // 获取公司列表
        companyAPI.POST("company", companyController.Add)          // 新增公司
        companyAPI.PUT("company/:id", companyController.Update)    // 修改公司
        companyAPI.DELETE("company/:id", companyController.Delete) // 删除公司
    }
 
    // 仓库管理
    warehouseController := new(controllers.WarehouseController)
    warehouseAPI := r.Group(urlPrefix + "/warehouse")
    {
        warehouseAPI.GET("warehouse", warehouseController.List)          // 获取仓库列表
        warehouseAPI.POST("warehouse", warehouseController.Add)          // 新增仓库
        warehouseAPI.PUT("warehouse/:id", warehouseController.Update)    // 修改仓库
        warehouseAPI.DELETE("warehouse/:id", warehouseController.Delete) // 删除仓库
    }
 
    // 作业类型
    operationTypeController := new(controllers.OperationTypeController)
    operationTypeAPI := r.Group(urlPrefix + "/warehouse")
    {
        operationTypeAPI.GET("operationType", operationTypeController.List)          // 获取作业类型列表
        operationTypeAPI.POST("operationType", operationTypeController.Add)          // 新增作业类型
        operationTypeAPI.PUT("operationType/:id", operationTypeController.Update)    // 修改作业类型
        operationTypeAPI.DELETE("operationType/:id", operationTypeController.Delete) // 删除作业类型
    }
 
    //产品
    productController := new(controllers.ProductController)
    productAPI := r.Group(urlPrefix + "/product")
    {
        productAPI.POST("addProduct", productController.AddProduct)         // 新增产品
        productAPI.POST("getProductList", productController.GetProductList) // 获取产品列表
    }
 
    return r
}