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

tianxiaoliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git


The following commit(s) were added to refs/heads/master by this push:
     new 03e6118  [SCB-2094]Bson parsing specification for persistent data 
(#854)
03e6118 is described below

commit 03e61187ded45b24ee6783ec3d5816fb5d5a6334
Author: robotLJW <[email protected]>
AuthorDate: Tue Feb 9 17:51:58 2021 +0800

    [SCB-2094]Bson parsing specification for persistent data (#854)
---
 datasource/mongo/account.go                        |   2 +-
 datasource/mongo/database.go                       |  85 +++--
 datasource/mongo/heartbeat/cache/heartbeatcache.go |   3 +-
 datasource/mongo/sd/listwatch_test.go              |   6 +-
 examples/mongodb_data_struct.yaml                  | 362 ++++++++++++---------
 go.mod                                             |   2 +-
 pkg/rbacframe/account.go                           |   4 +-
 7 files changed, 258 insertions(+), 206 deletions(-)

diff --git a/datasource/mongo/account.go b/datasource/mongo/account.go
index 99811e6..2720338 100644
--- a/datasource/mongo/account.go
+++ b/datasource/mongo/account.go
@@ -140,7 +140,7 @@ func (ds *DataSource) UpdateAccount(ctx context.Context, 
key string, account *rb
                        ColumnID:                  account.ID,
                        ColumnAccountName:         account.Name,
                        ColumnPassword:            account.Password,
-                       ColumnRole:                account.Roles,
+                       ColumnRoles:               account.Roles,
                        ColumnTokenExpirationTime: account.TokenExpirationTime,
                        ColumnCurrentPassword:     account.CurrentPassword,
                        ColumnStatus:              account.Status,
diff --git a/datasource/mongo/database.go b/datasource/mongo/database.go
index 876ec33..2161055 100644
--- a/datasource/mongo/database.go
+++ b/datasource/mongo/database.go
@@ -41,91 +41,88 @@ const (
        ColumnDomain              = "domain"
        ColumnProject             = "project"
        ColumnTag                 = "tags"
-       ColumnSchemaID            = "schemaid"
-       ColumnServiceID           = "serviceid"
-       ColumnRuleID              = "ruleid"
+       ColumnSchemaID            = "schema_id"
+       ColumnServiceID           = "service_id"
+       ColumnRuleID              = "rule_id"
        ColumnService             = "service"
        ColumnProperty            = "properties"
-       ColumnModTime             = "modtimestamp"
+       ColumnModTime             = "mod_timestamp"
        ColumnEnv                 = "env"
        ColumnAppID               = "app"
-       ColumnServiceName         = "servicename"
+       ColumnServiceName         = "service_name"
        ColumnAlias               = "alias"
        ColumnVersion             = "version"
        ColumnSchemas             = "schemas"
        ColumnAttribute           = "attribute"
        ColumnPattern             = "pattern"
        ColumnDescription         = "description"
-       ColumnRuleType            = "ruletype"
+       ColumnRuleType            = "rule_type"
        ColumnSchema              = "schema"
-       ColumnSchemaSummary       = "schemasummary"
+       ColumnSchemaSummary       = "schema_summary"
        ColumnDep                 = "dep"
        ColumnDependency          = "dependency"
        ColumnRule                = "rule"
        ColumnInstance            = "instance"
-       ColumnInstanceID          = "instanceid"
-       ColumnConsumerID          = "consumerid"
-       ColumnMongoID             = "_id"
+       ColumnInstanceID          = "instance_id"
        ColumnTenant              = "tenant"
        ColumnServiceType         = "type"
-       ColumnServiceKey          = "servicekey"
-       ColumnConsumer            = "consumer"
+       ColumnServiceKey          = "service_key"
        ColumnID                  = "id"
        ColumnAccountName         = "name"
        ColumnRoleName            = "name"
        ColumnPerms               = "perms"
        ColumnPassword            = "password"
-       ColumnRole                = "role"
-       ColumnTokenExpirationTime = "tokenexpirationtime"
-       ColumnCurrentPassword     = "currentpassword"
+       ColumnRoles               = "roles"
+       ColumnTokenExpirationTime = "token_expiration_time"
+       ColumnCurrentPassword     = "current_password"
        ColumnStatus              = "status"
-       ColumnRefreshTime         = "refreshtime"
+       ColumnRefreshTime         = "refresh_time"
 )
 
 type Service struct {
-       Domain  string
-       Project string
-       Tags    map[string]string
-       Service *pb.MicroService
+       Domain  string            `json:"domain,omitempty"`
+       Project string            `json:"project,omitempty"`
+       Tags    map[string]string `json:"tags,omitempty"`
+       Service *pb.MicroService  `json:"service,omitempty"`
 }
 
 type Schema struct {
-       Domain        string
-       Project       string
-       ServiceID     string
-       SchemaID      string
-       Schema        string
-       SchemaSummary string
+       Domain        string `json:"domain,omitempty"`
+       Project       string `json:"project,omitempty"`
+       ServiceID     string `json:"serviceID,omitempty" bson:"service_id"`
+       SchemaID      string `json:"schemaID,omitempty" bson:"schema_id"`
+       Schema        string `json:"schema,omitempty"`
+       SchemaSummary string `json:"schemaSummary,omitempty" 
bson:"schema_summary"`
 }
 
 type Rule struct {
-       Domain    string
-       Project   string
-       ServiceID string
-       Rule      *pb.ServiceRule
+       Domain    string          `json:"domain,omitempty"`
+       Project   string          `json:"project,omitempty"`
+       ServiceID string          `json:"serviceID,omitempty" bson:"service_id"`
+       Rule      *pb.ServiceRule `json:"rule,omitempty"`
 }
 
 type Instance struct {
-       Domain      string
-       Project     string
-       RefreshTime time.Time
-       Instance    *pb.MicroServiceInstance
+       Domain      string                   `json:"domain,omitempty"`
+       Project     string                   `json:"project,omitempty"`
+       RefreshTime time.Time                `json:"refreshTime,omitempty" 
bson:"refresh_time"`
+       Instance    *pb.MicroServiceInstance `json:"instance,omitempty"`
 }
 
 type ConsumerDep struct {
-       Domain      string
-       Project     string
-       ConsumerID  string
-       UUID        string
-       ConsumerDep *pb.ConsumerDependency
+       Domain      string                 `json:"domain,omitempty"`
+       Project     string                 `json:"project,omitempty"`
+       ConsumerID  string                 `json:"consumerID,omitempty" 
bson:"consumer_id"`
+       UUID        string                 `json:"uuID,omitempty" bson:"uu_id"`
+       ConsumerDep *pb.ConsumerDependency `json:"consumerDep,omitempty" 
bson:"consumer_dep"`
 }
 
 type DependencyRule struct {
-       Type       string
-       Domain     string
-       Project    string
-       ServiceKey *pb.MicroServiceKey
-       Dep        *pb.MicroServiceDependency
+       Type       string                     `json:"type,omitempty"`
+       Domain     string                     `json:"domain,omitempty"`
+       Project    string                     `json:"project,omitempty"`
+       ServiceKey *pb.MicroServiceKey        `json:"serviceKey,omitempty" 
bson:"service_key"`
+       Dep        *pb.MicroServiceDependency `json:"dep,omitempty"`
 }
 
 type DelDepCacheKey struct {
diff --git a/datasource/mongo/heartbeat/cache/heartbeatcache.go 
b/datasource/mongo/heartbeat/cache/heartbeatcache.go
index 46588e9..a9f4d80 100644
--- a/datasource/mongo/heartbeat/cache/heartbeatcache.go
+++ b/datasource/mongo/heartbeat/cache/heartbeatcache.go
@@ -45,9 +45,8 @@ func NewHeartBeatCheck(opts heartbeat.Options) 
(heartbeat.HealthCheck, error) {
 func (h *HeartBeatCheck) Heartbeat(ctx context.Context, request 
*pb.HeartbeatRequest) (*pb.HeartbeatResponse, error) {
        if ins, ok := instanceHeartbeatStore.Get(request.InstanceId); ok {
                return inCacheStrategy(ctx, request, ins)
-       } else {
-               return notInCacheStrategy(ctx, request)
        }
+       return notInCacheStrategy(ctx, request)
 }
 
 func inCacheStrategy(ctx context.Context, request *pb.HeartbeatRequest, 
insHeartbeatInfo interface{}) (*pb.HeartbeatResponse, error) {
diff --git a/datasource/mongo/sd/listwatch_test.go 
b/datasource/mongo/sd/listwatch_test.go
index 2e5a8b0..bb8d561 100644
--- a/datasource/mongo/sd/listwatch_test.go
+++ b/datasource/mongo/sd/listwatch_test.go
@@ -27,10 +27,10 @@ func TestListWatchConfig_String(t *testing.T) {
 func TestDoParseWatchRspToMongoInfo(t *testing.T) {
        documentID := primitive.NewObjectID()
 
-       mockDocument, _ := bson.Marshal(bson.M{"_id": documentID, "domain": 
"default", "project": "default", "instance": bson.M{"instanceid": 
"8064a600438511eb8584fa163e8a81c9", "serviceid": 
"91afbe0faa9dc1594689139f099eb293b0cd048d",
-               "hostname": "ecs-hcsadlab-dev-0002", "status": "UP", 
"timestamp": "1608552622", "modtimestamp": "1608552622", "version": "0.0.1"}})
+       mockDocument, _ := bson.Marshal(bson.M{"_id": documentID, "domain": 
"default", "project": "default", "instance": bson.M{"instance_id": 
"8064a600438511eb8584fa163e8a81c9", "service_id": 
"91afbe0faa9dc1594689139f099eb293b0cd048d",
+               "hostname": "ecs-hcsadlab-dev-0002", "status": "UP", 
"timestamp": "1608552622", "mod_timestamp": "1608552622", "version": "0.0.1"}})
 
-       mockServiceDocument, _ := bson.Marshal(bson.M{"_id": documentID, 
"domain": "default", "project": "default", "service": bson.M{"serviceid": 
"91afbe0faa9dc1594689139f099eb293b0cd048d", "timestamp": "1608552622", 
"modtimestamp": "1608552622", "version": "0.0.1"}})
+       mockServiceDocument, _ := bson.Marshal(bson.M{"_id": documentID, 
"domain": "default", "project": "default", "service": bson.M{"service_id": 
"91afbe0faa9dc1594689139f099eb293b0cd048d", "timestamp": "1608552622", 
"mod_timestamp": "1608552622", "version": "0.0.1"}})
 
        // case instance insertOp
 
diff --git a/examples/mongodb_data_struct.yaml 
b/examples/mongodb_data_struct.yaml
index acb9fd6..d82eab9 100644
--- a/examples/mongodb_data_struct.yaml
+++ b/examples/mongodb_data_struct.yaml
@@ -1,7 +1,14 @@
+#type Service struct {
+#  Domain  string            `json:"domain,omitempty"`
+#  Project string            `json:"project,omitempty"`
+#  Tags    map[string]string `json:"tags,omitempty"`
+#  Service *pb.MicroService  `json:"service,omitempty"`
+#}
+
 #type MicroService struct {
-#  ServiceId    string             `protobuf:"bytes,1,opt,name=serviceId" 
json:"serviceId,omitempty"`
-#  AppId        string             `protobuf:"bytes,2,opt,name=appId" 
json:"appId,omitempty"`
-#  ServiceName  string             `protobuf:"bytes,3,opt,name=serviceName" 
json:"serviceName,omitempty"`
+#  ServiceId    string             `protobuf:"bytes,1,opt,name=serviceId" 
json:"serviceId,omitempty" bson:"service_id"`
+#  AppId        string             `protobuf:"bytes,2,opt,name=appId" 
json:"appId,omitempty" bson:"app"`
+#  ServiceName  string             `protobuf:"bytes,3,opt,name=serviceName" 
json:"serviceName,omitempty" bson:"service_name"`
 #  Version      string             `protobuf:"bytes,4,opt,name=version" 
json:"version,omitempty"`
 #  Description  string             `protobuf:"bytes,5,opt,name=description" 
json:"description,omitempty"`
 #  Level        string             `protobuf:"bytes,6,opt,name=level" 
json:"level,omitempty"`
@@ -12,206 +19,255 @@
 #  Timestamp    string             `protobuf:"bytes,11,opt,name=timestamp" 
json:"timestamp,omitempty"`
 #  Providers    []*MicroServiceKey `protobuf:"bytes,12,rep,name=providers" 
json:"providers,omitempty"`
 #  Alias        string             `protobuf:"bytes,13,opt,name=alias" 
json:"alias,omitempty"`
-#  LBStrategy   map[string]string  `protobuf:"bytes,14,rep,name=LBStrategy" 
json:"LBStrategy,omitempty" protobuf_key:"bytes,1,opt,name=key" 
protobuf_val:"bytes,2,opt,name=value"`
-#  ModTimestamp string             `protobuf:"bytes,15,opt,name=modTimestamp" 
json:"modTimestamp,omitempty"`
-#  Environment  string             `protobuf:"bytes,16,opt,name=environment" 
json:"environment,omitempty"`
-#  RegisterBy   string             `protobuf:"bytes,17,opt,name=registerBy" 
json:"registerBy,omitempty"`
+#  LBStrategy   map[string]string  `protobuf:"bytes,14,rep,name=LBStrategy" 
json:"LBStrategy,omitempty" protobuf_key:"bytes,1,opt,name=key" 
protobuf_val:"bytes,2,opt,name=value" bson:"lb_strategy"`
+#  ModTimestamp string             `protobuf:"bytes,15,opt,name=modTimestamp" 
json:"modTimestamp,omitempty" bson:"mod_timestamp"`
+#  Environment  string             `protobuf:"bytes,16,opt,name=environment" 
json:"environment,omitempty" bson:"env"`
+#  RegisterBy   string             `protobuf:"bytes,17,opt,name=registerBy" 
json:"registerBy,omitempty" bson:"register_by"`
 #  Framework    *FrameWorkProperty `protobuf:"bytes,18,opt,name=framework" 
json:"framework,omitempty"`
 #}
 
 #collection: service
 {
-  "_id": "xxx",
-  "serviceId": "7062417bf9ebd4c646bb23059003cea42180894a",
-  "appId": "",
-  "serviceName": "SERVICE-CENTER",
-  "domain": "default",
-  "project": "default",
-  "version": "0.0.1",
-  "description": "This is data struct in mongodb",
-  "level": "info",
-  "schema": ["first_schema", "second_schema"],
-  "paths": [{
-              "Path": "aeiou",
-              "Property": {}
-            } ],
-  "status": "UP",
-  "properties": { "allowCrossApp": "true" },
-  "timestamp": "1500519927",
-  "providers":[{
-                 "appId": "",
-                 "serviceName": "SERVICE-CENTER",
-                 "version": "0.0.2"
-               }],
-  "alias": "service-center",
-  "LBStrategy": {"strategy-1": "round-robin"},
-  "modTimeStamp": "1500519927",
-  "environment": "development",
-  "registerBy": "PLATFORM",
-  "framework": {"name": "UNKNOW", "version": "0.0.1"}
+  "_id" : ObjectId("6021fb9527d99d766f82e44f"),
+  "domain" : "new_default",
+  "project" : "new_default",
+  "tags" : null,
+  "service" : {
+    "service_id" : "6ea4d1c36a8311eba78dfa163e176e7b",
+    "app" : "dep_create_dep_group",
+    "service_name" : "dep_create_dep_consumer",
+    "version" : "1.0.0",
+    "description" : "",
+    "level" : "FRONT",
+    "schemas" : null,
+    "paths" : null,
+    "status" : "UP",
+    "properties" : null,
+    "timestamp" : "1612839829",
+    "providers" : null,
+    "alias" : "",
+    "lb_strategy" : null,
+    "mod_timestamp" : "1612839829",
+    "env" : "",
+    "register_by" : "",
+    "framework" : null
+  }
 }
 
+#type Instance struct {
+#  Domain      string                   `json:"domain,omitempty"`
+#  Project     string                   `json:"project,omitempty"`
+#  RefreshTime time.Time                `json:"refreshTime,omitempty" 
bson:"refresh_time"`
+#  Instance    *pb.MicroServiceInstance `json:"instance,omitempty"`
+#}
+
 #type MicroServiceInstance struct {
-#  InstanceId     string            `protobuf:"bytes,1,opt,name=instanceId" 
json:"instanceId,omitempty"`
-#  ServiceId      string            `protobuf:"bytes,2,opt,name=serviceId" 
json:"serviceId,omitempty"`
+#  InstanceId     string            `protobuf:"bytes,1,opt,name=instanceId" 
json:"instanceId,omitempty" bson:"instance_id"`
+#  ServiceId      string            `protobuf:"bytes,2,opt,name=serviceId" 
json:"serviceId,omitempty" bson:"service_id"`
 #  Endpoints      []string          `protobuf:"bytes,3,rep,name=endpoints" 
json:"endpoints,omitempty"`
 #  HostName       string            `protobuf:"bytes,4,opt,name=hostName" 
json:"hostName,omitempty"`
 #  Status         string            `protobuf:"bytes,5,opt,name=status" 
json:"status,omitempty"`
 #  Properties     map[string]string `protobuf:"bytes,6,rep,name=properties" 
json:"properties,omitempty" protobuf_key:"bytes,1,opt,name=key" 
protobuf_val:"bytes,2,opt,name=value"`
-#  HealthCheck    *HealthCheck      `protobuf:"bytes,7,opt,name=healthCheck" 
json:"healthCheck,omitempty"`
+#  HealthCheck    *HealthCheck      `protobuf:"bytes,7,opt,name=healthCheck" 
json:"healthCheck,omitempty" bson:"health_check"`
 #  Timestamp      string            `protobuf:"bytes,8,opt,name=timestamp" 
json:"timestamp,omitempty"`
-#  DataCenterInfo *DataCenterInfo   
`protobuf:"bytes,9,opt,name=dataCenterInfo" json:"dataCenterInfo,omitempty"`
-#  ModTimestamp   string            `protobuf:"bytes,10,opt,name=modTimestamp" 
json:"modTimestamp,omitempty"`
+#  DataCenterInfo *DataCenterInfo   
`protobuf:"bytes,9,opt,name=dataCenterInfo" json:"dataCenterInfo,omitempty" 
bson:"data_center_info"`
+#  ModTimestamp   string            `protobuf:"bytes,10,opt,name=modTimestamp" 
json:"modTimestamp,omitempty" bson:"mod_timestamp"`
 #  Version        string            `protobuf:"bytes,11,opt,name=version" 
json:"version,omitempty"`
 #}
 
 # collection: instance
 {
-  "_id": "xxx",
-  "instanceId": "7062417bf9ebd4c646bb23059003cea42180894b",
-  "serviceId": "7062417bf9ebd4c646bb23059003cea42180894a",
-  "domain": "default",
-  "project": "default",
-  "endpoints": [
-    "rest://192.168.88.109:30100/"
-  ],
-  "hostName": "cse",
-  "status": "normal",
-  "properties": {
-    "allowCrossApp": "true"
-  },
-  "healthCheck": {
-    "mode": "push",
-    "times": 1,
-    "port": 0,
-    "interval": 6
-  },
-  "timestamp": "1500519927",
-  "dataCenterInfo": {
-    "availableZone": "az1",
-    "name": "dc1",
-    "region": "cn-north"
-  },
-  "modTimestamp": "1500519927",
-  "leaseId": "1234",
-  "version": "0.0.2"
+  "_id" : ObjectId("60222c6f4fe067987f40803e"),
+  "domain" : "default",
+  "project" : "default",
+  "refresh_time" : ISODate("2021-02-09T06:32:15.562Z"),
+  "instance" : {
+    "instance_id" : "8cde54a46aa011ebab42fa163e176e7b",
+    "service_id" : "8cddc7ce6aa011ebab40fa163e176e7b",
+    "endpoints" : [
+        "find:127.0.0.9:8080"
+    ],
+    "hostname" : "UT-HOST-MS",
+    "status" : "UP",
+    "properties" : null,
+    "health_check" : {
+      "mode" : "push",
+      "port" : 0,
+      "interval" : 30,
+      "times" : 3,
+      "url" : ""
+    },
+    "timestamp" : "1612852335",
+    "data_center_info" : null,
+    "mod_timestamp" : "1612852335",
+    "version" : "1.0.0"
+  }
 }
 
 #type Schema struct {
-#  SchemaId string `protobuf:"bytes,1,opt,name=schemaId" 
json:"schemaId,omitempty"`
-#  Summary  string `protobuf:"bytes,2,opt,name=summary" 
json:"summary,omitempty"`
-#  Schema   string `protobuf:"bytes,3,opt,name=schema" json:"schema,omitempty"`
+#  Domain        string `json:"domain,omitempty"`
+#  Project       string `json:"project,omitempty"`
+#  ServiceId     string `json:"serviceId,omitempty" bson:"service_id"`
+#  SchemaId      string `json:"schemaId,omitempty" bson:"schema_id"`
+#  Schema        string `json:"schema,omitempty"`
+#  SchemaSummary string `json:"schemaSummary,omitempty" bson:"schema_summary"`
 #}
 
 # collection schema
 {
-  "_id": "xxx",
-  "serviceId": "7062417bf9ebd4c646bb23059003cea42180894b",
-  "schemaId": "first_schema",
-  "domain": "default",
-  "project": "default",
-  "schema": "schema",
-  "summary": "summary"
+  "_id" : ObjectId("6021fb9827d99d766f82e4f7"),
+  "domain" : "default",
+  "project" : "default",
+  "service_id" : "70302da16a8311eba7cbfa163e176e7b",
+  "schema_id" : "ServiceCombTestTheLimitOfSchemasServiceMS19",
+  "schema" : "ServiceCombTestTheLimitOfSchemasServiceMS19",
+  "schema_summary" : "ServiceCombTestTheLimitOfSchemasServiceMS19"
 }
 
+#type Rule struct {
+#  Domain    string          `json:"domain,omitempty"`
+#  Project   string          `json:"project,omitempty"`
+#  ServiceId string          `json:"serviceId,omitempty" bson:"service_id"`
+#  Rule      *pb.ServiceRule `json:"rule,omitempty"`
+#}
+
 #type ServiceRule struct {
-#  RuleId       string `protobuf:"bytes,1,opt,name=ruleId" 
json:"ruleId,omitempty"`
-#  RuleType     string `protobuf:"bytes,2,opt,name=ruleType" 
json:"ruleType,omitempty"`
+#  RuleId       string `protobuf:"bytes,1,opt,name=ruleId" 
json:"ruleId,omitempty" bson:"rule_id"`
+#  RuleType     string `protobuf:"bytes,2,opt,name=ruleType" 
json:"ruleType,omitempty" bson:"rule_type"`
 #  Attribute    string `protobuf:"bytes,3,opt,name=attribute" 
json:"attribute,omitempty"`
 #  Pattern      string `protobuf:"bytes,4,opt,name=pattern" 
json:"pattern,omitempty"`
 #  Description  string `protobuf:"bytes,5,opt,name=description" 
json:"description,omitempty"`
 #  Timestamp    string `protobuf:"bytes,6,opt,name=timestamp" 
json:"timestamp,omitempty"`
-#  ModTimestamp string `protobuf:"bytes,7,opt,name=modTimestamp" 
json:"modTimestamp,omitempty"`
+#  ModTimestamp string `protobuf:"bytes,7,opt,name=modTimestamp" 
json:"modTimestamp,omitempty" bson:"mod_timestamp"`
 #}
 # collection rules
 {
-  "_id": "xxx",
-  "domain": "default",
-  "project": "default",
-  "serviceId": "7062417bf9ebd4c646bb23059003cea42180894b",
-  "ruleId": "Deny",
-  "roleType": "admin",
-  "attribute": "tag_a",
-  "pattern": "a+",
-  "description": "aeiou",
-  "timestamp": "1500519927",
-  "modTimestamp": "1500519928"
-}
-
-# collection tags
-{
-  "_id": "xxx",
-  "domain": "default",
-  "project": "default",
-  "serviceId": "7062417bf9ebd4c646bb23059003cea42180894b",
-  "tagKey1": "tagValue1",
-  "tagKey2": "tagValue2"
+  "_id" : ObjectId("6021fb9727d99d766f82e48a"),
+  "domain" : "default",
+  "project" : "default",
+  "service_id" : "7026973b6a8311eba792fa163e176e7b",
+  "rule" : {
+    "rule_id" : "702897cf6a8311eba79dfa163e176e7b",
+    "rule_type" : "BLACK",
+    "attribute" : "ServiceName",
+    "pattern" : "18",
+    "description" : "test white",
+    "timestamp" : "1612839831",
+    "mod_timestamp" : "1612839831"
+  }
 }
 
+#type ConsumerDep struct {
+#  Domain      string                 `json:"domain,omitempty"`
+#  Project     string                 `json:"project,omitempty"`
+#  ConsumerId  string                 `json:"consumerId,omitempty" 
bson:"consumer_id"`
+#  UUId        string                 `json:"uuId,omitempty" bson:"uu_id"`
+#  ConsumerDep *pb.ConsumerDependency `json:"consumerDep,omitempty" 
bson:"consumer_dep"`
+#}
 
 #type ConsumerDependency struct {
 #  Consumer  *MicroServiceKey   `protobuf:"bytes,1,opt,name=consumer" 
json:"consumer,omitempty"`
 #  Providers []*MicroServiceKey `protobuf:"bytes,2,rep,name=providers" 
json:"providers,omitempty"`
 #  Override  bool               `protobuf:"varint,3,opt,name=override" 
json:"override,omitempty"`
 #}
+
+#type MicroServiceKey struct {
+#  Tenant      string `protobuf:"bytes,1,opt,name=tenant" 
json:"tenant,omitempty"`
+#  Environment string `protobuf:"bytes,2,opt,name=environment" 
json:"environment,omitempty" bson:"env"`
+#  AppId       string `protobuf:"bytes,3,opt,name=appId" 
json:"appId,omitempty" bson:"app"`
+#  ServiceName string `protobuf:"bytes,4,opt,name=serviceName" 
json:"serviceName,omitempty" bson:"service_name"`
+#  Alias       string `protobuf:"bytes,5,opt,name=alias" 
json:"alias,omitempty"`
+#  Version     string `protobuf:"bytes,6,opt,name=version" 
json:"version,omitempty"`
+#}
+
 # collection dependencies
 {
-  "_id": "xxx",
-  "domain": "default",
-  "project": "default",
-  #  serviceId
-  "consumerId": "7062417bf9ebd4c646bb23059003cea42180894b",
-  "uuid": "0",
-  "consumer": {
-    "tenant": "default/default",
-    "project": "project",
-    "appId": "appId",
-    "serviceName": "ServiceCenter",
-    "version": "0.0.1",
-    "environment": "development",
-    "alias": "serviceCenter"
-  },
-  "providers": [{
-                 "tenant": "default/default",
-                 "project": "project",
-                 "appId": "appId",
-                 "serviceName": "ServiceCenterProvider",
-                 "version": "0.0.2",
-                 "environment": "development",
-                 "alias": "serviceCenterProvider"
-               }],
-  "override": true
+  "_id" : ObjectId("6021fb9527d99d766f82e45f"),
+  "domain" : "new_default",
+  "project" : "new_default",
+  "consumer_id" : "6ea4d1c36a8311eba78dfa163e176e7b",
+  "uu_id" : "6eaeb1dd6a8311eba790fa163e176e7b",
+  "consumer_dep" : {
+    "consumer" : {
+      "tenant" : "new_default/new_default",
+      "env" : "",
+      "app" : "dep_create_dep_group",
+      "service_name" : "dep_create_dep_consumer",
+      "alias" : "",
+      "version" : "1.0.0"
+    },
+    "providers" : null,
+    "override" : false
+  }
 }
 
-#type Account struct {
-#  ID                  string `json:"id,omitempty"`
-#  Name                string `json:"name,omitempty"`
-#  Password            string `json:"password,omitempty"`
-#  Role                string `json:"role,omitempty"`
-#  TokenExpirationTime string `json:"tokenExpirationTime,omitempty"`
-#  CurrentPassword     string `json:"currentPassword,omitempty"`
-#  Status              string `json:"status,omitempty"`
+#type DependencyRule struct {
+#  Type       string                     `json:"type,omitempty"`
+#  Domain     string                     `json:"domain,omitempty"`
+#  Project    string                     `json:"project,omitempty"`
+#  ServiceKey *pb.MicroServiceKey        `json:"serviceKey,omitempty" 
bson:"service_key"`
+#  Dep        *pb.MicroServiceDependency `json:"dep,omitempty"`
 #}
-# collection account
-{
-  "_id": "xxx",
-  "account": "account_name",
-  "password": "password",
-  "role": "admin",
-  "tokenExpirationTime": "1500519927",
-  "currentPassword": "password",
-  "status": "normal"
-}
 
-# collection domain
+#type MicroServiceKey struct {
+#  Tenant      string `protobuf:"bytes,1,opt,name=tenant" 
json:"tenant,omitempty"`
+#  Environment string `protobuf:"bytes,2,opt,name=environment" 
json:"environment,omitempty" bson:"env"`
+#  AppId       string `protobuf:"bytes,3,opt,name=appId" 
json:"appId,omitempty" bson:"app"`
+#  ServiceName string `protobuf:"bytes,4,opt,name=serviceName" 
json:"serviceName,omitempty" bson:"service_name"`
+#  Alias       string `protobuf:"bytes,5,opt,name=alias" 
json:"alias,omitempty"`
+#  Version     string `protobuf:"bytes,6,opt,name=version" 
json:"version,omitempty"`
+#}
+
+#type MicroServiceDependency struct {
+#  Dependency []*MicroServiceKey `json:"Dependency,omitempty"`
+#}
+
+# collection dependencies
 {
-  "_id": "xxx",
-  "domain": "domain"
+  "_id" : ObjectId("6022302751a77062a95dd0da"),
+  "service_key" : {
+    "app" : "create_dep_group",
+    "env" : "production",
+    "service_name" : "create_dep_consumer",
+    "tenant" : "default/default",
+    "version" : "1.0.0"
+  },
+  "type" : "c",
+  "dep" : {
+    "dependency" : [
+      {
+        "tenant" : "default/default",
+        "env" : "",
+        "app" : "service_group_provider",
+        "service_name" : "service_name_provider",
+        "alias" : "",
+        "version" : "latest"
+      }
+    ]
+  }
 }
 
-# collection project
+
+#type Account struct {
+#  ID                  string   `json:"id,omitempty"`
+#  Name                string   `json:"name,omitempty"`
+#  Password            string   `json:"password,omitempty"`
+#  Roles               []string `json:"roles,omitempty"`
+#  TokenExpirationTime string   `json:"tokenExpirationTime,omitempty" 
bson:"token_expiration_time"`
+#  CurrentPassword     string   `json:"currentPassword,omitempty" 
bson:"current_password"`
+#  Status              string   `json:"status,omitempty"`
+#}
+
+# collection account
 {
-  "_id": "xxx",
-  "domain": "domain",
-  "project": "project"
-}
\ No newline at end of file
+  "_id" : ObjectId("60223e99184f264aee398238"),
+  "id" : "6038bf9f6aab11ebbcdefa163e176e7b",
+  "name" : "test-account1",
+  "password" : "$2a$14$eYyD9DiOA1vGXOyhPTjbhO6CYuGnOVt8VQ8V/sWEmExyvwOQeNI2i",
+  "roles" : [
+      "admin"
+  ],
+  "token_expiration_time" : "2020-12-30",
+  "current_password" : "tnuocca-tset1",
+  "status" : ""
+}
diff --git a/go.mod b/go.mod
index ccd2f53..552ce00 100644
--- a/go.mod
+++ b/go.mod
@@ -17,7 +17,7 @@ require (
        github.com/dgrijalva/jwt-go v3.2.0+incompatible
        github.com/dustin/go-humanize v1.0.0 // indirect
        github.com/ghodss/yaml v1.0.0
-       github.com/go-chassis/cari v0.0.2-0.20210203013205-0083e3b092cf
+       github.com/go-chassis/cari v0.0.2-0.20210208095358-3bccdf2ce456
        github.com/go-chassis/foundation v0.2.2
        github.com/go-chassis/go-archaius v1.3.6-0.20201130023516-387922b408d0
        github.com/go-chassis/go-chassis/v2 v2.1.1-0.20201208095114-93feb76fd997
diff --git a/pkg/rbacframe/account.go b/pkg/rbacframe/account.go
index 795ca5a..fe95fc9 100644
--- a/pkg/rbacframe/account.go
+++ b/pkg/rbacframe/account.go
@@ -31,8 +31,8 @@ type Account struct {
        Name                string   `json:"name,omitempty"`
        Password            string   `json:"password,omitempty"`
        Roles               []string `json:"roles,omitempty"`
-       TokenExpirationTime string   `json:"tokenExpirationTime,omitempty"`
-       CurrentPassword     string   `json:"currentPassword,omitempty"`
+       TokenExpirationTime string   `json:"tokenExpirationTime,omitempty" 
bson:"token_expiration_time"`
+       CurrentPassword     string   `json:"currentPassword,omitempty" 
bson:"current_password"`
        Status              string   `json:"status,omitempty"`
 }
 

Reply via email to