MatchHisService.go 1.3 KB
Newer Older
S
shi.zeyuan 已提交
1 2
package service

3 4 5 6 7
import (
	"tesou.io/platform/foot-parent/foot-api/common/base"
	"tesou.io/platform/foot-parent/foot-api/module/match/pojo"
	"tesou.io/platform/foot-parent/foot-core/common/base/service/mysql"
)
S
shi.zeyuan 已提交
8 9 10 11

type MatchHisService struct {
	mysql.BaseService
}
12

13
func (this *MatchHisService) Exist(v *pojo.MatchHis) bool {
14 15
	has, err := mysql.GetEngine().Table("`t_match_his`").Where(" `Id` = ?  ", v.Id).Exist()
	if err != nil {
16
		base.Log.Error("Exist", err)
17 18 19
	}
	return has
}
M
monomania 已提交
20

21 22 23 24 25 26
func (this *MatchHisService) FindAll() []*pojo.MatchHis {
	dataList := make([]*pojo.MatchHis, 0)
	mysql.GetEngine().OrderBy("MatchDate").Find(&dataList)
	return dataList
}

M
monomania 已提交
27 28 29 30 31
func (this *MatchHisService) FindById(matchId string) *pojo.MatchHis {
	data := new(pojo.MatchHis)
	data.Id = matchId
	_, err := mysql.GetEngine().Get(data)
	if err != nil {
M
monomania 已提交
32
		base.Log.Error("FindById:", err)
M
monomania 已提交
33 34 35
	}
	return data
}
36 37 38 39 40 41 42 43 44

/**
查找未结束的比赛
*/
func (this *MatchHisService) FindBySeason(season string) []*pojo.MatchLast {
	sql_build := `
SELECT 
  la.* 
FROM
M
1.xxx  
monomania 已提交
45 46
  foot.t_match_his la
WHERE 1=1
47
	`
M
1.xxx  
monomania 已提交
48
	sql_build = sql_build + " AND la.MatchDate >= '" + season + "-01-01 00:00:00' AND la.MatchDate <= '" + season + "-12-31 23:59:59'"
49 50 51 52 53 54 55

	//结果值
	dataList := make([]*pojo.MatchLast, 0)
	//执行查询
	this.FindBySQL(sql_build, &dataList)
	return dataList
}