GraphQL API and utilities for the rpdata project
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.4 KiB

  1. package models
  2. import "time"
  3. // A Comment is a comment on a chapter.
  4. type Comment struct {
  5. ID string `bson:"_id"`
  6. ChapterID string `bson:"chapterId"`
  7. Subject string `bson:"subject"`
  8. Author string `bson:"author"`
  9. CharacterName string `bson:"characterName"`
  10. CharacterID string `bson:"characterId"`
  11. FictionalDate time.Time `bson:"fictionalDate"`
  12. CreatedDate time.Time `bson:"createdDate"`
  13. EditedDate time.Time `bson:"editedDate"`
  14. Source string `bson:"source"`
  15. }
  16. func (comment *Comment) ApplyUpdate(update CommentUpdate) {
  17. if update.Source != nil {
  18. comment.Source = *update.Source
  19. }
  20. if update.CharacterName != nil {
  21. comment.CharacterName = *update.CharacterName
  22. }
  23. if update.CharacterID != nil {
  24. comment.CharacterID = *update.CharacterID
  25. }
  26. if update.Subject != nil {
  27. comment.Subject = *update.Subject
  28. }
  29. if update.FictionalDate != nil {
  30. comment.FictionalDate = *update.FictionalDate
  31. }
  32. comment.EditedDate = time.Now()
  33. }
  34. // IsChangeObject is an interface implementation to identify it as a valid
  35. // ChangeObject in GQL.
  36. func (*Comment) IsChangeObject() {
  37. panic("this method is a dummy, and so is its caller")
  38. }
  39. type CommentFilter struct {
  40. ChapterID *string
  41. Limit int
  42. }
  43. type CommentUpdate struct {
  44. Source *string
  45. CharacterName *string
  46. CharacterID *string
  47. Subject *string
  48. FictionalDate *time.Time
  49. }