package main import ( "code.hoteas.com/golang/hotime" "code.hoteas.com/golang/hotime/dri/aliyun" "code.hoteas.com/golang/hotime/dri/baidu" "code.hoteas.com/golang/hotime/dri/tencent" "strings" "code.hoteas.com/golang/hotime/dri/ddsms" "fmt" "iedc-go/admin" "iedc-go/app" "time" ) func main() { date, _ := time.Parse("2006-01-02 15:04", time.Now().Format("2006-01-02")+" 14:00") fmt.Println(date, date.Unix()) //fmt.Println("0123456"[1:7]) appIns := hotime.Init("config/config.json") notNeedLogin := []string{"token", "login", "test", "auth", "upload", "info"} //不需要登录的操作 //RESTfull接口适配 appIns.SetConnectListener(func(context *hotime.Context) bool { if len(context.RouterString) > 0 && context.RouterString[0] == "admin" { return false } //判断是否需要登录,不需要登录则直接执行mtd if len(context.RouterString) == 3 && !strings.Contains(context.RouterString[2], ".") { if context.RouterString[0] == "app" && context.RouterString[1] == "user" { isNeedLogin := true for i := 0; i < len(notNeedLogin); i++ { if notNeedLogin[i] == context.RouterString[2] { isNeedLogin = false break } } if !isNeedLogin { return false } } //微信操作无需登录 if context.RouterString[0] == "app" && context.RouterString[1] == "wechat" { return false } //微信操作无需登录 if context.RouterString[0] == "app" && context.RouterString[1] == "sms" { return false } //微信操作无需登录 if context.RouterString[0] == "app" && context.RouterString[1] == "tag" { return false } //微信操作无需登录 if context.RouterString[0] == "app" && context.RouterString[1] == "analyse" { return false } //微信操作无需登录 if context.RouterString[0] == "app" && context.RouterString[1] == "category" { return false } //没有登录 if context.Session("user_id").Data == nil { context.Display(2, "没有登录") return true } } //支撑权限设置 return false }) appIns.Router["admin"]["company_inout"] = admin.CompanyInOutCtr appIns.Router["admin"]["test"] = admin.TestCtr //makeCode := code.MakeCode{} //fmt.Println(common.ObjToStr(makeCode.Db2JSON("admin","test",appIns.Db))) if ddsms.DDY.ApiKey == "" { ddsms.DDY.Init(appIns.Config.GetString("smsKey")) } tencent.Company.Init(appIns.Config.GetString("tencentSecretId"), appIns.Config.GetString("tencentSecretKey")) aliyun.Company.Init(appIns.Config.GetString("aliyunApiCode")) baidu.BaiDuMap.Init(appIns.Config.GetString("baiduAk")) appIns.Run(hotime.Router{ "app": app.Project, }) }