intimate_view/goserver/main.go

54 lines
1.0 KiB
Go
Raw Normal View History

2020-08-18 11:22:29 +00:00
package main
import (
"database/sql"
"time"
"github.com/gin-gonic/gin"
_ "github.com/go-sql-driver/mysql"
)
var StoreStreamer *sql.DB
func init() {
db, err := sql.Open("mysql", InitConfig.Database.ExtractorURI)
if err != nil {
panic(err)
}
StoreStreamer = db
}
2020-08-20 11:29:22 +00:00
type Result struct {
Code int
Error string
Data interface{}
}
type ObjectQuery struct {
2020-08-18 11:22:29 +00:00
Uid int64
Platform string
2020-08-19 11:32:01 +00:00
UserId string
2020-08-18 11:22:29 +00:00
UserName string
LiveUrl string
2020-08-19 11:32:01 +00:00
Tags []string
2020-08-18 11:22:29 +00:00
Followers int64
Views int64
Gratuity int64
LiveTitle string
2020-08-19 11:32:01 +00:00
LiveStartTime *time.Time
LiveEndTime *time.Time
UpdateTime *time.Time
2020-08-18 11:22:29 +00:00
}
func main() {
engine := gin.New() //r := gin.Default() //使用默认中间件
engine.Use(gin.Logger())
2020-08-19 11:32:01 +00:00
engine.Use(Cors())
engine.GET("twitcasting/query", TwitcastingQuery)
2020-08-20 11:29:22 +00:00
engine.GET("openrec/query", OpenrecQuery)
engine.GET("twitch/query", TwitchQuery)
engine.GET("tag/count", CountTag)
2020-08-23 16:23:43 +00:00
engine.GET("tag/allcount", CountTag)
2020-08-18 11:22:29 +00:00
engine.Run(":5500")
}