Skip to content

A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.

feat(badge): init entity

kumfo969592589cf8
diff --git a/internal/base/constant/object_type.go b/internal/base/constant/object_type.go
index b3e3883d..eef952c4 100644
--- a/internal/base/constant/object_type.go
+++ b/internal/base/constant/object_type.go
@@ -27,6 +27,9 @@ const (
CollectionObjectType = "collection"
CommentObjectType = "comment"
ReportObjectType = "report"
+ BadgeObjectType = "badge"
+ BadgeAwardObjectType = "badge_award"
+ BadgeGroupObjectType = "badge_group"
)
var (
@@ -38,15 +41,21 @@ var (
CollectionObjectType: 6,
CommentObjectType: 7,
ReportObjectType: 8,
+ BadgeObjectType: 9,
+ BadgeAwardObjectType: 10,
+ BadgeGroupObjectType: 11,
}
ObjectTypeNumberMapping = map[int]string{
- 1: QuestionObjectType,
- 2: AnswerObjectType,
- 3: TagObjectType,
- 4: UserObjectType,
- 6: CollectionObjectType,
- 7: CommentObjectType,
- 8: ReportObjectType,
+ 1: QuestionObjectType,
+ 2: AnswerObjectType,
+ 3: TagObjectType,
+ 4: UserObjectType,
+ 6: CollectionObjectType,
+ 7: CommentObjectType,
+ 8: ReportObjectType,
+ 9: BadgeObjectType,
+ 10: BadgeAwardObjectType,
+ 11: BadgeGroupObjectType,
}
)
diff --git a/internal/entity/badge.go b/internal/entity/badge.go
new file mode 100644
index 00000000..d310ef79
--- /dev/null
+++ b/internal/entity/badge.go
@@ -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"
+
+// Badge badge
+type Badge struct {
+ ID string `json:"id" xorm:"id"`
+ CreatedAt time.Time `json:"created_at" xorm:"created_at"`
+ UpdatedAt time.Time `json:"updated_at" xorm:"updated_at"`
+ Name string `json:"name" xorm:"name"`
+ AwardTotal int64 `json:"award_total" xorm:"award_total"`
+ Description string `json:"description" xorm:"description"`
+ Status int8 `json:"status" xorm:"status"`
+ BadgeGroupId int64 `json:"badge_group_id" xorm:"badge_group_id"`
+ Single int8 `json:"single" xorm:"single"`
+ Collect string `json:"collect" xorm:"collect"`
+ Handler string `json:"handler" xorm:"handler"`
+ Param string `json:"param" xorm:"param"`
+}
+
+// TableName badge table name
+func (*Badge) TableName() string {
+ return "badge"
+}
diff --git a/internal/entity/badge_award.go b/internal/entity/badge_award.go
new file mode 100644
index 00000000..fe1dab96
--- /dev/null
+++ b/internal/entity/badge_award.go
@@ -0,0 +1,39 @@
+/*
+ * 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"
+
+// BadgeAward badge_award
+type BadgeAward struct {
+ ID string `json:"id" xorm:"id"`
+ CreatedAt time.Time `json:"created_at" xorm:"created_at"`
+ UpdatedAt time.Time `json:"updated_at" xorm:"updated_at"`
+ UserId int64 `json:"user_id" xorm:"user_id"`
+ BadgeId int64 `json:"badge_id" xorm:"badge_id"`
+ ObjectId int64 `json:"object_id" xorm:"object_id"`
+ BadgeGroupId int8 `json:"badge_group_id" xorm:"badge_group_id"`
+ IsBadgeDeleted int8 `json:"is_badge_deleted" xorm:"is_badge_deleted"`
+}
+
+// TableName badge_award table name
+func (*BadgeAward) TableName() string {
+ return "badge_award"
+}
diff --git a/internal/entity/badge_group.go b/internal/entity/badge_group.go
new file mode 100644
index 00000000..14535299
--- /dev/null
+++ b/internal/entity/badge_group.go
@@ -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:"id"`
+ Name string `json:"name" xorm:"name"`
+ CreatedAt time.Time `json:"created_at" xorm:"created_at"`
+ UpdatedAt time.Time `json:"updated_at" xorm:"updated_at"`
+}
+
+// TableName badge_group table name
+func (*BadgeGroup) TableName() string {
+ return "badge_group"
+}