|
|
@@ -10,26 +10,6 @@ import (
|
|
|
"time"
|
|
|
)
|
|
|
|
|
|
-type TransactionOperations struct {
|
|
|
- Operations
|
|
|
-}
|
|
|
-
|
|
|
-func (op *TransactionOperations) RollbackTransaction() {
|
|
|
- defer func() {
|
|
|
- op.processDB = op.initDB
|
|
|
- }()
|
|
|
-
|
|
|
- op.processDB.Rollback()
|
|
|
-}
|
|
|
-
|
|
|
-func (op *TransactionOperations) CommitTransaction() {
|
|
|
- defer func() {
|
|
|
- op.processDB = op.initDB
|
|
|
- }()
|
|
|
-
|
|
|
- op.processDB.Commit()
|
|
|
-}
|
|
|
-
|
|
|
type Operations struct {
|
|
|
initDB *gorm.DB
|
|
|
processDB *gorm.DB
|
|
|
@@ -228,8 +208,8 @@ func (op *Operations) Delete() error {
|
|
|
return op.processDB.Delete(make(map[string]any)).Error
|
|
|
}
|
|
|
|
|
|
-func (op *Operations) Updates(updateData map[string]any) error {
|
|
|
- err := op.processDB.Updates(updateData).Error
|
|
|
+func (op *Operations) Updates(newTableRow map[string]any) error {
|
|
|
+ err := op.processDB.Updates(newTableRow).Error
|
|
|
if err != nil {
|
|
|
if strings.Contains(err.Error(), "SQLSTATE 23505") {
|
|
|
return dberr.ErrDBRecordHasExist
|
|
|
@@ -241,8 +221,8 @@ func (op *Operations) Updates(updateData map[string]any) error {
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
-func (op *Operations) UpdatesWithRowsAffected(updateData map[string]any) (int64, error) {
|
|
|
- op.processDB = op.processDB.Updates(updateData)
|
|
|
+func (op *Operations) UpdatesWithRowsAffected(newTableRow map[string]any) (int64, error) {
|
|
|
+ op.processDB = op.processDB.Updates(newTableRow)
|
|
|
if op.processDB.Error != nil {
|
|
|
return 0, op.processDB.Error
|
|
|
}
|