1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- package models
- import (
- "time"
- "github.com/beego/beego/v2/client/orm"
- )
- type UserRecord struct {
- UserRecordId int `orm:"column(user_record_id);pk"`
- OpenId string `description:"用户openid,最大长度:32"`
- UnionId string `description:"用户unionid,最大长度:64"`
- Subscribe int `description:"是否关注"`
- SubscribeTime time.Time `description:""`
- NickName string `descritpion:"用户昵称,最大长度:32"`
- RealName string `descritpion:"用户实际名称,最大长度:32"`
- Sex int `descritpion:"普通用户性别,1为男性,2为女性"`
- Province string `description:"普通用户个人资料填写的省份,最大长度:30"`
- City string `description:"普通用户个人资料填写的城市,最大长度:30"`
- Country string `description:"国家,如中国为CN,最大长度:30"`
- Headimgurl string `description:"用户第三方(微信)头像,最大长度:512"`
- CreateTime time.Time `description:"创建时间,关系添加时间、用户授权时间"`
- SessionKey string `description:"微信小程序会话密钥,最大长度:255"`
- UserId int `description:"用户id"`
- }
- // 根据用户id和平台id获取用户关系
- func GetUserRecordByUserId(userId int) (item *UserRecord, err error) {
- sql := `SELECT * FROM user_record WHERE user_id=? `
- err = orm.NewOrm().Raw(sql, userId).QueryRow(&item)
- return
- }
- func GetUserRecordByUnionids(unionIds []string) (items []*UserRecord, err error) {
- if len(unionIds) == 0 {
- return
- }
- sql := `SELECT * FROM user_record WHERE union_id IN (`
- for range unionIds {
- sql += "?,"
- }
- sql = sql[:len(sql)-1]
- sql += `) `
- _, err = orm.NewOrm().Raw(sql, unionIds).QueryRows(&items)
- return
- }
|