开始新增代码生成配置2.0功能,配置文件格式规定完成
This commit is contained in:
parent
1a53f587e8
commit
30e275a27d
@ -303,7 +303,7 @@ func (that *Application) handler(w http.ResponseWriter, req *http.Request) {
|
|||||||
http.SetCookie(w, &http.Cookie{Name: that.Config.GetString("sessionName"), Value: sessionId, Path: "/"})
|
http.SetCookie(w, &http.Cookie{Name: that.Config.GetString("sessionName"), Value: sessionId, Path: "/"})
|
||||||
} else {
|
} else {
|
||||||
//跨域允许需要设置cookie的允许跨域https才有效果
|
//跨域允许需要设置cookie的允许跨域https才有效果
|
||||||
w.Header().Set("Set-Cookie", that.Config.GetString("sessionName")+"="+sessionId+"; SameSite=None; Secure")
|
w.Header().Set("Set-Cookie", that.Config.GetString("sessionName")+"="+sessionId+"; Path=/; SameSite=None; Secure")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sessionId = cookie.Value
|
sessionId = cookie.Value
|
||||||
@ -461,9 +461,9 @@ func Init(config string) Application {
|
|||||||
codeConfig := appIns.Config.GetMap("codeConfig")
|
codeConfig := appIns.Config.GetMap("codeConfig")
|
||||||
if codeConfig != nil {
|
if codeConfig != nil {
|
||||||
for k, _ := range codeConfig {
|
for k, _ := range codeConfig {
|
||||||
if appIns.Config.GetInt("mode") == 2{
|
if appIns.Config.GetInt("mode") == 2 {
|
||||||
appIns.MakeCode.Db2JSON(k, codeConfig.GetString(k), &appIns.Db)
|
appIns.MakeCode.Db2JSON(k, codeConfig.GetString(k), &appIns.Db)
|
||||||
}else{
|
} else {
|
||||||
appIns.MakeCode.Db2JSON(k, codeConfig.GetString(k), nil)
|
appIns.MakeCode.Db2JSON(k, codeConfig.GetString(k), nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
34
cache/cache.go
vendored
34
cache/cache.go
vendored
@ -21,7 +21,7 @@ func (that *HoTimeCache) Session(key string, data ...interface{}) *Obj {
|
|||||||
//内存缓存有
|
//内存缓存有
|
||||||
if that.memoryCache != nil && that.memoryCache.SessionSet {
|
if that.memoryCache != nil && that.memoryCache.SessionSet {
|
||||||
reData = that.memoryCache.Cache(key, data...)
|
reData = that.memoryCache.Cache(key, data...)
|
||||||
if reData != nil {
|
if reData.Data != nil {
|
||||||
return reData
|
return reData
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -29,9 +29,9 @@ func (that *HoTimeCache) Session(key string, data ...interface{}) *Obj {
|
|||||||
//redis缓存有
|
//redis缓存有
|
||||||
if that.redisCache != nil && that.redisCache.SessionSet {
|
if that.redisCache != nil && that.redisCache.SessionSet {
|
||||||
reData = that.redisCache.Cache(key, data...)
|
reData = that.redisCache.Cache(key, data...)
|
||||||
if reData != nil {
|
if reData.Data != nil {
|
||||||
if that.memoryCache != nil && that.memoryCache.SessionSet {
|
if that.memoryCache != nil && that.memoryCache.SessionSet {
|
||||||
that.memoryCache.Cache(key, reData)
|
that.memoryCache.Cache(key, reData.Data)
|
||||||
}
|
}
|
||||||
return reData
|
return reData
|
||||||
}
|
}
|
||||||
@ -40,12 +40,12 @@ func (that *HoTimeCache) Session(key string, data ...interface{}) *Obj {
|
|||||||
//db缓存有
|
//db缓存有
|
||||||
if that.dbCache != nil && that.dbCache.SessionSet {
|
if that.dbCache != nil && that.dbCache.SessionSet {
|
||||||
reData = that.dbCache.Cache(key, data...)
|
reData = that.dbCache.Cache(key, data...)
|
||||||
if reData != nil {
|
if reData.Data != nil {
|
||||||
if that.memoryCache != nil && that.memoryCache.SessionSet {
|
if that.memoryCache != nil && that.memoryCache.SessionSet {
|
||||||
that.memoryCache.Cache(key, reData)
|
that.memoryCache.Cache(key, reData.Data)
|
||||||
}
|
}
|
||||||
if that.redisCache != nil && that.redisCache.SessionSet {
|
if that.redisCache != nil && that.redisCache.SessionSet {
|
||||||
that.redisCache.Cache(key, reData)
|
that.redisCache.Cache(key, reData.Data)
|
||||||
}
|
}
|
||||||
|
|
||||||
return reData
|
return reData
|
||||||
@ -76,7 +76,7 @@ func (that *HoTimeCache) Db(key string, data ...interface{}) *Obj {
|
|||||||
//内存缓存有
|
//内存缓存有
|
||||||
if that.memoryCache != nil && that.memoryCache.DbSet {
|
if that.memoryCache != nil && that.memoryCache.DbSet {
|
||||||
reData = that.memoryCache.Cache(key, data...)
|
reData = that.memoryCache.Cache(key, data...)
|
||||||
if reData != nil {
|
if reData.Data != nil {
|
||||||
return reData
|
return reData
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -84,9 +84,9 @@ func (that *HoTimeCache) Db(key string, data ...interface{}) *Obj {
|
|||||||
//redis缓存有
|
//redis缓存有
|
||||||
if that.redisCache != nil && that.redisCache.DbSet {
|
if that.redisCache != nil && that.redisCache.DbSet {
|
||||||
reData = that.redisCache.Cache(key, data...)
|
reData = that.redisCache.Cache(key, data...)
|
||||||
if reData != nil {
|
if reData.Data != nil {
|
||||||
if that.memoryCache != nil && that.memoryCache.DbSet {
|
if that.memoryCache != nil && that.memoryCache.DbSet {
|
||||||
that.memoryCache.Cache(key, reData)
|
that.memoryCache.Cache(key, reData.Data)
|
||||||
}
|
}
|
||||||
return reData
|
return reData
|
||||||
}
|
}
|
||||||
@ -95,13 +95,13 @@ func (that *HoTimeCache) Db(key string, data ...interface{}) *Obj {
|
|||||||
//redis缓存有
|
//redis缓存有
|
||||||
if that.dbCache != nil && that.dbCache.DbSet {
|
if that.dbCache != nil && that.dbCache.DbSet {
|
||||||
reData = that.dbCache.Cache(key, data...)
|
reData = that.dbCache.Cache(key, data...)
|
||||||
if reData != nil {
|
if reData.Data != nil {
|
||||||
if that.memoryCache != nil && that.memoryCache.DbSet {
|
if that.memoryCache != nil && that.memoryCache.DbSet {
|
||||||
that.memoryCache.Cache(key, reData)
|
that.memoryCache.Cache(key, reData.Data)
|
||||||
}
|
}
|
||||||
|
|
||||||
if that.redisCache != nil && that.redisCache.DbSet {
|
if that.redisCache != nil && that.redisCache.DbSet {
|
||||||
that.redisCache.Cache(key, reData)
|
that.redisCache.Cache(key, reData.Data)
|
||||||
}
|
}
|
||||||
|
|
||||||
return reData
|
return reData
|
||||||
@ -140,10 +140,10 @@ func (that *HoTimeCache) Cache(key string, data ...interface{}) *Obj {
|
|||||||
//redis缓存有
|
//redis缓存有
|
||||||
if that.redisCache != nil {
|
if that.redisCache != nil {
|
||||||
reData = that.redisCache.Cache(key, data...)
|
reData = that.redisCache.Cache(key, data...)
|
||||||
if reData != nil {
|
if reData.Data != nil {
|
||||||
|
|
||||||
if that.memoryCache != nil {
|
if that.memoryCache != nil {
|
||||||
that.memoryCache.Cache(key, reData)
|
that.memoryCache.Cache(key, reData.Data)
|
||||||
}
|
}
|
||||||
return reData
|
return reData
|
||||||
}
|
}
|
||||||
@ -152,12 +152,12 @@ func (that *HoTimeCache) Cache(key string, data ...interface{}) *Obj {
|
|||||||
//redis缓存有
|
//redis缓存有
|
||||||
if that.dbCache != nil {
|
if that.dbCache != nil {
|
||||||
reData = that.dbCache.Cache(key, data...)
|
reData = that.dbCache.Cache(key, data...)
|
||||||
if reData != nil {
|
if reData.Data != nil {
|
||||||
if that.memoryCache != nil {
|
if that.memoryCache != nil {
|
||||||
that.memoryCache.Cache(key, reData)
|
that.memoryCache.Cache(key, reData.Data)
|
||||||
}
|
}
|
||||||
if that.redisCache != nil {
|
if that.redisCache != nil {
|
||||||
that.redisCache.Cache(key, reData)
|
that.redisCache.Cache(key, reData.Data)
|
||||||
}
|
}
|
||||||
return reData
|
return reData
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ var ColumnNameType = []ColumnShow{
|
|||||||
{"latitude", false, true, true, false, "", false},
|
{"latitude", false, true, true, false, "", false},
|
||||||
{"longitude", false, true, true, false, "", false},
|
{"longitude", false, true, true, false, "", false},
|
||||||
|
|
||||||
{"index", false, false, false, false, "", false},
|
{"index", false, false, false, false, "index", false},
|
||||||
{"password", false, true, false, false, "password", false},
|
{"password", false, true, false, false, "password", false},
|
||||||
{"pwd", false, true, false, false, "password", false},
|
{"pwd", false, true, false, false, "password", false},
|
||||||
{"info", false, true, true, false, "", false},
|
{"info", false, true, true, false, "", false},
|
||||||
@ -80,14 +80,15 @@ var ColumnNameType = []ColumnShow{
|
|||||||
{"content", false, true, true, false, "", false},
|
{"content", false, true, true, false, "", false},
|
||||||
{"address", false, true, true, false, "", false},
|
{"address", false, true, true, false, "", false},
|
||||||
{"full_name", false, true, true, false, "", false},
|
{"full_name", false, true, true, false, "", false},
|
||||||
{"create_time", false, false, true, false, "", false},
|
{"create_time", false, false, true, false, "time", true},
|
||||||
{"modify_time", false, false, true, false, "", false},
|
{"modify_time", true, false, true, false, "time", true},
|
||||||
{"image", false, true, true, false, "image", false},
|
{"image", false, true, true, false, "image", false},
|
||||||
{"img", false, true, true, false, "image", false},
|
{"img", false, true, true, false, "image", false},
|
||||||
|
{"icon", false, true, true, false, "image", false},
|
||||||
{"avatar", false, true, true, false, "image", false},
|
{"avatar", false, true, true, false, "image", false},
|
||||||
{"file", false, true, true, false, "file", false},
|
{"file", false, true, true, false, "file", false},
|
||||||
{"age", false, true, true, false, "", false},
|
{"age", false, true, true, false, "", false},
|
||||||
{"email", false, true, true, false, "", false},
|
{"email", false, true, true, false, "", false},
|
||||||
{"time", true, false, true, false, "", false},
|
{"time", true, false, true, false, "time", false},
|
||||||
{"level", false, false, true, false, "", false},
|
{"level", false, false, true, false, "", false},
|
||||||
}
|
}
|
||||||
|
102
code/makecode.go
102
code/makecode.go
@ -10,6 +10,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type MakeCode struct {
|
type MakeCode struct {
|
||||||
@ -112,7 +113,7 @@ func (that *MakeCode) Db2JSON(name string, path string, db *db.HoTimeDB) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if db==nil{
|
if db == nil {
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -143,27 +144,14 @@ func (that *MakeCode) Db2JSON(name string, path string, db *db.HoTimeDB) {
|
|||||||
"auth": []string{"add", "delete", "edit", "info"},
|
"auth": []string{"add", "delete", "edit", "info"},
|
||||||
"columns": []Map{},
|
"columns": []Map{},
|
||||||
"search": []Map{
|
"search": []Map{
|
||||||
//{"type": "tree", "name": "oid", "label": "组织", "table": "organization", "showName": "label", "children": "children"},
|
|
||||||
{"type": "search", "name": "keyword", "label": "请输入关键词", "value": nil},
|
{"type": "search", "name": "keyword", "label": "请输入关键词", "value": nil},
|
||||||
{"type": "search", "name": "daterange", "label": "时间段", "value": nil},
|
{"type": "search", "name": "daterange", "label": "时间段", "value": nil},
|
||||||
{"type": "search", "name": "sort", "label": "排序", "value": nil},
|
{"type": "search", "name": "sort", "label": "排序", "value": nil},
|
||||||
//{"type": "select", "name": "state", "label": "状态", "value": nil,
|
|
||||||
// "options": []Map{
|
|
||||||
// {"name": "正常", "value": 0},
|
|
||||||
// {"name": "异常", "value": 1},
|
|
||||||
// {"name": "全部", "value": nil},
|
|
||||||
// },
|
|
||||||
//},
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//else {
|
|
||||||
// if !(that.TableConfig.GetMap(v.GetString("name")).GetString("label") != "备注" &&
|
|
||||||
// v.GetString("label") == "备注") {
|
|
||||||
// that.TableConfig.GetMap(v.GetString("name"))["label"] = v.GetString("label")
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//}
|
|
||||||
//初始化
|
//初始化
|
||||||
if that.TableColumns[v.GetString("name")] == nil {
|
if that.TableColumns[v.GetString("name")] == nil {
|
||||||
that.TableColumns[v.GetString("name")] = make(map[string]Map)
|
that.TableColumns[v.GetString("name")] = make(map[string]Map)
|
||||||
@ -184,6 +172,7 @@ func (that *MakeCode) Db2JSON(name string, path string, db *db.HoTimeDB) {
|
|||||||
|
|
||||||
idSlice = append(idSlice, tableInfo)
|
idSlice = append(idSlice, tableInfo)
|
||||||
for _, info := range tableInfo {
|
for _, info := range tableInfo {
|
||||||
|
|
||||||
if info.GetString("label") == "" {
|
if info.GetString("label") == "" {
|
||||||
info["label"] = info.GetString("name")
|
info["label"] = info.GetString("name")
|
||||||
}
|
}
|
||||||
@ -191,10 +180,9 @@ func (that *MakeCode) Db2JSON(name string, path string, db *db.HoTimeDB) {
|
|||||||
|
|
||||||
if coloum == nil {
|
if coloum == nil {
|
||||||
//根据类型判断真实类型
|
//根据类型判断真实类型
|
||||||
for k, v := range ColumnDataType {
|
for k, v1 := range ColumnDataType {
|
||||||
if strings.Contains(info.GetString("type"), k) || strings.Contains(info.GetString("name"), k) {
|
if strings.Contains(info.GetString("name"), k) || strings.Contains(info.GetString("type"), k) {
|
||||||
info["type"] = v
|
info["type"] = v1
|
||||||
break
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -211,30 +199,41 @@ func (that *MakeCode) Db2JSON(name string, path string, db *db.HoTimeDB) {
|
|||||||
coloum["label"] = info.GetString("label")[:indexNum]
|
coloum["label"] = info.GetString("label")[:indexNum]
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, v := range ColumnNameType {
|
for _, ColumnName := range ColumnNameType {
|
||||||
if (v.Strict && coloum.GetString("name") == v.Name) || (!v.Strict && strings.Contains(coloum.GetString("name"), v.Name)) {
|
if (ColumnName.Strict && coloum.GetString("name") == ColumnName.Name) ||
|
||||||
|
(!ColumnName.Strict && strings.Contains(coloum.GetString("name"), ColumnName.Name)) {
|
||||||
//全部都不需要则不加入
|
//全部都不需要则不加入
|
||||||
if v.Edit == false && v.List == false && v.Info == false {
|
if ColumnName.Edit == false && ColumnName.List == false && ColumnName.Info == false {
|
||||||
coloum["notUse"] = true
|
coloum["notUse"] = true
|
||||||
|
//continue
|
||||||
|
}
|
||||||
|
coloum["info"] = ColumnName.Info
|
||||||
|
coloum["edit"] = ColumnName.Edit
|
||||||
|
coloum["add"] = ColumnName.Edit
|
||||||
|
coloum["list"] = ColumnName.List
|
||||||
|
coloum["must"] = ColumnName.Must
|
||||||
|
|
||||||
|
if ColumnName.Info {
|
||||||
|
delete(coloum, "info")
|
||||||
|
}
|
||||||
|
if ColumnName.Edit {
|
||||||
|
delete(coloum, "edit")
|
||||||
|
delete(coloum, "add")
|
||||||
|
}
|
||||||
|
if ColumnName.List {
|
||||||
|
delete(coloum, "list")
|
||||||
|
}
|
||||||
|
if ColumnName.Must {
|
||||||
|
delete(coloum, "must")
|
||||||
|
}
|
||||||
|
|
||||||
|
if ColumnName.Type != "" {
|
||||||
|
coloum["type"] = ColumnName.Type
|
||||||
|
}
|
||||||
|
if ColumnName.Strict && coloum.GetString("name") == ColumnName.Name {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if v.Info == false {
|
|
||||||
coloum["info"] = v.Info
|
|
||||||
}
|
|
||||||
if v.Edit == false {
|
|
||||||
coloum["edit"] = v.Edit
|
|
||||||
coloum["add"] = v.Edit
|
|
||||||
}
|
|
||||||
if v.List == false {
|
|
||||||
coloum["list"] = v.List
|
|
||||||
}
|
|
||||||
if v.Must == true {
|
|
||||||
coloum["must"] = v.Must
|
|
||||||
}
|
|
||||||
if v.Type != "" {
|
|
||||||
coloum["type"] = v.Type
|
|
||||||
}
|
|
||||||
break
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -243,9 +242,9 @@ func (that *MakeCode) Db2JSON(name string, path string, db *db.HoTimeDB) {
|
|||||||
coloum["sortable"] = true
|
coloum["sortable"] = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if !coloum.GetBool("notUse") {
|
//if !coloum.GetBool("notUse") {
|
||||||
that.TableConfig.GetMap(v.GetString("name"))["columns"] = append(that.TableConfig.GetMap(v.GetString("name")).GetSlice("columns"), coloum)
|
that.TableConfig.GetMap(v.GetString("name"))["columns"] = append(that.TableConfig.GetMap(v.GetString("name")).GetSlice("columns"), coloum)
|
||||||
}
|
//}
|
||||||
//如果是select类型需要设置options
|
//如果是select类型需要设置options
|
||||||
//if coloum.GetString("type") == "select" {
|
//if coloum.GetString("type") == "select" {
|
||||||
|
|
||||||
@ -535,7 +534,13 @@ func (that *MakeCode) Add(table string, req *http.Request) Map {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if v.GetString("name") == "create_time" {
|
||||||
|
data[v.GetString("name")] = time.Now().Unix()
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if v.GetString("name") == "modify_time" {
|
||||||
|
data[v.GetString("name")] = time.Now().Unix()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(data) == 0 {
|
if len(data) == 0 {
|
||||||
@ -562,6 +567,9 @@ func (that *MakeCode) Edit(table string, req *http.Request) Map {
|
|||||||
data[v.GetString("name")] = reqValue
|
data[v.GetString("name")] = reqValue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if v.GetString("name") == "modify_time" {
|
||||||
|
data[v.GetString("name")] = time.Now().Unix()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(data) == 0 {
|
if len(data) == 0 {
|
||||||
@ -590,13 +598,15 @@ func (that *MakeCode) Search(table string, req *http.Request, db *db.HoTimeDB) (
|
|||||||
if v.GetString("link") != "" &&
|
if v.GetString("link") != "" &&
|
||||||
v.GetString("name") != "parent_id" {
|
v.GetString("name") != "parent_id" {
|
||||||
|
|
||||||
reStr += v.GetString("link") + "." +
|
reStr += table + "." + v.GetString("name") + "," +
|
||||||
v.GetString("value") + " AS " +
|
v.GetString("link") + "." + v.GetString("value") + " AS " +
|
||||||
v.GetString("link") + "_" + v.GetString("name") + "_" + v.GetString("value") + ","
|
v.GetString("link") + "_" + v.GetString("name") + "_" + v.GetString("value") + ","
|
||||||
|
|
||||||
leftJoin["[>]"+v.GetString("link")] =
|
leftJoin["[>]"+v.GetString("link")] =
|
||||||
table + "." + v.GetString("name") + "=" +
|
table + "." + v.GetString("name") + "=" +
|
||||||
v.GetString("link") + ".id"
|
v.GetString("link") + ".id"
|
||||||
|
//准备加入索引
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
reStr += table + "." + v.GetString("name") + ","
|
reStr += table + "." + v.GetString("name") + ","
|
||||||
}
|
}
|
||||||
@ -647,7 +657,7 @@ func (that *MakeCode) Search(table string, req *http.Request, db *db.HoTimeDB) (
|
|||||||
}
|
}
|
||||||
//日期类型
|
//日期类型
|
||||||
if searchItemName == "daterange" && v.GetString("type") == "time" {
|
if searchItemName == "daterange" && v.GetString("type") == "time" {
|
||||||
fmt.Println(req.Form["daterange"])
|
//fmt.Println(req.Form["daterange"])
|
||||||
daterange[table+"."+v.GetString("name")+"[<>]"] = ObjToSlice(req.Form["daterange"])
|
daterange[table+"."+v.GetString("name")+"[<>]"] = ObjToSlice(req.Form["daterange"])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,25 +15,47 @@ var Project = Proj{
|
|||||||
{{tablesCtr}}
|
{{tablesCtr}}
|
||||||
"hotime":Ctr{
|
"hotime":Ctr{
|
||||||
"login": func(this *Context) {
|
"login": func(this *Context) {
|
||||||
name:=this.Req.FormValue("name")
|
name := this.Req.FormValue("name")
|
||||||
password:=this.Req.FormValue("password")
|
password := this.Req.FormValue("password")
|
||||||
if name==""||password==""{
|
if name == "" || password == "" {
|
||||||
this.Display(3,"参数不足")
|
this.Display(3, "参数不足")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
user:=this.Db.Get("{{name}}","*",Map{"AND":Map{"name":name,"password":Md5(password)}})
|
user := this.Db.Get("admin", "*", Map{"AND": Map{"name": name, "password": Md5(password)}})
|
||||||
if user==nil{
|
if user == nil {
|
||||||
this.Display(5,"登录失败")
|
this.Display(5, "登录失败")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.Session("id",user.GetCeilInt("id"))
|
this.Session("admin_id", user.GetCeilInt("id"))
|
||||||
this.Session("name",name)
|
this.Session("admin_name", name)
|
||||||
this.Display(0,"登录成功")
|
this.Display(0, this.SessionId)
|
||||||
},
|
},
|
||||||
"logout": func(this *Context) {
|
"logout": func(this *Context) {
|
||||||
this.Session("id",nil)
|
this.Session("admin_id", nil)
|
||||||
this.Session("name",nil)
|
this.Session("admin_name", nil)
|
||||||
this.Display(0,"退出登录成功")
|
this.Display(0, "退出登录成功")
|
||||||
|
},
|
||||||
|
"info": func(that *Context) {
|
||||||
|
re := that.Db.Get("admin", that.MakeCode.Info("admin"), Map{"id": that.Session("admin_id").ToCeilInt()})
|
||||||
|
|
||||||
|
if re == nil {
|
||||||
|
that.Display(4, "找不到对应信息")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for k, v := range re {
|
||||||
|
|
||||||
|
column := that.MakeCode.TableColumns["admin"][k]
|
||||||
|
if column == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if (column["list"] == nil || column.GetBool("list")) && column.GetString("link") != "" {
|
||||||
|
re[column.GetString("link")] = that.Db.Get(column.GetString("link"), column.GetString("value"), Map{"id": v})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
that.Display(0, re)
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
@ -5,7 +5,7 @@ import (
|
|||||||
. "../../../hotime/common"
|
. "../../../hotime/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
var ID = "3c5fc9732b8ddcb0a91b428976f2ce86"
|
var ID = "7d33119d7fef7daa5b9be2e1c75e5392"
|
||||||
|
|
||||||
// Project 管理端项目
|
// Project 管理端项目
|
||||||
var Project = Proj{
|
var Project = Proj{
|
||||||
@ -17,6 +17,7 @@ var Project = Proj{
|
|||||||
"org": orgCtr,
|
"org": orgCtr,
|
||||||
"role": roleCtr,
|
"role": roleCtr,
|
||||||
"user": userCtr,
|
"user": userCtr,
|
||||||
|
|
||||||
"hotime": Ctr{
|
"hotime": Ctr{
|
||||||
"login": func(this *Context) {
|
"login": func(this *Context) {
|
||||||
name := this.Req.FormValue("name")
|
name := this.Req.FormValue("name")
|
||||||
|
@ -3,7 +3,6 @@ package app
|
|||||||
import (
|
import (
|
||||||
. "../../../hotime"
|
. "../../../hotime"
|
||||||
. "../../../hotime/common"
|
. "../../../hotime/common"
|
||||||
"fmt"
|
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -19,8 +18,8 @@ var ctg_order_dateCtr = Ctr{
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
todayPMTime, _ := time.Parse("2006-01-02 15:04", time.Now().Format("2006-01-02")+" 14:00")
|
todayPMTime, _ := time.ParseInLocation("2006-01-02 15:04", time.Now().Format("2006-01-02")+" 14:00", time.Local)
|
||||||
todayAMTime, _ := time.Parse("2006-01-02 15:04", time.Now().Format("2006-01-02"+" 09:00"))
|
todayAMTime, _ := time.ParseInLocation("2006-01-02 15:04", time.Now().Format("2006-01-02")+" 09:00", time.Local)
|
||||||
|
|
||||||
weekDay := 1
|
weekDay := 1
|
||||||
|
|
||||||
@ -74,9 +73,9 @@ var ctg_order_dateCtr = Ctr{
|
|||||||
}
|
}
|
||||||
|
|
||||||
dayPM := that.Db.Get("ctg_order_date", "*", Map{"AND": Map{"category_id": category.GetCeilInt("id"), "date": todayPMTime.Unix() + int64(24*60*60*(i+1))}})
|
dayPM := that.Db.Get("ctg_order_date", "*", Map{"AND": Map{"category_id": category.GetCeilInt("id"), "date": todayPMTime.Unix() + int64(24*60*60*(i+1))}})
|
||||||
fmt.Println(that.Db.LastQuery, that.Db.LastData, dayPM, that.Db.LastErr)
|
//fmt.Println(that.Db.LastQuery, that.Db.LastData, dayPM, that.Db.LastErr)
|
||||||
if dayPM == nil {
|
if dayPM == nil {
|
||||||
fmt.Println("dasdasdasda")
|
//fmt.Println("dasdasdasda")
|
||||||
dayPM = Map{"name": "14:00-16:00",
|
dayPM = Map{"name": "14:00-16:00",
|
||||||
"date": todayPMTime.Unix() + int64(24*60*60*(i+1)),
|
"date": todayPMTime.Unix() + int64(24*60*60*(i+1)),
|
||||||
"create_time": time.Now().Unix(),
|
"create_time": time.Now().Unix(),
|
||||||
|
BIN
example/bzyy.exe
BIN
example/bzyy.exe
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@ -42,7 +42,7 @@
|
|||||||
"4": "数据处理异常",
|
"4": "数据处理异常",
|
||||||
"5": "数据结果异常"
|
"5": "数据结果异常"
|
||||||
},
|
},
|
||||||
"mode": 0,
|
"mode": 2,
|
||||||
"port": "80",
|
"port": "80",
|
||||||
"sessionName": "HOTIME",
|
"sessionName": "HOTIME",
|
||||||
"tpt": "tpt"
|
"tpt": "tpt"
|
||||||
|
@ -13,15 +13,19 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
fmt.Println(time.Now().Weekday().String())
|
date, _ := time.Parse("2006-01-02 15:04", time.Now().Format("2006-01-02")+" 14:00")
|
||||||
|
fmt.Println(date, date.Unix())
|
||||||
appIns := hotime.Init("config/config.json")
|
appIns := hotime.Init("config/config.json")
|
||||||
//RESTfull接口适配
|
//RESTfull接口适配
|
||||||
appIns.SetConnectListener(func(context *hotime.Context) bool {
|
appIns.SetConnectListener(func(context *hotime.Context) bool {
|
||||||
|
|
||||||
if len(context.RouterString)>1&& context.RouterString[0] == "admin" {
|
if len(context.RouterString) > 1 && context.RouterString[0] == "admin" {
|
||||||
if context.RouterString[1] == "hotime" && context.RouterString[2] == "login" {
|
if context.RouterString[1] == "hotime" && context.RouterString[2] == "login" {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
if context.RouterString[1] == "hotime" && context.RouterString[2] == "logout" {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
if context.Session("admin_id").Data == nil {
|
if context.Session("admin_id").Data == nil {
|
||||||
context.Display(2, "你还没有登录")
|
context.Display(2, "你还没有登录")
|
||||||
|
Loading…
Reference in New Issue
Block a user