answer/internal/entity/answer_entity.go

58 lines
2.4 KiB
Go
Raw Normal View History

2022-09-27 17:59:05 +08:00
package entity
import "time"
const (
Answer_Search_OrderBy_Default = "default"
Answer_Search_OrderBy_Time = "updated"
Answer_Search_OrderBy_Vote = "vote"
AnswerStatusAvailable = 1
AnswerStatusDeleted = 10
)
var CmsAnswerSearchStatus = map[string]int{
"available": AnswerStatusAvailable,
"deleted": AnswerStatusDeleted,
}
// Answer answer
type Answer struct {
ID string `xorm:"not null pk autoincr comment('answer id') BIGINT(20) id"`
2022-10-19 14:56:22 +08:00
CreatedAt time.Time `xorm:"created comment('create time') not null default CURRENT_TIMESTAMP TIMESTAMP created_at"`
UpdatedAt time.Time `xorm:"not null default CURRENT_TIMESTAMP comment('update time') TIMESTAMP updated_at"`
2022-09-27 17:59:05 +08:00
QuestionID string `xorm:"not null default 0 comment('question id') BIGINT(20) question_id"`
2022-10-19 14:56:22 +08:00
UserID string `xorm:"not null default 0 comment('answer user id') BIGINT(20) INDEX user_id"`
OriginalText string `xorm:"not null comment('original text') MEDIUMTEXT original_text"`
ParsedText string `xorm:"not null comment('parsed text') MEDIUMTEXT parsed_text"`
Status int `xorm:"not null default 1 comment('answer status(available: 1; deleted: 10)') INT(11) status"`
2022-09-27 17:59:05 +08:00
Adopted int `xorm:"not null default 1 comment('adopted (1 failed 2 adopted)') INT(11) adopted"`
CommentCount int `xorm:"not null default 0 comment('comment count') INT(11) comment_count"`
VoteCount int `xorm:"not null default 0 comment('vote count') INT(11) vote_count"`
2022-10-19 14:56:22 +08:00
RevisionID string `xorm:"not null default 0 comment('revision id') BIGINT(20) revision_id"`
2022-09-27 17:59:05 +08:00
}
type AnswerSearch struct {
Answer
Order string `json:"order_by" ` // default or updated
Page int `json:"page" form:"page"` //Query number of pages
PageSize int `json:"page_size" form:"page_size"` //Search page size
}
type CmsAnswerSearch struct {
Page int `json:"page" form:"page"` //Query number of pages
PageSize int `json:"page_size" form:"page_size"` //Search page size
Status int `json:"-" form:"-"`
StatusStr string `json:"status" form:"status"` //Status 1 Available 2 closed 10 Deleted
}
type AdminSetAnswerStatusRequest struct {
StatusStr string `json:"status" form:"status"`
AnswerID string `json:"answer_id" form:"answer_id"`
}
// TableName answer table name
func (Answer) TableName() string {
return "answer"
}