scan the QR code to log in on the WeChat public account

This commit is contained in:
landaiqing
2024-08-15 23:56:46 +08:00
parent 55759a33db
commit e8fbff7e7f
28 changed files with 1095 additions and 432 deletions

View File

@@ -0,0 +1,3 @@
package user_social_service
type UserSocialService struct{}

View File

@@ -0,0 +1,31 @@
package user_social_service
import (
"errors"
"gorm.io/gorm"
"schisandra-cloud-album/global"
"schisandra-cloud-album/model"
)
// AddUserSocial 添加社会化登录用户信息
func (UserSocialService) AddUserSocial(user model.ScaAuthUserSocial) error {
result := global.DB.Create(&user)
if result.Error != nil {
return result.Error
}
return nil
}
// QueryUserSocialByOpenID 根据openID查询用户信息
func (UserSocialService) QueryUserSocialByOpenID(openID string) (model.ScaAuthUserSocial, error) {
var user model.ScaAuthUserSocial
result := global.DB.Where("open_id = ? and deleted = 0", openID).First(&user)
if result.Error != nil {
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
return model.ScaAuthUserSocial{}, result.Error
}
return model.ScaAuthUserSocial{}, result.Error
}
return user, nil
}