Browse Source

调整业务model结构; 修改业务默认值

路佳明 1 week ago
parent
commit
14ea32689a

+ 16 - 13
app/observe/models/ot_biz.gen.go

@@ -14,19 +14,22 @@ const TableNameBiz = "ot_biz"
 
 // Biz mapped from table <ot_biz>
 type Biz struct {
-	ID            int64          `gorm:"column:id;type:bigint(20) unsigned;primaryKey;autoIncrement:true" json:"id"`
-	CreatedAt     time.Time      `gorm:"column:created_at;type:datetime(3)" json:"created_at"`
-	UpdatedAt     time.Time      `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"`
-	Name          string         `gorm:"column:name;type:varchar(255);not null" json:"name"`
-	Hash          string         `gorm:"column:hash;type:varchar(100);not null;uniqueIndex:hash,priority:1;uniqueIndex:ot_biz_pk2,priority:1;comment:业务唯一哈希值, 通过app_alias, service_name, span_name计算得出, 防止数据重建后metrics统计失效" json:"hash"` // 业务唯一哈希值, 通过app_alias, service_name, span_name计算得出, 防止数据重建后metrics统计失效
-	AppID         int64          `gorm:"column:app_id;type:bigint(20);not null" json:"app_id"`
-	AppAlias      string         `gorm:"column:app_alias;type:varchar(30);not null;uniqueIndex:ot_biz_pk,priority:1;comment:业务别名" json:"app_alias"` // 业务别名
-	ServiceName   string         `gorm:"column:service_name;type:varchar(50);not null;uniqueIndex:ot_biz_pk,priority:2" json:"service_name"`
-	SpanName      string         `gorm:"column:span_name;type:varchar(255);not null;uniqueIndex:ot_biz_pk,priority:3" json:"span_name"`
-	IsAutoCreated int64          `gorm:"column:is_auto_created;type:bigint(20);not null" json:"is_auto_created"`
-	SpanKind      string         `gorm:"column:span_kind;type:varchar(20);not null;comment:span类型" json:"span_kind"` // span类型
-	Favor         int32          `gorm:"column:favor;type:tinyint(4);not null;comment:收藏 0未收藏 1已收藏" json:"favor"`    // 收藏 0未收藏 1已收藏
-	DeletedAt     gorm.DeletedAt `gorm:"column:deleted_at;type:datetime(3);index:idx_ot_biz_deleted_at,priority:1" json:"deleted_at"`
+	ID             int64          `gorm:"column:id;type:bigint(20) unsigned;primaryKey;autoIncrement:true" json:"id"`
+	CreatedAt      time.Time      `gorm:"column:created_at;type:datetime(3)" json:"created_at"`
+	UpdatedAt      time.Time      `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"`
+	Name           string         `gorm:"column:name;type:varchar(255);not null" json:"name"`
+	Hash           string         `gorm:"column:hash;type:varchar(255);not null;uniqueIndex:ot_biz_pk2,priority:1;comment:业务唯一哈希值, 通过app_alias, service_name, span_name计算得出, 防止数据重建后metrics统计失效" json:"hash"` // 业务唯一哈希值, 通过app_alias, service_name, span_name计算得出, 防止数据重建后metrics统计失效
+	AppID          int64          `gorm:"column:app_id;type:bigint(20);not null" json:"app_id"`
+	AppAlias       string         `gorm:"column:app_alias;type:varchar(30);not null;uniqueIndex:ot_biz_pk,priority:1;comment:业务别名" json:"app_alias"` // 业务别名
+	ServiceName    string         `gorm:"column:service_name;type:varchar(50);not null;uniqueIndex:ot_biz_pk,priority:2" json:"service_name"`
+	SpanName       string         `gorm:"column:span_name;type:varchar(255);not null;uniqueIndex:ot_biz_pk,priority:3" json:"span_name"`
+	IsAutoCreated  int64          `gorm:"column:is_auto_created;type:bigint(20);not null" json:"is_auto_created"`
+	SpanKind       string         `gorm:"column:span_kind;type:varchar(20);not null;uniqueIndex:ot_biz_pk,priority:4;comment:span类型" json:"span_kind"` // span类型
+	Favor          int32          `gorm:"column:favor;type:tinyint(4);not null;comment:收藏 0未收藏 1已收藏" json:"favor"`                                     // 收藏 0未收藏 1已收藏
+	Active         int32          `gorm:"column:active;type:tinyint(4);not null;comment:活跃 0不活跃 1活跃" json:"active"`                                    // 活跃 0不活跃 1活跃
+	NodeNum        int32          `gorm:"column:node_num;type:int(11);not null;default:1;comment:结点数量" json:"node_num"`                                // 结点数量
+	AccessDatabase int32          `gorm:"column:access_database;type:tinyint(4);not null;comment:是否访问数据库 0否 1是" json:"access_database"`                // 是否访问数据库 0否 1是
+	DeletedAt      gorm.DeletedAt `gorm:"column:deleted_at;type:datetime(3);index:idx_ot_biz_deleted_at,priority:1" json:"deleted_at"`
 }
 
 // TableName Biz's table name

+ 5 - 5
app/observe/models/ot_biz_edge.gen.go

@@ -13,17 +13,17 @@ const TableNameBizEdge = "ot_biz_edge"
 // BizEdge mapped from table <ot_biz_edge>
 type BizEdge struct {
 	ID         int64     `gorm:"column:id;type:bigint(20);primaryKey;autoIncrement:true" json:"id"`
-	Source     int64     `gorm:"column:source;type:bigint(20);not null;uniqueIndex:ot_biz_edge_pk,priority:2" json:"source"`
-	Target     int64     `gorm:"column:target;type:bigint(20);not null;uniqueIndex:ot_biz_edge_pk,priority:3" json:"target"`
-	SourceHash string    `gorm:"column:source_hash;type:varchar(100);not null;comment:源节点hash" json:"source_hash"`  // 源节点hash
-	TargetHash string    `gorm:"column:target_hash;type:varchar(100);not null;comment:目标节点hash" json:"target_hash"` // 目标节点hash
+	Source     int64     `gorm:"column:source;type:bigint(20);not null" json:"source"`
+	Target     int64     `gorm:"column:target;type:bigint(20);not null" json:"target"`
+	SourceHash string    `gorm:"column:source_hash;type:varchar(100);not null;uniqueIndex:ot_biz_edge_pk,priority:2;comment:源节点hash" json:"source_hash"`  // 源节点hash
+	TargetHash string    `gorm:"column:target_hash;type:varchar(100);not null;uniqueIndex:ot_biz_edge_pk,priority:3;comment:目标节点hash" json:"target_hash"` // 目标节点hash
 	Type       string    `gorm:"column:type;type:varchar(30);not null;default:0" json:"type"`
 	BizId      int64     `gorm:"column:biz_id;type:bigint(20);not null" json:"biz_id"`
 	BizHash    string    `gorm:"column:biz_hash;type:varchar(100);not null;uniqueIndex:ot_biz_edge_pk,priority:1;comment:业务唯一哈希值" json:"biz_hash"` // 业务唯一哈希值
 	AppId      int64     `gorm:"column:app_id;type:bigint(20);not null" json:"app_id"`
 	AppAlias   string    `gorm:"column:app_alias;type:varchar(30);not null;comment:应用别名" json:"app_alias"`                          // 应用别名
 	CreatedAt  time.Time `gorm:"column:created_at;type:datetime;not null;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"` // 创建时间
-	UpdatedAt  time.Time `gorm:"column:updated_at;type:datetime;not null;comment:更新时间" json:"updated_at"`                           // 更新时间
+	UpdatedAt  time.Time `gorm:"column:updated_at;type:datetime;comment:更新时间" json:"updated_at"`                                    // 更新时间
 }
 
 // TableName BizEdge's table name

+ 20 - 14
app/observe/models/ot_biz_node.gen.go

@@ -4,24 +4,30 @@
 
 package models
 
+import (
+	"time"
+)
+
 const TableNameBizNode = "ot_biz_node"
 
 // BizNode mapped from table <ot_biz_node>
 type BizNode struct {
-	ID          int64  `gorm:"column:id;type:bigint(20);primaryKey;autoIncrement:true;comment:主键id" json:"id"`                                                                                                                                   // 主键id
-	Name        string `gorm:"column:name;type:varchar(100);comment:结点名称" json:"name"`                                                                                                                                                           // 结点名称
-	Hash        string `gorm:"column:hash;type:varchar(100);not null;uniqueIndex:hash,priority:1;uniqueIndex:ot_biz_node_pk2,priority:1;comment:业务结点哈希, 唯一, 由biz_alias, service_name, span_name, span_kind计算得出,防止重建后metric统计数据错乱失效" json:"hash"` // 业务结点哈希, 唯一, 由biz_alias, service_name, span_name, span_kind计算得出,防止重建后metric统计数据错乱失效
-	Type        int64  `gorm:"column:type;type:bigint(20);comment:类型 0未知 1client 2http 3rpc" json:"type"`                                                                                                                                        // 类型 0未知 1client 2http 3rpc
-	ExternalID  int64  `gorm:"column:external_id;type:bigint(20);comment:拓展id,根据type判断它对应的表" json:"external_id"`                                                                                                                                 // 拓展id,根据type判断它对应的表
-	BizID       int64  `gorm:"column:biz_id;type:bigint(20);comment:业务id" json:"biz_id"`                                                                                                                                                         // 业务id
-	BizHash     string `gorm:"column:biz_hash;type:varchar(100);comment:业务唯一哈希值" json:"biz_hash"`                                                                                                                                                // 业务唯一哈希值
-	AppID       int64  `gorm:"column:app_id;type:bigint(20);comment:应用id" json:"app_id"`                                                                                                                                                         // 应用id
-	AppAlias    string `gorm:"column:app_alias;type:varchar(30);uniqueIndex:ot_biz_node_pk,priority:1;comment:应用别名" json:"app_alias"`                                                                                                            // 应用别名
-	ServiceName string `gorm:"column:service_name;type:varchar(50);uniqueIndex:ot_biz_node_pk,priority:2;comment:服务名称" json:"service_name"`                                                                                                      // 服务名称
-	SpanName    string `gorm:"column:span_name;type:varchar(255);uniqueIndex:ot_biz_node_pk,priority:3;comment:span名称" json:"span_name"`                                                                                                         // span名称
-	SpanKind    string `gorm:"column:span_kind;type:varchar(20);uniqueIndex:ot_biz_node_pk,priority:4;comment:span类别" json:"span_kind"`                                                                                                          // span类别
-	SpanType    string `gorm:"column:span_type;type:varchar(30);not null;comment:类似span_kind,但更精确" json:"span_type"`                                                                                                                             // 类似span_kind,但更精确
-	IsVirtual   int64  `gorm:"column:is_virtual;type:bigint(20);comment:是否为虚拟结点(已废除)" json:"is_virtual"`                                                                                                                                         // 是否为虚拟结点(已废除)
+	ID          int64     `gorm:"column:id;type:bigint(20);primaryKey;autoIncrement:true;comment:主键id" json:"id"`                                                                                            // 主键id
+	Name        string    `gorm:"column:name;type:varchar(100);comment:结点名称" json:"name"`                                                                                                                    // 结点名称
+	Hash        string    `gorm:"column:hash;type:varchar(255);not null;uniqueIndex:hash,priority:1;comment:业务结点哈希, 唯一, 由biz_alias, service_name, span_name, span_kind计算得出,防止重建后metric统计数据错乱失效" json:"hash"` // 业务结点哈希, 唯一, 由biz_alias, service_name, span_name, span_kind计算得出,防止重建后metric统计数据错乱失效
+	Type        int64     `gorm:"column:type;type:bigint(20);comment:类型 0未知 1client 2http 3rpc" json:"type"`                                                                                                 // 类型 0未知 1client 2http 3rpc
+	ExternalID  int64     `gorm:"column:external_id;type:bigint(20);comment:拓展id,根据type判断它对应的表" json:"external_id"`                                                                                          // 拓展id,根据type判断它对应的表
+	BizID       int64     `gorm:"column:biz_id;type:bigint(20);comment:业务id" json:"biz_id"`                                                                                                                  // 业务id
+	BizHash     string    `gorm:"column:biz_hash;type:varchar(100);comment:业务唯一哈希值" json:"biz_hash"`                                                                                                         // 业务唯一哈希值
+	AppID       int64     `gorm:"column:app_id;type:bigint(20);comment:应用id" json:"app_id"`                                                                                                                  // 应用id
+	AppAlias    string    `gorm:"column:app_alias;type:varchar(30);uniqueIndex:ot_biz_node_pk,priority:1;comment:应用别名" json:"app_alias"`                                                                     // 应用别名
+	ServiceName string    `gorm:"column:service_name;type:varchar(50);uniqueIndex:ot_biz_node_pk,priority:2;comment:服务名称" json:"service_name"`                                                               // 服务名称
+	SpanName    string    `gorm:"column:span_name;type:varchar(255);uniqueIndex:ot_biz_node_pk,priority:3;comment:span名称" json:"span_name"`                                                                  // span名称
+	SpanKind    string    `gorm:"column:span_kind;type:varchar(20);uniqueIndex:ot_biz_node_pk,priority:4;comment:span类别" json:"span_kind"`                                                                   // span类别
+	SpanType    string    `gorm:"column:span_type;type:varchar(30);not null;comment:类似span_kind,但更精确" json:"span_type"`                                                                                      // 类似span_kind,但更精确
+	IsVirtual   int64     `gorm:"column:is_virtual;type:bigint(20);comment:是否为虚拟结点(已废除)" json:"is_virtual"`                                                                                                  // 是否为虚拟结点(已废除)
+	CreatedAt   time.Time `gorm:"column:created_at;type:datetime;not null;default:CURRENT_TIMESTAMP;comment:创建时间" json:"created_at"`                                                                         // 创建时间
+	UpdatedAt   time.Time `gorm:"column:updated_at;type:datetime;comment:更新时间" json:"updated_at"`                                                                                                            // 更新时间
 }
 
 // TableName BizNode's table name

+ 1 - 0
cmd/consumer/biz/biz.go

@@ -362,6 +362,7 @@ func GenBiz2() {
 				SpanKind:      root.SpanKind,
 				IsAutoCreated: 1,
 				Favor:         0,
+				Active:        1,
 			}
 			subNodes, subEdges := getNodeAndEdge(root)
 			for _, node := range subNodes {