diff --git a/comment/comment.go b/comment/comment.go index a5c996c..81ecbf5 100644 --- a/comment/comment.go +++ b/comment/comment.go @@ -1,9 +1,9 @@ package comment import ( + guuid "github.com/google/uuid" "github.com/nspcc-dev/neo-go/pkg/interop/native/std" "github.com/nspcc-dev/neo-go/pkg/interop/storage" - "github.com/rs/xid" ) type Comment struct { @@ -18,7 +18,7 @@ type Comment struct { func CreateNewComment(authorId string, postId string, text string) { ctx := storage.GetContext() newComment := Comment{ - id: xid.New().String(), + id: guuid.New().String(), authorId: authorId, postId: postId, text: text, @@ -29,7 +29,6 @@ func CreateNewComment(authorId string, postId string, text string) { comments := GetByPostId(postId) comments = append(comments, newComment) storage.Put(ctx, postId+"_comment", std.Serialize(comments)) - storage.Put(ctx, newComment.id, std.Serialize(newComment)) } func GetByPostId(postId string) []Comment { @@ -57,12 +56,7 @@ func GetComment(commentId string, postId string) Comment { } } - panic("Коммента с таким айдишником нету v poste nety") -} - -func GetComment(commentId string) Comment { - ctx := storage.GetContext() - return std.Deserialize(storage.Get(ctx, commentId).([]byte)).(Comment) + panic("Коммента с таким айдишником нету") } func RateComment(isLike bool, postId string, commentId string) { @@ -86,4 +80,4 @@ func UpdateComment(comment Comment, postId string) { } storage.Put(ctx, postId+"_comment", std.Serialize(comments)) -} +} \ No newline at end of file diff --git a/comment/comment.json b/comment/comment.json index 76f4d83..e876375 100755 --- a/comment/comment.json +++ b/comment/comment.json @@ -1 +1 @@ -{"name":"comment","abi":{"methods":[{"name":"_initialize","offset":0,"parameters":[],"returntype":"Void","safe":false},{"name":"runtimeNotify","offset":21,"parameters":[{"name":"args","type":"Array"}],"returntype":"Void","safe":false}],"events":[{"name":"Hello world!","parameters":[{"name":"args","type":"Array"}]}]},"features":{},"groups":[],"permissions":[{"contract":"*","methods":"*"}],"supportedstandards":[],"trusts":[],"extra":null} \ No newline at end of file +{"name":"comment","abi":{"methods":[{"name":"createNewComment","offset":0,"parameters":[{"name":"authorId","type":"String"},{"name":"postId","type":"String"},{"name":"text","type":"String"}],"returntype":"Void","safe":false},{"name":"getByAuthorId","offset":109,"parameters":[{"name":"postId","type":"String"},{"name":"authorId","type":"String"}],"returntype":"Array","safe":false},{"name":"getByPostId","offset":61,"parameters":[{"name":"postId","type":"String"}],"returntype":"Array","safe":false},{"name":"getComment","offset":157,"parameters":[{"name":"commentId","type":"String"},{"name":"postId","type":"String"}],"returntype":"Array","safe":false},{"name":"rateComment","offset":259,"parameters":[{"name":"isLike","type":"Boolean"},{"name":"postId","type":"String"},{"name":"commentId","type":"String"}],"returntype":"Void","safe":false}],"events":[{"name":"Hello world!","parameters":[{"name":"args","type":"Array"}]}]},"features":{},"groups":[],"permissions":[{"contract":"*","methods":"*"}],"supportedstandards":[],"trusts":[],"extra":null} \ No newline at end of file diff --git a/comment/comment.nef b/comment/comment.nef index 22d6ebd..62776e6 100755 Binary files a/comment/comment.nef and b/comment/comment.nef differ