package dto

import (
	"crypto/md5"
	"encoding/hex"
	"go-admin/common/dto"
	"time"
)

type OrgPlayerGetPageReq struct {
	dto.Pagination `search:"-"`
	PlayerUserId   string `form:"playerUserId"  search:"-"`
	TeamId         string `form:"teamId"  search:"-"`
	TeamName       string `form:"teamName"  search:"type:contains;column:team_name;table:ot" comment:""`
	PlayerName     string `form:"playerName"  search:"type:contains;column:player_name;table:op" comment:""`
	Status         string `form:"status"  search:"type:exact;column:status;table:op" comment:""`
}
type OrgPlayerGetPageReply struct {
	Id           string `json:"id" comment:"球员id"` //球员id
	ClubId       string `json:"clubId" comment:"俱乐部id"`
	ClubName     string `json:"clubName" comment:"俱乐部名称"`
	TeamId       string `json:"teamId" comment:"球队id"`
	TeamName     string `json:"teamName" comment:"球队名称"`
	PlayerName   string `json:"playerName" comment:"球员名称"`
	PlayerImg    string `json:"playerImg" comment:"球员照片"`
	PlayerNameEn string `json:"playerNameEn" comment:"球员名称英文"`
	PlayerNumber string `json:"playerNumber" comment:"球衣号"`
	Position     string `json:"position" comment:"场上位置"`
	Sex          string `json:"sex" comment:"性别"`
	Status       string `json:"status" comment:"状态"`
}

type MatchId struct {
	Id string `json:"id" `
}

type OrgPlayerOrder struct {
	Id           int       `form:"idOrder"  search:"type:order;column:id;table:org_player"`
	ClubId       string    `form:"clubIdOrder"  search:"type:order;column:club_id;table:org_player"`
	TeamId       string    `form:"teamIdOrder"  search:"type:order;column:team_id;table:org_player"`
	PlayerName   string    `form:"playerNameOrder"  search:"type:order;column:player_name;table:org_player"`
	IdCard       string    `form:"idCardOrder"  search:"type:order;column:id_card;table:org_player"`
	Sex          string    `form:"sexOrder"  search:"type:order;column:sex;table:org_player"`
	PlayerNumber string    `form:"playerNumberOrder"  search:"type:order;column:player_number;table:org_player"`
	Position     string    `form:"positionOrder"  search:"type:order;column:position;table:org_player"`
	PlayerImg    string    `form:"playerImgOrder"  search:"type:order;column:player_img;table:org_player"`
	PlayerUserId string    `form:"playerUserIdOrder"  search:"type:order;column:player_user_id;table:org_player"`
	ShareConf    string    `form:"shareConfOrder"  search:"type:order;column:share_conf;table:org_player"`
	CreateBy     string    `form:"createByOrder"  search:"type:order;column:create_by;table:org_player"`
	UpdateBy     string    `form:"updateByOrder"  search:"type:order;column:update_by;table:org_player"`
	CreatedAt    time.Time `form:"createdAtOrder"  search:"type:order;column:created_at;table:org_player"`
	UpdatedAt    time.Time `form:"updatedAtOrder"  search:"type:order;column:updated_at;table:org_player"`
	DeletedAt    time.Time `form:"deletedAtOrder"  search:"type:order;column:deleted_at;table:org_player"`
}

func (m *OrgPlayerGetPageReq) GetNeedSearch() interface{} {
	return *m
}

type OrgPlayerDataGetReq struct {
	PlayerId string `form:"playerId" json:"playerId"`
	SeasonId string `form:"seasonId" json:"seasonId"`
	Match    string `form:"match" json:"match"`
}

type OrgPlayerDataGetReply struct {
	Scoring    string `json:"scoring"`
	CountMatch string `json:"countMatch"`
}
type OrgPlayerGetInfoReq struct {
	dto.Pagination `search:"-"`
	PlayerId       int `form:"playerId" json:"playerId"`
}

type OrgPlayerGetInfoReply struct {
	OrgPlayerInfo OrgPlayerGetReply        `json:"orgPlayerInfo"`
	DataAvg       OrgMatchInfo             `json:"dataAvg"`
	OrgMatchInfo  OrgMatchInfo             `json:"orgMatchInfo"`
	RoundsScoring []OrgPlayerRoundsScoring `json:"roundsScoring"`
}

type OrgMatchInfo struct {
	Id         string `json:"id"`
	SeasonId   string `json:"seasonId" comment:"赛季id"`
	SeasonName string `json:"seasonName" comment:"赛季名称"`
	LeagueName string `json:"leagueName" comment:"联赛级别"`
	TeamName   string `json:"teamName" comment:"球队名称"`
	CountMatch string `json:"countMatch" comment:"场次"`
	dto.TotalScoring
}

type OrgPlayerRoundsScoring struct {
	Id             string `json:"id"`
	TeamAScore     string `json:"teamAScore"`
	TeamBScore     string `json:"teamBScore"`
	TeamAName      string `json:"teamAName"`
	TeamBName      string `json:"teamBName"`
	TeamAId        string `json:"teamAId"`
	TeamBId        string `json:"teamBId"`
	MatchStartTime string `json:"matchStartTime"`
	MatchEndTime   string `json:"matchEndTime"`
	TeamName       string `json:"teamName"`
	CountMatch     string `json:"countMatch" comment:"场次"`
	SeasonName     string `json:"seasonName" comment:"赛季名称"`
	LeagueName     string `json:"leagueName" comment:"联赛级别"`
	dto.RoundsScoring
}

type GetRoundsReq struct {
	PlayerId string `form:"playerId" json:"playerId"`
}
type GetRoundsReply struct {
	Id           string `json:"id"`
	LeagueId     string `json:"leagueId"`
	LeagueName   string `json:"leagueName"`
	DivisionName string `json:"divisionName"`
	SeasonId     string `json:"seasonId"`
	SeasonName   string `json:"seasonName"`
	MatchId      string `json:"matchId"`
	Rounds       string `json:"rounds"`
}

type OrgPlayerGetOrgMatchEvaluateReq struct {
	dto.Pagination `search:"-"`
	LeagueId       string `form:"leagueId"  json:"leagueId"`
	SeasonId       string `form:"seasonId" json:"seasonId"`
	MatchId        string `form:"matchId" json:"matchId"`
	Rounds         string `form:"rounds"  json:"rounds"`
	PlayerId       string `form:"playerId" json:"playerId"`
	Type           string `form:"type" json:"type"`
}

type OrgPlayerGetOrgMatchEvaluateReply struct {
	Id             string `json:"id"`
	WonderfulId    string `json:"wonderfulId" comment:"精彩时刻id"`
	WonderfulUrl   string `json:"wonderfulUrl" comment:"精彩时刻url"`
	WonderfulTitle string `json:"wonderfulTitle" comment:"精彩时刻标题"`
	FileId         string `json:"fileId" comment:"文件id"`
}

type OrgPlayerGetOrgMatchEvaluateContentReq struct {
	dto.Pagination `search:"-"`
	PlayerId       string `form:"playerId" json:"playerId"`
}

type OrgPlayerGetOrgMatchEvaluateContentReply struct {
	Id           string `json:"id"`
	LeagueName   string `json:"leagueName"`
	DivisionName string `json:"divisionName"`
	SeasonName   string `json:"seasonName"`
	MatchId      string `json:"matchId"`
	Rounds       string `json:"rounds"`
	Content      string `json:"content"`
	ContentDate  string `json:"contentDate"`
	ContentImg   string `json:"contentImg"`
}

// OrgPlayerGetReq 功能获取请求参数
type OrgPlayerGetReq struct {
	PlayerId int `uri:"id"`
}

type OrgPlayerGetReply struct {
	Id            int    `json:"id" comment:"球员id"`
	ClubId        string `json:"clubId" comment:"俱乐部id"`
	ClubName      string `json:"clubName" comment:"俱乐部名称"`
	ClubLogo      string `json:"clubLogo" comment:"俱乐部logo"`
	ClubQrcode    string `json:"clubQrcode" comment:"俱乐部二维码"`
	TeamId        string `json:"teamId" comment:"球队id"`
	TeamName      string `json:"teamName" comment:"球队名称"`
	SeasonId      string `json:"seasonId" comment:"赛季id"`
	PlayerName    string `json:"playerName" comment:"球员名称"`
	PlayerNameEn  string `json:"playerNameEn" comment:"球员名称英文"`
	IdCard        string `json:"idCard" comment:"身份证号"`
	Sex           string `json:"sex" comment:"性别"`
	PlayerNumber  string `json:"playerNumber" comment:"球衣号"`
	Position      string `json:"position" comment:"场上位置"`
	PlayerImg     string `json:"playerImg" comment:"球员照片"`
	Username      string `json:"username" comment:"账号"`
	ShareConf     string `json:"shareConf" comment:"分享功能 1 开启 2 关闭"`
	Status        string `json:"status" comment:"状态 1 离队 2 在队"` //1 离队 2 在队
	TotalScoring  string `json:"totalScoring"`
	SeasonScoring string `json:"seasonScoring"`
	CountMatch    string `json:"countMatch"`
}

func (s *OrgPlayerGetReq) GetId() interface{} {
	return s.PlayerId
}

func Pwd(password string) string {
	if password == "" {
		return ""
	}
	// 改为md5 修改时需同时修改登录的加密
	h := md5.New()
	h.Write([]byte(password))
	return hex.EncodeToString(h.Sum(nil))

	//var hash []byte
	//var err error
	//if hash, err = bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost); err != nil {
	//	return ""
	//} else {
	//	return string(hash)
	//}
}
