1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- package models
- import (
- "github.com/beego/beego/v2/client/orm"
- "time"
- )
- type CygxUserRecord struct {
- UserRecordId int `orm:"column(user_record_id);pk"`
- OpenId string `description:"用户openid,最大长度:32"`
- UnionId string `description:"用户unionid,最大长度:64"`
- NickName 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:"创建时间,关系添加时间、用户授权时间"`
- }
- // 添加
- func AddCygxUserRecord(item *CygxUserRecord) (lastId int64, err error) {
- o := orm.NewOrm()
- lastId, err = o.Insert(item)
- return
- }
- // 获取数量
- func GetCygxUserRecordCount(openId string) (count int, err error) {
- o := orm.NewOrmUsingDB("weekly_report")
- sqlCount := ` SELECT COUNT(1) AS count FROM user_record WHERE open_id=? `
- err = o.Raw(sqlCount, openId).QueryRow(&count)
- return
- }
- // 修改
- func UpdateCygxUserRecord(item *CygxUserRecord) (err error) {
- o := orm.NewOrm()
- msql := ` UPDATE cygx_user_record SET nick_name = ?,sex=?,province=?,city=? ,country=? ,headimgurl=? WHERE open_id = ? `
- _, err = o.Raw(msql, item.NickName, item.Sex, item.Province, item.City, item.Country, item.Headimgurl, item.OpenId).Exec()
- return
- }
- // 修改
- func UpdateUserRecord(item *CygxUserRecord) (err error) {
- o := orm.NewOrmUsingDB("weekly_report")
- msql := ` UPDATE user_record SET nick_name = ?,sex=?,province=?,city=? ,country=? ,headimgurl=? WHERE union_id = ? AND create_platform = 4 `
- _, err = o.Raw(msql, item.NickName, item.Sex, item.Province, item.City, item.Country, item.Headimgurl, item.UnionId).Exec()
- return
- }
|