chore: import upstream snapshot with attribution
CI / Check and lint (push) Failing after 1s
Lint / Lint (ubuntu-latest) (push) Failing after 1s

This commit is contained in:
wehub-resource-sync
2026-07-13 12:22:32 +08:00
commit 39dbe3a57d
1131 changed files with 272709 additions and 0 deletions
+63
View File
@@ -0,0 +1,63 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package entity
import "time"
const (
ActivityAvailable = 0
ActivityCancelled = 1
)
// Activity activity
type Activity struct {
ID string `xorm:"not null pk autoincr BIGINT(20) id"`
CreatedAt time.Time `xorm:"created TIMESTAMP created_at"`
UpdatedAt time.Time `xorm:"updated TIMESTAMP updated_at"`
CancelledAt time.Time `xorm:"TIMESTAMP cancelled_at"`
UserID string `xorm:"not null index BIGINT(20) user_id"`
TriggerUserID int64 `xorm:"not null default 0 index BIGINT(20) trigger_user_id"`
ObjectID string `xorm:"not null default 0 index BIGINT(20) object_id"`
OriginalObjectID string `xorm:"not null default 0 BIGINT(20) original_object_id"`
ActivityType int `xorm:"not null INT(11) activity_type"`
Cancelled int `xorm:"not null default 0 TINYINT(4) cancelled"`
Rank int `xorm:"not null default 0 INT(11) rank"`
HasRank int `xorm:"not null default 0 TINYINT(4) has_rank"`
RevisionID int64 `xorm:"not null default 0 BIGINT(20) revision_id"`
}
type ActivityRankSum struct {
Rank int `xorm:"not null default 0 INT(11) rank"`
}
type ActivityUserRankStat struct {
UserID string `xorm:"user_id"`
Rank int `xorm:"rank_amount"`
}
type ActivityUserVoteStat struct {
UserID string `xorm:"user_id"`
VoteCount int `xorm:"vote_count"`
}
// TableName activity table name
func (Activity) TableName() string {
return "activity"
}
+37
View File
@@ -0,0 +1,37 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package entity
import "time"
// AIConversation AI
type AIConversation struct {
ID int `xorm:"not null pk autoincr INT(11) id"`
CreatedAt time.Time `xorm:"created not null default CURRENT_TIMESTAMP TIMESTAMP created_at"`
UpdatedAt time.Time `xorm:"updated not null default CURRENT_TIMESTAMP TIMESTAMP updated_at"`
ConversationID string `xorm:"not null unique VARCHAR(255) conversation_id"`
Topic string `xorm:"not null MEDIUMTEXT topic"`
UserID string `xorm:"not null default 0 BIGINT(20) user_id"`
}
// TableName returns the table name
func (AIConversation) TableName() string {
return "ai_conversation"
}
+41
View File
@@ -0,0 +1,41 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package entity
import "time"
// AIConversationRecord AI Conversation Record
type AIConversationRecord struct {
ID int `xorm:"not null pk autoincr INT(11) id"`
CreatedAt time.Time `xorm:"created not null default CURRENT_TIMESTAMP TIMESTAMP created_at"`
UpdatedAt time.Time `xorm:"updated not null default CURRENT_TIMESTAMP TIMESTAMP updated_at"`
ConversationID string `xorm:"not null VARCHAR(255) conversation_id"`
ChatCompletionID string `xorm:"not null VARCHAR(255) chat_completion_id"`
Role string `xorm:"not null default '' VARCHAR(128) role"`
Content string `xorm:"not null MEDIUMTEXT content"`
ReasoningContent string `xorm:"MEDIUMTEXT reasoning_content"`
Helpful int `xorm:"not null default 0 INT(11) helpful"`
Unhelpful int `xorm:"not null default 0 INT(11) unhelpful"`
}
// TableName returns the table name
func (AIConversationRecord) TableName() string {
return "ai_conversation_record"
}
+78
View File
@@ -0,0 +1,78 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package entity
import "time"
const (
AnswerSearchOrderByDefault = "default"
AnswerSearchOrderByTime = "updated"
AnswerSearchOrderByVote = "vote"
AnswerSearchOrderByTimeAsc = "created"
AnswerStatusAvailable = 1
AnswerStatusDeleted = 10
AnswerStatusPending = 11
)
var AdminAnswerSearchStatus = map[string]int{
"available": AnswerStatusAvailable,
"deleted": AnswerStatusDeleted,
"pending": AnswerStatusPending,
}
// Answer answer
type Answer struct {
ID string `xorm:"not null pk autoincr BIGINT(20) id"`
CreatedAt time.Time `xorm:"created not null default CURRENT_TIMESTAMP TIMESTAMP created_at"`
UpdatedAt time.Time `xorm:"updated_at TIMESTAMP"`
QuestionID string `xorm:"not null default 0 BIGINT(20) question_id"`
UserID string `xorm:"not null default 0 BIGINT(20) INDEX user_id"`
LastEditUserID string `xorm:"not null default 0 BIGINT(20) last_edit_user_id"`
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"`
Accepted int `xorm:"not null default 1 INT(11) adopted"`
CommentCount int `xorm:"not null default 0 INT(11) comment_count"`
VoteCount int `xorm:"not null default 0 INT(11) vote_count"`
RevisionID string `xorm:"not null default 0 BIGINT(20) revision_id"`
}
type AnswerSearch struct {
Answer
IncludeDeleted bool `json:"include_deleted"`
LoginUserID string `json:"login_user_id"`
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 PersonalAnswerPageQueryCond struct {
Page int
PageSize int
UserID string
Order string
ShowPending bool
}
// TableName answer table name
func (Answer) TableName() string {
return "answer"
}
+42
View File
@@ -0,0 +1,42 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package entity
import (
"time"
)
// APIKey entity
type APIKey struct {
ID int `xorm:"not null pk autoincr INT(11) id"`
CreatedAt time.Time `xorm:"created not null default CURRENT_TIMESTAMP TIMESTAMP created_at"`
UpdatedAt time.Time `xorm:"updated not null default CURRENT_TIMESTAMP TIMESTAMP updated_at"`
LastUsedAt time.Time `xorm:"not null default CURRENT_TIMESTAMP TIMESTAMP last_used_at"`
Description string `xorm:"not null MEDIUMTEXT description"`
AccessKey string `xorm:"not null unique VARCHAR(255) access_key"`
Scope string `xorm:"not null VARCHAR(255) scope"`
UserID string `xorm:"not null default 0 BIGINT(20) user_id"`
Hidden int `xorm:"not null default 0 INT(11) hidden"`
}
// TableName category table name
func (c *APIKey) TableName() string {
return "api_key"
}
+30
View File
@@ -0,0 +1,30 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package entity
// UserCacheInfo User Cache Information
type UserCacheInfo struct {
UserID string `json:"user_id"`
UserStatus int `json:"user_status"`
EmailStatus int `json:"email_status"`
RoleID int `json:"role_id"`
ExternalID string `json:"external_id"`
VisitToken string `json:"visit_token"`
}
+69
View File
@@ -0,0 +1,69 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package entity
import "time"
const (
IsBadgeNotDeleted = 0
IsBadgeDeleted = 1
BadgeEmptyAwardKey = "0"
)
// BadgeAward badge_award
type BadgeAward struct {
ID string `xorm:"not null pk BIGINT(20) id"`
CreatedAt time.Time `xorm:"created not null default CURRENT_TIMESTAMP TIMESTAMP created_at"`
UpdatedAt time.Time `xorm:"updated not null default CURRENT_TIMESTAMP TIMESTAMP updated_at"`
UserID string `xorm:"not null index BIGINT(20) user_id"`
BadgeID string `xorm:"not null index BIGINT(20) badge_id"`
AwardKey string `xorm:"not null index VARCHAR(64) award_key"`
BadgeGroupID int64 `xorm:"not null index BIGINT(20) badge_group_id"`
IsBadgeDeleted int8 `xorm:"not null TINYINT(1) is_badge_deleted"`
}
// TableName badge_award table name
func (BadgeAward) TableName() string {
return "badge_award"
}
type BadgeEarnedCount struct {
BadgeID string `xorm:"badge_id"`
EarnedCount int64 `xorm:"earned_count"`
}
// TableName badge_award table name
func (BadgeEarnedCount) TableName() string {
return "badge_award"
}
type BadgeAwardRecent struct {
Created time.Time `xorm:"created"`
BadgeID string `xorm:"badge_id"`
AwardKey string `xorm:"award_key"`
EarnedCount int64 `xorm:"earned_count"`
IsBadgeDeleted int8 `xorm:"is_badge_deleted"`
}
// TableName badge_award table name
func (BadgeAwardRecent) TableName() string {
return "badge_award"
}
+72
View File
@@ -0,0 +1,72 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package entity
import (
"time"
"github.com/tidwall/gjson"
)
type BadgeLevel int
const (
BadgeStatusActive = 1
BadgeStatusDeleted = 10
BadgeStatusInactive = 11
BadgeLevelBronze BadgeLevel = 1
BadgeLevelSilver BadgeLevel = 2
BadgeLevelGold BadgeLevel = 3
BadgeSingleAward = 1
BadgeMultiAward = 2
)
// Badge badge
type Badge struct {
ID string `xorm:"not null pk BIGINT(20) id"`
CreatedAt time.Time `xorm:"created not null default CURRENT_TIMESTAMP TIMESTAMP created_at"`
UpdatedAt time.Time `xorm:"updated not null default CURRENT_TIMESTAMP TIMESTAMP updated_at"`
Name string `xorm:"not null default '' VARCHAR(256) name"`
Icon string `xorm:"not null default '' VARCHAR(1024) icon"`
AwardCount int `xorm:"not null default 0 INT(11) award_count"`
Description string `xorm:"not null MEDIUMTEXT description"`
Status int8 `xorm:"not null default 1 INT(11) status"`
BadgeGroupID int64 `xorm:"not null default 0 BIGINT(20) badge_group_id"`
Level BadgeLevel `xorm:"not null default 1 TINYINT(4) level"`
Single int8 `xorm:"not null default 1 TINYINT(4) single"`
Collect string `xorm:"not null default '' VARCHAR(128) collect"`
Handler string `xorm:"not null default '' VARCHAR(128) handler"`
Param string `xorm:"not null TEXT param"`
}
// TableName badge table name
func (b *Badge) TableName() string {
return "badge"
}
func (b *Badge) GetIntParam(key string) int64 {
return gjson.Get(b.Param, key).Int()
}
func (b *Badge) GetStringParam(key string) string {
return gjson.Get(b.Param, key).String()
}
+35
View File
@@ -0,0 +1,35 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package entity
import "time"
// BadgeGroup badge_group
type BadgeGroup struct {
ID string `json:"id" xorm:"not null pk autoincr BIGINT(20) id"`
Name string `json:"name" xorm:"not null default '' VARCHAR(256) name"`
CreatedAt time.Time `json:"created_at" xorm:"created not null default CURRENT_TIMESTAMP TIMESTAMP created_at"`
UpdatedAt time.Time `json:"updated_at" xorm:"updated not null default CURRENT_TIMESTAMP TIMESTAMP updated_at"`
}
// TableName badge_group table name
func (BadgeGroup) TableName() string {
return "badge_group"
}
+41
View File
@@ -0,0 +1,41 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package entity
const (
CaptchaActionEmail = "email"
CaptchaActionPassword = "password"
CaptchaActionEditUserinfo = "edit_userinfo"
CaptchaActionQuestion = "question"
CaptchaActionAnswer = "answer"
CaptchaActionComment = "comment"
CaptchaActionEdit = "edit"
CaptchaActionInvitationAnswer = "invitation_answer"
CaptchaActionSearch = "search"
CaptchaActionReport = "report"
CaptchaActionDelete = "delete"
CaptchaActionVote = "vote"
)
type ActionRecordInfo struct {
LastTime int64 `json:"last_time"`
Num int `json:"num"`
Config string `json:"config"`
}
+43
View File
@@ -0,0 +1,43 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package entity
import "time"
// Collection collection
type Collection struct {
ID string `xorm:"not null pk default 0 BIGINT(20) id"`
CreatedAt time.Time `xorm:"created not null default CURRENT_TIMESTAMP TIMESTAMP created_at"`
UpdatedAt time.Time `xorm:"updated not null default CURRENT_TIMESTAMP TIMESTAMP updated_at"`
UserID string `xorm:"not null default 0 BIGINT(20) INDEX user_id"`
ObjectID string `xorm:"not null default 0 BIGINT(20) object_id"`
UserCollectionGroupID string `xorm:"not null default 0 BIGINT(20) user_collection_group_id"`
}
type CollectionSearch struct {
Collection
Page int `json:"page" form:"page"` // Query number of pages
PageSize int `json:"page_size" form:"page_size"` // Search page size
}
// TableName collection table name
func (Collection) TableName() string {
return "collection"
}
@@ -0,0 +1,37 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package entity
import "time"
// CollectionGroup collection group
type CollectionGroup struct {
ID string `xorm:"not null pk autoincr BIGINT(20) id"`
CreatedAt time.Time `xorm:"created not null default CURRENT_TIMESTAMP TIMESTAMP created_at"`
UpdatedAt time.Time `xorm:"updated not null default CURRENT_TIMESTAMP TIMESTAMP updated_at"`
UserID string `xorm:"not null default 0 BIGINT(20) INDEX user_id"`
Name string `xorm:"not null default '' VARCHAR(50) name"`
DefaultGroup int `xorm:"not null default 1 INT(11) default_group"`
}
// TableName collection group table name
func (CollectionGroup) TableName() string {
return "collection_group"
}
+94
View File
@@ -0,0 +1,94 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package entity
import (
"database/sql"
"fmt"
"time"
"github.com/apache/answer/pkg/converter"
)
const (
CommentStatusAvailable = 1
CommentStatusDeleted = 10
CommentStatusPending = 11
)
// Comment comment
type Comment struct {
ID string `xorm:"not null pk autoincr BIGINT(20) id"`
CreatedAt time.Time `xorm:"created TIMESTAMP created_at"`
UpdatedAt time.Time `xorm:"updated TIMESTAMP updated_at"`
UserID string `xorm:"not null default 0 BIGINT(20) user_id"`
ReplyUserID sql.NullInt64 `xorm:"BIGINT(20) reply_user_id"`
ReplyCommentID sql.NullInt64 `xorm:"BIGINT(20) reply_comment_id"`
ObjectID string `xorm:"not null default 0 BIGINT(20) INDEX object_id"`
QuestionID string `xorm:"not null default 0 BIGINT(20) question_id"`
VoteCount int `xorm:"not null default 0 INT(11) vote_count"`
Status int `xorm:"not null default 0 TINYINT(4) status"`
OriginalText string `xorm:"not null MEDIUMTEXT original_text"`
ParsedText string `xorm:"not null MEDIUMTEXT parsed_text"`
}
// TableName comment table name
func (c *Comment) TableName() string {
return "comment"
}
// GetReplyUserID get reply user id
func (c *Comment) GetReplyUserID() string {
if c.ReplyUserID.Valid {
return fmt.Sprintf("%d", c.ReplyUserID.Int64)
}
return ""
}
// GetReplyCommentID get reply comment id
func (c *Comment) GetReplyCommentID() string {
if c.ReplyCommentID.Valid {
return fmt.Sprintf("%d", c.ReplyCommentID.Int64)
}
return ""
}
// SetReplyUserID set reply user id
func (c *Comment) SetReplyUserID(str string) {
if len(str) > 0 {
c.ReplyUserID = sql.NullInt64{Int64: converter.StringToInt64(str), Valid: true}
} else {
c.ReplyUserID = sql.NullInt64{Valid: false}
}
}
// SetReplyCommentID set reply comment id
func (c *Comment) SetReplyCommentID(str string) {
if len(str) > 0 {
c.ReplyCommentID = sql.NullInt64{Int64: converter.StringToInt64(str), Valid: true}
} else {
c.ReplyCommentID = sql.NullInt64{Valid: false}
}
}
// GetMentionUsernameList get mention username list
func (c *Comment) GetMentionUsernameList() []string {
return converter.GetMentionUsernameList(c.OriginalText)
}
+73
View File
@@ -0,0 +1,73 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package entity
import (
"encoding/json"
"github.com/segmentfault/pacman/log"
"github.com/apache/answer/pkg/converter"
)
// Config config
type Config struct {
ID int `xorm:"not null pk autoincr INT(11) id"`
Key string `xorm:"unique VARCHAR(128) key"`
Value string `xorm:"TEXT value"`
}
// TableName config table name
func (c *Config) TableName() string {
return "config"
}
func (c *Config) BuildByJSON(data []byte) {
cf := &Config{}
_ = json.Unmarshal(data, cf)
c.ID = cf.ID
c.Key = cf.Key
c.Value = cf.Value
}
func (c *Config) JsonString() string {
data, _ := json.Marshal(c)
return string(data)
}
// GetIntValue get int value
func (c *Config) GetIntValue() int {
if len(c.Value) == 0 {
log.Warnf("config value is empty, key: %s, value: %s", c.Key, c.Value)
}
return converter.StringToInt(c.Value)
}
// GetArrayStringValue get array string value
func (c *Config) GetArrayStringValue() []string {
var arr []string
_ = json.Unmarshal([]byte(c.Value), &arr)
return arr
}
// GetByteValue get byte value
func (c *Config) GetByteValue() []byte {
return []byte(c.Value)
}
+45
View File
@@ -0,0 +1,45 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package entity
import "time"
const (
FileRecordStatusAvailable = 1
FileRecordStatusDeleted = 10
)
// FileRecord file record
type FileRecord struct {
ID int `xorm:"not null pk autoincr INT(10) id"`
CreatedAt time.Time `xorm:"not null default CURRENT_TIMESTAMP created TIMESTAMP created_at"`
UpdatedAt time.Time `xorm:"not null default CURRENT_TIMESTAMP updated TIMESTAMP updated_at"`
UserID string `xorm:"not null default 0 BIGINT(20) user_id"`
FilePath string `xorm:"not null VARCHAR(256) file_path"`
FileURL string `xorm:"not null VARCHAR(1024) file_url"`
ObjectID string `xorm:"not null default 0 INDEX BIGINT(20) object_id"`
Source string `xorm:"not null VARCHAR(128) source"`
Status int `xorm:"not null default 0 TINYINT(4) status"`
}
// TableName file record table name
func (FileRecord) TableName() string {
return "file_record"
}
+45
View File
@@ -0,0 +1,45 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package entity
import "time"
const (
QuestionEditSummaryKey = "question.edit.summary"
QuestionCloseReasonKey = "question.close.reason"
AnswerEditSummaryKey = "answer.edit.summary"
TagEditSummaryKey = "tag.edit.summary"
ObjectReactSummaryKey = "object.react.summary"
)
// Meta meta
type Meta struct {
ID int `xorm:"not null pk autoincr INT(10) id"`
CreatedAt time.Time `xorm:"not null default CURRENT_TIMESTAMP created TIMESTAMP created_at"`
UpdatedAt time.Time `xorm:"not null default CURRENT_TIMESTAMP updated TIMESTAMP updated_at"`
ObjectID string `xorm:"not null default 0 INDEX BIGINT(20) object_id"`
Key string `xorm:"not null VARCHAR(100) key"`
Value string `xorm:"not null MEDIUMTEXT value"`
}
// TableName meta table name
func (Meta) TableName() string {
return "meta"
}
+41
View File
@@ -0,0 +1,41 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package entity
import "time"
// Notification notification
type Notification struct {
ID string `xorm:"not null pk autoincr BIGINT(20) id"`
CreatedAt time.Time `xorm:"created TIMESTAMP created_at"`
UpdatedAt time.Time `xorm:"TIMESTAMP updated_at"`
UserID string `xorm:"not null default 0 BIGINT(20) INDEX user_id"`
ObjectID string `xorm:"not null default 0 INDEX BIGINT(20) object_id"`
Content string `xorm:"not null TEXT content"`
Type int `xorm:"not null default 0 INT(11) type"`
MsgType int `xorm:"not null default 0 INT(11) msg_type"`
IsRead int `xorm:"not null default 1 INT(11) is_read"`
Status int `xorm:"not null default 1 INT(11) status"`
}
// TableName notification table name
func (Notification) TableName() string {
return "notification"
}
+32
View File
@@ -0,0 +1,32 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package entity
// PluginConfig plugin config
type PluginConfig struct {
ID int `xorm:"not null pk autoincr INT(11) id"`
PluginSlugName string `xorm:"unique VARCHAR(128) plugin_slug_name"`
Value string `xorm:"TEXT value"`
}
// TableName config table name
func (PluginConfig) TableName() string {
return "plugin_config"
}
@@ -0,0 +1,32 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package entity
type PluginKVStorage struct {
ID int `xorm:"not null pk autoincr INT(11) id"`
PluginSlugName string `xorm:"not null VARCHAR(128) UNIQUE(uk_psg) plugin_slug_name"`
Group string `xorm:"not null VARCHAR(128) UNIQUE(uk_psg) 'group'"`
Key string `xorm:"not null VARCHAR(128) UNIQUE(uk_psg) 'key'"`
Value string `xorm:"not null TEXT value"`
}
func (PluginKVStorage) TableName() string {
return "plugin_kv_storage"
}
@@ -0,0 +1,33 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package entity
// PluginUserConfig plugin config
type PluginUserConfig struct {
ID int `xorm:"not null pk autoincr INT(11) id"`
UserID string `xorm:"not null default 0 BIGINT(20) UNIQUE(uk_up) user_id"`
PluginSlugName string `xorm:"VARCHAR(128) UNIQUE(uk_up) plugin_slug_name"`
Value string `xorm:"TEXT value"`
}
// TableName config table name
func (PluginUserConfig) TableName() string {
return "plugin_user_config"
}
+37
View File
@@ -0,0 +1,37 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package entity
import "time"
// Power power
type Power struct {
ID int `xorm:"not null pk autoincr INT(11) id"`
CreatedAt time.Time `xorm:"created TIMESTAMP created_at"`
UpdatedAt time.Time `xorm:"updated TIMESTAMP updated_at"`
Name string `xorm:"not null default '' VARCHAR(50) name"`
PowerType string `xorm:"not null default '' VARCHAR(100) power_type"`
Description string `xorm:"not null default '' VARCHAR(200) description"`
}
// TableName power table name
func (Power) TableName() string {
return "power"
}
+100
View File
@@ -0,0 +1,100 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package entity
import (
"time"
)
const (
QuestionStatusAvailable = 1
QuestionStatusClosed = 2
QuestionStatusDeleted = 10
QuestionStatusPending = 11
QuestionUnPin = 1
QuestionPin = 2
QuestionShow = 1
QuestionHide = 2
)
var AdminQuestionSearchStatus = map[string]int{
"available": QuestionStatusAvailable,
"closed": QuestionStatusClosed,
"deleted": QuestionStatusDeleted,
"pending": QuestionStatusPending,
}
var AdminQuestionSearchStatusIntToString = map[int]string{
QuestionStatusAvailable: "available",
QuestionStatusClosed: "closed",
QuestionStatusDeleted: "deleted",
QuestionStatusPending: "pending",
}
// 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"`
UpdatedAt time.Time `xorm:"updated_at TIMESTAMP"`
UserID string `xorm:"not null default 0 BIGINT(20) INDEX user_id"`
InviteUserID string `xorm:"TEXT invite_user_id"`
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"`
Pin int `xorm:"not null default 1 INT(11) pin"`
Show int `xorm:"not null default 1 INT(11) show"`
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"`
HotScore int `xorm:"not null default 0 INT(11) hot_score"`
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"`
PostUpdateTime time.Time `xorm:"post_update_time TIMESTAMP"`
RevisionID string `xorm:"not null default 0 BIGINT(20) revision_id"`
LinkedCount int `xorm:"not null default 0 INT(11) linked_count"`
}
// TableName question table name
func (Question) TableName() string {
return "question"
}
// 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"`
}
+44
View File
@@ -0,0 +1,44 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package entity
import (
"time"
)
const (
QuestionLinkStatusAvailable = 1
QuestionLinkStatusDeleted = 2
)
type QuestionLink struct {
ID string `xorm:"not null pk autoincr BIGINT(20) id"`
CreatedAt time.Time `xorm:"not null default CURRENT_TIMESTAMP TIMESTAMP created_at"`
UpdatedAt time.Time `xorm:"updated_at TIMESTAMP"`
FromQuestionID string `xorm:"not null default 0 BIGINT(20) index from_question_id"`
FromAnswerID string `xorm:"BIGINT(20) from_answer_id"`
ToQuestionID string `xorm:"not null default 0 BIGINT(20) index to_question_id"`
ToAnswerID string `xorm:"BIGINT(20) to_answer_id"`
Status int `xorm:"not null default 1 INT(11) status"`
}
func (QuestionLink) TableName() string {
return "question_link"
}
+58
View File
@@ -0,0 +1,58 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package entity
import "time"
const (
ReportStatusPending = 1
ReportStatusCompleted = 2
ReportStatusIgnore = 3
ReportStatusDeleted = 10
)
var (
ReportStatus = map[string]int{
"pending": ReportStatusPending,
"completed": ReportStatusCompleted,
"deleted": ReportStatusDeleted,
}
)
// Report report
type Report struct {
ID string `xorm:"not null pk autoincr BIGINT(20) id"`
CreatedAt time.Time `xorm:"created TIMESTAMP created_at"`
UpdatedAt time.Time `xorm:"updated TIMESTAMP updated_at"`
UserID string `xorm:"not null BIGINT(20) user_id"`
ObjectID string `xorm:"not null BIGINT(20) object_id"`
ReportedUserID string `xorm:"not null default 0 BIGINT(20) reported_user_id"`
ObjectType int `xorm:"not null default 0 INT(11) object_type"`
ReportType int `xorm:"not null default 0 INT(11) report_type"`
Content string `xorm:"not null TEXT content"`
FlaggedType int `xorm:"not null default 0 INT(11) flagged_type"`
FlaggedContent string `xorm:"TEXT flagged_content"`
Status int `xorm:"not null default 1 INT(11) status"`
}
// TableName report table name
func (Report) TableName() string {
return "report"
}
+47
View File
@@ -0,0 +1,47 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package entity
import "time"
const (
ReviewStatusPending = 1
ReviewStatusApproved = 2
ReviewStatusRejected = 3
)
// Review review
type Review struct {
ID int `xorm:"not null pk autoincr BIGINT(20) id"`
CreatedAt time.Time `xorm:"created TIMESTAMP created_at"`
UpdatedAt time.Time `xorm:"updated TIMESTAMP updated_at"`
UserID string `xorm:"not null BIGINT(20) user_id"`
ObjectID string `xorm:"not null BIGINT(20) object_id"`
ObjectType int `xorm:"not null default 0 INT(11) object_type"`
ReviewerUserID string `xorm:"not null default 0 BIGINT(20) reviewer_user_id"`
Submitter string `xorm:"not null default '' VARCHAR(100) submitter"`
Reason string `xorm:"not null TEXT reason"`
Status int `xorm:"not null default 0 INT(11) status"`
}
// TableName review table name
func (Review) TableName() string {
return "review"
}
+55
View File
@@ -0,0 +1,55 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package entity
import (
"time"
)
const (
// RevisionNormalStatus this revision is normal
RevisionNormalStatus = 0
// RevisionUnreviewedStatus this revision is unreviewed
RevisionUnreviewedStatus = 1
// RevisionReviewPassStatus this revision is reviewed and approved by operator
RevisionReviewPassStatus = 2
// RevisionReviewRejectStatus this revision is reviewed and rejected by operator
RevisionReviewRejectStatus = 3
)
// Revision revision
type Revision struct {
ID string `xorm:"not null pk autoincr BIGINT(20) id"`
CreatedAt time.Time `xorm:"created TIMESTAMP created_at"`
UpdatedAt time.Time `xorm:"updated TIMESTAMP updated_at"`
UserID string `xorm:"not null default 0 BIGINT(20) user_id"`
ObjectType int `xorm:"not null default 0 INT(11) object_type"`
ObjectID string `xorm:"not null default 0 BIGINT(20) INDEX object_id"`
Title string `xorm:"not null default '' VARCHAR(255) title"`
Content string `xorm:"not null MEDIUMTEXT content"`
Log string `xorm:"VARCHAR(255) log"`
Status int `xorm:"not null default 1 INT(11) status"`
ReviewUserID int64 `xorm:"not null default 0 BIGINT(20) review_user_id"`
}
// TableName revision table name
func (Revision) TableName() string {
return "revision"
}
+36
View File
@@ -0,0 +1,36 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package entity
import "time"
// Role role
type Role struct {
ID int `xorm:"not null pk autoincr INT(11) id"`
CreatedAt time.Time `xorm:"created TIMESTAMP created_at"`
UpdatedAt time.Time `xorm:"updated TIMESTAMP updated_at"`
Name string `xorm:"not null default '' VARCHAR(50) name"`
Description string `xorm:"not null default '' VARCHAR(200) description"`
}
// TableName user table name
func (Role) TableName() string {
return "role"
}
+36
View File
@@ -0,0 +1,36 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package entity
import "time"
// RolePowerRel role power rel
type RolePowerRel struct {
ID int `xorm:"not null pk autoincr INT(11) id"`
CreatedAt time.Time `xorm:"created TIMESTAMP created_at"`
UpdatedAt time.Time `xorm:"updated TIMESTAMP updated_at"`
RoleID int `xorm:"not null default 0 INT(11) role_id"`
PowerType string `xorm:"not null default '' VARCHAR(200) power_type"`
}
// TableName role power rel table name
func (RolePowerRel) TableName() string {
return "role_power_rel"
}
+37
View File
@@ -0,0 +1,37 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package entity
import "time"
// SiteInfo site information setting
type SiteInfo struct {
ID string `xorm:"not null pk autoincr INT(11) id"`
CreatedAt time.Time `xorm:"created TIMESTAMP created_at"`
UpdatedAt time.Time `xorm:"updated TIMESTAMP updated_at"`
Type string `xorm:"not null VARCHAR(64) type"`
Content string `xorm:"not null MEDIUMTEXT content"`
Status int `xorm:"not null default 1 INT(11) status"`
}
// TableName table name
func (*SiteInfo) TableName() string {
return "site_info"
}
+57
View File
@@ -0,0 +1,57 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package entity
import "time"
const (
TagStatusAvailable = 1
TagStatusDeleted = 10
)
var TagStatusDisplayMapping = map[int]string{
TagStatusAvailable: "available",
TagStatusDeleted: "deleted",
}
// Tag tag
type Tag struct {
ID string `xorm:"not null pk comment('tag_id') BIGINT(20) id"`
CreatedAt time.Time `xorm:"created TIMESTAMP created_at"`
UpdatedAt time.Time `xorm:"updated TIMESTAMP updated_at"`
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"`
OriginalText string `xorm:"not null MEDIUMTEXT original_text"`
ParsedText string `xorm:"not null MEDIUMTEXT parsed_text"`
FollowCount int `xorm:"not null default 0 INT(11) follow_count"`
QuestionCount int `xorm:"not null default 0 INT(11) question_count"`
Status int `xorm:"not null default 1 INT(11) status"`
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"`
UserID string `xorm:"not null default 0 BIGINT(20) user_id"`
}
// TableName tag table name
func (Tag) TableName() string {
return "tag"
}
+43
View File
@@ -0,0 +1,43 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package entity
import "time"
const (
TagRelStatusAvailable = 1
TagRelStatusHide = 2
TagRelStatusDeleted = 10
)
// TagRel tag relation
type TagRel struct {
ID int64 `xorm:"not null pk autoincr BIGINT(20) id"`
CreatedAt time.Time `xorm:"created TIMESTAMP created_at"`
UpdatedAt time.Time `xorm:"updated TIMESTAMP updated_at"`
ObjectID string `xorm:"not null INDEX UNIQUE(s) BIGINT(20) object_id"`
TagID string `xorm:"not null INDEX UNIQUE(s) BIGINT(20) tag_id"`
Status int `xorm:"not null default 1 INT(11) status"`
}
// TableName tag list table name
func (TagRel) TableName() string {
return "tag_rel"
}
+31
View File
@@ -0,0 +1,31 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package entity
// Uniqid uniqid
type Uniqid struct {
ID int64 `xorm:"not null pk autoincr BIGINT(20) id"`
UniqidType int `xorm:"not null default 0 INT(11) uniqid_type"`
}
// TableName uniqid table name
func (Uniqid) TableName() string {
return "uniqid"
}
+84
View File
@@ -0,0 +1,84 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package entity
import "time"
const (
UserStatusAvailable = 1
UserStatusSuspended = 9
UserStatusDeleted = 10
)
const (
EmailStatusAvailable = 1
EmailStatusToBeVerified = 2
)
const (
UserAdminFlag = 1
)
// PermanentSuspensionTime is a fixed time representing permanent suspension (2099-12-31 23:59:59)
var PermanentSuspensionTime = time.Date(2099, 12, 31, 23, 59, 59, 0, time.UTC)
// User user
type User struct {
ID string `xorm:"not null pk autoincr BIGINT(20) id"`
CreatedAt time.Time `xorm:"created TIMESTAMP created_at"`
UpdatedAt time.Time `xorm:"updated TIMESTAMP updated_at"`
SuspendedAt time.Time `xorm:"TIMESTAMP suspended_at"`
SuspendedUntil time.Time `xorm:"DATETIME suspended_until"`
DeletedAt time.Time `xorm:"TIMESTAMP deleted_at"`
LastLoginDate time.Time `xorm:"TIMESTAMP last_login_date"`
Username string `xorm:"not null default '' VARCHAR(50) UNIQUE username"`
Pass string `xorm:"not null default '' VARCHAR(255) pass"`
EMail string `xorm:"not null VARCHAR(100) e_mail"`
MailStatus int `xorm:"not null default 2 TINYINT(4) mail_status"`
NoticeStatus int `xorm:"not null default 2 INT(11) notice_status"`
FollowCount int `xorm:"not null default 0 INT(11) follow_count"`
AnswerCount int `xorm:"not null default 0 INT(11) answer_count"`
QuestionCount int `xorm:"not null default 0 INT(11) question_count"`
Rank int `xorm:"not null default 0 INT(11) rank"`
Status int `xorm:"not null default 1 INT(11) status"`
AuthorityGroup int `xorm:"not null default 1 INT(11) authority_group"`
DisplayName string `xorm:"not null default '' VARCHAR(30) display_name"`
Avatar string `xorm:"not null TEXT avatar"`
Mobile string `xorm:"not null VARCHAR(20) mobile"`
Bio string `xorm:"not null TEXT bio"`
BioHTML string `xorm:"not null TEXT bio_html"`
Website string `xorm:"not null default '' VARCHAR(255) website"`
Location string `xorm:"not null default '' VARCHAR(100) location"`
IPInfo string `xorm:"not null default '' VARCHAR(255) ip_info"`
IsAdmin bool `xorm:"not null default false BOOL is_admin"`
Language string `xorm:"not null default '' VARCHAR(100) language"`
ColorScheme string `xorm:"not null default '' VARCHAR(100) color_scheme"`
}
// TableName user table name
func (User) TableName() string {
return "user"
}
type UserSearch struct {
User
Page int `json:"page" form:"page"` // Query number of pages
PageSize int `json:"page_size" form:"page_size"` // Search page size
}
@@ -0,0 +1,38 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package entity
import "time"
// UserExternalLogin user external login
type UserExternalLogin struct {
ID int64 `xorm:"not null pk autoincr BIGINT(20) id"`
CreatedAt time.Time `xorm:"created TIMESTAMP created_at"`
UpdatedAt time.Time `xorm:"updated TIMESTAMP updated_at"`
UserID string `xorm:"not null default 0 BIGINT(20) user_id"`
Provider string `xorm:"not null default '' VARCHAR(100) provider"`
ExternalID string `xorm:"not null default '' VARCHAR(128) external_id"`
MetaInfo string `xorm:"TEXT meta_info"`
}
// TableName table name
func (UserExternalLogin) TableName() string {
return "user_external_login"
}
@@ -0,0 +1,38 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package entity
import "time"
// UserNotificationConfig user notification config
type UserNotificationConfig struct {
ID string `xorm:"not null pk autoincr BIGINT(20) id"`
CreatedAt time.Time `xorm:"created TIMESTAMP created_at"`
UpdatedAt time.Time `xorm:"updated TIMESTAMP updated_at"`
UserID string `xorm:"not null default 0 INDEX UNIQUE(uk_us) BIGINT(20) INDEX user_id"`
Source string `xorm:"not null default '' INDEX UNIQUE(uk_us) VARCHAR(64) source"`
Channels string `xorm:"not null TEXT channels"`
Enabled bool `xorm:"not null default false BOOL enabled"`
}
// TableName notification table name
func (UserNotificationConfig) TableName() string {
return "user_notification_config"
}
+36
View File
@@ -0,0 +1,36 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package entity
import "time"
// UserRoleRel role
type UserRoleRel struct {
ID int `xorm:"not null pk autoincr INT(11) id"`
CreatedAt time.Time `xorm:"created TIMESTAMP created_at"`
UpdatedAt time.Time `xorm:"updated TIMESTAMP updated_at"`
UserID string `xorm:"not null default 0 BIGINT(20) user_id"`
RoleID int `xorm:"not null default 0 INT(11) role_id"`
}
// TableName user role rel table name
func (UserRoleRel) TableName() string {
return "user_role_rel"
}
+31
View File
@@ -0,0 +1,31 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package entity
// Version version
type Version struct {
ID int `xorm:"not null pk autoincr INT(11) id"`
VersionNumber int64 `xorm:"not null default 0 INT(11) version_number"`
}
// TableName config table name
func (Version) TableName() string {
return "version"
}