Compare commits

..

3 Commits

Author SHA1 Message Date
hoteas b940afa6b0 数据库操作优化 2022-08-15 05:59:06 +08:00
hoteas 8afd00ff86 修复登录bug 2022-08-11 10:41:35 +08:00
hoteas 8992fd6d3a 解决BUG 2022-08-11 10:18:48 +08:00
3 changed files with 110 additions and 20 deletions
+22 -10
View File
@@ -675,11 +675,15 @@ var TptProject = Proj{
where := Map{"name": name}
if that.MakeCodeRouter[hotimeName].TableColumns[fileConfig.GetString("table")]["phone"] != nil {
where["phone"] = name
where = Map{"AND": Map{"OR": where, "password": Md5(password)}}
where = Map{"OR": where, "password": Md5(password)}
} else {
where["password"] = Md5(password)
}
if len(where) > 1 {
where = Map{"AND": where}
}
user := that.Db.Get(fileConfig.GetString("table"), "*", where)
if user == nil {
@@ -776,16 +780,24 @@ var TptProject = Proj{
name = v2.GetString("table")
}
if v2["auth"] != nil {
newAuth := Slice{}
for k3, _ := range linkAuth.GetSlice(name) {
v3 := linkAuth.GetSlice(name).GetString(k3)
if strings.Contains(v2.GetString("auth"), v3) {
newAuth = append(newAuth, v3)
}
}
linkAuth[name] = newAuth
}
if linkAuth[name] == nil {
linkAuth[name] = v2["auth"]
} else {
newAuth := Slice{}
for k3, _ := range linkAuth.GetSlice(name) {
v3 := linkAuth.GetSlice(name).GetString(k3)
if strings.Contains(v2.GetString("auth"), v3) {
newAuth = append(newAuth, v3)
}
}
linkAuth[name] = newAuth
continue
}
}
}
}
+85 -7
View File
@@ -70,7 +70,21 @@ func (that *HotimeDBBuilder) Select(qu ...interface{}) []Map {
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)
}
@@ -101,19 +115,51 @@ func (that *HotimeDBBuilder) FullJoin(table, joinStr string) *HotimeDBBuilder {
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 {
that.join = Slice{}
}
if join == nil {
if data == nil {
return that
}
that.join = append(that.join, join)
that.join = append(that.join, data)
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 {
return that
}
@@ -129,7 +175,22 @@ func (that *HotimeDBBuilder) And(where Map) *HotimeDBBuilder {
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 {
return that
}
@@ -144,7 +205,24 @@ func (that *HotimeDBBuilder) Or(where Map) *HotimeDBBuilder {
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 {
return that
}
+3 -3
View File
@@ -23,9 +23,9 @@
],
"db": {
"mysql": {
"host": "192.168.6.253",
"name": "dgs-cms",
"password": "dasda8454456",
"host": "192.168.2.20",
"name": "gov_crawler",
"password": "fh22y8b882d",
"port": "3306",
"prefix": "",
"user": "root"