• haoyanbin's avatar
    1 · f4300b15
    haoyanbin authored
    f4300b15
match.go 3.75 KB
package dto

import "gorm.io/gorm"

type PageMatchInfo struct {
	Id                      string `json:"id"`
	LeagueName              string `json:"leagueName"`
	DivisionName            string `json:"divisionName"`
	SeasonId                string `json:"seasonId"`
	SeasonName              string `json:"seasonName"`
	Rounds                  string `json:"rounds"`
	ClubName                string `json:"clubName"`
	TeamId                  string `json:"teamId"`
	TeamName                string `json:"teamName"`
	PlayerId                string `json:"playerId"`
	PlayerName              string `json:"playerName"`
	PlayerNumber            string `json:"playerNumber"`
	Position                string `json:"position"`
	WonderfulMomentImg      string `json:"wonderfulMomentImg" comment:"精彩时刻图"`
	WonderfulMomentMv       string `json:"wonderfulMomentMv" comment:"精彩时刻视频"`
	WonderfulMomentImgTitle string `json:"wonderfulMomentImgTitle" comment:"精彩时刻图标题"`
	WonderfulMomentMvTitle  string `json:"wonderfulMomentMvTitle" comment:"精彩时刻视频标题"`
	TeamAName               string `json:"team_a_name" comment:"a队名"`
	TeamBName               string `json:"team_b_name" comment:"b队名"`
}

type TotalScoring struct {
	Scoring        string `json:"scoring" comment:"得分"`
	Rebound        string `json:"rebound" comment:"篮板"`
	Assist         string `json:"assist" comment:"助攻"`
	Steal          string `json:"steal" comment:"抢断"`
	FreeThrow      string `json:"freeThrow" comment:"罚球"`
	BlockShot      string `json:"blockShot" comment:"盖帽"`
	Foul           string `json:"foul" comment:"犯规"`
	TwoPointShot   string `json:"twoPointShot" comment:"2分进球数量"`
	ThreePointShot string `json:"threePointShot" comment:"3分进球数量"`
}

type RoundsScoring struct {
	PlayerName     string `json:"player_name" comment:"球员名称"`
	PlayerNumber   string `json:"player_number" comment:"球员号码"`
	Position       string `json:"position" comment:"场上位置"`
	Rounds         string `json:"rounds" comment:"轮次"`
	Grouping       string `json:"grouping" comment:"分组"`
	OtherTeam      string `json:"otherTeam" comment:"对方球队"`
	Scoring        string `json:"scoring" comment:"得分"`
	Rebound        string `json:"rebound" comment:"篮板"`
	Assist         string `json:"assist" comment:"助攻"`
	Steal          string `json:"steal" comment:"抢断"`
	FreeThrow      string `json:"freeThrow" comment:"罚球"`
	BlockShot      string `json:"blockShot" comment:"盖帽"`
	Foul           string `json:"foul" comment:"犯规"`
	TwoPointShot   string `json:"twoPointShot" comment:"2分进球数量"`
	ThreePointShot string `json:"threePointShot" comment:"3分进球数量"`
}

func SetWhere(tableName string, fieldName string, fieldValue string) func(db *gorm.DB) *gorm.DB {
	return func(db *gorm.DB) *gorm.DB {
		if fieldValue == "0" || fieldValue == "" {
			return db
		}
		if tableName == "" {
			return db.Where(fieldName+" = ?", fieldValue)
		}
		return db.Where(tableName+"."+fieldName+" = ?", fieldValue)
	}
}

func SetWhereIn(tableName string, fieldName string, fieldValue string) func(db *gorm.DB) *gorm.DB {
	return func(db *gorm.DB) *gorm.DB {
		if fieldValue == "0" || fieldValue == "" {
			return db
		}
		if tableName == "" {
			return db.Where(fieldName + " in (" + fieldValue + ")")
		}
		return db.Where(tableName + "." + fieldName + " in (" + fieldValue + ")")
	}
}

func SetWhereNotIn(tableName string, fieldName string, fieldValue string) func(db *gorm.DB) *gorm.DB {
	return func(db *gorm.DB) *gorm.DB {
		if fieldValue == "0" || fieldValue == "" {
			return db
		}
		if tableName == "" {
			return db.Where(fieldName + " not in (" + fieldValue + ")")
		}
		return db.Where(tableName + "." + fieldName + " not in (" + fieldValue + ")")
	}
}