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


The following commit(s) were added to refs/heads/feat/1.4.0/badge by this push:
     new b7022949 feat(badge): update entity
b7022949 is described below

commit b70229492031fcf117e25aa5a50e5dc8a1a6dcd5
Author: kumfo <[email protected]>
AuthorDate: Wed Jul 31 14:00:18 2024 +0800

    feat(badge): update entity
---
 internal/entity/badge.go       | 27 ++++++++++++++++-----------
 internal/entity/badge_award.go | 14 +++++++-------
 internal/entity/badge_group.go |  8 ++++----
 3 files changed, 27 insertions(+), 22 deletions(-)

diff --git a/internal/entity/badge.go b/internal/entity/badge.go
index d310ef79..0b296f61 100644
--- a/internal/entity/badge.go
+++ b/internal/entity/badge.go
@@ -21,20 +21,25 @@ package entity
 
 import "time"
 
+const (
+       BadgeStatusAvailable = 1
+       BadgeStatusDeleted   = 10
+)
+
 // 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"`
+       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"`
+       Name         string    `json:"name" xorm:"not null default '' 
VARCHAR(256) name"`
+       AwardCount   int64     `json:"award_count" xorm:"not null default 0 
INT(11) award_count"`
+       Description  string    `json:"description" xorm:"not null default '' 
MEDIUMTEXT description"`
+       Status       int8      `json:"status" xorm:"not null default 1 INT(11) 
status"`
+       BadgeGroupId int64     `json:"badge_group_id" xorm:"not null default 0 
BIGINT(20) badge_group_id"`
+       Single       int8      `json:"single" xorm:"not null default 1 
TINYINT(4) single"`
+       Collect      string    `json:"collect" xorm:"not null default '' 
VARCHAR(64) collect"`
+       Handler      string    `json:"handler" xorm:"not null default '' 
VARCHAR(64) handler"`
+       Param        string    `json:"param" xorm:"not null default '' 
VARCHAR(128) param"`
 }
 
 // TableName badge table name
diff --git a/internal/entity/badge_award.go b/internal/entity/badge_award.go
index fe1dab96..01100b1f 100644
--- a/internal/entity/badge_award.go
+++ b/internal/entity/badge_award.go
@@ -24,13 +24,13 @@ 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"`
+       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"`
+       UserId         int64     `json:"user_id" xorm:"not null index 
BIGINT(20) user_id"`
+       BadgeId        int64     `json:"badge_id" xorm:"not null index 
BIGINT(20) badge_id"`
+       ObjectId       int64     `json:"object_id" xorm:"not null index 
BIGINT(20) object_id"`
+       BadgeGroupId   int8      `json:"badge_group_id" xorm:"not null index 
BIGINT(20) badge_group_id"`
+       IsBadgeDeleted int8      `json:"is_badge_deleted" xorm:"not null index 
TINYINT(1) s_badge_deleted"`
 }
 
 // TableName badge_award table name
diff --git a/internal/entity/badge_group.go b/internal/entity/badge_group.go
index 14535299..9953d067 100644
--- a/internal/entity/badge_group.go
+++ b/internal/entity/badge_group.go
@@ -23,10 +23,10 @@ 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"`
+       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

Reply via email to