Gisle Aune
6 years ago
5 changed files with 124 additions and 0 deletions
-
2cmd/rpdata-server/main.go
-
60graph2/queries/comment.go
-
4graph2/schema/root.gql
-
23graph2/schema/types/Comment.gql
-
35models/comments/add.go
@ -0,0 +1,35 @@ |
|||
package comments |
|||
|
|||
import ( |
|||
"time" |
|||
|
|||
"git.aiterp.net/rpdata/api/models" |
|||
) |
|||
|
|||
// Add adds a comment.
|
|||
func Add(chapter models.Chapter, subject, author, source, characterName string, character *models.Character, createdDate time.Time, fictionalDate time.Time) (models.Comment, error) { |
|||
characterID := "" |
|||
if character != nil { |
|||
characterID = character.ID |
|||
} |
|||
|
|||
comment := models.Comment{ |
|||
ID: makeCommentID(), |
|||
ChapterID: chapter.ID, |
|||
Subject: subject, |
|||
Author: author, |
|||
CharacterName: characterName, |
|||
CharacterID: characterID, |
|||
FictionalDate: fictionalDate, |
|||
CreatedDate: createdDate, |
|||
EditedDate: createdDate, |
|||
Source: source, |
|||
} |
|||
|
|||
err := collection.Insert(comment) |
|||
if err != nil { |
|||
return models.Comment{}, err |
|||
} |
|||
|
|||
return comment, nil |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue