iedc-go/main.go

90 lines
2.6 KiB
Go
Raw Normal View History

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"
2023-03-02 18:46:29 +00:00
"code.hoteas.com/golang/hotime/dri/baidu"
2022-10-30 17:18:19 +00:00
"code.hoteas.com/golang/hotime/dri/tencent"
2022-10-30 15:44:05 +00:00
"strings"
2022-10-30 17:18:19 +00:00
"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())
//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
}
2023-03-02 18:46:29 +00:00
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"))
2022-10-30 15:44:05 +00:00
appIns.Run(hotime.Router{
"app": app.Project,
})
}