-
GetAccountStatus
- 此方法获取令牌账户的当前状态。此方法可由链代码的
Token Admin
或令牌账户所有者调用。
-
func (t *Controller) GetAccountStatus(orgId string, userId string) (interface{}, error) {
accountId, err := t.Ctx.ERC721Account.GenerateAccountId(orgId, userId)
if err != nil {
return nil, fmt.Errorf("error in getting the generating accountId of (Org-Id: %s, User-Id: %s)", orgId, userId)
}
auth, err := t.Ctx.ERC721Auth.CheckAuthorization("ERC721AccountStatus.Get", "TOKEN", map[string]string{"accountId": accountId})
if err != nil && !auth {
return nil, fmt.Errorf("error in authorizing the caller %s", err.Error())
}
accountStatus, err := t.Ctx.ERC721AccountStatus.GetAccountStatus(accountId)
if err != nil {
return t.Ctx.ERC721AccountStatus.GetDefaultAccountStatus(accountId)
}
return accountStatus, nil
}
- 参数:
orgId: string
—当前组织中用户的成员服务提供商 (MSP) ID。
userId: string
—用户的用户名或电子邮件 ID。
- 返回:
- 成功后,标记账户状态的 JSON 表示形式。如果在账户的分类账中未找到状态,因为账户是在账户状态功能可用之前创建的,则回应中的状态将列为
active
。
- 返回值示例:
{
"AssetType": "oaccountStatus",
"StatusId": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7",
"AccountId": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
"Status": "active"
}
-
GetAccountStatusHistory
- 此方法获取帐户状态的历史记录。此方法可由链代码的
Token Admin
或令牌账户所有者调用。
-
func (t *Controller) GetAccountStatusHistory(orgId string, userId string) (interface{}, error) {
accountId, err := t.Ctx.ERC721Account.GenerateAccountId(orgId, userId)
if err != nil {
return nil, fmt.Errorf("error in getting the generating accountId of (Org-Id: %s, User-Id: %s)", orgId, userId)
}
_, err = t.Ctx.ERC721Account.GetAccount(accountId)
if err != nil {
return nil, fmt.Errorf("error in GetAccountStatusHistory: %s", err)
}
auth, err := t.Ctx.ERC721Auth.CheckAuthorization("ERC721AccountStatus.Get", "TOKEN", map[string]string{"accountId": accountId})
if err != nil && !auth {
return nil, fmt.Errorf("error in authorizing the caller %s", err.Error())
}
statusId, err := t.Ctx.ERC721AccountStatus.GenerateAccountStatusId(accountId)
if err != nil {
return nil, err
}
accountStatusHistory, err := t.Ctx.ERC721AccountStatus.History(statusId)
if err != nil {
return []map[string]interface{}{}, nil
}
return accountStatusHistory, nil
}
- 参数:
orgId: string
—当前组织中用户的成员服务提供商 (MSP) ID。
userId: string
—用户的用户名或电子邮件 ID。
- 返回:
- 返回值示例:
[
{
"IsDelete": "false",
"Timestamp": "2022-12-02T16:20:34+05:30",
"TxId": "af1601c7a14b4becf4bb3b285d85553b39bf234caaf1cd488a284a31a2d9df78",
"Value": {
"AccountId": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
"AssetType": "oaccountStatus",
"Status": "suspended",
"StatusId": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7"
}
},
{
"IsDelete": "false",
"Timestamp": "2022-12-02T16:19:15+05:30",
"TxId": "4b307b989063e43add5357ab110e19174d586b9746cc8a30c9aa3a2b0b48a34e",
"Value": {
"AccountId": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
"AssetType": "oaccountStatus",
"Status": "active",
"StatusId": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7"
}
}
]
-
ActivateAccount
- 此方法会激活令牌账户。此方法只能由链代码的
Token Admin
调用。无法删除帐户。对于在账户状态功能可用之前创建的任何账户,必须调用此方法才能将账户状态设置为 active
。
-
func (t *Controller) ActivateAccount(orgId string, userId string) (interface{}, error) {
accountId, err := t.Ctx.ERC721Account.GenerateAccountId(orgId, userId)
if err != nil {
return nil, fmt.Errorf("error in getting the generating accountId of (Org-Id: %s, User-Id: %s)", orgId, userId)
}
auth, err := t.Ctx.ERC721Auth.CheckAuthorization("ERC721AccountStatus.ActivateAccount", "TOKEN")
if err != nil && !auth {
return nil, fmt.Errorf("error in authorizing the caller %s", err.Error())
}
return t.Ctx.ERC721Account.ActivateAccount(accountId)
}
- 参数:
orgId: string
—当前组织中用户的成员服务提供商 (MSP) ID。
userId: string
—用户的用户名或电子邮件 ID。
- 返回:
- 返回值示例:
{
"AssetType": "oaccountStatus",
"StatusId": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7",
"AccountId": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
"Status": "active"
}
-
SuspendAccount
- 此方法将暂停令牌账户。此方法只能由链代码的
Token Admin
调用。账户暂停后,无法完成任何更新账户的操作。无法删除已删除的账户。
-
func (t *Controller) SuspendAccount(orgId string, userId string) (interface{}, error) {
accountId, err := t.Ctx.ERC721Account.GenerateAccountId(orgId, userId)
if err != nil {
return nil, fmt.Errorf("error in getting the generating accountId of (Org-Id: %s, User-Id: %s)", orgId, userId)
}
auth, err := t.Ctx.ERC721Auth.CheckAuthorization("ERC721AccountStatus.SuspendAccount", "TOKEN")
if err != nil && !auth {
return nil, fmt.Errorf("error in authorizing the caller %s", err.Error())
}
return t.Ctx.ERC721Account.SuspendAccount(accountId)
}
- 参数:
orgId: string
—当前组织中用户的成员服务提供商 (MSP) ID。
userId: string
—用户的用户名或电子邮件 ID。
- 返回:
- 返回值示例:
{
"AssetType": "oaccountStatus",
"StatusId": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7",
"AccountId": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
"Status": "suspended"
}
-
DeleteAccount
- 此方法将删除令牌账户。此方法只能由链代码的
Token Admin
调用。删除账户后,无法完成任何更新账户的操作。已删除的账户处于最终状态,无法更改为任何其他状态。要删除帐户,帐户余额必须为零。
-
func (t *Controller) DeleteAccount(orgId string, userId string) (interface{}, error) {
accountId, err := t.Ctx.ERC721Account.GenerateAccountId(orgId, userId)
if err != nil {
return nil, fmt.Errorf("error in getting the generating accountId of (Org-Id: %s, User-Id: %s)", orgId, userId)
}
auth, err := t.Ctx.ERC721Auth.CheckAuthorization("ERC721AccountStatus.DeleteAccount", "TOKEN")
if err != nil && !auth {
return nil, fmt.Errorf("error in authorizing the caller %s", err.Error())
}
return t.Ctx.ERC721Account.DeleteAccount(accountId)
}
- 参数:
orgId: string
—当前组织中用户的成员服务提供商 (MSP) ID。
userId: string
—用户的用户名或电子邮件 ID。
- 返回:
- 返回值示例:
{
"AssetType": "oaccountStatus",
"StatusId": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7",
"AccountId": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
"Status": "deleted"
}