Files
hotime/example/main.go
T

87 lines
2.3 KiB
Go
Raw Normal View History

2017-08-17 02:37:00 +00:00
package main
import (
2021-05-22 04:52:03 +08:00
"../../hotime"
2022-02-24 06:26:36 +08:00
"strings"
2022-01-17 04:47:39 +08:00
//"../dri/aliyun"
"../dri/baidu"
2021-10-21 22:52:40 +08:00
"../dri/ddsms"
2022-01-17 04:47:39 +08:00
"./admin"
"./app"
2017-09-05 03:09:13 +00:00
"fmt"
2018-04-08 16:02:13 +00:00
"time"
2017-08-17 02:37:00 +00:00
)
func main() {
date, _ := time.Parse("2006-01-02 15:04", time.Now().Format("2006-01-02")+" 14:00")
fmt.Println(date, date.Unix())
2022-01-17 04:47:39 +08:00
baidu.DefaultBaiDuMap.Init("ZeT902EZvVgIoGVWEFK3osUm")
2021-10-27 00:27:24 +08:00
//fmt.Println("0123456"[1:7])
2021-06-04 10:04:37 +08:00
appIns := hotime.Init("config/config.json")
2022-03-03 21:23:57 +08:00
notNeedLogin := []string{"token", "login", "test", "auth", "upload", "info"} //不需要登录的操作
2021-05-29 02:57:03 +08:00
//RESTfull接口适配
2017-09-05 03:09:13 +00:00
appIns.SetConnectListener(func(context *hotime.Context) bool {
2022-02-28 08:53:38 +08:00
if len(context.RouterString) > 0 && context.RouterString[0] == "admin" {
2022-02-24 06:26:36 +08:00
return true
}
//判断是否需要登录,不需要登录则直接执行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 true
}
}
//微信操作无需登录
if context.RouterString[0] == "app" && context.RouterString[1] == "wechat" {
return true
}
//微信操作无需登录
if context.RouterString[0] == "app" && context.RouterString[1] == "sms" {
return true
}
//微信操作无需登录
if context.RouterString[0] == "app" && context.RouterString[1] == "tag" {
return true
}
//微信操作无需登录
if context.RouterString[0] == "app" && context.RouterString[1] == "analyse" {
return true
}
2022-03-03 21:23:57 +08:00
//微信操作无需登录
if context.RouterString[0] == "app" && context.RouterString[1] == "category" {
return true
}
2022-02-24 06:26:36 +08:00
//没有登录
if context.Session("user_id").Data == nil {
context.Display(2, "没有登录")
return false
}
}
2022-01-10 13:23:39 +08:00
//支撑权限设置
2021-12-27 20:40:16 +08:00
return true
2017-09-05 03:09:13 +00:00
})
2022-01-17 04:47:39 +08:00
appIns.Router["admin"]["company_inout"] = admin.CompanyInOutCtr
2022-01-22 16:12:02 +08:00
appIns.Router["admin"]["test"] = admin.TestCtr
2017-08-17 02:37:00 +00:00
//makeCode := code.MakeCode{}
//fmt.Println(common.ObjToStr(makeCode.Db2JSON("admin","test",appIns.Db)))
2021-10-21 22:52:40 +08:00
if ddsms.DefaultDDY.ApiKey == "" {
ddsms.DefaultDDY.Init(appIns.Config.GetString("smsKey"))
}
2017-09-05 03:09:13 +00:00
appIns.Run(hotime.Router{
2021-12-27 20:40:16 +08:00
"app": app.Project,
2017-09-05 03:09:13 +00:00
})
2017-08-17 02:37:00 +00:00
}