package dboperations import ( "git.sxidc.com/go-tools/dboperations/operations" "strings" ) var dbOperationsInstance operations.DBOperations func GetInstance() operations.DBOperations { return dbOperationsInstance } func InitInstance(dbConfig *operations.DBConfig) error { if dbOperationsInstance != nil { return nil } dbOperations, err := operations.NewOperations(dbConfig) if err != nil { return err } dbOperationsInstance = dbOperations return nil } func DestroyInstance() error { if dbOperationsInstance == nil { return nil } err := operations.DestroyOperation(dbOperationsInstance.(*operations.Operations)) if err != nil { return err } dbOperationsInstance = nil return nil } func IsErrorDBRecordHasExist(err error) bool { return strings.Contains(err.Error(), "记录已存在") } func IsErrorDBRecordNotExist(err error) bool { return strings.Contains(err.Error(), "记录不存在") }