2017-08-17 02:37:00 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2021-05-21 20:52:03 +00:00
|
|
|
"../../hotime"
|
2022-01-16 20:47:39 +00:00
|
|
|
"../common"
|
|
|
|
"io/ioutil"
|
|
|
|
|
|
|
|
//"../dri/aliyun"
|
|
|
|
"../dri/baidu"
|
2021-10-21 14:52:40 +00:00
|
|
|
"../dri/ddsms"
|
2022-01-16 20:47:39 +00:00
|
|
|
"./admin"
|
2021-08-28 05:05:12 +00:00
|
|
|
"./app"
|
2017-09-05 03:09:13 +00:00
|
|
|
"fmt"
|
2022-01-16 20:47:39 +00:00
|
|
|
"github.com/xuri/excelize"
|
|
|
|
"os"
|
2018-04-08 16:02:13 +00:00
|
|
|
"time"
|
2017-08-17 02:37:00 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2021-09-15 20:33:10 +00:00
|
|
|
date, _ := time.Parse("2006-01-02 15:04", time.Now().Format("2006-01-02")+" 14:00")
|
|
|
|
fmt.Println(date, date.Unix())
|
2022-01-16 20:47:39 +00:00
|
|
|
|
|
|
|
baidu.DefaultBaiDuMap.Init("ZeT902EZvVgIoGVWEFK3osUm")
|
2021-10-26 16:27:24 +00:00
|
|
|
//fmt.Println("0123456"[1:7])
|
2021-06-04 02:04:37 +00:00
|
|
|
appIns := hotime.Init("config/config.json")
|
2021-05-28 18:57:03 +00:00
|
|
|
//RESTfull接口适配
|
2017-09-05 03:09:13 +00:00
|
|
|
appIns.SetConnectListener(func(context *hotime.Context) bool {
|
2022-01-10 05:23:39 +00:00
|
|
|
//支撑权限设置
|
2021-12-27 12:40:16 +00:00
|
|
|
return true
|
2017-09-05 03:09:13 +00:00
|
|
|
})
|
2022-01-16 20:47:39 +00:00
|
|
|
appIns.Router["admin"]["company_inout"] = admin.CompanyInOutCtr
|
|
|
|
appIns.Router["admin"]["test"] = hotime.Ctr{
|
|
|
|
|
|
|
|
"test": func(this *hotime.Context) {
|
|
|
|
data := excel()
|
|
|
|
this.Display(0, data)
|
|
|
|
},
|
|
|
|
|
|
|
|
"api": func(this *hotime.Context) {
|
|
|
|
//curl -i --get --include 'http://api.81api.com/getCompanyBaseInfo/小米科技有限责任公司/' -H 'Authorization:APPCODE 你自己的AppCode'
|
|
|
|
//aliyun.DefaultCompany.Init("06c6a07e89dd45c88de040ee1489eef7")
|
|
|
|
//data,err:=aliyun.DefaultCompany.GetCompanyBaseInfo("小米科技有限责任公司")
|
|
|
|
//fmt.Println(data)
|
|
|
|
//if err!=nil{
|
|
|
|
// this.Display(4,err)
|
|
|
|
// return
|
|
|
|
//}
|
|
|
|
|
|
|
|
data1, _ := baidu.DefaultBaiDuMap.GetPosition("简阳市东溪镇奎星路28号")
|
|
|
|
|
|
|
|
this.Display(0, common.ObjToMap(data1))
|
|
|
|
|
|
|
|
},
|
|
|
|
"temp": func(this *hotime.Context) {
|
|
|
|
count := 0
|
|
|
|
for true {
|
|
|
|
|
|
|
|
data := this.Db.Get("area_copy", "id,parent_id,`index`,parent_code", common.Map{"index": nil, "ORDER": "`level` ASC"})
|
|
|
|
|
|
|
|
if data == nil {
|
|
|
|
break
|
|
|
|
}
|
|
|
|
count++
|
|
|
|
//if data.GetCeilInt("parent_id")==0{
|
|
|
|
// data["parent_id"]=3750
|
|
|
|
//}
|
|
|
|
parentData := this.Db.Get("area_copy", "id,parent_id,`index`", common.Map{"area_code": data.GetString("parent_code")})
|
|
|
|
if parentData == nil {
|
|
|
|
this.Db.Update("area_copy", common.Map{"index": data.GetString("id") + ","}, common.Map{"id": data.GetString("id")})
|
|
|
|
} else {
|
|
|
|
this.Db.Update("area_copy", common.Map{"index": parentData.GetString("index") + data.GetString("id") + ",", "parent_id": parentData["id"]}, common.Map{"id": data.GetString("id")})
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
this.Display(0, count)
|
|
|
|
|
|
|
|
},
|
|
|
|
"tempctg": func(this *hotime.Context) {
|
|
|
|
dataBytes, e := ioutil.ReadFile("2017.json")
|
|
|
|
if e != nil {
|
|
|
|
this.Display(4, e)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
data := common.ObjToSlice(string(dataBytes))
|
|
|
|
|
|
|
|
for k, _ := range data {
|
|
|
|
ins := data.GetMap(k)
|
|
|
|
ins["level"] = 1
|
|
|
|
id := this.Db.Insert("category", common.Map{"name": ins.GetString("name"),
|
|
|
|
"code": ins.GetString("code"),
|
|
|
|
"level": ins["level"],
|
|
|
|
"parent_id": 1,
|
|
|
|
"admin_id": this.Session("admin_id").ToInt(),
|
|
|
|
"create_time": time.Now().Unix(),
|
|
|
|
"modify_time": time.Now().Unix(),
|
|
|
|
})
|
|
|
|
|
|
|
|
if id != 0 {
|
|
|
|
ins["id"] = id
|
|
|
|
}
|
|
|
|
|
|
|
|
ins["index"] = ",1," + common.ObjToStr(id) + ","
|
|
|
|
this.Db.Update("category", common.Map{"index": ins["index"]}, common.Map{"id": ins["id"]})
|
|
|
|
|
|
|
|
run(ins, this)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
}
|
2017-08-17 02:37:00 +00:00
|
|
|
|
2021-06-03 18:57:56 +00:00
|
|
|
//makeCode := code.MakeCode{}
|
|
|
|
//fmt.Println(common.ObjToStr(makeCode.Db2JSON("admin","test",appIns.Db)))
|
2021-10-21 14:52:40 +00:00
|
|
|
if ddsms.DefaultDDY.ApiKey == "" {
|
|
|
|
ddsms.DefaultDDY.Init(appIns.Config.GetString("smsKey"))
|
|
|
|
}
|
2021-06-03 18:57:56 +00:00
|
|
|
|
2017-09-05 03:09:13 +00:00
|
|
|
appIns.Run(hotime.Router{
|
2021-12-27 12:40:16 +00:00
|
|
|
"app": app.Project,
|
2017-09-05 03:09:13 +00:00
|
|
|
})
|
2017-08-17 02:37:00 +00:00
|
|
|
}
|
2022-01-16 20:47:39 +00:00
|
|
|
|
|
|
|
func excel() common.Slice {
|
|
|
|
xlsx, err := excelize.OpenFile("tpt/piduqu.xlsx")
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println(err)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
list := xlsx.GetSheetList()
|
|
|
|
data := common.Slice{}
|
|
|
|
for _, v := range list {
|
|
|
|
rows, e := xlsx.GetRows(v)
|
|
|
|
fmt.Println(rows, e)
|
|
|
|
data = append(data, rows)
|
|
|
|
|
|
|
|
//for k1,v1:=range rows{
|
|
|
|
//
|
|
|
|
//}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return data
|
|
|
|
}
|
|
|
|
|
|
|
|
func run(ins common.Map, this *hotime.Context) {
|
|
|
|
cs := ins.GetSlice("children")
|
|
|
|
if cs == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
for ck, _ := range cs {
|
|
|
|
|
|
|
|
cins := cs.GetMap(ck)
|
|
|
|
cins["level"] = ins.GetCeilInt("level") + 1
|
|
|
|
id := this.Db.Insert("category", common.Map{"name": cins.GetString("name"),
|
|
|
|
"code": cins.GetString("code"),
|
|
|
|
"level": cins["level"],
|
|
|
|
"parent_id": ins["id"],
|
|
|
|
"admin_id": this.Session("admin_id").ToInt(),
|
|
|
|
"create_time": time.Now().Unix(),
|
|
|
|
"modify_time": time.Now().Unix(),
|
|
|
|
})
|
|
|
|
|
|
|
|
if id != 0 {
|
|
|
|
cins["id"] = id
|
|
|
|
}
|
|
|
|
|
|
|
|
cins["index"] = ins.GetString("index") + common.ObjToStr(id) + ","
|
|
|
|
this.Db.Update("category", common.Map{"index": cins["index"]}, common.Map{"id": cins["id"]})
|
|
|
|
|
|
|
|
run(cins, this)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|