parent
f0138ec845
commit
7fafcdba47
@ -0,0 +1,18 @@ |
||||
package main |
||||
|
||||
import ( |
||||
"code.gitea.io/gitea/models" |
||||
"git.jonasfranz.software/JonasFranzDEV/giteaplugin/interfaces" |
||||
) |
||||
|
||||
type UserDatabaseImpl struct {} |
||||
|
||||
func (*UserDatabaseImpl) CreateUser(user *interfaces.User) error { |
||||
return models.CreateUser(&models.User{ |
||||
Name: user.Name, |
||||
Email: user.Email, |
||||
Passwd: user.Passwd, |
||||
IsAdmin: user.IsAdmin, |
||||
IsActive: user.IsActive, |
||||
}) |
||||
} |
Binary file not shown.
@ -0,0 +1,12 @@ |
||||
package main |
||||
|
||||
import ( |
||||
"git.jonasfranz.software/JonasFranzDEV/giteaplugin/interfaces" |
||||
"plugin" |
||||
) |
||||
|
||||
func main() { |
||||
p, _ := plugin.Open("demo.so") |
||||
start, _ := p.Lookup("Start") |
||||
start.(func(database interfaces.UserDatabase))(&UserDatabaseImpl{}) |
||||
} |
@ -0,0 +1,13 @@ |
||||
package interfaces |
||||
|
||||
type User struct { |
||||
Name string |
||||
Email string |
||||
Passwd string |
||||
IsAdmin bool |
||||
IsActive bool |
||||
} |
||||
|
||||
type UserDatabase interface { |
||||
CreateUser(user *User) error |
||||
} |
@ -1,19 +0,0 @@ |
||||
package main |
||||
|
||||
import ( |
||||
"code.gitea.io/gitea/models" |
||||
"code.gitea.io/gitea/modules/log" |
||||
) |
||||
|
||||
func StartPlugin() { |
||||
err := models.CreateUser(&models.User{ |
||||
Name: "NicePlugin", |
||||
Email: "plugin@knt.li", |
||||
Passwd: "test", |
||||
IsActive: false, |
||||
IsAdmin: false, |
||||
}) |
||||
if err != nil { |
||||
log.Error(4, "StartPlugin: %v", err) |
||||
} |
||||
} |
@ -0,0 +1,7 @@ |
||||
package main |
||||
|
||||
import "git.jonasfranz.software/JonasFranzDEV/giteaplugin/interfaces" |
||||
|
||||
func Start(database interfaces.UserDatabase) { |
||||
_ = database.CreateUser(&interfaces.User{}) |
||||
} |
Loading…
Reference in new issue