almanac-reward.go
1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package models
import (
"database/sql"
"fmt"
db "client/icesimba.mail/database"
)
type AlmanacReward struct {
ImgUrl string `json:"almanac_url"`
Props []PropJson `json:"props"`
}
func QueryAlmanacReward(date string, gameId string) (out AlmanacReward, err error) {
sqlQu := "select rewardid,imgurl from ice_reward_almanac where date=? and gameid=? limit 1"
fmt.Printf("select rewardid,imgurl from ice_reward_almanac where date=%s and gameid=%s limit 1", date, gameId)
var (
rewardIdNull sql.NullString
imgUrlNull sql.NullString
)
err = db.SqlDB.QueryRow(sqlQu, date, gameId).Scan(
&rewardIdNull,
&imgUrlNull,
)
if err != nil {
return
}
if imgUrlNull.Valid {
checkstr := imgUrlNull.String[:4]
if checkstr == "http" {
out.ImgUrl = imgUrlNull.String
} else {
out.ImgUrl = "http://iceplayimage.icesimba.cn/" + imgUrlNull.String
}
}
if rewardIdNull.Valid {
rewardProp := RewardProp{
RewardId: rewardIdNull.String,
}
props := Props{}
props, err = rewardProp.QueryRewardProp()
out.Props = props.PropOut
}
return
}