answer/internal/entity/question_entity.go

70 lines
2.8 KiB
Go
Raw Normal View History

2022-09-27 17:59:05 +08:00
package entity
import (
"time"
)
const (
QuestionStatusAvailable = 1
2022-11-22 19:48:27 +08:00
QuestionStatusClosed = 2
2022-09-27 17:59:05 +08:00
QuestionStatusDeleted = 10
)
2022-12-21 16:55:16 +08:00
var AdminQuestionSearchStatus = map[string]int{
2022-09-27 17:59:05 +08:00
"available": QuestionStatusAvailable,
2022-11-22 19:48:27 +08:00
"closed": QuestionStatusClosed,
2022-09-27 17:59:05 +08:00
"deleted": QuestionStatusDeleted,
}
2022-12-21 16:55:16 +08:00
var AdminQuestionSearchStatusIntToString = map[int]string{
2022-09-30 10:22:41 +08:00
QuestionStatusAvailable: "available",
2022-11-22 19:48:27 +08:00
QuestionStatusClosed: "closed",
2022-09-30 10:22:41 +08:00
QuestionStatusDeleted: "deleted",
}
2022-09-27 17:59:05 +08:00
// Question question
type Question struct {
ID string `xorm:"not null pk BIGINT(20) id"`
CreatedAt time.Time `xorm:"not null default CURRENT_TIMESTAMP TIMESTAMP created_at"`
2022-11-29 14:56:22 +08:00
UpdatedAt time.Time `xorm:"updated_at TIMESTAMP"`
UserID string `xorm:"not null default 0 BIGINT(20) INDEX user_id"`
2022-12-01 15:26:20 +08:00
LastEditUserID string `xorm:"not null default 0 BIGINT(20) last_edit_user_id"`
Title string `xorm:"not null default '' VARCHAR(150) title"`
OriginalText string `xorm:"not null MEDIUMTEXT original_text"`
ParsedText string `xorm:"not null MEDIUMTEXT parsed_text"`
Status int `xorm:"not null default 1 INT(11) status"`
ViewCount int `xorm:"not null default 0 INT(11) view_count"`
UniqueViewCount int `xorm:"not null default 0 INT(11) unique_view_count"`
VoteCount int `xorm:"not null default 0 INT(11) vote_count"`
AnswerCount int `xorm:"not null default 0 INT(11) answer_count"`
CollectionCount int `xorm:"not null default 0 INT(11) collection_count"`
FollowCount int `xorm:"not null default 0 INT(11) follow_count"`
AcceptedAnswerID string `xorm:"not null default 0 BIGINT(20) accepted_answer_id"`
LastAnswerID string `xorm:"not null default 0 BIGINT(20) last_answer_id"`
2022-11-29 14:56:22 +08:00
PostUpdateTime time.Time `xorm:"post_update_time TIMESTAMP"`
2022-11-21 16:51:13 +08:00
RevisionID string `xorm:"not null default 0 BIGINT(20) revision_id"`
2022-09-27 17:59:05 +08:00
}
// TableName question table name
func (Question) TableName() string {
return "question"
}
2022-11-21 16:51:13 +08:00
// QuestionWithTagsRevision question
type QuestionWithTagsRevision struct {
Question
Tags []*TagSimpleInfoForRevision `json:"tags"`
}
// TagSimpleInfoForRevision tag simple info for revision
type TagSimpleInfoForRevision struct {
ID string `xorm:"not null pk comment('tag_id') BIGINT(20) id"`
MainTagID int64 `xorm:"not null default 0 BIGINT(20) main_tag_id"`
MainTagSlugName string `xorm:"not null default '' VARCHAR(35) main_tag_slug_name"`
SlugName string `xorm:"not null default '' unique VARCHAR(35) slug_name"`
DisplayName string `xorm:"not null default '' VARCHAR(35) display_name"`
Recommend bool `xorm:"not null default false BOOL recommend"`
Reserved bool `xorm:"not null default false BOOL reserved"`
RevisionID string `xorm:"not null default 0 BIGINT(20) revision_id"`
2022-11-21 16:51:13 +08:00
}