附近小店
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

db_user_virtual_amount.go 1.1 KiB

2 miesięcy temu
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package db
  2. import (
  3. "applet/app/db/model"
  4. "applet/app/utils"
  5. "xorm.io/xorm"
  6. )
  7. func GetUserVirtualAmountOne(session *xorm.Session, uid int, coinId int) (*model.UserVirtualAmount, error) {
  8. var m model.UserVirtualAmount
  9. isExist, err := session.Table("user_virtual_amount").Where("uid = ? AND coin_id = ?", uid, coinId).Get(&m)
  10. if err != nil {
  11. return nil, err
  12. }
  13. if !isExist {
  14. return nil, nil
  15. }
  16. return &m, nil
  17. }
  18. func GetUserVirtualAmountOneEg(eg *xorm.Engine, uid int, coinId int) (*model.UserVirtualAmount, error) {
  19. var m model.UserVirtualAmount
  20. isExist, err := eg.Table("user_virtual_amount").Where("uid = ? AND coin_id = ?", uid, coinId).Get(&m)
  21. if err != nil {
  22. return nil, err
  23. }
  24. if !isExist {
  25. return nil, nil
  26. }
  27. return &m, nil
  28. }
  29. func GetUserVirtualAmountSum(eg *xorm.Engine, uid int) (string, error) {
  30. var m model.UserVirtualAmount
  31. sum, err := eg.Table("user_virtual_amount").Where("uid = ? ", uid).Sum(&m, "amount")
  32. if err != nil {
  33. return "0", err
  34. }
  35. return utils.Float64ToStr(sum), nil
  36. }
  37. /*func UserVirtualAmountUpdateWithSession(session *xorm.Session, m *model.UserVirtualAmount) bool {
  38. }*/