guandan.go 1013 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package model
  2. import (
  3. "active/internal/model/goldbrick"
  4. "git.jiaxianghudong.com/webs/pkg/xgorm"
  5. "gorm.io/gorm/clause"
  6. )
  7. type GdUserInfo struct {
  8. Id int64 `json:"-"`
  9. UserId int64 `json:"user_id"`
  10. GameId int64 `json:"game_id"`
  11. RealName string `json:"real_name"`
  12. IdCard string `json:"id_card"`
  13. Address string `json:"address"`
  14. Phone string `json:"phone"`
  15. EnrollType string `json:"enroll_type"`
  16. CreateTime string `json:"-"`
  17. }
  18. func (GdUserInfo) TableName() string {
  19. return "gd_user_info"
  20. }
  21. func (this *GdUserInfo) Save() error {
  22. db := xgorm.NewConn(goldbrick.GoldBrickGorm)
  23. db.Clauses(clause.OnConflict{
  24. Columns: []clause.Column{{Name: "user_id"}, {Name: "game_id"}},
  25. UpdateAll: true,
  26. }).Create(this)
  27. return db.Save(this).Error
  28. }
  29. func (this *GdUserInfo) One() error {
  30. gameID := this.GameId
  31. userId := this.UserId
  32. this.Id = 0
  33. db := xgorm.NewConn(goldbrick.GoldBrickGorm)
  34. return db.Where("user_id = ? and game_id = ?", userId, gameID).First(this).Error
  35. }