(c *gin.Context)
| 196 | } |
| 197 | |
| 198 | func databaseList(c *gin.Context) { |
| 199 | // query account belongings |
| 200 | developer := getDeveloperID(c) |
| 201 | |
| 202 | p, err := model.GetMainAccount(model.GetDB(c), developer) |
| 203 | if err != nil { |
| 204 | _ = c.Error(err) |
| 205 | abortWithError(c, http.StatusForbidden, ErrNoMainAccount) |
| 206 | return |
| 207 | } |
| 208 | |
| 209 | req := new(types.QueryAccountSQLChainProfilesReq) |
| 210 | resp := new(types.QueryAccountSQLChainProfilesResp) |
| 211 | |
| 212 | accountAddr, err := p.Account.Get() |
| 213 | if err != nil { |
| 214 | _ = c.Error(err) |
| 215 | abortWithError(c, http.StatusBadRequest, ErrParseAccountFailed) |
| 216 | return |
| 217 | } |
| 218 | |
| 219 | req.Addr = accountAddr |
| 220 | err = rpc.RequestBP(route.MCCQueryAccountSQLChainProfiles.String(), req, resp) |
| 221 | if err != nil { |
| 222 | _ = c.Error(err) |
| 223 | abortWithError(c, http.StatusInternalServerError, ErrSendETLSRPCFailed) |
| 224 | return |
| 225 | } |
| 226 | |
| 227 | var profiles []gin.H |
| 228 | |
| 229 | for _, p := range resp.Profiles { |
| 230 | var profile = gin.H{} |
| 231 | |
| 232 | for _, user := range p.Users { |
| 233 | if user.Address == accountAddr && user.Permission.HasSuperPermission() { |
| 234 | profile["id"] = p.ID |
| 235 | profile["deposit"] = user.Deposit |
| 236 | profile["arrears"] = user.Arrears |
| 237 | profile["advance_payment"] = user.AdvancePayment |
| 238 | |
| 239 | profiles = append(profiles, profile) |
| 240 | } |
| 241 | } |
| 242 | } |
| 243 | |
| 244 | responseWithData(c, http.StatusOK, gin.H{ |
| 245 | "profiles": profiles, |
| 246 | }) |
| 247 | } |
| 248 | |
| 249 | func createDatabase(db *gorp.DbMap, developer int64, account int64, nodeCount uint16) (tx hash.Hash, dbID proto.DatabaseID, key *asymmetric.PrivateKey, err error) { |
| 250 | p, err := model.GetAccountByID(db, developer, account) |
nothing calls this directly
no test coverage detected