| | |
| | | util.ResponseFormat(c, code.RequestParamError, "单位不能为空") |
| | | return |
| | | } |
| | | if params.BarCode == "" { |
| | | m, err := models.NewMaterialSearch().SetBarCode(params.BarCode).First() |
| | | if err != nil || m != nil { //查出物料表是物料已存在 |
| | | util.ResponseFormat(c, code.RequestParamError, "条形码已经被使用") |
| | | return |
| | | } |
| | | } |
| | | //params.ID = utils.GetUUID() |
| | | |
| | | err := models.WithTransaction(func(tx *gorm.DB) error { |
| | |
| | | util.ResponseFormat(c, code.RequestParamError, "单位不能为空") |
| | | return |
| | | } |
| | | if params.BarCode == "" { |
| | | m, err := models.NewMaterialSearch().SetBarCode(params.BarCode).First() |
| | | if err != nil || (m != nil && m.ID != params.ID) { //查出物料且ID不一样, |
| | | util.ResponseFormat(c, code.RequestParamError, "条形码已经被使用") |
| | | return |
| | | } |
| | | } |
| | | err := models.NewMaterialSearch().SetID(params.ID).Save(¶ms) |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "产品信息更新失败") |