Skip to content

Commit d49eba3

Browse files
committed
mv dir model to sqldb
1 parent a4edaa7 commit d49eba3

File tree

157 files changed

+613
-630
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

157 files changed

+613
-630
lines changed

cmd/initDatabase.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"github.com/spf13/cobra"
1111

1212
"github.com/IBAX-io/go-ibax/packages/conf"
13-
"github.com/IBAX-io/go-ibax/packages/model"
13+
"github.com/IBAX-io/go-ibax/packages/storage/sqldb"
1414
)
1515

1616
// initDatabaseCmd represents the initDatabase command
@@ -19,7 +19,7 @@ var initDatabaseCmd = &cobra.Command{
1919
Short: "Initializing database",
2020
PreRun: loadConfigWKey,
2121
Run: func(cmd *cobra.Command, args []string) {
22-
if err := model.InitDB(conf.Config.DB); err != nil {
22+
if err := sqldb.InitDB(conf.Config.DB); err != nil {
2323
log.WithError(err).Fatal("init db")
2424
}
2525
log.Info("initDatabase completed")

cmd/rollback.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ package cmd
88
import (
99
"github.com/IBAX-io/go-ibax/packages/conf"
1010
"github.com/IBAX-io/go-ibax/packages/conf/syspar"
11-
"github.com/IBAX-io/go-ibax/packages/model"
1211
"github.com/IBAX-io/go-ibax/packages/rollback"
1312
"github.com/IBAX-io/go-ibax/packages/smart"
13+
"github.com/IBAX-io/go-ibax/packages/storage/sqldb"
1414
"github.com/IBAX-io/go-ibax/packages/utils"
1515

1616
log "github.com/sirupsen/logrus"
@@ -28,7 +28,7 @@ var rollbackCmd = &cobra.Command{
2828
f := utils.LockOrDie(conf.Config.DirPathConf.LockFilePath)
2929
defer f.Unlock()
3030

31-
if err := model.GormInit(conf.Config.DB); err != nil {
31+
if err := sqldb.GormInit(conf.Config.DB); err != nil {
3232
log.WithError(err).Fatal("init db")
3333
return
3434
}

packages/api/api.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"net/http"
1212
"strings"
1313

14-
"github.com/IBAX-io/go-ibax/packages/model"
14+
"github.com/IBAX-io/go-ibax/packages/storage/sqldb"
1515

1616
"github.com/gorilla/schema"
1717

@@ -76,7 +76,7 @@ func errorResponse(w http.ResponseWriter, err error, code ...int) {
7676
jsonResponse(w, et)
7777
}
7878

79-
func JsonCodeResponse(w http.ResponseWriter, ct *model.Response) {
79+
func JsonCodeResponse(w http.ResponseWriter, ct *sqldb.Response) {
8080
jsonResponse(w, ct)
8181
}
8282

packages/api/app_content.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ import (
1212

1313
"github.com/IBAX-io/go-ibax/packages/consts"
1414
"github.com/IBAX-io/go-ibax/packages/converter"
15-
"github.com/IBAX-io/go-ibax/packages/model"
15+
"github.com/IBAX-io/go-ibax/packages/storage/sqldb"
1616

1717
log "github.com/sirupsen/logrus"
1818
)
1919

2020
type appContentResult struct {
21-
Blocks []model.BlockInterface `json:"blocks"`
22-
Pages []model.Page `json:"pages"`
23-
Contracts []model.Contract `json:"contracts"`
21+
Blocks []sqldb.BlockInterface `json:"blocks"`
22+
Pages []sqldb.Page `json:"pages"`
23+
Contracts []sqldb.Contract `json:"contracts"`
2424
}
2525

2626
func (m Mode) getAppContentHandler(w http.ResponseWriter, r *http.Request) {
@@ -38,9 +38,9 @@ func (m Mode) getAppContentHandler(w http.ResponseWriter, r *http.Request) {
3838
logger := getLogger(r)
3939
params := mux.Vars(r)
4040

41-
bi := &model.BlockInterface{}
42-
p := &model.Page{}
43-
c := &model.Contract{}
41+
bi := &sqldb.BlockInterface{}
42+
p := &sqldb.Page{}
43+
c := &sqldb.Contract{}
4444
appID := converter.StrToInt64(params["appID"])
4545
ecosystemID := converter.StrToInt64(form.EcosystemPrefix)
4646

packages/api/appparam.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010

1111
"github.com/IBAX-io/go-ibax/packages/consts"
1212
"github.com/IBAX-io/go-ibax/packages/converter"
13-
"github.com/IBAX-io/go-ibax/packages/model"
13+
"github.com/IBAX-io/go-ibax/packages/storage/sqldb"
1414

1515
"github.com/gorilla/mux"
1616
log "github.com/sirupsen/logrus"
@@ -29,7 +29,7 @@ func (m Mode) GetAppParamHandler(w http.ResponseWriter, r *http.Request) {
2929

3030
params := mux.Vars(r)
3131

32-
ap := &model.AppParam{}
32+
ap := &sqldb.AppParam{}
3333
ap.SetTablePrefix(form.EcosystemPrefix)
3434
name := params["name"]
3535
found, err := ap.Get(nil, converter.StrToInt64(params["appID"]), name)

packages/api/appparams.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010

1111
"github.com/IBAX-io/go-ibax/packages/consts"
1212
"github.com/IBAX-io/go-ibax/packages/converter"
13-
"github.com/IBAX-io/go-ibax/packages/model"
13+
"github.com/IBAX-io/go-ibax/packages/storage/sqldb"
1414

1515
"github.com/gorilla/mux"
1616

@@ -46,7 +46,7 @@ func (m Mode) getAppParamsHandler(w http.ResponseWriter, r *http.Request) {
4646
params := mux.Vars(r)
4747
logger := getLogger(r)
4848

49-
ap := &model.AppParam{}
49+
ap := &sqldb.AppParam{}
5050
ap.SetTablePrefix(form.EcosystemPrefix)
5151

5252
list, err := ap.GetAllAppParameters(converter.StrToInt64(params["appID"]))

packages/api/balance.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010

1111
"github.com/IBAX-io/go-ibax/packages/consts"
1212
"github.com/IBAX-io/go-ibax/packages/converter"
13-
"github.com/IBAX-io/go-ibax/packages/model"
13+
"github.com/IBAX-io/go-ibax/packages/storage/sqldb"
1414

1515
"github.com/gorilla/mux"
1616
log "github.com/sirupsen/logrus"
@@ -41,7 +41,7 @@ func (m Mode) getBalanceHandler(w http.ResponseWriter, r *http.Request) {
4141
return
4242
}
4343

44-
key := &model.Key{}
44+
key := &sqldb.Key{}
4545
key.SetTablePrefix(form.EcosystemID)
4646
_, err := key.Get(nil, keyID)
4747
if err != nil {

packages/api/balance_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"net/url"
1212
"testing"
1313

14-
"github.com/IBAX-io/go-ibax/packages/model"
14+
"github.com/IBAX-io/go-ibax/packages/storage/sqldb"
1515
)
1616

1717
func TestBalance(t *testing.T) {
@@ -44,7 +44,7 @@ func TestAssignBalance(t *testing.T) {
4444
t.Error(err)
4545
return
4646
}
47-
var ret model.Response
47+
var ret sqldb.Response
4848
err := sendGet(`assignbalance/`+gAddress, nil, &ret)
4949
if err != nil {
5050
t.Error(err)

packages/api/block.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
"github.com/IBAX-io/go-ibax/packages/block"
1515
"github.com/IBAX-io/go-ibax/packages/consts"
1616
"github.com/IBAX-io/go-ibax/packages/converter"
17-
"github.com/IBAX-io/go-ibax/packages/model"
17+
"github.com/IBAX-io/go-ibax/packages/storage/sqldb"
1818

1919
"errors"
2020

@@ -29,7 +29,7 @@ type maxBlockResult struct {
2929
func getMaxBlockHandler(w http.ResponseWriter, r *http.Request) {
3030
logger := getLogger(r)
3131

32-
block := &model.Block{}
32+
block := &sqldb.BlockChain{}
3333
found, err := block.GetMaxBlock()
3434
if err != nil {
3535
logger.WithFields(log.Fields{"type": consts.DBError, "error": err}).Error("getting max block")
@@ -60,7 +60,7 @@ func getBlockInfoHandler(w http.ResponseWriter, r *http.Request) {
6060
params := mux.Vars(r)
6161

6262
blockID := converter.StrToInt64(params["id"])
63-
block := model.Block{}
63+
block := sqldb.BlockChain{}
6464
found, err := block.Get(blockID)
6565
if err != nil {
6666
logger.WithFields(log.Fields{"type": consts.DBError, "error": err}).Error("getting block")
@@ -117,7 +117,7 @@ func getBlocksTxInfoHandler(w http.ResponseWriter, r *http.Request) {
117117
}
118118
logger := getLogger(r)
119119

120-
blocks, err := model.GetBlockchain(form.BlockID, form.BlockID+form.Count, model.OrderASC)
120+
blocks, err := sqldb.GetBlockchain(form.BlockID, form.BlockID+form.Count, sqldb.OrderASC)
121121
if err != nil {
122122
logger.WithFields(log.Fields{"type": consts.DBError, "error": err}).Error("on getting blocks range")
123123
errorResponse(w, err)
@@ -157,7 +157,7 @@ func getBlocksTxInfoHandler(w http.ResponseWriter, r *http.Request) {
157157

158158
txInfoCollection = append(txInfoCollection, txInfo)
159159

160-
logger.WithFields(log.Fields{"block_id": blockModel.ID, "tx hash": txInfo.Hash, "contract_name": txInfo.ContractName, "key_id": txInfo.KeyID, "params": txInfoCollection}).Debug("Block Transactions Information")
160+
logger.WithFields(log.Fields{"block_id": blockModel.ID, "tx hash": txInfo.Hash, "contract_name": txInfo.ContractName, "key_id": txInfo.KeyID, "params": txInfoCollection}).Debug("BlockChain Transactions Information")
161161
}
162162

163163
result[blockModel.ID] = txInfoCollection
@@ -219,7 +219,7 @@ func getBlocksDetailedInfoHandler(w http.ResponseWriter, r *http.Request) {
219219

220220
logger := getLogger(r)
221221

222-
blocks, err := model.GetBlockchain(form.BlockID, form.BlockID+form.Count, model.OrderASC)
222+
blocks, err := sqldb.GetBlockchain(form.BlockID, form.BlockID+form.Count, sqldb.OrderASC)
223223
if err != nil {
224224
logger.WithFields(log.Fields{"type": consts.DBError, "error": err}).Error("on getting blocks range")
225225
errorResponse(w, err)
@@ -257,7 +257,7 @@ func getBlocksDetailedInfoHandler(w http.ResponseWriter, r *http.Request) {
257257

258258
txDetailedInfoCollection = append(txDetailedInfoCollection, txDetailedInfo)
259259

260-
logger.WithFields(log.Fields{"block_id": blockModel.ID, "tx hash": txDetailedInfo.Hash, "contract_name": txDetailedInfo.ContractName, "key_id": txDetailedInfo.KeyID, "time": txDetailedInfo.Time, "type": txDetailedInfo.Type, "params": txDetailedInfoCollection}).Debug("Block Transactions Information")
260+
logger.WithFields(log.Fields{"block_id": blockModel.ID, "tx hash": txDetailedInfo.Hash, "contract_name": txDetailedInfo.ContractName, "key_id": txDetailedInfo.KeyID, "time": txDetailedInfo.Time, "type": txDetailedInfo.Type, "params": txDetailedInfoCollection}).Debug("BlockChain Transactions Information")
261261
}
262262

263263
header := BlockHeaderInfo{

packages/api/content.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
"github.com/IBAX-io/go-ibax/packages/consts"
1919
"github.com/IBAX-io/go-ibax/packages/converter"
2020
"github.com/IBAX-io/go-ibax/packages/crypto"
21-
"github.com/IBAX-io/go-ibax/packages/model"
21+
"github.com/IBAX-io/go-ibax/packages/storage/sqldb"
2222
"github.com/IBAX-io/go-ibax/packages/template"
2323

2424
"github.com/gorilla/mux"
@@ -81,7 +81,7 @@ func initVars(r *http.Request) *map[string]string {
8181
vars["isMobile"] = "0"
8282
}
8383
if len(vars["ecosystem_id"]) != 0 {
84-
ecosystems := model.Ecosystem{}
84+
ecosystems := sqldb.Ecosystem{}
8585
if found, _ := ecosystems.Get(nil, converter.StrToInt64(vars["ecosystem_id"])); found {
8686
vars["ecosystem_name"] = ecosystems.Name
8787
}
@@ -109,13 +109,13 @@ func parseEcosystem(in string) (string, string) {
109109
return converter.Int64ToStr(ecosystem), name
110110
}
111111

112-
func pageValue(r *http.Request) (*model.Page, string, error) {
112+
func pageValue(r *http.Request) (*sqldb.Page, string, error) {
113113
params := mux.Vars(r)
114114
logger := getLogger(r)
115115
client := getClient(r)
116116

117117
var ecosystem string
118-
page := &model.Page{}
118+
page := &sqldb.Page{}
119119
name := params["name"]
120120
if strings.HasPrefix(name, `@`) {
121121
ecosystem, name = parseEcosystem(name)
@@ -151,7 +151,7 @@ func getPage(r *http.Request) (result *contentResult, err error) {
151151
logger := getLogger(r)
152152

153153
client := getClient(r)
154-
menu := &model.Menu{}
154+
menu := &sqldb.Menu{}
155155
menu.SetTablePrefix(client.Prefix())
156156
_, err = menu.Get(page.Menu)
157157
if err != nil {
@@ -246,7 +246,7 @@ func getMenuHandler(w http.ResponseWriter, r *http.Request) {
246246
logger := getLogger(r)
247247

248248
var ecosystem string
249-
menu := &model.Menu{}
249+
menu := &sqldb.Menu{}
250250
name := params["name"]
251251
if strings.HasPrefix(name, `@`) {
252252
ecosystem, name = parseEcosystem(name)

0 commit comments

Comments
 (0)