zhangqian
2024-07-03 f45e4cb8045fe60f96f467dc4ea1e2ae57445712
controllers/warehouse.go
@@ -41,19 +41,21 @@
      util.ResponseFormat(c, code.RequestParamError, err.Error())
      return
   }
   err := models.WithTransaction(func(tx *gorm.DB) error {
      err := models.NewWarehouseSearch().SetOrm(tx).Create(&params)
      if err != nil {
         return err
      }
   //创建视图
   view := &models.Location{
      Name:      params.Code,
      JointName: params.Code,
      Type:      constvar.LocationTypeView,
         WarehouseId: params.Id,
   }
   id, err := models.NewLocationSearch().CreateReturnId(view)
   if err != nil {
      util.ResponseFormat(c, code.SaveFail, "视图创建失败")
      return
   }
   err = models.WithTransaction(func(tx *gorm.DB) error {
      err := models.NewWarehouseSearch().SetOrm(tx).Create(&params)
      viewId, err := models.NewLocationSearch().CreateReturnId(view)
      if err != nil {
         return err
      }
@@ -64,7 +66,7 @@
         JointName:         params.Name,
         Type:              constvar.LocationTypeInternal,
         ReplenishLocation: true,
         ParentId:          id,
         ParentId:          viewId,
         WarehouseId:       params.Id,
      }
      locationId, err := models.NewLocationSearch().SetOrm(tx).CreateReturnId(location)