Save method
This commit is contained in:
@ -21,11 +21,11 @@ type RepoBase[T schema.Tabler] struct {
|
||||
GetMethod[T]
|
||||
ExistsMethod[T]
|
||||
CountMethod[T]
|
||||
methods []MethodInitInterface[T]
|
||||
SaveMethod[T]
|
||||
}
|
||||
|
||||
func (repo *RepoBase[T]) InitMethods() {
|
||||
for _, method := range repo.methods {
|
||||
func (repo *RepoBase[T]) InitMethods(methods []MethodInitInterface[T]) {
|
||||
for _, method := range methods {
|
||||
method.Init(repo)
|
||||
}
|
||||
}
|
||||
@ -42,11 +42,12 @@ func (m *RepoBase[T]) Init(dbConn *gorm.DB, options *RepoOptions) {
|
||||
}
|
||||
}
|
||||
|
||||
m.methods = []MethodInitInterface[T]{
|
||||
methods := []MethodInitInterface[T]{
|
||||
&m.ListMethod,
|
||||
&m.GetMethod,
|
||||
&m.ExistsMethod,
|
||||
&m.CountMethod,
|
||||
&m.SaveMethod,
|
||||
}
|
||||
m.InitMethods()
|
||||
m.InitMethods(methods)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user