-
-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:muety/wakapi
- Loading branch information
Showing
26 changed files
with
5,870 additions
and
5,477 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,5 @@ pkged.go | |
package-lock.json | ||
node_modules | ||
.DS_Store | ||
.venv | ||
venv |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ import ( | |
) | ||
|
||
type AliasRepositoryMock struct { | ||
BaseRepositoryMock | ||
mock.Mock | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package mocks | ||
|
||
import ( | ||
"github.com/stretchr/testify/mock" | ||
) | ||
|
||
type BaseRepositoryMock struct { | ||
mock.Mock | ||
} | ||
|
||
func (m *BaseRepositoryMock) GetDialector() string { | ||
args := m.Called() | ||
return args.Get(0).(string) | ||
} | ||
|
||
func (m *BaseRepositoryMock) GetTableDDLMysql(s string) (string, error) { | ||
args := m.Called(s) | ||
return args.Get(0).(string), args.Error(1) | ||
} | ||
|
||
func (m *BaseRepositoryMock) GetTableDDLSqlite(s string) (string, error) { | ||
args := m.Called(s) | ||
return args.Get(0).(string), args.Error(1) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ import ( | |
) | ||
|
||
type SummaryRepositoryMock struct { | ||
BaseRepositoryMock | ||
mock.Mock | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package repositories | ||
|
||
import ( | ||
"errors" | ||
"gorm.io/gorm" | ||
) | ||
|
||
type BaseRepository struct { | ||
db *gorm.DB | ||
} | ||
|
||
func NewBaseRepository(db *gorm.DB) BaseRepository { | ||
return BaseRepository{db: db} | ||
} | ||
|
||
func (r *BaseRepository) GetDialector() string { | ||
return r.db.Dialector.Name() | ||
} | ||
|
||
func (r *BaseRepository) GetTableDDLMysql(tableName string) (result string, err error) { | ||
if dialector := r.GetDialector(); dialector == "sqlite" || dialector == "sqlite3" { | ||
err = r.db.Raw("show create table ?", tableName).Scan(&result).Error | ||
} else { | ||
err = errors.New("not a mysql database") | ||
} | ||
return result, err | ||
} | ||
|
||
func (r *BaseRepository) GetTableDDLSqlite(tableName string) (result string, err error) { | ||
if dialector := r.GetDialector(); dialector == "sqlite" || dialector == "sqlite3" { | ||
err = r.db.Table("sqlite_master"). | ||
Select("sql"). | ||
Where("type = ?", "table"). | ||
Where("name = ?", tableName). | ||
Take(&result).Error | ||
} else { | ||
err = errors.New("not an sqlite database") | ||
} | ||
return result, err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.