jiangshuai
2023-11-17 81827a26b91b07c997716f5f595e9e3121c18cf5
controllers/product_controller.go
@@ -214,6 +214,22 @@
      return
   }
   //更新在库的产品类型
   if params.CategoryId > 0 {
      find, _ := models.NewLocationProductAmountSearch().SetProductId(params.ID).Find()
      if len(find) > 0 {
         var ids []int
         for _, f := range find {
            if f.ProductCategoryID != params.CategoryId {
               ids = append(ids, f.Id)
            }
         }
         m := make(map[string]interface{})
         m["productCategoryId"] = params.CategoryId
         _ = models.NewLocationProductAmountSearch().SetIds(ids).UpdateByMap(m)
      }
   }
   materialAttachmentList := []*models.MaterialAttachment{}
   for _, v := range params.AttachmentIDs {
      ma := &models.MaterialAttachment{MaterialID: params.ID, AttachmentID: v}
@@ -318,7 +334,7 @@
      return
   }
   first, err := models.NewProductCategorySearch().SetID(cast.ToUint(id)).First()
   first, err := models.NewProductCategorySearch().SetID(cast.ToInt(id)).First()
   if err != nil {
      util.ResponseFormat(c, code.RequestParamError, "查找失败")
      return
@@ -343,7 +359,7 @@
      util.ResponseFormat(c, code.RequestParamError, "产品类型名称不能为空")
      return
   }
   err := models.NewProductCategorySearch().SetID(params.ID).Save(&params)
   err := models.NewProductCategorySearch().SetID(params.Id).Save(&params)
   if err != nil {
      util.ResponseFormat(c, code.RequestParamError, "产品类型信息更新失败")
      return
@@ -364,7 +380,7 @@
      util.ResponseFormat(c, code.RequestParamError, "无效id")
      return
   }
   err := models.NewProductCategorySearch().SetID(cast.ToUint(id)).Delete()
   err := models.NewProductCategorySearch().SetID(cast.ToInt(id)).Delete()
   if err != nil {
      util.ResponseFormat(c, code.RequestParamError, "删除失败")
      return