Skip to content

Commit b9cda22

Browse files
committed
export api db vars/types
1 parent 64107d4 commit b9cda22

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

api/db.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import (
66
"github.com/eja/tibula/db"
77
)
88

9-
type dbTypeLink = db.TypeLink
10-
type dbTypeModule = db.TypeModule
11-
type dbTypeSession = db.TypeSession
9+
type TypeDbLink = db.TypeLink
10+
type TypeDbModule = db.TypeModule
11+
type TypeDbSession = db.TypeSession
1212

13-
var dbSession = db.Session
13+
var DbSession = db.Session

api/main.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ func Set() TypeApi {
1616
DefaultSearchOrder: "ejaLog DESC",
1717
Values: make(map[string]string),
1818
SearchOrder: make(map[string]string),
19-
Link: dbTypeLink{},
19+
Link: TypeDbLink{},
2020
}
2121
}
2222

2323
func Run(eja TypeApi, sessionSave bool) (result TypeApi, err error) {
2424
var user map[string]string
2525

26-
db := dbSession()
26+
db := DbSession()
2727

2828
//open db connection
2929
if err = db.Open(sys.Options.DbType, sys.Options.DbName, sys.Options.DbUser, sys.Options.DbPass, sys.Options.DbHost, sys.Options.DbPort); err != nil {
@@ -121,7 +121,7 @@ func Run(eja TypeApi, sessionSave bool) (result TypeApi, err error) {
121121
if eja.ModuleId == eja.Link.ModuleId && eja.Id == eja.Link.FieldId && eja.Id > 0 {
122122
db.SessionCleanLink(eja.Owner)
123123
db.SessionCleanSearch(eja.Owner)
124-
eja.Link = dbTypeLink{}
124+
eja.Link = TypeDbLink{}
125125
eja.Action = "edit"
126126
eja.Linking = false
127127
}

api/plugins.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ import (
66
"encoding/json"
77
)
88

9-
type TypePlugins map[string]func(TypeApi, dbTypeSession) TypeApi
9+
type TypePlugins map[string]func(TypeApi, TypeDbSession) TypeApi
1010

1111
var Plugins = TypePlugins{
12-
"ejaProfile": func(eja TypeApi, db dbTypeSession) TypeApi {
12+
"ejaProfile": func(eja TypeApi, db TypeDbSession) TypeApi {
1313
eja.Alert = nil
1414
if eja.Action == "run" {
1515
if eja.Values["passwordOld"] == "" || eja.Values["passwordNew"] == "" || eja.Values["passwordRepeat"] == "" {
@@ -31,13 +31,13 @@ var Plugins = TypePlugins{
3131
}
3232
return eja
3333
},
34-
"ejaImport": func(eja TypeApi, db dbTypeSession) TypeApi {
34+
"ejaImport": func(eja TypeApi, db TypeDbSession) TypeApi {
3535
if eja.Action == "run" {
3636
moduleName := eja.Values["moduleName"]
3737
moduleData := eja.Values["import"]
3838
dataImport := db.Number(eja.Values["dataImport"])
3939
if moduleData != "" {
40-
var module dbTypeModule
40+
var module TypeDbModule
4141
if err := json.Unmarshal([]byte(moduleData), &module); err != nil {
4242
alert(&eja.Alert, db.Translate("ejaImportJsonError", eja.Owner))
4343
} else {
@@ -61,7 +61,7 @@ var Plugins = TypePlugins{
6161
}
6262
return eja
6363
},
64-
"ejaExport": func(eja TypeApi, db dbTypeSession) TypeApi {
64+
"ejaExport": func(eja TypeApi, db TypeDbSession) TypeApi {
6565
if eja.Action == "run" {
6666
moduleId := db.Number(eja.Values["ejaModuleId"])
6767
dataExport := db.Number(eja.Values["dataExport"]) > 0

0 commit comments

Comments
 (0)