forked from golang/hotime
接入RESTfull风格接口
This commit is contained in:
parent
c46fdd8985
commit
465ea889a2
@ -180,7 +180,10 @@ func (that *Application) SetCache() {
|
||||
cacheIns := HoTimeCache{}
|
||||
cacheIns.Init(that.Config.GetMap("cache"), HoTimeDBInterface(&that.Db), &that.Error)
|
||||
that.HoTimeCache = &cacheIns
|
||||
//debug模式开启的时候关闭数据库缓存,防止调试出问题
|
||||
if that.Config.GetInt("debug") == 0 {
|
||||
that.Db.HoTimeCache = &cacheIns
|
||||
}
|
||||
}
|
||||
|
||||
// SetConfig 设置配置文件路径全路径或者相对路径
|
||||
|
4
db/db.go
4
db/db.go
@ -142,7 +142,7 @@ func (that *HoTimeDB) Row(resl *sql.Rows) []Map {
|
||||
if a[j] != nil && reflect.ValueOf(a[j]).Type().String() == "[]uint8" {
|
||||
lis[strs[j]] = string(a[j].([]byte))
|
||||
} else {
|
||||
lis[strs[j]] = a[j]
|
||||
lis[strs[j]] = a[j] //取实际类型
|
||||
}
|
||||
|
||||
}
|
||||
@ -472,7 +472,7 @@ func (that *HoTimeDB) Select(table string, qu ...interface{}) []Map {
|
||||
//如果缓存有则从缓存取
|
||||
cacheData := that.HoTimeCache.Db(table + ":" + md5)
|
||||
|
||||
if cacheData.Data != nil {
|
||||
if cacheData != nil && cacheData.Data != nil {
|
||||
return cacheData.ToMapArray()
|
||||
}
|
||||
}
|
||||
|
@ -2,11 +2,16 @@ package admin
|
||||
|
||||
import (
|
||||
. "../../../hotime"
|
||||
. "../../../hotime/common"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
var UserCtr = Ctr{
|
||||
"info": func(this *Context) {
|
||||
user := this.Db.Get(this.RouterString[1], "*", Map{"uid": this.RouterString[2]})
|
||||
|
||||
fmt.Println(user.Get("utime"), user.GetFloat64("utime"), user.GetInt("utime"))
|
||||
this.Display(0, user)
|
||||
},
|
||||
"add": func(this *Context) {
|
||||
|
||||
@ -18,6 +23,8 @@ var UserCtr = Ctr{
|
||||
|
||||
},
|
||||
"search": func(this *Context) {
|
||||
|
||||
user := this.Db.Select(this.RouterString[1], "*")
|
||||
fmt.Println(user)
|
||||
this.Display(0, user)
|
||||
},
|
||||
}
|
||||
|
2
var.go
2
var.go
@ -41,7 +41,7 @@ var ConfigNote = Map{
|
||||
"logFile": "无默认,非必须,如果需要存储日志文件时使用,保存格式为:a/b/c/20060102150405.txt,将生成:a/b/c/年月日时分秒.txt,按需设置",
|
||||
"webConnectLogShow": "默认true,非必须,访问日志如果需要web访问链接、访问ip、访问时间打印,false为关闭true开启此功能",
|
||||
"webConnectLogFile": "无默认,非必须,webConnectLogShow开启之后才能使用,如果需要存储日志文件时使用,保存格式为:a/b/c/20060102150405.txt,将生成:a/b/c/年月日时分秒.txt,按需设置",
|
||||
"debug": "默认1,必须,0关闭,其他开启,0用于生产环境;其他值用于开发测试,会显示更多内容并能够辅助研发,自动生成配置文件、代码等功能,web无缓存", //debug 0关闭1开启
|
||||
"debug": "默认1,必须,0关闭,其他开启,0用于生产环境;其他值用于开发测试,会显示更多内容并能够辅助研发,自动生成配置文件、代码等功能,web无缓存,数据库不启用缓存", //debug 0关闭1开启
|
||||
"db": Map{
|
||||
"注释": "配置即启用,非必须,默认使用sqlite数据库",
|
||||
"mysql": Map{
|
||||
|
Loading…
Reference in New Issue
Block a user