2022-09-27 17:59:05 +08:00
|
|
|
package schema
|
|
|
|
|
2022-12-12 18:21:03 +08:00
|
|
|
const (
|
2022-12-12 19:03:41 +08:00
|
|
|
SitemapMaxSize = 50000
|
2022-12-12 18:21:03 +08:00
|
|
|
SitemapCachekey = "answer@sitemap"
|
|
|
|
SitemapPageCachekey = "answer@sitemap@page%d"
|
|
|
|
)
|
|
|
|
|
2022-09-27 17:59:05 +08:00
|
|
|
// RemoveQuestionReq delete question request
|
|
|
|
type RemoveQuestionReq struct {
|
|
|
|
// question id
|
2022-12-02 17:24:46 +08:00
|
|
|
ID string `validate:"required" json:"id"`
|
2022-11-22 16:22:30 +08:00
|
|
|
UserID string `json:"-" ` // user_id
|
|
|
|
IsAdmin bool `json:"-"`
|
2022-09-27 17:59:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
type CloseQuestionReq struct {
|
2022-12-02 17:24:46 +08:00
|
|
|
ID string `validate:"required" json:"id"`
|
|
|
|
CloseType int `json:"close_type"` // close_type
|
|
|
|
CloseMsg string `json:"close_msg"` // close_type
|
|
|
|
UserID string `json:"-"` // user_id
|
2022-09-27 17:59:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
type CloseQuestionMeta struct {
|
|
|
|
CloseType int `json:"close_type"`
|
|
|
|
CloseMsg string `json:"close_msg"`
|
|
|
|
}
|
|
|
|
|
2022-12-02 17:24:46 +08:00
|
|
|
// ReopenQuestionReq reopen question request
|
|
|
|
type ReopenQuestionReq struct {
|
|
|
|
QuestionID string `json:"question_id"`
|
|
|
|
UserID string `json:"-"`
|
|
|
|
}
|
|
|
|
|
2022-09-27 17:59:05 +08:00
|
|
|
type QuestionAdd struct {
|
|
|
|
// question title
|
2022-09-29 16:39:34 +08:00
|
|
|
Title string `validate:"required,gte=6,lte=150" json:"title"`
|
2022-09-27 17:59:05 +08:00
|
|
|
// content
|
|
|
|
Content string `validate:"required,gte=6,lte=65535" json:"content"`
|
|
|
|
// html
|
2022-11-01 15:25:44 +08:00
|
|
|
HTML string `validate:"required,gte=6,lte=65535" json:"html"`
|
2022-09-27 17:59:05 +08:00
|
|
|
// tags
|
|
|
|
Tags []*TagItem `validate:"required,dive" json:"tags"`
|
|
|
|
// user id
|
|
|
|
UserID string `json:"-"`
|
2022-11-25 16:43:00 +08:00
|
|
|
QuestionPermission
|
2022-11-25 12:07:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
type QuestionPermission struct {
|
|
|
|
// whether user can add it
|
|
|
|
CanAdd bool `json:"-"`
|
|
|
|
// whether user can edit it
|
|
|
|
CanEdit bool `json:"-"`
|
|
|
|
// whether user can delete it
|
|
|
|
CanDelete bool `json:"-"`
|
|
|
|
// whether user can close it
|
|
|
|
CanClose bool `json:"-"`
|
2022-12-02 15:08:18 +08:00
|
|
|
// whether user can reopen it
|
|
|
|
CanReopen bool `json:"-"`
|
2022-12-08 11:14:56 +08:00
|
|
|
// whether user can use reserved it
|
|
|
|
CanUseReservedTag bool `json:"-"`
|
2022-09-27 17:59:05 +08:00
|
|
|
}
|
|
|
|
|
2022-11-23 15:19:17 +08:00
|
|
|
type CheckCanQuestionUpdate struct {
|
|
|
|
// question id
|
2022-11-24 17:58:22 +08:00
|
|
|
ID string `validate:"required" form:"id"`
|
2022-11-23 15:19:17 +08:00
|
|
|
// user id
|
|
|
|
UserID string `json:"-"`
|
|
|
|
IsAdmin bool `json:"-"`
|
|
|
|
}
|
|
|
|
|
2022-09-27 17:59:05 +08:00
|
|
|
type QuestionUpdate struct {
|
|
|
|
// question id
|
|
|
|
ID string `validate:"required" json:"id"`
|
|
|
|
// question title
|
2022-09-29 16:39:34 +08:00
|
|
|
Title string `validate:"required,gte=6,lte=150" json:"title"`
|
2022-09-27 17:59:05 +08:00
|
|
|
// content
|
|
|
|
Content string `validate:"required,gte=6,lte=65535" json:"content"`
|
|
|
|
// html
|
2022-11-01 15:25:44 +08:00
|
|
|
HTML string `validate:"required,gte=6,lte=65535" json:"html"`
|
2022-09-27 17:59:05 +08:00
|
|
|
// tags
|
|
|
|
Tags []*TagItem `validate:"required,dive" json:"tags"`
|
|
|
|
// edit summary
|
|
|
|
EditSummary string `validate:"omitempty" json:"edit_summary"`
|
|
|
|
// user id
|
2022-11-24 18:00:30 +08:00
|
|
|
UserID string `json:"-"`
|
|
|
|
NoNeedReview bool `json:"-"`
|
2022-11-25 16:43:00 +08:00
|
|
|
QuestionPermission
|
2022-09-27 17:59:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
type QuestionBaseInfo struct {
|
|
|
|
ID string `json:"id" `
|
2022-10-21 12:00:50 +08:00
|
|
|
Title string `json:"title" xorm:"title"` // title
|
|
|
|
ViewCount int `json:"view_count" xorm:"view_count"` // view count
|
|
|
|
AnswerCount int `json:"answer_count" xorm:"answer_count"` // answer count
|
|
|
|
CollectionCount int `json:"collection_count" xorm:"collection_count"` // collection count
|
|
|
|
FollowCount int `json:"follow_count" xorm:"follow_count"` // follow count
|
2022-09-30 10:22:41 +08:00
|
|
|
Status string `json:"status"`
|
2022-09-27 17:59:05 +08:00
|
|
|
AcceptedAnswer bool `json:"accepted_answer"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type QuestionInfo struct {
|
|
|
|
ID string `json:"id" `
|
2022-10-21 12:00:50 +08:00
|
|
|
Title string `json:"title" xorm:"title"` // title
|
|
|
|
Content string `json:"content" xorm:"content"` // content
|
2022-11-01 15:25:44 +08:00
|
|
|
HTML string `json:"html" xorm:"html"` // html
|
2022-12-07 17:05:19 +08:00
|
|
|
Description string `json:"description"` //description
|
2022-09-27 17:59:05 +08:00
|
|
|
Tags []*TagResp `json:"tags" ` // tags
|
|
|
|
ViewCount int `json:"view_count" xorm:"view_count"` // view_count
|
|
|
|
UniqueViewCount int `json:"unique_view_count" xorm:"unique_view_count"` // unique_view_count
|
|
|
|
VoteCount int `json:"vote_count" xorm:"vote_count"` // vote_count
|
2022-10-21 12:00:50 +08:00
|
|
|
AnswerCount int `json:"answer_count" xorm:"answer_count"` // answer count
|
|
|
|
CollectionCount int `json:"collection_count" xorm:"collection_count"` // collection count
|
|
|
|
FollowCount int `json:"follow_count" xorm:"follow_count"` // follow count
|
2022-11-01 15:25:44 +08:00
|
|
|
AcceptedAnswerID string `json:"accepted_answer_id" ` // accepted_answer_id
|
|
|
|
LastAnswerID string `json:"last_answer_id" ` // last_answer_id
|
2022-09-27 17:59:05 +08:00
|
|
|
CreateTime int64 `json:"create_time" ` // create_time
|
|
|
|
UpdateTime int64 `json:"-"` // update_time
|
|
|
|
PostUpdateTime int64 `json:"update_time"`
|
|
|
|
QuestionUpdateTime int64 `json:"edit_time"`
|
|
|
|
Status int `json:"status"`
|
|
|
|
Operation *Operation `json:"operation,omitempty"`
|
2022-11-01 15:25:44 +08:00
|
|
|
UserID string `json:"-" `
|
2022-12-01 15:26:20 +08:00
|
|
|
LastEditUserID string `json:"-" `
|
|
|
|
LastAnsweredUserID string `json:"-" `
|
2022-09-27 17:59:05 +08:00
|
|
|
UserInfo *UserBasicInfo `json:"user_info"`
|
|
|
|
UpdateUserInfo *UserBasicInfo `json:"update_user_info,omitempty"`
|
|
|
|
LastAnsweredUserInfo *UserBasicInfo `json:"last_answered_user_info,omitempty"`
|
|
|
|
Answered bool `json:"answered"`
|
|
|
|
Collected bool `json:"collected"`
|
|
|
|
VoteStatus string `json:"vote_status"`
|
|
|
|
IsFollowed bool `json:"is_followed"`
|
|
|
|
|
|
|
|
// MemberActions
|
|
|
|
MemberActions []*PermissionMemberAction `json:"member_actions"`
|
|
|
|
}
|
|
|
|
|
2022-12-01 18:15:39 +08:00
|
|
|
// UpdateQuestionResp update question resp
|
|
|
|
type UpdateQuestionResp struct {
|
|
|
|
WaitForReview bool `json:"wait_for_review"`
|
|
|
|
}
|
|
|
|
|
2022-09-27 17:59:05 +08:00
|
|
|
type AdminQuestionInfo struct {
|
|
|
|
ID string `json:"id"`
|
|
|
|
Title string `json:"title"`
|
|
|
|
VoteCount int `json:"vote_count"`
|
|
|
|
AnswerCount int `json:"answer_count"`
|
|
|
|
AcceptedAnswerID string `json:"accepted_answer_id"`
|
|
|
|
CreateTime int64 `json:"create_time"`
|
|
|
|
UpdateTime int64 `json:"update_time"`
|
|
|
|
EditTime int64 `json:"edit_time"`
|
|
|
|
UserID string `json:"-" `
|
|
|
|
UserInfo *UserBasicInfo `json:"user_info"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type Operation struct {
|
2022-11-01 15:25:44 +08:00
|
|
|
OperationType string `json:"operation_type"`
|
|
|
|
OperationDescription string `json:"operation_description"`
|
|
|
|
OperationMsg string `json:"operation_msg"`
|
|
|
|
OperationTime int64 `json:"operation_time"`
|
2022-09-27 17:59:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
type GetCloseTypeResp struct {
|
|
|
|
// report name
|
|
|
|
Name string `json:"name"`
|
|
|
|
// report description
|
|
|
|
Description string `json:"description"`
|
|
|
|
// report source
|
|
|
|
Source string `json:"source"`
|
|
|
|
// report type
|
|
|
|
Type int `json:"type"`
|
|
|
|
// is have content
|
|
|
|
HaveContent bool `json:"have_content"`
|
|
|
|
// content type
|
|
|
|
ContentType string `json:"content_type"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type UserAnswerInfo struct {
|
|
|
|
AnswerID string `json:"answer_id"`
|
|
|
|
QuestionID string `json:"question_id"`
|
|
|
|
Adopted int `json:"adopted"`
|
|
|
|
VoteCount int `json:"vote_count"`
|
|
|
|
CreateTime int `json:"create_time"`
|
|
|
|
UpdateTime int `json:"update_time"`
|
|
|
|
QuestionInfo struct {
|
|
|
|
Title string `json:"title"`
|
|
|
|
Tags []interface{} `json:"tags"`
|
|
|
|
} `json:"question_info"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type UserQuestionInfo struct {
|
|
|
|
ID string `json:"question_id"`
|
|
|
|
Title string `json:"title"`
|
|
|
|
VoteCount int `json:"vote_count"`
|
|
|
|
Tags []interface{} `json:"tags"`
|
|
|
|
ViewCount int `json:"view_count"`
|
|
|
|
AnswerCount int `json:"answer_count"`
|
|
|
|
CollectionCount int `json:"collection_count"`
|
|
|
|
CreateTime int `json:"create_time"`
|
2022-11-01 15:25:44 +08:00
|
|
|
AcceptedAnswerID string `json:"accepted_answer_id"`
|
2022-09-30 10:22:41 +08:00
|
|
|
Status string `json:"status"`
|
2022-09-27 17:59:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
type QuestionSearch struct {
|
2022-11-01 15:37:22 +08:00
|
|
|
Page int `json:"page" form:"page"` // Query number of pages
|
|
|
|
PageSize int `json:"page_size" form:"page_size"` // Search page size
|
|
|
|
Order string `json:"order" form:"order"` // Search order by
|
|
|
|
// Tags []string `json:"tags" form:"tags"` // Search tag
|
2022-10-27 10:41:57 +08:00
|
|
|
Tag string `json:"tag" form:"tag"` //Search tag
|
2022-11-01 15:37:22 +08:00
|
|
|
TagIDs []string `json:"-" form:"-"` // Search tag
|
|
|
|
UserName string `json:"username" form:"username"` // Search username
|
2022-09-27 17:59:05 +08:00
|
|
|
UserID string `json:"-" form:"-"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type CmsQuestionSearch struct {
|
2022-11-01 15:25:44 +08:00
|
|
|
Page int `json:"page" form:"page"` // Query number of pages
|
|
|
|
PageSize int `json:"page_size" form:"page_size"` // Search page size
|
2022-09-27 17:59:05 +08:00
|
|
|
Status int `json:"-" form:"-"`
|
2022-11-22 16:22:30 +08:00
|
|
|
StatusStr string `json:"status" form:"status"` // Status 1 Available 2 closed 10 UserDeleted
|
2022-11-01 09:12:12 +08:00
|
|
|
Query string `validate:"omitempty,gt=0,lte=100" json:"query" form:"query" ` //Query string
|
2022-09-27 17:59:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
type AdminSetQuestionStatusRequest struct {
|
|
|
|
StatusStr string `json:"status" form:"status"`
|
|
|
|
QuestionID string `json:"question_id" form:"question_id"`
|
|
|
|
}
|
2022-12-12 18:21:03 +08:00
|
|
|
|
|
|
|
type SiteMapList struct {
|
|
|
|
QuestionIDs []*SiteMapQuestionInfo `json:"question_ids"`
|
|
|
|
MaxPageNum []int `json:"max_page_num"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type SiteMapPageList struct {
|
|
|
|
PageData []*SiteMapQuestionInfo `json:"page_data"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type SiteMapQuestionInfo struct {
|
|
|
|
ID string `json:"id"`
|
|
|
|
Title string `json:"title"`
|
|
|
|
UpdateTime string `json:"time"`
|
|
|
|
}
|