feat: complete login

This commit is contained in:
yanghao05
2025-04-15 21:20:04 +08:00
parent 45a0b6848a
commit ca08568e1a
23 changed files with 842 additions and 28 deletions

View File

@@ -227,3 +227,23 @@ func (m *usersModel) PostList(ctx context.Context, userId int64, pagination *req
Pagination: *pagination,
}, nil
}
// GetUserIDByOpenID
func (m *usersModel) GetUserByOpenID(ctx context.Context, openID string) (*model.Users, error) {
tbl := table.Users
stmt := tbl.
SELECT(tbl.AllColumns).
WHERE(
tbl.OpenID.EQ(String(openID)),
)
m.log.Infof("sql: %s", stmt.DebugSql())
var user model.Users
if err := stmt.QueryContext(ctx, db, &user); err != nil {
m.log.Errorf("error querying user by OpenID: %v", err)
return nil, err
}
return &user, nil
}