Commit eb5462f8 authored by hujiebin's avatar hujiebin

fix:batchGet

parent 5522be36
......@@ -68,10 +68,7 @@ func BatchGetVips(userIds []uint64) (map[uint64]*int64, error) {
end = len(userIds)
}
start := 0
for end <= len(userIds) {
if end > len(userIds) {
end = len(userIds)
}
for start < len(userIds) {
tmp := make([]UserVip, 0)
err := mysql.Db.Where("user_id IN ?", userIds[start:end]).Find(&tmp).Error
if err != nil {
......@@ -84,6 +81,9 @@ func BatchGetVips(userIds []uint64) (map[uint64]*int64, error) {
}
start += 500
end += 500
if end > len(userIds) {
end = len(userIds)
}
//mylogrus.MyLog.Infof("BatchGetVips start:%v-end:%v", start, end)
}
......
......@@ -18,7 +18,7 @@ func TestGetUserMap(t *testing.T) {
func TestGetUserVipMap(t *testing.T) {
var userIds []uint64
for i := 0; i < 1500; i++ {
for i := 0; i < 10502; i++ {
userIds = append(userIds, 7642)
}
res, err := user_m.BatchGetVips(userIds)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment