2022-10-30 15:44:05 +00:00
|
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
import (
|
2022-10-30 17:18:19 +00:00
|
|
|
|
"code.hoteas.com/golang/hotime"
|
|
|
|
|
"code.hoteas.com/golang/hotime/dri/aliyun"
|
|
|
|
|
"code.hoteas.com/golang/hotime/dri/tencent"
|
2022-10-30 15:44:05 +00:00
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
|
|
//"../dri/aliyun"
|
2022-10-30 17:18:19 +00:00
|
|
|
|
"code.hoteas.com/golang/hotime/dri/baidu"
|
|
|
|
|
"code.hoteas.com/golang/hotime/dri/ddsms"
|
2022-10-30 15:44:05 +00:00
|
|
|
|
"fmt"
|
2022-10-30 17:18:19 +00:00
|
|
|
|
"iedc-go/admin"
|
|
|
|
|
"iedc-go/app"
|
2022-10-30 15:44:05 +00:00
|
|
|
|
"time"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
|
date, _ := time.Parse("2006-01-02 15:04", time.Now().Format("2006-01-02")+" 14:00")
|
|
|
|
|
fmt.Println(date, date.Unix())
|
|
|
|
|
|
2022-10-30 17:18:19 +00:00
|
|
|
|
baidu.BaiDuMap.Init("ZeT902EZvVgIoGVWEFK3osUm")
|
2022-10-30 15:44:05 +00:00
|
|
|
|
//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" {
|
2022-10-30 17:18:19 +00:00
|
|
|
|
return false
|
2022-10-30 15:44:05 +00:00
|
|
|
|
}
|
|
|
|
|
//判断是否需要登录,不需要登录则直接执行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 {
|
2022-10-30 17:18:19 +00:00
|
|
|
|
return false
|
2022-10-30 15:44:05 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//微信操作无需登录
|
|
|
|
|
if context.RouterString[0] == "app" && context.RouterString[1] == "wechat" {
|
2022-10-30 17:18:19 +00:00
|
|
|
|
return false
|
2022-10-30 15:44:05 +00:00
|
|
|
|
}
|
|
|
|
|
//微信操作无需登录
|
|
|
|
|
if context.RouterString[0] == "app" && context.RouterString[1] == "sms" {
|
2022-10-30 17:18:19 +00:00
|
|
|
|
return false
|
2022-10-30 15:44:05 +00:00
|
|
|
|
}
|
|
|
|
|
//微信操作无需登录
|
|
|
|
|
if context.RouterString[0] == "app" && context.RouterString[1] == "tag" {
|
2022-10-30 17:18:19 +00:00
|
|
|
|
return false
|
2022-10-30 15:44:05 +00:00
|
|
|
|
}
|
|
|
|
|
//微信操作无需登录
|
|
|
|
|
if context.RouterString[0] == "app" && context.RouterString[1] == "analyse" {
|
2022-10-30 17:18:19 +00:00
|
|
|
|
return false
|
2022-10-30 15:44:05 +00:00
|
|
|
|
}
|
|
|
|
|
//微信操作无需登录
|
|
|
|
|
if context.RouterString[0] == "app" && context.RouterString[1] == "category" {
|
2022-10-30 17:18:19 +00:00
|
|
|
|
return false
|
2022-10-30 15:44:05 +00:00
|
|
|
|
}
|
|
|
|
|
//没有登录
|
|
|
|
|
if context.Session("user_id").Data == nil {
|
|
|
|
|
context.Display(2, "没有登录")
|
2022-10-30 17:18:19 +00:00
|
|
|
|
return true
|
2022-10-30 15:44:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
//支撑权限设置
|
2022-10-30 17:18:19 +00:00
|
|
|
|
return false
|
2022-10-30 15:44:05 +00:00
|
|
|
|
})
|
|
|
|
|
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)))
|
2022-10-30 17:18:19 +00:00
|
|
|
|
if ddsms.DDY.ApiKey == "" {
|
|
|
|
|
ddsms.DDY.Init(appIns.Config.GetString("smsKey"))
|
2022-10-30 15:44:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-10-30 17:18:19 +00:00
|
|
|
|
tencent.Company.Init("AKIDklZa1qBr3B0x1G643cg8B6UO5JZm2KX8o43G", "tdda7oro526h96dvicYkep1xsWFmHkt33xvqs2K")
|
|
|
|
|
aliyun.Company.Init("06c6a07e89dd45c88de040ee1489eef7")
|
2022-10-30 15:44:05 +00:00
|
|
|
|
appIns.Run(hotime.Router{
|
|
|
|
|
"app": app.Project,
|
|
|
|
|
})
|
|
|
|
|
}
|