Browse Source

修改Count接口

yjp 10 months ago
parent
commit
ac0b7581b4
2 changed files with 9 additions and 3 deletions
  1. 1 1
      operations/interface.go
  2. 8 2
      operations/operations.go

+ 1 - 1
operations/interface.go

@@ -58,7 +58,7 @@ type BaseDBOperations interface {
 	Row() (*TableRow, error)
 
 	// 其他方法
-	Count(count *int64) error
+	Count() (int64, error)
 	CheckExist() (bool, error)
 	CheckHasOnlyOne() (bool, error)
 }

+ 8 - 2
operations/operations.go

@@ -285,8 +285,14 @@ func (op *Operations) Row() (*TableRow, error) {
 	return NewTableRowFromMap(valueMap), nil
 }
 
-func (op *Operations) Count(count *int64) error {
-	return op.processDB.Count(count).Error
+func (op *Operations) Count() (int64, error) {
+	var count int64
+	err := op.processDB.Count(&count).Error
+	if err != nil {
+		return 0, err
+	}
+
+	return count, nil
 }
 
 func (op *Operations) CheckExist() (bool, error) {