Skip to content

Commit 28762c8

Browse files
committed
fix(sqlite): slice qurey
1 parent 0cebcca commit 28762c8

4 files changed

Lines changed: 13 additions & 25 deletions

File tree

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.20
44

55
require (
66
github.com/FloatTech/floatbox v0.0.0-20241106130736-5aea0a935024
7-
github.com/FloatTech/sqlite v1.7.0
7+
github.com/FloatTech/sqlite v1.7.1
88
github.com/RomiChan/syncx v0.0.0-20240418144900-b7402ffdebc7
99
github.com/antchfx/htmlquery v1.3.3
1010
github.com/corona10/goimagehash v1.1.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
github.com/FloatTech/floatbox v0.0.0-20241106130736-5aea0a935024 h1:mrvWpiwfRklt9AyiQjKgDGJjf4YL6FZ3yC+ydbkuF2o=
22
github.com/FloatTech/floatbox v0.0.0-20241106130736-5aea0a935024/go.mod h1:+P3hs+Cvl10/Aj3SNE96TuBvKAXCe+XD1pKphTZyiwk=
3-
github.com/FloatTech/sqlite v1.7.0 h1:FGSn4pCR12kESozn7IvNx3U39dwR/AcFM9oPyGACsl0=
4-
github.com/FloatTech/sqlite v1.7.0/go.mod h1:/4tzfCGhrZnnjC1U8vcfwGQeF6eR649fhOsS3+Le0+s=
3+
github.com/FloatTech/sqlite v1.7.1 h1:XKUY0+MNaRmvEIgRv7QLbl7PFVpUfQ72+XQg+no2Vq0=
4+
github.com/FloatTech/sqlite v1.7.1/go.mod h1:/4tzfCGhrZnnjC1U8vcfwGQeF6eR649fhOsS3+Le0+s=
55
github.com/FloatTech/ttl v0.0.0-20240716161252-965925764562 h1:snfw7FNFym1eNnLrQ/VCf80LiQo9C7jHgrunZDwiRcY=
66
github.com/FloatTech/ttl v0.0.0-20240716161252-965925764562/go.mod h1:fHZFWGquNXuHttu9dUYoKuNbm3dzLETnIOnm1muSfDs=
77
github.com/RomiChan/syncx v0.0.0-20240418144900-b7402ffdebc7 h1:S/ferNiehVjNaBMNNBxUjLtVmP/YWD6Yh79RfPv4ehU=

niu/test_test.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,3 @@ func TestCheckProp(t *testing.T) {
2727
}
2828
t.Log("成功")
2929
}
30-
31-
func TestProcessNiuNiuAction(t *testing.T) {
32-
user := &userInfo{
33-
UID: 123,
34-
Length: 12,
35-
WeiGe: 2,
36-
}
37-
action, err := user.processNiuNiuAction("11")
38-
if err != nil {
39-
t.Error(err)
40-
}
41-
t.Log(action, "---------", user)
42-
}

wallet/wallet.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,32 +82,33 @@ func InsertWalletOf(uid int64, money int) error {
8282
}
8383

8484
// 获取钱包数据 no lock
85-
func (sql *Storage) getWalletOf(uid int64) (wallet Wallet) {
85+
func (s *Storage) getWalletOf(uid int64) (wallet Wallet) {
8686
uidstr := strconv.FormatInt(uid, 10)
87-
_ = sql.db.Find("storage", &wallet, "WHERE uid = ?", uidstr)
87+
_ = s.db.Find("storage", &wallet, "WHERE uid = ?", uidstr)
8888
return
8989
}
9090

9191
// 获取钱包数据组
92-
func (sql *Storage) getGroupWalletOf(sortable bool, uids ...int64) (wallets []Wallet, err error) {
93-
sql.RLock()
94-
defer sql.RUnlock()
92+
func (s *Storage) getGroupWalletOf(sortable bool, uids ...int64) (wallets []Wallet, err error) {
93+
s.RLock()
94+
defer s.RUnlock()
9595
wallets = make([]Wallet, 0, len(uids))
9696
sort := "ASC"
9797
if sortable {
9898
sort = "DESC"
9999
}
100100
info := Wallet{}
101-
err = sql.db.FindFor("storage", &info, "WHERE uid IN ? ORDER BY money "+sort, func() error {
101+
q, sl := sql.QuerySet("WHERE uid", "IN", uids)
102+
err = s.db.FindFor("storage", &info, q+" ORDER BY money "+sort, func() error {
102103
wallets = append(wallets, info)
103104
return nil
104-
}, uids)
105+
}, sl...)
105106
return
106107
}
107108

108109
// 更新钱包 no lock
109-
func (sql *Storage) updateWalletOf(uid int64, money int) (err error) {
110-
return sql.db.Insert("storage", &Wallet{
110+
func (s *Storage) updateWalletOf(uid int64, money int) (err error) {
111+
return s.db.Insert("storage", &Wallet{
111112
UID: uid,
112113
Money: money,
113114
})

0 commit comments

Comments
 (0)