36 lines
639 B
Go
36 lines
639 B
Go
package v2
|
|
|
|
import (
|
|
"time"
|
|
"github.com/gin-gonic/gin"
|
|
"gorm.io/gorm"
|
|
"wx-backend-go/models"
|
|
|
|
)
|
|
|
|
|
|
|
|
func Greeting(c *gin.Context) {
|
|
c.JSON(200, gin.H{
|
|
"message": "Chen" ,
|
|
})
|
|
}
|
|
|
|
type FootballLeague struct {
|
|
LeagueID int `json:"league_id"`
|
|
LeagueName string `json:"league_name"`
|
|
LeagueAllName string `json:"league_all_name"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
}
|
|
|
|
func GetLeagueList(c *gin.Context) {
|
|
session := models.DB.Session(&gorm.Session{})
|
|
|
|
var leagueList []FootballLeague
|
|
session.Model(&models.FootballLeague{}).Limit(10).Find(&leagueList)
|
|
|
|
c.JSON(200, gin.H{
|
|
"data": leagueList,
|
|
})
|
|
|
|
} |