master
hwf452 9 months ago
parent 6eab664b31
commit 61a878ddf4

@ -29,8 +29,8 @@ func initLogs() {
logs.SetLogger(logs.AdapterConsole, `{"level":7}`) logs.SetLogger(logs.AdapterConsole, `{"level":7}`)
} else if beego.BConfig.RunMode == beego.PROD { } else if beego.BConfig.RunMode == beego.PROD {
wd, _ := os.Getwd() wd, _ := os.Getwd()
//dir := wd + "/logs/" dir := wd + "/logs/"
dir := wd + "\\logs\\" //dir := wd + "\\logs\\"
_, err := os.Stat(dir) _, err := os.Stat(dir)
if os.IsNotExist(err) { if os.IsNotExist(err) {
os.Mkdir(dir, os.ModePerm) os.Mkdir(dir, os.ModePerm)

@ -21,7 +21,7 @@ syncFrequencyWeather = "0 16 * * * *"
mysqluser = "root" mysqluser = "root"
mysqlpass = "Skyinno251," mysqlpass = "Skyinno251,"
mysqlurls = "192.168.2.18:3306" mysqlurls = "192.168.2.18:3306"
mysqldb = "weather" mysqldb = "gorm"
mysqlparams = "charset=utf8mb4&parseTime=True&loc=Local" mysqlparams = "charset=utf8mb4&parseTime=True&loc=Local"
#连接池空闲 #连接池空闲
mysqlmaxIdle = 10 mysqlmaxIdle = 10

@ -1,2 +1,5 @@
2025/03/01 09:16:03.273 [I] [asm_amd64.s:1650] http server Running on http://:8082 2025/03/01 09:16:03.273 [I] [asm_amd64.s:1650] http server Running on http://:8082
2025/03/01 09:16:19.037 [I] [asm_amd64.s:1650] http server Running on http://:8082 2025/03/01 09:16:19.037 [I] [asm_amd64.s:1650] http server Running on http://:8082
2025/03/03 13:37:36.152 [I] [asm_amd64.s:1650] http server Running on http://:8082
2025/03/03 13:41:54.166 [I] [asm_amd64.s:1650] http server Running on http://:8082
2025/03/03 13:44:25.608 [I] [asm_amd64.s:1650] http server Running on http://:8082

@ -2,3 +2,9 @@
2025/03/01 09:16:03.273 [I] [asm_amd64.s:1650] http server Running on http://:8082 2025/03/01 09:16:03.273 [I] [asm_amd64.s:1650] http server Running on http://:8082
2025/03/01 09:16:19.032 [N] [initialize.go:21] 数据库注册成功: weather@192.168.2.18:3306 2025/03/01 09:16:19.032 [N] [initialize.go:21] 数据库注册成功: weather@192.168.2.18:3306
2025/03/01 09:16:19.037 [I] [asm_amd64.s:1650] http server Running on http://:8082 2025/03/01 09:16:19.037 [I] [asm_amd64.s:1650] http server Running on http://:8082
2025/03/03 13:37:36.148 [N] [initialize.go:21] 数据库注册成功: gorm@192.168.2.18:3306
2025/03/03 13:37:36.152 [I] [asm_amd64.s:1650] http server Running on http://:8082
2025/03/03 13:41:54.161 [N] [initialize.go:21] 数据库注册成功: gorm@192.168.2.18:3306
2025/03/03 13:41:54.166 [I] [asm_amd64.s:1650] http server Running on http://:8082
2025/03/03 13:44:25.602 [N] [initialize.go:21] 数据库注册成功: gorm@192.168.2.18:3306
2025/03/03 13:44:25.608 [I] [asm_amd64.s:1650] http server Running on http://:8082

@ -1,2 +1,5 @@
2025/03/01 09:16:03.266 [N] [initialize.go:21] 数据库注册成功: weather@192.168.2.18:3306 2025/03/01 09:16:03.266 [N] [initialize.go:21] 数据库注册成功: weather@192.168.2.18:3306
2025/03/01 09:16:19.032 [N] [initialize.go:21] 数据库注册成功: weather@192.168.2.18:3306 2025/03/01 09:16:19.032 [N] [initialize.go:21] 数据库注册成功: weather@192.168.2.18:3306
2025/03/03 13:37:36.148 [N] [initialize.go:21] 数据库注册成功: gorm@192.168.2.18:3306
2025/03/03 13:41:54.161 [N] [initialize.go:21] 数据库注册成功: gorm@192.168.2.18:3306
2025/03/03 13:44:25.602 [N] [initialize.go:21] 数据库注册成功: gorm@192.168.2.18:3306

@ -24,3 +24,4 @@ func GetNmcCityList() []*NmcCity {
orm.NewOrm().QueryTable(new(NmcCity)).All(&items) orm.NewOrm().QueryTable(new(NmcCity)).All(&items)
return items return items
} }

@ -0,0 +1,26 @@
package models
import (
"github.com/astaxie/beego/orm"
"time"
)
type NmcProvince struct {
Code string `json:"code" orm:"pk;column(code);size(50)"`
Name string `json:"name" orm:"column(name);size(50)"`
Url string `json:"url" orm:"column(url);size(50)"`
CreateDate time.Time `json:"createDate" orm:"column(create_date);auto_now_add;type(datetime)"`
LastUpdateDate time.Time `json:"lastUpdateDate" orm:"column(last_update_date);auto_now;type(datetime)"`
}
func init() {
orm.RegisterModel(new(NmcProvince))
}
func GetNmcProvinceList() []*NmcProvince {
items := make([]*NmcProvince, 0)
orm.NewOrm().QueryTable(new(NmcCity)).All(&items)
return items
}

@ -12,10 +12,17 @@ import (
type HttpWeatherService struct { type HttpWeatherService struct {
} }
func SyncNmcCityAndNmcProvince() {
}
func (s *HttpWeatherService) GetNmcNowWeather() { func (s *HttpWeatherService) GetNmcNowWeather() {
citys := models.GetNmcCityList() citys := models.GetNmcCityList()
fmt.Println(citys) fmt.Println(citys)
fmt.Println(len(citys)) fmt.Println(len(citys))
if len(citys)==0 {
SyncNmcCityAndNmcProvince()
}
var wg sync.WaitGroup var wg sync.WaitGroup
for _, item := range citys { for _, item := range citys {
time.Sleep(time.Millisecond * 300) time.Sleep(time.Millisecond * 300)

Binary file not shown.
Loading…
Cancel
Save