18 lines
281 B
Go
18 lines
281 B
Go
package query
|
|
|
|
import (
|
|
"sync"
|
|
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
type AutoIncrementID struct {
|
|
mutex sync.Mutex
|
|
}
|
|
|
|
func (ai *AutoIncrementID) Next(db *gorm.DB) (int, error) {
|
|
ai.mutex.Lock()
|
|
defer ai.mutex.Unlock()
|
|
id, err := FindLatestIncidentId(db)
|
|
return (id + 1), err
|
|
} |