add tysc handlers to kontor-gin
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
|
||||
type Position 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 (position *Position) TableName() string {
|
||||
return "field_position"
|
||||
}
|
||||
|
||||
type PositionDTO 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 ConvertPositionsToDtos(positions []Position) []PositionDTO {
|
||||
dtos := make([]PositionDTO, len(positions))
|
||||
for i, position := range positions {
|
||||
dtos[i] = PositionDTO{
|
||||
ID: position.ID,
|
||||
CreatedAt: position.CreatedAt,
|
||||
UpdatedAt: position.UpdatedAt,
|
||||
DeletedAt: position.DeletedAt,
|
||||
Version: position.Version,
|
||||
Name: position.Name,
|
||||
ShortName: position.ShortName,
|
||||
SportID: position.SportID,
|
||||
}
|
||||
}
|
||||
return dtos
|
||||
}
|
||||
Reference in New Issue
Block a user