package db import ( "applet/app/db/model" "applet/app/utils/logx" "xorm.io/xorm" ) type UserFollowWxOfficialAccountDb struct { Db *xorm.Engine `json:"db"` } func (userFollowWxOfficialAccountDb *UserFollowWxOfficialAccountDb) Set() { // set方法 userFollowWxOfficialAccountDb.Db = Db } func (userFollowWxOfficialAccountDb *UserFollowWxOfficialAccountDb) GetUserFollowWxOfficialAccountByOpenId(openId string) (m *model.UserFollowWxOfficialAccount, err error) { m = new(model.UserFollowWxOfficialAccount) has, err := userFollowWxOfficialAccountDb.Db.Where("user_wx_open_id =?", openId).Get(m) if err != nil { return nil, logx.Error(err) } if has == false { return nil, nil } return m, nil }