package router

import (
	"github.com/gin-gonic/gin"
	"go-admin/app/admin/apis/inventorymanage"
	"go-admin/app/admin/middleware"
	jwt "go-admin/pkg/jwtauth"
)

func registerInventoryManageRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) {
	r := v1.Group("/inventory").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole())
	r.POST("list", inventorymanage.GetInventoryList)            // 库存列表
	r.POST("detail", inventorymanage.GetInventoryDetail)        // 库存详情
	r.POST("detail_new", inventorymanage.GetInventoryDetailNew) // 库存详情页专用接口，门店复选
	r.POST("delivery", inventorymanage.DeliveryCargo)           // 出库
	r.POST("print", inventorymanage.BatchPrint)                 // 批量打印
	r.POST("import", inventorymanage.BatchImport)               // 库存导入
	r.POST("add_remark", inventorymanage.AddRemark)             // 添加备注
	r.POST("query_code", inventorymanage.QueryCode)             // 查询商品串码或者条码
	r.POST("query_name", inventorymanage.QueryName)             // 通过名称模糊查询商品库存详情
	r.POST("imei/trace", inventorymanage.ImeiTrace)             // 串码追踪

	// 产品入库
	r1 := v1.Group("/inventory/product").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole())
	r1.POST("add", inventorymanage.ProductInventoryAdd)         // 新增
	r1.POST("edit", inventorymanage.ProductInventoryEdit)       // 编辑
	r1.POST("audit", inventorymanage.ProductInventoryAudit)     // 审核
	r1.POST("delete", inventorymanage.ProductInventoryDelete)   // 删除
	r1.POST("list", inventorymanage.ProductInventoryList)       // 列表
	r1.POST("detail", inventorymanage.ProductInventoryDetail)   // 详情
	r1.POST("getIMEI", inventorymanage.ProductInventoryGetIMEI) // 系统生成串码

	// 库存调拨
	r3 := v1.Group("/inventory/allot").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole())
	r3.POST("add", inventorymanage.InventoryAllotAdd)         // 新增
	r3.POST("edit", inventorymanage.InventoryAllotEdit)       // 编辑
	r3.POST("audit", inventorymanage.InventoryAllotAudit)     // 审核
	r3.POST("delete", inventorymanage.InventoryAllotDelete)   // 删除
	r3.POST("list", inventorymanage.InventoryAllotList)       // 列表
	r3.POST("detail", inventorymanage.InventoryAllotDetail)   // 详情
	r3.POST("deliver", inventorymanage.InventoryAllotDeliver) // 发货
	r3.POST("receive", inventorymanage.InventoryAllotReceive) // 收货

	// 库存变动
	r2 := v1.Group("/inventory/change").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole())
	r2.POST("add", inventorymanage.InventoryChangeAdd)       // 新增
	r2.POST("edit", inventorymanage.InventoryChangeEdit)     // 编辑
	r2.POST("audit", inventorymanage.InventoryChangeAudit)   // 审核
	r2.POST("delete", inventorymanage.InventoryChangeDelete) // 删除
	r2.POST("list", inventorymanage.InventoryChangeList)     // 列表
	r2.POST("detail", inventorymanage.InventoryChangeDetail) // 详情

	// 库存报表
	r4 := v1.Group("/inventory/report").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole())
	r4.POST("product", inventorymanage.InventoryReportByProduct)        // 产品库存汇总（按门店）
	r4.POST("allot", inventorymanage.InventoryReportByAllot)            // 库存调拨汇总
	r4.POST("allot_detail", inventorymanage.InventoryReportAllotDetail) // 库存调拨明细
	r4.POST("other", inventorymanage.InventoryReportByOther)            // 其他出入库汇总
	r4.POST("other_detail", inventorymanage.InventoryReportOtherDetail) // 其他出入库明细

}
