Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7a8b86ed12 | |||
| b940afa6b0 |
+2
-7
@@ -566,14 +566,9 @@ func Init(config string) *Application {
|
|||||||
codeMake["name"] = codeMake.GetString("table")
|
codeMake["name"] = codeMake.GetString("table")
|
||||||
}
|
}
|
||||||
|
|
||||||
if appIns.Config.GetInt("mode") > 0 {
|
appIns.MakeCodeRouter[codeMake.GetString("name")] = &code.MakeCode{Error: appIns.Error}
|
||||||
appIns.MakeCodeRouter[codeMake.GetString("name")] = &code.MakeCode{Error: appIns.Error}
|
appIns.MakeCodeRouter[codeMake.GetString("name")].Db2JSON(&appIns.Db, codeMake)
|
||||||
|
|
||||||
appIns.MakeCodeRouter[codeMake.GetString("name")].Db2JSON(&appIns.Db, codeMake)
|
|
||||||
} else {
|
|
||||||
appIns.MakeCodeRouter[codeMake.GetString("name")] = &code.MakeCode{Error: appIns.Error}
|
|
||||||
appIns.MakeCodeRouter[codeMake.GetString("name")].Db2JSON(nil, codeMake)
|
|
||||||
}
|
|
||||||
//接入动态代码层
|
//接入动态代码层
|
||||||
if appIns.Router == nil {
|
if appIns.Router == nil {
|
||||||
appIns.Router = Router{}
|
appIns.Router = Router{}
|
||||||
|
|||||||
+87
-8
@@ -13,6 +13,7 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type HoTimeDB struct {
|
type HoTimeDB struct {
|
||||||
@@ -70,7 +71,21 @@ func (that *HotimeDBBuilder) Select(qu ...interface{}) []Map {
|
|||||||
return that.HoTimeDB.Select(that.table, that.join, qu, that.where)
|
return that.HoTimeDB.Select(that.table, that.join, qu, that.where)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (that *HotimeDBBuilder) Update(data Map) int64 {
|
func (that *HotimeDBBuilder) Update(qu ...interface{}) int64 {
|
||||||
|
lth := len(qu)
|
||||||
|
if lth == 0 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
data := Map{}
|
||||||
|
if lth == 1 {
|
||||||
|
data = ObjToMap(qu[0])
|
||||||
|
}
|
||||||
|
if lth > 1 {
|
||||||
|
for k := 1; k < lth; k++ {
|
||||||
|
data[ObjToStr(k-1)] = qu[k]
|
||||||
|
k++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return that.HoTimeDB.Update(that.table, data, that.where)
|
return that.HoTimeDB.Update(that.table, data, that.where)
|
||||||
}
|
}
|
||||||
@@ -101,19 +116,51 @@ func (that *HotimeDBBuilder) FullJoin(table, joinStr string) *HotimeDBBuilder {
|
|||||||
return that
|
return that
|
||||||
}
|
}
|
||||||
|
|
||||||
func (that *HotimeDBBuilder) Join(join Map) *HotimeDBBuilder {
|
func (that *HotimeDBBuilder) Join(qu ...interface{}) *HotimeDBBuilder {
|
||||||
|
lth := len(qu)
|
||||||
|
if lth == 0 {
|
||||||
|
return that
|
||||||
|
}
|
||||||
|
data := Map{}
|
||||||
|
if lth == 1 {
|
||||||
|
data = ObjToMap(qu[0])
|
||||||
|
}
|
||||||
|
if lth > 1 {
|
||||||
|
for k := 1; k < lth; k++ {
|
||||||
|
data[ObjToStr(k-1)] = qu[k]
|
||||||
|
k++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if that.join == nil {
|
if that.join == nil {
|
||||||
that.join = Slice{}
|
that.join = Slice{}
|
||||||
}
|
}
|
||||||
if join == nil {
|
if data == nil {
|
||||||
return that
|
return that
|
||||||
}
|
}
|
||||||
|
|
||||||
that.join = append(that.join, join)
|
that.join = append(that.join, data)
|
||||||
return that
|
return that
|
||||||
}
|
}
|
||||||
|
|
||||||
func (that *HotimeDBBuilder) And(where Map) *HotimeDBBuilder {
|
func (that *HotimeDBBuilder) And(qu ...interface{}) *HotimeDBBuilder {
|
||||||
|
|
||||||
|
lth := len(qu)
|
||||||
|
if lth == 0 {
|
||||||
|
return that
|
||||||
|
}
|
||||||
|
var where Map
|
||||||
|
if lth == 1 {
|
||||||
|
where = ObjToMap(qu[0])
|
||||||
|
}
|
||||||
|
if lth > 1 {
|
||||||
|
where = Map{}
|
||||||
|
for k := 1; k < lth; k++ {
|
||||||
|
where[ObjToStr(k-1)] = qu[k]
|
||||||
|
k++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if where == nil {
|
if where == nil {
|
||||||
return that
|
return that
|
||||||
}
|
}
|
||||||
@@ -129,7 +176,22 @@ func (that *HotimeDBBuilder) And(where Map) *HotimeDBBuilder {
|
|||||||
return that
|
return that
|
||||||
}
|
}
|
||||||
|
|
||||||
func (that *HotimeDBBuilder) Or(where Map) *HotimeDBBuilder {
|
func (that *HotimeDBBuilder) Or(qu ...interface{}) *HotimeDBBuilder {
|
||||||
|
lth := len(qu)
|
||||||
|
if lth == 0 {
|
||||||
|
return that
|
||||||
|
}
|
||||||
|
var where Map
|
||||||
|
if lth == 1 {
|
||||||
|
where = ObjToMap(qu[0])
|
||||||
|
}
|
||||||
|
if lth > 1 {
|
||||||
|
where = Map{}
|
||||||
|
for k := 1; k < lth; k++ {
|
||||||
|
where[ObjToStr(k-1)] = qu[k]
|
||||||
|
k++
|
||||||
|
}
|
||||||
|
}
|
||||||
if where == nil {
|
if where == nil {
|
||||||
return that
|
return that
|
||||||
}
|
}
|
||||||
@@ -144,7 +206,24 @@ func (that *HotimeDBBuilder) Or(where Map) *HotimeDBBuilder {
|
|||||||
|
|
||||||
return that
|
return that
|
||||||
}
|
}
|
||||||
func (that *HotimeDBBuilder) Where(where Map) *HotimeDBBuilder {
|
func (that *HotimeDBBuilder) Where(qu ...interface{}) *HotimeDBBuilder {
|
||||||
|
|
||||||
|
lth := len(qu)
|
||||||
|
if lth == 0 {
|
||||||
|
return that
|
||||||
|
}
|
||||||
|
var where Map
|
||||||
|
if lth == 1 {
|
||||||
|
where = ObjToMap(qu[0])
|
||||||
|
}
|
||||||
|
if lth > 1 {
|
||||||
|
where = Map{}
|
||||||
|
for k := 1; k < lth; k++ {
|
||||||
|
where[ObjToStr(k-1)] = qu[k]
|
||||||
|
k++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if where == nil {
|
if where == nil {
|
||||||
return that
|
return that
|
||||||
}
|
}
|
||||||
@@ -236,7 +315,7 @@ func (that *HoTimeDB) InitDb(err ...*Error) *Error {
|
|||||||
e := that.SlaveDB.Ping()
|
e := that.SlaveDB.Ping()
|
||||||
that.LastErr.SetError(e)
|
that.LastErr.SetError(e)
|
||||||
}
|
}
|
||||||
|
that.DB.SetConnMaxLifetime(time.Second)
|
||||||
return that.LastErr
|
return that.LastErr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user