package model import ( "active/internal/model/goldbrick" "git.jiaxianghudong.com/webs/pkg/xgorm" "gorm.io/gorm/clause" ) type GdUserInfo struct { Id int64 `json:"-"` UserId int64 `json:"user_id"` GameId int64 `json:"game_id"` RealName string `json:"real_name"` IdCard string `json:"id_card"` Address string `json:"address"` Phone string `json:"phone"` EnrollType string `json:"enroll_type"` CreateTime string `json:"-"` } func (GdUserInfo) TableName() string { return "gd_user_info" } func (this *GdUserInfo) Save() error { db := xgorm.NewConn(goldbrick.GoldBrickGorm) db.Clauses(clause.OnConflict{ Columns: []clause.Column{{Name: "user_id"}, {Name: "game_id"}}, UpdateAll: true, }).Create(this) return db.Save(this).Error } func (this *GdUserInfo) One() error { gameID := this.GameId userId := this.UserId this.Id = 0 db := xgorm.NewConn(goldbrick.GoldBrickGorm) return db.Where("user_id = ? and game_id = ?", userId, gameID).First(this).Error }