49 lines
1.2 KiB
Go
49 lines
1.2 KiB
Go
package main
|
|
|
|
import (
|
|
"bindbox-game/configs"
|
|
"bindbox-game/internal/repository/mysql"
|
|
"bindbox-game/internal/repository/mysql/model"
|
|
"flag"
|
|
"fmt"
|
|
)
|
|
|
|
func main() {
|
|
flag.Parse()
|
|
configs.Init()
|
|
dbRepo, err := mysql.New()
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
db := dbRepo.GetDbR()
|
|
|
|
userID := int64(9072) //
|
|
|
|
// 1. Simple Count
|
|
var total int64
|
|
db.Table(model.TableNameUserInventory).
|
|
Where("user_id = ?", userID).
|
|
Count(&total)
|
|
fmt.Printf("Total Inventory Count (All Status): %d\n", total)
|
|
|
|
// 2. Count by Status 1 (Held)
|
|
var heldCount int64
|
|
db.Table(model.TableNameUserInventory).
|
|
Where("user_id = ?", userID).
|
|
Where("status = ?", 1).
|
|
Count(&heldCount)
|
|
fmt.Printf("Held Inventory Count (Status=1): %d\n", heldCount)
|
|
|
|
// 3. Count via Service Logic (ListInventoryWithProduct often filters by status=1)
|
|
// We simulate what the service might be doing.
|
|
// Check if there are products associated?
|
|
|
|
// Let's list some items to see what they look like
|
|
var items []model.UserInventory
|
|
db.Where("user_id = ?", userID).Limit(50).Find(&items)
|
|
fmt.Printf("Found %d items details:\n", len(items))
|
|
for _, item := range items {
|
|
fmt.Printf("ID: %d, ProductID: %d, OrderID: %d, Status: %d\n", item.ID, item.ProductID, item.OrderID, item.Status)
|
|
}
|
|
}
|