package cygx

import (
	"github.com/beego/beego/v2/client/orm"
	"time"
)

type CygxClptSession struct {
	SessionId       int `orm:"column(session_id);pk"`
	Mobile          string
	UserId          int
	AccessToken     string
	ExpireTime      time.Time
	CreateTime      time.Time
	LastUpdatedTime time.Time
	OpenId          string `description:"用户openid，最大长度：32"`
	UnionId         string `description:"用户unionid，最大长度：64"`
}

// 根据用户id字符串获取用户绑定时间 (查研观向与买方研选小程序)
func GetCygxClptSessionrByUserIdsMyfx(userIds string) (items []*CygxClptSession, err error) {
	o := orm.NewOrmUsingDB("hz_cygx")
	sql := `SELECT user_id,min(created_time) as create_time FROM cygx_clpt_session WHERE user_id in (` + userIds + `) group by user_id`
	_, err = o.Raw(sql).QueryRows(&items)
	return
}

type CygxMfyxWebSession struct {
	Mobile          string
	UserId          int
	AccessToken     string
	ExpireTime      time.Time
	CreateTime      time.Time
	LastUpdatedTime time.Time
	OpenId          string `description:"用户openid，最大长度：32"`
	UnionId         string `description:"用户unionid，最大长度：64"`
	SessionStatus   int    `description:"token状态，0正常，1被顶号"`
}

// 根据用户id字符串获取用户绑定时间 (买方研选网页版)
func GetCygxMfyxWebSessionByUserIdsMyfx(userIds string) (items []*CygxMfyxWebSession, err error) {
	o := orm.NewOrmUsingDB("hz_cygx")
	sql := `SELECT user_id,min(created_time) as create_time FROM cygx_mfyx_web_session WHERE user_id in (` + userIds + `) group by user_id`
	_, err = o.Raw(sql).QueryRows(&items)
	return
}
