-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
env YDB_MYSQL_TEST as mysql default datasource
- Loading branch information
Showing
4 changed files
with
71 additions
and
51 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
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 |
---|---|---|
|
@@ -3,6 +3,7 @@ package main | |
import ( | ||
"errors" | ||
"github.com/goplus/yap/ydb" | ||
_ "github.com/goplus/yap/ydb/mysql" | ||
_ "github.com/goplus/yap/ydb/sqlite3" | ||
"time" | ||
) | ||
|
@@ -38,7 +39,7 @@ type foo struct { | |
} | ||
|
||
func main() { | ||
//line ydb/demo/foo/foo_ydb.gox:82:1 | ||
//line ydb/demo/foo/foo_ydb.gox:83:1 | ||
ydb.Gopt_AppGen_Main(new(ydb.AppGen), new(foo)) | ||
} | ||
|
||
|
@@ -53,101 +54,101 @@ func Hmac(pwd string, salt string) string { | |
//line ydb/demo/foo/foo.gop:14:1 | ||
return "" | ||
} | ||
//line ydb/demo/foo/foo_ydb.gox:35 | ||
//line ydb/demo/foo/foo_ydb.gox:36 | ||
func (this *foo) Main() { | ||
//line ydb/demo/foo/foo_ydb.gox:35:1 | ||
this.Engine__0("sqlite3") | ||
//line ydb/demo/foo/foo_ydb.gox:37:1 | ||
//line ydb/demo/foo/foo_ydb.gox:36:1 | ||
this.Engine__0("mysql") | ||
//line ydb/demo/foo/foo_ydb.gox:38:1 | ||
ydb.Gopt_Sql_Gopx_Table[User](this, "user v0.1.0") | ||
//line ydb/demo/foo/foo_ydb.gox:39:1 | ||
ydb.Gopt_Sql_Gopx_Table[Article](this, "v0.1.0") | ||
//line ydb/demo/foo/foo_ydb.gox:40:1 | ||
ydb.Gopt_Sql_Gopx_Table[Article](this, "v0.1.0") | ||
//line ydb/demo/foo/foo_ydb.gox:41:1 | ||
this.From("oldart v0.9.1", func() { | ||
}) | ||
//line ydb/demo/foo/foo_ydb.gox:45:1 | ||
//line ydb/demo/foo/foo_ydb.gox:46:1 | ||
ydb.Gopt_Sql_Gopx_Table[Tag](this, "v0.1.0") | ||
//line ydb/demo/foo/foo_ydb.gox:47:1 | ||
this.Class("Users", func() { | ||
//line ydb/demo/foo/foo_ydb.gox:48:1 | ||
this.Class("Users", func() { | ||
//line ydb/demo/foo/foo_ydb.gox:49:1 | ||
this.Use("user") | ||
//line ydb/demo/foo/foo_ydb.gox:50:1 | ||
this.Api("register", func(id string, pwd string, nickname string, email string, tel string, ctime time.Time) error { | ||
//line ydb/demo/foo/foo_ydb.gox:51:1 | ||
if email == "" && tel == "" { | ||
this.Api("register", func(id string, pwd string, nickname string, email string, tel string, ctime time.Time) error { | ||
//line ydb/demo/foo/foo_ydb.gox:52:1 | ||
if email == "" && tel == "" { | ||
//line ydb/demo/foo/foo_ydb.gox:53:1 | ||
return ErrNoEmailAndTel | ||
} | ||
//line ydb/demo/foo/foo_ydb.gox:54:1 | ||
this.Limit__2(3, "email=?", email) | ||
//line ydb/demo/foo/foo_ydb.gox:55:1 | ||
this.Limit__2(3, "email=?", email) | ||
//line ydb/demo/foo/foo_ydb.gox:56:1 | ||
this.Limit__2(3, "tel=?", tel) | ||
//line ydb/demo/foo/foo_ydb.gox:57:1 | ||
salt := Rand() | ||
//line ydb/demo/foo/foo_ydb.gox:58:1 | ||
spwd := Hmac(pwd, salt) | ||
salt := Rand() | ||
//line ydb/demo/foo/foo_ydb.gox:59:1 | ||
spwd := Hmac(pwd, salt) | ||
//line ydb/demo/foo/foo_ydb.gox:60:1 | ||
this.Insert__1(&User{Id: id, Spwd: spwd, Salt: salt, Nickname: nickname, Email: email, Tel: tel, Ctime: ctime}) | ||
//line ydb/demo/foo/foo_ydb.gox:61:1 | ||
//line ydb/demo/foo/foo_ydb.gox:62:1 | ||
return nil | ||
}) | ||
//line ydb/demo/foo/foo_ydb.gox:63:1 | ||
this.Call__1("user", "pwd", "nickname", "", "", time.Now()) | ||
//line ydb/demo/foo/foo_ydb.gox:64:1 | ||
this.Ret__1(ErrNoEmailAndTel) | ||
this.Call__1("user", "pwd", "nickname", "", "", time.Now()) | ||
//line ydb/demo/foo/foo_ydb.gox:65:1 | ||
this.Call__1("user", "pwd", "nickname", "[email protected]", "", time.Now()) | ||
this.Ret__1(ErrNoEmailAndTel) | ||
//line ydb/demo/foo/foo_ydb.gox:66:1 | ||
this.Ret__0(nil) | ||
this.Call__1("user", "pwd", "nickname", "[email protected]", "", time.Now()) | ||
//line ydb/demo/foo/foo_ydb.gox:67:1 | ||
this.Call__1("user", "pwd", "nickname", "[email protected]", "13500000000", time.Now()) | ||
this.Ret__0(nil) | ||
//line ydb/demo/foo/foo_ydb.gox:68:1 | ||
this.Call__1("user", "pwd", "nickname", "[email protected]", "13500000000", time.Now()) | ||
//line ydb/demo/foo/foo_ydb.gox:69:1 | ||
this.Ret__1(ydb.ErrDuplicated) | ||
//line ydb/demo/foo/foo_ydb.gox:70:1 | ||
this.Api("login", func(id string, pwd string) bool { | ||
//line ydb/demo/foo/foo_ydb.gox:71:1 | ||
var spwd, salt string | ||
this.Api("login", func(id string, pwd string) bool { | ||
//line ydb/demo/foo/foo_ydb.gox:72:1 | ||
this.Query__1("id=?", id) | ||
var spwd, salt string | ||
//line ydb/demo/foo/foo_ydb.gox:73:1 | ||
this.Ret__1("salt", &salt, "spwd", &spwd) | ||
this.Query__1("id=?", id) | ||
//line ydb/demo/foo/foo_ydb.gox:74:1 | ||
this.Ret__1("salt", &salt, "spwd", &spwd) | ||
//line ydb/demo/foo/foo_ydb.gox:75:1 | ||
return Hmac(pwd, salt) == spwd | ||
}) | ||
//line ydb/demo/foo/foo_ydb.gox:76:1 | ||
this.Call__1("", "") | ||
//line ydb/demo/foo/foo_ydb.gox:77:1 | ||
this.Ret__1(false) | ||
this.Call__1("", "") | ||
//line ydb/demo/foo/foo_ydb.gox:78:1 | ||
this.Call__1("user", "pwd") | ||
this.Ret__1(false) | ||
//line ydb/demo/foo/foo_ydb.gox:79:1 | ||
this.Call__1("user", "pwd") | ||
//line ydb/demo/foo/foo_ydb.gox:80:1 | ||
this.Ret__1(true) | ||
}) | ||
//line ydb/demo/foo/foo_ydb.gox:82:1 | ||
this.Class("Articles", func() { | ||
//line ydb/demo/foo/foo_ydb.gox:83:1 | ||
this.Class("Articles", func() { | ||
//line ydb/demo/foo/foo_ydb.gox:84:1 | ||
this.Use("article") | ||
//line ydb/demo/foo/foo_ydb.gox:85:1 | ||
this.Api("listByTag", func(tag string) (result []ArticleEntry) { | ||
//line ydb/demo/foo/foo_ydb.gox:86:1 | ||
var ids []string | ||
this.Api("listByTag", func(tag string) (result []ArticleEntry) { | ||
//line ydb/demo/foo/foo_ydb.gox:87:1 | ||
this.Query__1("tag.name=?", tag) | ||
var ids []string | ||
//line ydb/demo/foo/foo_ydb.gox:88:1 | ||
this.Query__1("tag.name=?", tag) | ||
//line ydb/demo/foo/foo_ydb.gox:89:1 | ||
this.Ret__1("tag.article", &ids) | ||
//line ydb/demo/foo/foo_ydb.gox:90:1 | ||
this.Query__1("id=?", ids) | ||
//line ydb/demo/foo/foo_ydb.gox:91:1 | ||
this.Ret__1(&result) | ||
this.Query__1("id=?", ids) | ||
//line ydb/demo/foo/foo_ydb.gox:92:1 | ||
this.Ret__1(&result) | ||
//line ydb/demo/foo/foo_ydb.gox:93:1 | ||
return | ||
}) | ||
//line ydb/demo/foo/foo_ydb.gox:95:1 | ||
this.Api("listByAuthor", func(author string) (result []ArticleEntry) { | ||
//line ydb/demo/foo/foo_ydb.gox:96:1 | ||
this.Query__1("author=?", author) | ||
this.Api("listByAuthor", func(author string) (result []ArticleEntry) { | ||
//line ydb/demo/foo/foo_ydb.gox:97:1 | ||
this.Ret__1(&result) | ||
this.Query__1("author=?", author) | ||
//line ydb/demo/foo/foo_ydb.gox:98:1 | ||
this.Ret__1(&result) | ||
//line ydb/demo/foo/foo_ydb.gox:99:1 | ||
return | ||
}) | ||
}) | ||
|
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