MessageService.go 1.1 KB
Newer Older
M
monomania 已提交
1 2 3
package service

import (
4 5
	"encoding/json"
	"fmt"
S
shi.zeyuan 已提交
6
	"github.com/chanxuehong/wechat/mp/message/callback/response"
S
shi.zeyuan 已提交
7
	"tesou.io/platform/foot-parent/foot-api/common/base"
M
monomania 已提交
8
	"tesou.io/platform/foot-parent/foot-core/common/base/service/mysql"
M
monomania 已提交
9
	"tesou.io/platform/foot-parent/foot-core/module/leisu/service"
M
monomania 已提交
10 11 12 13
)

type MessageService struct {
	mysql.BaseService
M
monomania 已提交
14
	service.LeisuService
M
monomania 已提交
15 16
}

S
shi.zeyuan 已提交
17
func (this *MessageService) Today() []response.Article {
S
shi.zeyuan 已提交
18
	listData := this.LeisuService.ListPubAbleData()
S
shi.zeyuan 已提交
19
	articles := make([]response.Article,len(listData))
S
shi.zeyuan 已提交
20
	for i, e := range listData {
21 22 23
		bytes, _ := json.Marshal(e)
		base.Log.Warn("比赛信息:" + string(bytes))
		matchDateStr := e.MatchDate.Format("01月02日15点04分")
S
shi.zeyuan 已提交
24
		article := response.Article{}
25
		article.Title = fmt.Sprintf("%v", matchDateStr)
M
monomania 已提交
26
		article.Description = fmt.Sprintf("%v %v vs %v", e.LeagueName, e.MainTeam, e.GuestTeam)
S
shi.zeyuan 已提交
27 28 29
		article.PicURL = "http://mmbiz.qpic.cn/sz_mmbiz_jpg/BePaFicK2B5QZuw0bf1HsiarnqQXzuWxE9XYC25oe2mVLeguvo6Rd1j1D2ibRibfmpu8eDqs0lfXaEfXR2bhslrPKQ/0?wx_fmt=jpeg"
		article.URL = "https://gitee.com/aoe5188/foot-parent"
		articles[i] = article
M
monomania 已提交
30
	}
S
shi.zeyuan 已提交
31
	return articles
M
monomania 已提交
32
}