feat 微信登录

This commit is contained in:
2026-01-14 10:53:27 +08:00
parent 7aec1c2d4f
commit 3750ff1c34
12 changed files with 235 additions and 25 deletions

View File

@@ -82,3 +82,18 @@ func (d *UserDao) FindByPhone(phone string) (*model.User, error) {
}
return first, nil
}
// FindByWxUnionIDOrOpenID 通过微信unionID或openID查找用户
func (d *UserDao) FindByWxUnionIDOrOpenID(unionID, openID string) (*model.User, error) {
q := d.query.User.WithContext(d.ctx)
if unionID != "" {
q = q.Where(d.query.User.WxUnionID.Eq(unionID))
} else {
q = q.Where(d.query.User.WxMiniOpenID.Eq(openID))
}
first, err := q.First()
if err != nil {
return nil, err
}
return first, nil
}