fix: batch update categories list

pull/190/head
jakezhu9 2 years ago
parent cc54b6496a
commit 7db85afcbd

@ -427,10 +427,16 @@ func (c *categoryUpdateExecutor) UpdateBatch(ctx context.Context, categoryParams
err := dal.Transaction(ctx, func(txCtx context.Context) error {
categoryDAL := dal.GetQueryByCtx(txCtx).Category
err := categoryDAL.WithContext(txCtx).Omit(categoryDAL.CreateTime).Save(categories...)
if err != nil {
return WrapDBErr(err)
for _, category := range categories {
resultInfo, err := categoryDAL.WithContext(txCtx).Where(categoryDAL.ID.Eq(category.ID)).Select(field.Star).Omit(categoryDAL.CreateTime).Updates(category)
if err != nil {
return WrapDBErr(err)
}
if resultInfo.RowsAffected != 1 {
return xerr.DB.New("").WithMsg("update failed")
}
}
if err := c.prepare(txCtx, categoryParams); err != nil {
return err
}

Loading…
Cancel
Save