reward-prop.go
2.17 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
package models
import (
"database/sql"
db "client/icesimba.mail/database"
)
/*礼物设置表与礼物表的关系表*/
type RewardProp struct {
RewardId string //礼物配置Id
PropId []string //道具Id
PropCount []int //道具数量
}
func (in *RewardProp) QueryRewardProp() (out Props, err error) {
sqlQue := "select code,count from ice_reward_prop INNER JOIN ice_prop on ice_reward_prop.PROPID=ice_prop.ID AND rewardid=?"
rows, err := db.SqlDB.Query(sqlQue, in.RewardId)
if err != nil {
return
}
for rows.Next() {
var (
propid sql.NullString
count sql.NullInt64
)
prop := PropJson{}
err = rows.Scan(
&propid,
&count,
)
if propid.Valid {
prop.Id = propid.String
}
if count.Valid {
prop.Count = count.Int64
}
if err == nil {
out.PropOut = append(out.PropOut, prop)
}
}
if err != nil {
return
}
return
}
func QueryRPIcon(rewardId string) string {
sqlQue := "select icon from ice_reward_prop INNER JOIN ice_prop on ice_reward_prop.PROPID=ice_prop.ID AND rewardid=? limit 1"
var icon sql.NullString
db.SqlDB.QueryRow(sqlQue, rewardId).Scan(
&icon,
)
if icon.Valid {
checkstr := icon.String[:4]
if checkstr == "http" {
return icon.String
}
str := "http://iceplayimage.icesimba.cn/" + icon.String
return str
}
return ""
}
//func (in *RewardUser) UpdateRewardUser() (out RewardUser, err error) {
// sqlUp := "update ice_reward_user set ispost=?,isget=?,starttime=?,endtime=? where userid=? and rewardid=?"
// stmt, err := db.SqlDB.Prepare(sqlUp)
// defer stmt.Close()
// rs, err := stmt.Exec(
// in.IsPost[0],
// in.IsGet[0],
// in.StartTime[0],
// in.EndTime[0],
// in.UserId,
// in.RewardId[0],
// )
// if err != nil {
// err = errors.New("更新数据失败")
// return
// }
// _, err = rs.RowsAffected()
// return
//}
func (in *RewardProp) InsertGiftSetGift() (code int, out RewardProp, err error) {
// sqlIn := "insert into ice_giftset_gift(ggid,gsid,gid,num) VALUES (?, ?, ?, ?)"
// _, err = db.SqlDB.Exec(
// sqlIn,
// in.Id,
// in.RewardId,
// in.PropId,
// in.PropCount,
// )
// if err != nil {
// err = errors.New("插入数据失败")
// code = 400
// return
// }
// code = 200
return
}