Documentation ¶
Index ¶
- type Answer
- type AnswerRequest
- type PaginatedQuestions
- type Question
- type QuestionCreateRequest
- type QuestionService
- type Service
- func (s *Service) CreateAnswer(answer Answer, question_id uint) (Question, error)
- func (s *Service) CreateNewQuestion(question Question, topwords []types.TopWord) (Question, error)
- func (s *Service) GetAllQuestions() []*Question
- func (s *Service) GetQuestionBasedonSlug(slug string) Question
- func (s *Service) GetQuestionByID(id uint) Question
- func (s *Service) GetQuestionsBasedonTags(vals []string) []Question
- func (s *Service) GetQuestionsPaginate(pageID int) PaginatedQuestions
- func (s *Service) IsQuestionExist(id uint) bool
- func (s *Service) IsTitleExist(title string) bool
- func (s *Service) SearchPosts(q string) []Question
- func (s *Service) SearchQuestionsByTagsv2(tag string) []*Question
- func (s *Service) SearchQuestionsByTagsv2PGStringArray(tags pq.StringArray) []*Question
- func (s *Service) UpVotePost(user user.User, question Question) (bool, []types.TopWord)
- func (s *Service) UpdateQuestionViews(question Question)
- type Tag
- type UpVotedBy
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Answer ¶
type Answer struct { models.Model Title string `gorm:"column:title" json:"title"` Body string `gorm:"column:body" json:"body"` QuestionID int64 `gorm:"column:question_id" json:"question_id"` ViewCount int `gorm:"column:view_count default:0" json:"view_count"` DownVoteCount int `gorm:"column:down_vote_count default:0" json:"down_vote_count"` UpVoteCount int `grom:"column:up_vote_count default:0" json:"up_vote_count"` Score int `gorm:"column:score default:0" json:"score"` }
type AnswerRequest ¶
type PaginatedQuestions ¶
type Question ¶
type Question struct { models.Model // QuestionID int `gorm:"column:question_id primaryKey" json:"question_id"` Title string `gorm:"column:title" json:"title"` Body string `gorm:"column:body" json:"body"` IsAnswered bool `gorm:"column:is_answered default:false" json:"is_answered"` ViewCount int `gorm:"column:view_count default:0" json:"view_count"` DownVoteCount int `gorm:"column:down_vote_count default:0" json:"down_vote_count"` UpVoteCount int `grom:"column:up_vote_count default:0" json:"up_vote_count"` AnswerCount int `gorm:"column:answer_count default:0" json:"answer_count"` Score int `gorm:"column:score default:0" json:"score"` CreatedBy uint64 `gorm:"column:created_by" json:"created_by" ` Slug string `gorm:"column:slug" json:"slug"` Tags []Tag `gorm:"many2many:question_tags" json:"tags"` Answers []Answer `gor:"foreignKey:question_id;id" json:"answers"` UpvotedUsers []UpVotedBy `gorm:"many2many:question_id;id" json:"upvotedUsers"` Related []models.TopWord `gorm:"many2many:question_related" json:"relatedtopics"` }
type QuestionCreateRequest ¶
type QuestionService ¶
type QuestionService interface { CreateNewQuestion(question Question) (Question, error) GetAllQuestions() []*Question CreateAnswer(answer Answer, question_id string) (Question, error) SearchQuestions(q string) []Question SearchQuestionsByTags(tag string) []Question // pagination GetQuestionsPaginate(pageID int) []Question //utils GetQuestionByID(id uint) Question UpdateQuestionViews(id uint) IsQuestionExist(id uint) bool // vote UpVotePost(user *user.User, question *Question) //fetch GetQuestionsBasedonTags(vals []string) []Question // contains filtered or unexported methods }
QuestionService - interface for Question Service
type Service ¶
func NewService ¶
NewService - create a instance of this service and return a pointer to the servie
func (*Service) CreateAnswer ¶
func (*Service) CreateNewQuestion ¶
create a new question
func (*Service) GetAllQuestions ¶
fetch all posts avaible
func (*Service) GetQuestionBasedonSlug ¶
func (*Service) GetQuestionByID ¶
func (*Service) GetQuestionsBasedonTags ¶
func (*Service) GetQuestionsPaginate ¶
func (s *Service) GetQuestionsPaginate(pageID int) PaginatedQuestions
GetArticles returns all articles from the database
func (*Service) IsQuestionExist ¶
func (*Service) IsTitleExist ¶
func (*Service) SearchPosts ¶
seach for a post based on a keyword
func (*Service) SearchQuestionsByTagsv2 ¶
func (*Service) SearchQuestionsByTagsv2PGStringArray ¶
func (s *Service) SearchQuestionsByTagsv2PGStringArray(tags pq.StringArray) []*Question
func (*Service) UpVotePost ¶
upvote a posttopwords
func (*Service) UpdateQuestionViews ¶
update question views
Click to show internal directories.
Click to hide internal directories.