feat: swag.
This commit is contained in:
@@ -40,6 +40,20 @@ func NewProductInventoryAdminController() *ProductInventoryAdminController {
|
||||
return &ProductInventoryAdminController{DB: config.DB}
|
||||
}
|
||||
|
||||
// @Summary 获取产品库存列表
|
||||
// @Description 查询产品库存列表,支持多条件筛选
|
||||
// @Tags 产品库存管理
|
||||
// @Produce json
|
||||
// @Param keyword query string false "关键词(资产名称/序列号/购买方等模糊搜索)"
|
||||
// @Param productCode query string false "产品代码筛选"
|
||||
// @Param projectTypeCode query string false "项目类型代码筛选"
|
||||
// @Param suiteCode query string false "套件代码筛选"
|
||||
// @Param status query string false "状态筛选"
|
||||
// @Param soldTargetType query string false "购买方类型筛选"
|
||||
// @Param regionId query int false "区域ID"
|
||||
// @Security BearerAuth
|
||||
// @Success 200 {object} SwagAPIResponse "查询成功"
|
||||
// @Router /admin/product-inventories [get]
|
||||
func (pc *ProductInventoryAdminController) List(c *gin.Context) {
|
||||
var items []models.ProductInventory
|
||||
query := pc.DB.Model(&models.ProductInventory{}).Order("updated_at DESC, id DESC")
|
||||
@@ -79,6 +93,16 @@ func (pc *ProductInventoryAdminController) List(c *gin.Context) {
|
||||
writeSuccess(c, http.StatusOK, "query success", items)
|
||||
}
|
||||
|
||||
// @Summary 创建产品库存记录
|
||||
// @Description 创建新的产品库存记录
|
||||
// @Tags 产品库存管理
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param inventory body productInventoryPayload true "库存信息"
|
||||
// @Security BearerAuth
|
||||
// @Success 201 {object} SwagAPIResponse "创建成功"
|
||||
// @Failure 400 {object} SwagAPIResponse "请求参数错误"
|
||||
// @Router /admin/product-inventories [post]
|
||||
func (pc *ProductInventoryAdminController) Create(c *gin.Context) {
|
||||
var payload productInventoryPayload
|
||||
if err := c.ShouldBindJSON(&payload); err != nil {
|
||||
@@ -121,6 +145,18 @@ func (pc *ProductInventoryAdminController) Create(c *gin.Context) {
|
||||
writeSuccess(c, http.StatusCreated, "create success", record)
|
||||
}
|
||||
|
||||
// @Summary 更新产品库存
|
||||
// @Description 更新指定产品库存记录
|
||||
// @Tags 产品库存管理
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int true "库存ID"
|
||||
// @Param inventory body productInventoryPayload true "更新信息"
|
||||
// @Security BearerAuth
|
||||
// @Success 200 {object} SwagAPIResponse "更新成功"
|
||||
// @Failure 400 {object} SwagAPIResponse "请求参数错误"
|
||||
// @Failure 404 {object} SwagAPIResponse "库存记录不存在"
|
||||
// @Router /admin/product-inventories/{id} [put]
|
||||
func (pc *ProductInventoryAdminController) Update(c *gin.Context) {
|
||||
record, err := pc.findByID(c.Param("id"))
|
||||
if err != nil {
|
||||
@@ -167,6 +203,16 @@ func (pc *ProductInventoryAdminController) Update(c *gin.Context) {
|
||||
writeSuccess(c, http.StatusOK, "update success", record)
|
||||
}
|
||||
|
||||
// @Summary 删除产品库存
|
||||
// @Description 删除指定产品库存记录(已售出的无法删除)
|
||||
// @Tags 产品库存管理
|
||||
// @Produce json
|
||||
// @Param id path int true "库存ID"
|
||||
// @Security BearerAuth
|
||||
// @Success 200 {object} SwagAPIResponse "删除成功"
|
||||
// @Failure 404 {object} SwagAPIResponse "库存记录不存在"
|
||||
// @Failure 409 {object} SwagAPIResponse "已售出无法删除"
|
||||
// @Router /admin/product-inventories/{id} [delete]
|
||||
func (pc *ProductInventoryAdminController) Delete(c *gin.Context) {
|
||||
record, err := pc.findByID(c.Param("id"))
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user