этот коммит никогда не будет запушен
This commit is contained in:
parent
1b152f2b77
commit
cb81ed0aea
9 changed files with 25 additions and 10 deletions
|
@ -96,7 +96,7 @@ func GetByLogin(login string) []Comment {
|
|||
|
||||
func GetComment(commentId string) Comment {
|
||||
ctx := storage.GetContext()
|
||||
return storage.Get(ctx, commentId).(Comment)
|
||||
return std.Deserialize(storage.Get(ctx, commentId).([]byte)).(Comment)
|
||||
}
|
||||
|
||||
func GetCommentInPost(commentId string, postId string) Comment {
|
||||
|
|
1
Comment/comment.json
Executable file
1
Comment/comment.json
Executable file
|
@ -0,0 +1 @@
|
|||
{"name":"comment","abi":{"methods":[{"name":"_deploy","offset":0,"parameters":[{"name":"data","type":"Any"},{"name":"isUpdate","type":"Boolean"}],"returntype":"Void","safe":false},{"name":"createNewComment","offset":33,"parameters":[{"name":"userLogin","type":"String"},{"name":"postId","type":"String"},{"name":"text","type":"String"}],"returntype":"Void","safe":false},{"name":"getByLogin","offset":560,"parameters":[{"name":"login","type":"String"}],"returntype":"Array","safe":false},{"name":"getByLoginInPost","offset":509,"parameters":[{"name":"postId","type":"String"},{"name":"login","type":"String"}],"returntype":"Array","safe":false},{"name":"getByPostId","offset":410,"parameters":[{"name":"postId","type":"String"}],"returntype":"Array","safe":false},{"name":"getComment","offset":626,"parameters":[{"name":"commentId","type":"String"}],"returntype":"Array","safe":false},{"name":"getCommentInPost","offset":663,"parameters":[{"name":"commentId","type":"String"},{"name":"postId","type":"String"}],"returntype":"Array","safe":false},{"name":"rateComment","offset":768,"parameters":[{"name":"isLike","type":"Boolean"},{"name":"postId","type":"String"},{"name":"commentId","type":"String"}],"returntype":"Void","safe":false},{"name":"updateComment","offset":802,"parameters":[{"name":"comment","type":"Array"},{"name":"postId","type":"String"}],"returntype":"Void","safe":false}],"events":[{"name":"Hello world!","parameters":[{"name":"args","type":"Array"}]}]},"features":{},"groups":[],"permissions":[{"contract":"*","methods":"*"}],"supportedstandards":[],"trusts":[],"extra":null}
|
BIN
Comment/comment.nef
Executable file
BIN
Comment/comment.nef
Executable file
Binary file not shown.
|
@ -3,12 +3,12 @@ package Post
|
|||
import (
|
||||
"github.com/nspcc-dev/neo-go/pkg/interop/iterator"
|
||||
"github.com/nspcc-dev/neo-go/pkg/interop/native/std"
|
||||
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
|
||||
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
|
||||
)
|
||||
|
||||
type Post struct {
|
||||
postName string
|
||||
header string
|
||||
text string
|
||||
login string
|
||||
likes int
|
||||
|
@ -40,18 +40,24 @@ func NewPost(login string, text string, postName string) {
|
|||
storage.Put(ctx, post.id, std.Serialize(post))
|
||||
|
||||
updatePostIndex(login)
|
||||
lastPostIndex := storage.Get(ctx, login+lastIndex).(string)
|
||||
storage.Put(ctx, login+"_p_"+lastPostIndex, post.id)
|
||||
lastPostIndex := storage.Get(ctx, login+lastIndex).(int)
|
||||
storage.Put(ctx, login+"_p_"+std.Itoa10(lastPostIndex), post.id)
|
||||
runtime.Log("BLIN BLINSKIY POST " + post.id + "--------" + login + "_p_" + std.Itoa10(lastPostIndex))
|
||||
runtime.Log("AIDISHNIK " + storage.Get(ctx, post.id).(string))
|
||||
}
|
||||
|
||||
func GetAllPosts() []Post {
|
||||
posts := make([]Post, 0)
|
||||
ctx := storage.GetReadOnlyContext()
|
||||
runtime.Log("SUUUUUDAAAAAAAAAAAAAAAAA SUKA xyu")
|
||||
it := storage.Find(ctx, "post", storage.ValuesOnly|storage.DeserializeValues)
|
||||
for iterator.Next(it) {
|
||||
post := iterator.Value(it).(Post)
|
||||
runtime.Log("SUUUUUDAAAAAAAAAAAAAAAAA SUKA")
|
||||
runtime.Log(string(std.Serialize(post)))
|
||||
posts = append(posts, post)
|
||||
}
|
||||
|
||||
return posts
|
||||
}
|
||||
|
||||
|
@ -68,11 +74,14 @@ func GetPost(postId string) Post {
|
|||
|
||||
func GetAllPostsByUser(login string) []Post {
|
||||
ctx := storage.GetReadOnlyContext()
|
||||
var postsByUser []Post
|
||||
i := 0
|
||||
var postsByUser []Post = make([]Post, 0)
|
||||
i := 1
|
||||
n := getPostIndex(login)
|
||||
for i < n {
|
||||
post := storage.Get(ctx, login+"_p_"+std.Itoa10(i))
|
||||
runtime.Log("N NUM BLIN BLIN" + std.Itoa10(n))
|
||||
for i < n+1 {
|
||||
post_key := storage.Get(ctx, login+"_p_"+std.Itoa10(i)).(string)
|
||||
runtime.Log("SUKA POSTKEY " + post_key)
|
||||
post := storage.Get(ctx, post_key)
|
||||
i++
|
||||
postsByUser = append(postsByUser, std.Deserialize(post.([]byte)).(Post))
|
||||
}
|
||||
|
|
1
Post/post_contract.json
Executable file
1
Post/post_contract.json
Executable file
|
@ -0,0 +1 @@
|
|||
{"name":"Post","abi":{"methods":[{"name":"getAllPosts","offset":249,"parameters":[],"returntype":"Array","safe":false},{"name":"getAllPostsByUser","offset":466,"parameters":[{"name":"login","type":"String"}],"returntype":"Array","safe":false},{"name":"getPost","offset":408,"parameters":[{"name":"postId","type":"String"}],"returntype":"Array","safe":false},{"name":"newPost","offset":0,"parameters":[{"name":"login","type":"String"},{"name":"text","type":"String"},{"name":"postName","type":"String"}],"returntype":"Void","safe":false},{"name":"ratePost","offset":621,"parameters":[{"name":"isLike","type":"Boolean"},{"name":"postId","type":"String"}],"returntype":"Void","safe":false}],"events":[]},"features":{},"groups":[],"permissions":[{"contract":"*","methods":"*"}],"supportedstandards":[],"trusts":[],"extra":null}
|
BIN
Post/post_contract.nef
Executable file
BIN
Post/post_contract.nef
Executable file
Binary file not shown.
|
@ -21,7 +21,6 @@ const (
|
|||
|
||||
func NewUser(name string, surname string, login string, password string, owner interop.Hash160) {
|
||||
ctx := storage.GetContext()
|
||||
|
||||
existing_login := storage.Get(ctx, login)
|
||||
if existing_login != nil {
|
||||
panic("this login is taken by someone else")
|
||||
|
@ -38,7 +37,11 @@ func NewUser(name string, surname string, login string, password string, owner i
|
|||
saveUser(ctx, login, user)
|
||||
}
|
||||
|
||||
func GetUser(ctx storage.Context, login string) User {
|
||||
func GetUser(login string) User {
|
||||
return getUserTst(storage.GetReadOnlyContext(), login)
|
||||
}
|
||||
|
||||
func getUserTst(ctx storage.Context, login string) User {
|
||||
data := storage.Get(ctx, login)
|
||||
|
||||
if data == nil {
|
||||
|
|
1
User/user.json
Executable file
1
User/user.json
Executable file
|
@ -0,0 +1 @@
|
|||
{"name":"user","abi":{"methods":[{"name":"getUser","offset":80,"parameters":[{"name":"login","type":"String"}],"returntype":"Array","safe":false},{"name":"newUser","offset":0,"parameters":[{"name":"name","type":"String"},{"name":"surname","type":"String"},{"name":"login","type":"String"},{"name":"password","type":"String"},{"name":"owner","type":"Hash160"}],"returntype":"Void","safe":false}],"events":[]},"features":{},"groups":[],"permissions":[],"supportedstandards":[],"trusts":[],"extra":null}
|
BIN
User/user.nef
Executable file
BIN
User/user.nef
Executable file
Binary file not shown.
Loading…
Reference in a new issue