You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@answer.apache.org by ku...@apache.org on 2024/07/31 02:32:22 UTC

(incubator-answer) 01/01: feat(badge): init entity

This is an automated email from the ASF dual-hosted git repository.

kumfo pushed a commit to branch feat/1.4.0/badge
in repository https://gitbox.apache.org/repos/asf/incubator-answer.git

commit 969592589cf85940c41a2077e5ebe4d22d68569c
Author: kumfo <ku...@sifou.com>
AuthorDate: Wed Jul 31 10:32:10 2024 +0800

    feat(badge): init entity
---
 internal/base/constant/object_type.go              | 23 +++++++----
 internal/entity/badge.go                           | 43 ++++++++++++++++++++
 .../object_type.go => entity/badge_award.go}       | 47 ++++++++--------------
 .../object_type.go => entity/badge_group.go}       | 43 ++++++--------------
 4 files changed, 89 insertions(+), 67 deletions(-)

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/base/constant/object_type.go b/internal/entity/badge_award.go
similarity index 53%
copy from internal/base/constant/object_type.go
copy to internal/entity/badge_award.go
index b3e3883d..fe1dab96 100644
--- a/internal/base/constant/object_type.go
+++ b/internal/entity/badge_award.go
@@ -17,36 +17,23 @@
  * under the License.
  */
 
-package constant
+package entity
 
-const (
-	QuestionObjectType   = "question"
-	AnswerObjectType     = "answer"
-	TagObjectType        = "tag"
-	UserObjectType       = "user"
-	CollectionObjectType = "collection"
-	CommentObjectType    = "comment"
-	ReportObjectType     = "report"
-)
+import "time"
 
-var (
-	ObjectTypeStrMapping = map[string]int{
-		QuestionObjectType:   1,
-		AnswerObjectType:     2,
-		TagObjectType:        3,
-		UserObjectType:       4,
-		CollectionObjectType: 6,
-		CommentObjectType:    7,
-		ReportObjectType:     8,
-	}
+// 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"`
+}
 
-	ObjectTypeNumberMapping = map[int]string{
-		1: QuestionObjectType,
-		2: AnswerObjectType,
-		3: TagObjectType,
-		4: UserObjectType,
-		6: CollectionObjectType,
-		7: CommentObjectType,
-		8: ReportObjectType,
-	}
-)
+// TableName badge_award table name
+func (*BadgeAward) TableName() string {
+	return "badge_award"
+}
diff --git a/internal/base/constant/object_type.go b/internal/entity/badge_group.go
similarity index 53%
copy from internal/base/constant/object_type.go
copy to internal/entity/badge_group.go
index b3e3883d..14535299 100644
--- a/internal/base/constant/object_type.go
+++ b/internal/entity/badge_group.go
@@ -17,36 +17,19 @@
  * under the License.
  */
 
-package constant
+package entity
 
-const (
-	QuestionObjectType   = "question"
-	AnswerObjectType     = "answer"
-	TagObjectType        = "tag"
-	UserObjectType       = "user"
-	CollectionObjectType = "collection"
-	CommentObjectType    = "comment"
-	ReportObjectType     = "report"
-)
+import "time"
 
-var (
-	ObjectTypeStrMapping = map[string]int{
-		QuestionObjectType:   1,
-		AnswerObjectType:     2,
-		TagObjectType:        3,
-		UserObjectType:       4,
-		CollectionObjectType: 6,
-		CommentObjectType:    7,
-		ReportObjectType:     8,
-	}
+// 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"`
+}
 
-	ObjectTypeNumberMapping = map[int]string{
-		1: QuestionObjectType,
-		2: AnswerObjectType,
-		3: TagObjectType,
-		4: UserObjectType,
-		6: CollectionObjectType,
-		7: CommentObjectType,
-		8: ReportObjectType,
-	}
-)
+// TableName badge_group table name
+func (*BadgeGroup) TableName() string {
+	return "badge_group"
+}