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
|
}
|