1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- package user_record
- import "hongze/hongze_yb/global"
- // Update 更新对应字段数据
- func (userRecord *UserRecord) Update(updateCols []string) (err error) {
- err = global.DEFAULT_MYSQL.Model(userRecord).Select(updateCols).Updates(*userRecord).Error
- return
- }
- // ModifyUserRecordInfo 修改用户微信信息
- func (userRecord *UserRecord) ModifyUserRecordInfo(nickName, headimgUrl, city, province, country string, sex int64) (err error) {
- userRecord.NickName = nickName
- userRecord.Headimgurl = headimgUrl
- userRecord.City = city
- userRecord.Province = province
- userRecord.Country = country
- userRecord.Sex = sex
- var updateCols = []string{"NickName", "Headimgurl", "City", "Province", "Country", "Sex"}
- err = userRecord.Update(updateCols)
- return
- }
- // UnBindUserRecordByOpenid 解除绑定用户关系
- func (userRecord *UserRecord) UnBindUserRecordByOpenid() (err error) {
- userRecord.UserID = 0
- userRecord.BindAccount = ""
- var updateCols = []string{"UserID", "BindAccount"}
- err = userRecord.Update(updateCols)
- return
- }
- // UnBindUserRecordByOpenid 根据openid解除绑定用户关系
- func UnBindUserRecordByOpenid(openId string) (err error) {
- err = global.DEFAULT_MYSQL.Model(UserRecord{}).Select("UserID", "BindAccount").Where("open_id = ? ", openId).Updates(UserRecord{
- UserID: 0,
- BindAccount: "",
- }).Error
- return
- }
- // ModifySessionKeyByOpenid 根据openid更新sessionKey
- func ModifySessionKeyByOpenid(openId, sessionKey string) (err error) {
- err = global.DEFAULT_MYSQL.Model(UserRecord{}).Select("SessionKey").Where("open_id = ? ", openId).Updates(UserRecord{
- SessionKey: sessionKey,
- }).Error
- return
- }
- // UnBindUserRecordByUnionId 根据unionId和平台信息解除绑定用户关系
- func UnBindUserRecordByUnionId(unionId string, platform int) (err error) {
- err = global.DEFAULT_MYSQL.Model(UserRecord{}).Select("UserID", "BindAccount").Where("union_id = ? AND create_platform = ?", unionId, platform).Updates(UserRecord{
- UserID: 0,
- BindAccount: "",
- }).Error
- return
- }
- // ModifyUserIdByUnionId 根据unionId更改user_id
- func ModifyUserIdByUnionId(unionId string, userId int) (err error) {
- err = global.DEFAULT_MYSQL.Model(UserRecord{}).Select("UserID", "BindAccount").Where("union_id = ? AND user_id = 0", unionId).Updates(UserRecord{
- UserID: userId,
- }).Error
- return
- }
|