add tysc handlers to kontor-gin
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
|
||||
type Team struct {
|
||||
ID string `gorm:"type:string;primary_key;" json:"id"`
|
||||
CreatedAt time.Time `gorm:"column:created_date" json:"created_date"`
|
||||
UpdatedAt time.Time `gorm:"column:last_modified_date" json:"last_modified_date"`
|
||||
DeletedAt *time.Time `gorm:"column:deleted_date" json:"deleted_date"`
|
||||
Version int `gorm:"default:0" json:"version"`
|
||||
Name string `gorm:"column:name" json:"name"`
|
||||
ShortName string `gorm:"column:short_name" json:"short_name"`
|
||||
SportID string `gorm:"column:sport_id" json:"sport_id"`
|
||||
Sport Sport `gorm:"foreignKey:SportID" json:"sport"`
|
||||
Roosters []Rooster `gorm:"foreignKey:TeamID" json:"roosters"`
|
||||
}
|
||||
|
||||
func (team *Team) TableName() string {
|
||||
return "team"
|
||||
}
|
||||
|
||||
type TeamDTO struct {
|
||||
ID string `json:"id" binding:"required"`
|
||||
CreatedAt time.Time `json:"created_date" binding:"required"`
|
||||
UpdatedAt time.Time `json:"last_modified_date" binding:"required"`
|
||||
DeletedAt *time.Time `json:"deleted_date,omitempty" binding:"omitempty"`
|
||||
Version int `json:"version" binding:"required"`
|
||||
Name string `json:"name" binding:"required"`
|
||||
ShortName string `json:"short_name" binding:"required"`
|
||||
SportID string `json:"sport_id" binding:"required"`
|
||||
}
|
||||
|
||||
func ConvertTeamsToDtos(teams []Team) []TeamDTO {
|
||||
dtos := make([]TeamDTO, len(teams))
|
||||
for i, team := range teams {
|
||||
dtos[i] = TeamDTO{
|
||||
ID: team.ID,
|
||||
CreatedAt: team.CreatedAt,
|
||||
UpdatedAt: team.UpdatedAt,
|
||||
DeletedAt: team.DeletedAt,
|
||||
Version: team.Version,
|
||||
Name: team.Name,
|
||||
ShortName: team.ShortName,
|
||||
SportID: team.SportID,
|
||||
}
|
||||
}
|
||||
return dtos
|
||||
}
|
||||
Reference in New Issue
Block a user