diff --git a/application.go b/application.go index 8bbfe03..77126cb 100644 --- a/application.go +++ b/application.go @@ -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: "/"}) } else { //跨域允许需要设置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 { sessionId = cookie.Value @@ -459,11 +459,11 @@ func Init(config string) Application { appIns.SetCache() appIns.MakeCode = &code.MakeCode{} codeConfig := appIns.Config.GetMap("codeConfig") - if codeConfig != nil { + if codeConfig != nil { 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) - }else{ + } else { appIns.MakeCode.Db2JSON(k, codeConfig.GetString(k), nil) } } diff --git a/cache/cache.go b/cache/cache.go index 3f5c737..39ed1e6 100644 --- a/cache/cache.go +++ b/cache/cache.go @@ -21,7 +21,7 @@ func (that *HoTimeCache) Session(key string, data ...interface{}) *Obj { //内存缓存有 if that.memoryCache != nil && that.memoryCache.SessionSet { reData = that.memoryCache.Cache(key, data...) - if reData != nil { + if reData.Data != nil { return reData } } @@ -29,9 +29,9 @@ func (that *HoTimeCache) Session(key string, data ...interface{}) *Obj { //redis缓存有 if that.redisCache != nil && that.redisCache.SessionSet { reData = that.redisCache.Cache(key, data...) - if reData != nil { + if reData.Data != nil { if that.memoryCache != nil && that.memoryCache.SessionSet { - that.memoryCache.Cache(key, reData) + that.memoryCache.Cache(key, reData.Data) } return reData } @@ -40,12 +40,12 @@ func (that *HoTimeCache) Session(key string, data ...interface{}) *Obj { //db缓存有 if that.dbCache != nil && that.dbCache.SessionSet { reData = that.dbCache.Cache(key, data...) - if reData != nil { + if reData.Data != nil { 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 { - that.redisCache.Cache(key, reData) + that.redisCache.Cache(key, reData.Data) } return reData @@ -76,7 +76,7 @@ func (that *HoTimeCache) Db(key string, data ...interface{}) *Obj { //内存缓存有 if that.memoryCache != nil && that.memoryCache.DbSet { reData = that.memoryCache.Cache(key, data...) - if reData != nil { + if reData.Data != nil { return reData } } @@ -84,9 +84,9 @@ func (that *HoTimeCache) Db(key string, data ...interface{}) *Obj { //redis缓存有 if that.redisCache != nil && that.redisCache.DbSet { reData = that.redisCache.Cache(key, data...) - if reData != nil { + if reData.Data != nil { if that.memoryCache != nil && that.memoryCache.DbSet { - that.memoryCache.Cache(key, reData) + that.memoryCache.Cache(key, reData.Data) } return reData } @@ -95,13 +95,13 @@ func (that *HoTimeCache) Db(key string, data ...interface{}) *Obj { //redis缓存有 if that.dbCache != nil && that.dbCache.DbSet { reData = that.dbCache.Cache(key, data...) - if reData != nil { + if reData.Data != nil { 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 { - that.redisCache.Cache(key, reData) + that.redisCache.Cache(key, reData.Data) } return reData @@ -140,10 +140,10 @@ func (that *HoTimeCache) Cache(key string, data ...interface{}) *Obj { //redis缓存有 if that.redisCache != nil { reData = that.redisCache.Cache(key, data...) - if reData != nil { + if reData.Data != nil { if that.memoryCache != nil { - that.memoryCache.Cache(key, reData) + that.memoryCache.Cache(key, reData.Data) } return reData } @@ -152,12 +152,12 @@ func (that *HoTimeCache) Cache(key string, data ...interface{}) *Obj { //redis缓存有 if that.dbCache != nil { reData = that.dbCache.Cache(key, data...) - if reData != nil { + if reData.Data != nil { if that.memoryCache != nil { - that.memoryCache.Cache(key, reData) + that.memoryCache.Cache(key, reData.Data) } if that.redisCache != nil { - that.redisCache.Cache(key, reData) + that.redisCache.Cache(key, reData.Data) } return reData } diff --git a/code/config.go b/code/config.go index 2fa98a9..d0088c8 100644 --- a/code/config.go +++ b/code/config.go @@ -67,7 +67,7 @@ var ColumnNameType = []ColumnShow{ {"latitude", 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}, {"pwd", false, true, false, false, "password", false}, {"info", false, true, true, false, "", false}, @@ -80,14 +80,15 @@ var ColumnNameType = []ColumnShow{ {"content", false, true, true, false, "", false}, {"address", false, true, true, false, "", false}, {"full_name", false, true, true, false, "", false}, - {"create_time", false, false, true, false, "", false}, - {"modify_time", false, false, true, false, "", false}, + {"create_time", false, false, true, false, "time", true}, + {"modify_time", true, false, true, false, "time", true}, {"image", 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}, {"file", false, true, true, false, "file", false}, {"age", 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}, } diff --git a/code/makecode.go b/code/makecode.go index 4e9b146..1ef615a 100644 --- a/code/makecode.go +++ b/code/makecode.go @@ -10,6 +10,7 @@ import ( "os" "path/filepath" "strings" + "time" ) 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 } @@ -143,27 +144,14 @@ func (that *MakeCode) Db2JSON(name string, path string, db *db.HoTimeDB) { "auth": []string{"add", "delete", "edit", "info"}, "columns": []Map{}, "search": []Map{ - //{"type": "tree", "name": "oid", "label": "组织", "table": "organization", "showName": "label", "children": "children"}, + {"type": "search", "name": "keyword", "label": "请输入关键词", "value": nil}, {"type": "search", "name": "daterange", "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 { 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) for _, info := range tableInfo { + if info.GetString("label") == "" { info["label"] = info.GetString("name") } @@ -191,10 +180,9 @@ func (that *MakeCode) Db2JSON(name string, path string, db *db.HoTimeDB) { if coloum == nil { //根据类型判断真实类型 - for k, v := range ColumnDataType { - if strings.Contains(info.GetString("type"), k) || strings.Contains(info.GetString("name"), k) { - info["type"] = v - break + for k, v1 := range ColumnDataType { + if strings.Contains(info.GetString("name"), k) || strings.Contains(info.GetString("type"), k) { + info["type"] = v1 } } @@ -211,30 +199,41 @@ func (that *MakeCode) Db2JSON(name string, path string, db *db.HoTimeDB) { coloum["label"] = info.GetString("label")[:indexNum] } - for _, v := range ColumnNameType { - if (v.Strict && coloum.GetString("name") == v.Name) || (!v.Strict && strings.Contains(coloum.GetString("name"), v.Name)) { + for _, ColumnName := range ColumnNameType { + 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 + //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 } - 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 } - if !coloum.GetBool("notUse") { - that.TableConfig.GetMap(v.GetString("name"))["columns"] = append(that.TableConfig.GetMap(v.GetString("name")).GetSlice("columns"), coloum) - } + //if !coloum.GetBool("notUse") { + that.TableConfig.GetMap(v.GetString("name"))["columns"] = append(that.TableConfig.GetMap(v.GetString("name")).GetSlice("columns"), coloum) + //} //如果是select类型需要设置options //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 { @@ -562,6 +567,9 @@ func (that *MakeCode) Edit(table string, req *http.Request) Map { data[v.GetString("name")] = reqValue } } + if v.GetString("name") == "modify_time" { + data[v.GetString("name")] = time.Now().Unix() + } } if len(data) == 0 { @@ -590,13 +598,15 @@ func (that *MakeCode) Search(table string, req *http.Request, db *db.HoTimeDB) ( if v.GetString("link") != "" && v.GetString("name") != "parent_id" { - reStr += v.GetString("link") + "." + - v.GetString("value") + " AS " + + reStr += table + "." + v.GetString("name") + "," + + v.GetString("link") + "." + v.GetString("value") + " AS " + v.GetString("link") + "_" + v.GetString("name") + "_" + v.GetString("value") + "," leftJoin["[>]"+v.GetString("link")] = table + "." + v.GetString("name") + "=" + v.GetString("link") + ".id" + //准备加入索引 + } else { 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" { - fmt.Println(req.Form["daterange"]) + //fmt.Println(req.Form["daterange"]) daterange[table+"."+v.GetString("name")+"[<>]"] = ObjToSlice(req.Form["daterange"]) } } diff --git a/code/template.go b/code/template.go index 6520e29..05a6de0 100644 --- a/code/template.go +++ b/code/template.go @@ -15,26 +15,48 @@ var Project = Proj{ {{tablesCtr}} "hotime":Ctr{ "login": func(this *Context) { - name:=this.Req.FormValue("name") - password:=this.Req.FormValue("password") - if name==""||password==""{ - this.Display(3,"参数不足") + name := this.Req.FormValue("name") + password := this.Req.FormValue("password") + if name == "" || password == "" { + this.Display(3, "参数不足") return } - user:=this.Db.Get("{{name}}","*",Map{"AND":Map{"name":name,"password":Md5(password)}}) - if user==nil{ - this.Display(5,"登录失败") + user := this.Db.Get("admin", "*", Map{"AND": Map{"name": name, "password": Md5(password)}}) + if user == nil { + this.Display(5, "登录失败") return } - this.Session("id",user.GetCeilInt("id")) - this.Session("name",name) - this.Display(0,"登录成功") + this.Session("admin_id", user.GetCeilInt("id")) + this.Session("admin_name", name) + this.Display(0, this.SessionId) }, "logout": func(this *Context) { - this.Session("id",nil) - this.Session("name",nil) - this.Display(0,"退出登录成功") + this.Session("admin_id", nil) + this.Session("admin_name", nil) + 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) + }, + }, } ` var CtrTpt = `package {{name}} diff --git a/example/admin/init.go b/example/admin/init.go index 3f9a220..892b5e7 100644 --- a/example/admin/init.go +++ b/example/admin/init.go @@ -5,7 +5,7 @@ import ( . "../../../hotime/common" ) -var ID = "3c5fc9732b8ddcb0a91b428976f2ce86" +var ID = "7d33119d7fef7daa5b9be2e1c75e5392" // Project 管理端项目 var Project = Proj{ @@ -17,6 +17,7 @@ var Project = Proj{ "org": orgCtr, "role": roleCtr, "user": userCtr, + "hotime": Ctr{ "login": func(this *Context) { name := this.Req.FormValue("name") diff --git a/example/app/ctg_order_date.go b/example/app/ctg_order_date.go index b4feefa..331c4b7 100644 --- a/example/app/ctg_order_date.go +++ b/example/app/ctg_order_date.go @@ -3,7 +3,6 @@ package app import ( . "../../../hotime" . "../../../hotime/common" - "fmt" "time" ) @@ -19,8 +18,8 @@ var ctg_order_dateCtr = Ctr{ return } - todayPMTime, _ := time.Parse("2006-01-02 15:04", time.Now().Format("2006-01-02")+" 14:00") - todayAMTime, _ := time.Parse("2006-01-02 15:04", time.Now().Format("2006-01-02"+" 09:00")) + todayPMTime, _ := time.ParseInLocation("2006-01-02 15:04", time.Now().Format("2006-01-02")+" 14:00", time.Local) + todayAMTime, _ := time.ParseInLocation("2006-01-02 15:04", time.Now().Format("2006-01-02")+" 09:00", time.Local) 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))}}) - 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 { - fmt.Println("dasdasdasda") + //fmt.Println("dasdasdasda") dayPM = Map{"name": "14:00-16:00", "date": todayPMTime.Unix() + int64(24*60*60*(i+1)), "create_time": time.Now().Unix(), diff --git a/example/bzyy.exe b/example/bzyy.exe index 469ae05..31c4466 100644 Binary files a/example/bzyy.exe and b/example/bzyy.exe differ diff --git a/example/config/app.json b/example/config/app.json deleted file mode 100644 index 20ab320..0000000 --- a/example/config/app.json +++ /dev/null @@ -1,1232 +0,0 @@ -{ - "id": "3c5fc9732b8ddcb0a91b428976f2ce86", - "label": "HoTime管理平台", - "menus": [ - { - "icon": "el-icon-s-home", - "label": "平台首页", - "name": "HelloWorld" - }, - { - "icon": "el-icon-setting", - "label": "系统管理", - "menus": [ - { - "label": "人员管理", - "table": "admin" - }, - { - "label": "事项管理", - "table": "category" - }, - { - "label": "排号计划", - "table": "ctg_order_date" - }, - { - "label": "预约管理", - "table": "order" - }, - { - "label": "部门管理", - "table": "org" - }, - { - "label": "角色管理", - "table": "role" - }, - { - "label": "群众管理", - "table": "user" - } - ], - "name": "sys" - } - ], - "name": "admin", - "tables": { - "admin": { - "auth": [ - "add", - "delete", - "edit", - "info" - ], - "columns": [ - { - "add": false, - "edit": false, - "label": "ID", - "name": "id", - "sortable": true, - "type": "number" - }, - { - "label": "名称", - "name": "name", - "type": "text" - }, - { - "add": false, - "edit": false, - "label": "创建时间", - "list": false, - "name": "create_time", - "type": "time" - }, - { - "add": false, - "edit": false, - "label": "变更时间", - "list": false, - "name": "modify_time", - "type": "time" - }, - { - "label": "状态", - "list": false, - "must": true, - "name": "state", - "options": [ - { - "name": "已启用", - "value": "0" - }, - { - "name": "未启用", - "value": "1" - }, - { - "name": "异常", - "value": "2" - } - ], - "type": "select" - }, - { - "info": false, - "label": "密码", - "list": false, - "name": "password", - "type": "password" - }, - { - "label": "头像", - "list": false, - "name": "avatar_img", - "type": "image" - }, - { - "label": "管理分区", - "link": "category", - "name": "category_id", - "sortable": true, - "type": "number", - "value": "name" - }, - { - "label": "角色", - "link": "role", - "name": "role_id", - "sortable": true, - "type": "number", - "value": "name" - } - ], - "label": "人员管理", - "search": [ - { - "label": "请输入关键词", - "name": "keyword", - "type": "search", - "value": null - }, - { - "label": "时间段", - "name": "daterange", - "type": "search", - "value": null - }, - { - "label": "排序", - "name": "sort", - "type": "search", - "value": null - }, - { - "label": "状态", - "list": false, - "must": true, - "name": "state", - "options": [ - { - "name": "已启用", - "value": "0" - }, - { - "name": "未启用", - "value": "1" - }, - { - "name": "异常", - "value": "2" - }, - { - "name": "全部", - "value": null - } - ], - "type": "select", - "value": null - }, - { - "label": "管理分区", - "link": "category", - "name": "category_id", - "type": "tree", - "value": "name" - } - ], - "table": "admin" - }, - "category": { - "auth": [ - "add", - "delete", - "edit", - "info" - ], - "columns": [ - { - "add": false, - "edit": false, - "label": "ID", - "name": "id", - "sortable": true, - "type": "number" - }, - { - "label": "名称", - "name": "name", - "type": "text" - }, - { - "label": "排序 序号越大越排前面", - "list": false, - "name": "sort", - "sortable": true, - "type": "number" - }, - { - "label": "专区id", - "link": "category", - "name": "parent_id", - "sortable": true, - "type": "number", - "value": "name" - }, - { - "label": "创建人员", - "link": "admin", - "name": "admin_id", - "sortable": true, - "type": "number", - "value": "name" - }, - { - "add": false, - "edit": false, - "label": "创建时间", - "list": false, - "name": "create_time", - "type": "time" - }, - { - "add": false, - "edit": false, - "label": "变更时间", - "list": false, - "name": "modify_time", - "sortable": true, - "type": "number" - }, - { - "label": "状态", - "list": false, - "must": true, - "name": "state", - "options": [ - { - "name": "已启用", - "value": "0" - }, - { - "name": "未启用", - "value": "1" - }, - { - "name": "异常", - "value": "2" - } - ], - "type": "select" - }, - { - "label": "周一上午", - "name": "am1", - "sortable": true, - "type": "number" - }, - { - "label": "周二上午", - "name": "am2", - "sortable": true, - "type": "number" - }, - { - "label": "周三上午", - "name": "am3", - "sortable": true, - "type": "number" - }, - { - "label": "周四上午", - "name": "am4", - "sortable": true, - "type": "number" - }, - { - "label": "周五上午", - "name": "am5", - "sortable": true, - "type": "number" - }, - { - "label": "周一下午", - "name": "pm1", - "sortable": true, - "type": "number" - }, - { - "label": "周二下午", - "name": "pm2", - "sortable": true, - "type": "number" - }, - { - "label": "周三下午", - "name": "pm3", - "sortable": true, - "type": "number" - }, - { - "label": "周四下午", - "name": "pm4", - "sortable": true, - "type": "number" - }, - { - "label": "周五下午", - "name": "pm5", - "sortable": true, - "type": "number" - }, - { - "label": "办理地址", - "list": false, - "name": "address", - "type": "text" - }, - { - "label": "叫号起始号", - "name": "startnum", - "sortable": true, - "type": "number" - }, - { - "label": "办理窗口", - "name": "window", - "type": "text" - }, - { - "label": "天府通办APP端", - "must": true, - "name": "tftbapp", - "options": [ - { - "name": "未启用", - "value": "0" - }, - { - "name": "已启用", - "value": "1" - } - ], - "sortable": true, - "type": "select" - }, - { - "label": "天府通办web端", - "must": true, - "name": "tftbweb", - "options": [ - { - "name": "未启用", - "value": "0" - }, - { - "name": "已启用", - "value": "1" - } - ], - "sortable": true, - "type": "select" - }, - { - "label": "图标", - "name": "icon", - "type": "text" - } - ], - "label": "事项管理", - "search": [ - { - "label": "请输入关键词", - "name": "keyword", - "type": "search", - "value": null - }, - { - "label": "时间段", - "name": "daterange", - "type": "search", - "value": null - }, - { - "label": "排序", - "name": "sort", - "type": "search", - "value": null - }, - { - "label": "天府通办APP端", - "must": true, - "name": "tftbapp", - "options": [ - { - "name": "未启用", - "value": "0" - }, - { - "name": "已启用", - "value": "1" - }, - { - "name": "全部", - "value": null - } - ], - "sortable": true, - "type": "select", - "value": null - }, - { - "label": "天府通办web端", - "must": true, - "name": "tftbweb", - "options": [ - { - "name": "未启用", - "value": "0" - }, - { - "name": "已启用", - "value": "1" - }, - { - "name": "全部", - "value": null - } - ], - "sortable": true, - "type": "select", - "value": null - }, - { - "label": "状态", - "list": false, - "must": true, - "name": "state", - "options": [ - { - "name": "已启用", - "value": "0" - }, - { - "name": "未启用", - "value": "1" - }, - { - "name": "异常", - "value": "2" - }, - { - "name": "全部", - "value": null - } - ], - "type": "select", - "value": null - }, - { - "label": "专区id", - "link": "category", - "name": "parent_id", - "type": "tree", - "value": "name" - } - ], - "table": "category" - }, - "ctg_order_date": { - "auth": [ - "add", - "delete", - "edit", - "info" - ], - "columns": [ - { - "add": false, - "edit": false, - "label": "ID", - "name": "id", - "sortable": true, - "type": "number" - }, - { - "label": "名称", - "name": "name", - "type": "text" - }, - { - "add": false, - "edit": false, - "label": "创建时间", - "list": false, - "name": "create_time", - "sortable": true, - "type": "number" - }, - { - "add": false, - "edit": false, - "label": "变更时间", - "list": false, - "name": "modify_time", - "sortable": true, - "type": "number" - }, - { - "label": "状态", - "list": false, - "must": true, - "name": "state", - "options": [ - { - "name": "已启用", - "value": "0" - }, - { - "name": "未启用", - "value": "1" - }, - { - "name": "异常", - "value": "2" - } - ], - "type": "select" - }, - { - "label": "预约日期", - "name": "date", - "type": "time" - }, - { - "label": "排号起始数", - "name": "start_sn", - "sortable": true, - "type": "number" - }, - { - "label": "排号结束号", - "name": "max_sn", - "sortable": true, - "type": "number" - }, - { - "label": "当前排号", - "name": "now_sn", - "sortable": true, - "type": "number" - }, - { - "label": "类别", - "link": "category", - "name": "category_id", - "sortable": true, - "type": "number", - "value": "name" - } - ], - "label": "排号计划", - "search": [ - { - "label": "请输入关键词", - "name": "keyword", - "type": "search", - "value": null - }, - { - "label": "时间段", - "name": "daterange", - "type": "search", - "value": null - }, - { - "label": "排序", - "name": "sort", - "type": "search", - "value": null - }, - { - "label": "状态", - "list": false, - "must": true, - "name": "state", - "options": [ - { - "name": "已启用", - "value": "0" - }, - { - "name": "未启用", - "value": "1" - }, - { - "name": "异常", - "value": "2" - }, - { - "name": "全部", - "value": null - } - ], - "type": "select", - "value": null - }, - { - "label": "类别", - "link": "category", - "name": "category_id", - "type": "tree", - "value": "name" - } - ], - "table": "ctg_order_date" - }, - "order": { - "auth": [ - "add", - "delete", - "edit", - "info" - ], - "columns": [ - { - "add": false, - "edit": false, - "label": "ID", - "name": "id", - "sortable": true, - "type": "number" - }, - { - "label": "名称", - "name": "name", - "type": "text" - }, - { - "add": false, - "edit": false, - "label": "创建时间", - "list": false, - "name": "create_time", - "type": "time" - }, - { - "add": false, - "edit": false, - "label": "变更时间", - "list": false, - "name": "modify_time", - "sortable": true, - "type": "number" - }, - { - "label": "状态", - "list": false, - "must": true, - "name": "state", - "options": [ - { - "name": "已启用", - "value": "0" - }, - { - "name": "未启用", - "value": "1" - }, - { - "name": "异常", - "value": "2" - } - ], - "type": "select" - }, - { - "label": "预约用户", - "link": "user", - "name": "user_id", - "sortable": true, - "type": "number", - "value": "name" - }, - { - "label": "预约日期", - "name": "date", - "type": "time" - }, - { - "label": "排号", - "name": "sn", - "sortable": true, - "type": "number" - }, - { - "label": "预约分类", - "link": "category", - "name": "category_id", - "sortable": true, - "type": "number", - "value": "name" - }, - { - "label": "预约状态", - "must": true, - "name": "status", - "options": [ - { - "name": "待分配", - "value": "0" - }, - { - "name": "待办结", - "value": "1" - }, - { - "name": "已办结", - "value": "2" - }, - { - "name": "已逾期", - "value": "3" - }, - { - "name": "异常", - "value": "4" - } - ], - "type": "select" - }, - { - "label": "办事员", - "link": "admin", - "name": "admin_id", - "sortable": true, - "type": "number", - "value": "name" - } - ], - "label": "预约管理", - "search": [ - { - "label": "请输入关键词", - "name": "keyword", - "type": "search", - "value": null - }, - { - "label": "时间段", - "name": "daterange", - "type": "search", - "value": null - }, - { - "label": "排序", - "name": "sort", - "type": "search", - "value": null - }, - { - "label": "预约状态", - "must": true, - "name": "status", - "options": [ - { - "name": "待分配", - "value": "0" - }, - { - "name": "待办结", - "value": "1" - }, - { - "name": "已办结", - "value": "2" - }, - { - "name": "已逾期", - "value": "3" - }, - { - "name": "异常", - "value": "4" - }, - { - "name": "全部", - "value": null - } - ], - "type": "select", - "value": null - }, - { - "label": "状态", - "list": false, - "must": true, - "name": "state", - "options": [ - { - "name": "已启用", - "value": "0" - }, - { - "name": "未启用", - "value": "1" - }, - { - "name": "异常", - "value": "2" - }, - { - "name": "全部", - "value": null - } - ], - "type": "select", - "value": null - }, - { - "label": "预约分类", - "link": "category", - "name": "category_id", - "type": "tree", - "value": "name" - } - ], - "table": "order" - }, - "org": { - "auth": [ - "add", - "delete", - "edit", - "info" - ], - "columns": [ - { - "add": false, - "edit": false, - "label": "ID", - "name": "id", - "sortable": true, - "type": "number" - }, - { - "label": "编号", - "name": "sn", - "type": "text" - }, - { - "label": "组织名称", - "name": "name", - "type": "text" - }, - { - "label": "上级组织", - "link": "org", - "name": "parent_id", - "sortable": true, - "type": "number", - "value": "name" - }, - { - "label": "状态", - "list": false, - "must": true, - "name": "state", - "options": [ - { - "name": "启用", - "value": "0" - }, - { - "name": "未启用", - "value": "1" - }, - { - "name": "异常", - "value": "2" - } - ], - "type": "select" - }, - { - "add": false, - "edit": false, - "label": "注册时间", - "list": false, - "name": "create_time", - "type": "time" - }, - { - "add": false, - "edit": false, - "label": "变更时间", - "list": false, - "name": "modify_time", - "type": "time" - }, - { - "label": "创建用户", - "link": "admin", - "name": "admin_id", - "sortable": true, - "type": "number", - "value": "name" - } - ], - "label": "部门管理", - "search": [ - { - "label": "请输入关键词", - "name": "keyword", - "type": "search", - "value": null - }, - { - "label": "时间段", - "name": "daterange", - "type": "search", - "value": null - }, - { - "label": "排序", - "name": "sort", - "type": "search", - "value": null - }, - { - "label": "状态", - "list": false, - "must": true, - "name": "state", - "options": [ - { - "name": "启用", - "value": "0" - }, - { - "name": "未启用", - "value": "1" - }, - { - "name": "异常", - "value": "2" - }, - { - "name": "全部", - "value": null - } - ], - "type": "select", - "value": null - }, - { - "label": "上级组织", - "link": "org", - "name": "parent_id", - "type": "tree", - "value": "name" - } - ], - "table": "org" - }, - "role": { - "auth": [ - "add", - "delete", - "edit", - "info" - ], - "columns": [ - { - "add": false, - "edit": false, - "label": "ID", - "name": "id", - "sortable": true, - "type": "number" - }, - { - "label": "名称", - "name": "name", - "type": "text" - }, - { - "add": false, - "edit": false, - "label": "创建时间", - "list": false, - "name": "create_time", - "type": "time" - }, - { - "add": false, - "edit": false, - "label": "变更时间", - "list": false, - "name": "modify_time", - "sortable": true, - "type": "number" - }, - { - "label": "状态", - "list": false, - "must": true, - "name": "state", - "options": [ - { - "name": "已启用", - "value": "0" - }, - { - "name": "未启用", - "value": "1" - }, - { - "name": "异常", - "value": "2" - } - ], - "type": "select" - }, - { - "label": "规则", - "name": "rule", - "type": "text" - } - ], - "label": "角色管理", - "search": [ - { - "label": "请输入关键词", - "name": "keyword", - "type": "search", - "value": null - }, - { - "label": "时间段", - "name": "daterange", - "type": "search", - "value": null - }, - { - "label": "排序", - "name": "sort", - "type": "search", - "value": null - }, - { - "label": "状态", - "list": false, - "must": true, - "name": "state", - "options": [ - { - "name": "已启用", - "value": "0" - }, - { - "name": "未启用", - "value": "1" - }, - { - "name": "异常", - "value": "2" - }, - { - "name": "全部", - "value": null - } - ], - "type": "select", - "value": null - } - ], - "table": "role" - }, - "user": { - "auth": [ - "add", - "delete", - "edit", - "info" - ], - "columns": [ - { - "add": false, - "edit": false, - "label": "ID", - "name": "id", - "sortable": true, - "type": "number" - }, - { - "label": "编号", - "name": "sn", - "type": "text" - }, - { - "label": "用户姓名", - "name": "name", - "type": "text" - }, - { - "label": "手机号码", - "name": "phone", - "type": "text" - }, - { - "label": "邮箱", - "list": false, - "name": "idcard", - "type": "text" - }, - { - "label": "状态", - "list": false, - "must": true, - "name": "state", - "options": [ - { - "name": "正常", - "value": "0" - }, - { - "name": "异常", - "value": "1" - }, - { - "name": "隐藏", - "value": "2" - } - ], - "type": "select" - }, - { - "label": "头像", - "name": "avatar", - "type": "text" - }, - { - "add": false, - "edit": false, - "label": "创建时间", - "list": false, - "name": "create_time", - "type": "time" - }, - { - "add": false, - "edit": false, - "label": "变更时间", - "list": false, - "name": "modify_time", - "sortable": true, - "type": "number" - } - ], - "label": "群众管理", - "search": [ - { - "label": "请输入关键词", - "name": "keyword", - "type": "search", - "value": null - }, - { - "label": "时间段", - "name": "daterange", - "type": "search", - "value": null - }, - { - "label": "排序", - "name": "sort", - "type": "search", - "value": null - }, - { - "label": "状态", - "list": false, - "must": true, - "name": "state", - "options": [ - { - "name": "正常", - "value": "0" - }, - { - "name": "异常", - "value": "1" - }, - { - "name": "隐藏", - "value": "2" - }, - { - "name": "全部", - "value": null - } - ], - "type": "select", - "value": null - } - ], - "table": "user" - } - } -} \ No newline at end of file diff --git a/example/config/config.json b/example/config/config.json index 4d0f51d..638c8e4 100644 --- a/example/config/config.json +++ b/example/config/config.json @@ -42,7 +42,7 @@ "4": "数据处理异常", "5": "数据结果异常" }, - "mode": 0, + "mode": 2, "port": "80", "sessionName": "HOTIME", "tpt": "tpt" diff --git a/example/main.go b/example/main.go index 2169a77..7177442 100644 --- a/example/main.go +++ b/example/main.go @@ -13,15 +13,19 @@ import ( ) 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") //RESTfull接口适配 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" { return true } + if context.RouterString[1] == "hotime" && context.RouterString[2] == "logout" { + return true + } if context.Session("admin_id").Data == nil { context.Display(2, "你还没有登录")