| | |
| | | package com.zhitan.web.controller.system; |
| | | |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | import javax.annotation.Resource; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import cn.hutool.core.codec.Base64; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import com.zhitan.common.utils.SocialUtils; |
| | | import me.zhyd.oauth.request.AuthRequest; |
| | | import me.zhyd.oauth.utils.AuthStateUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import com.zhitan.common.constant.Constants; |
| | | import com.zhitan.common.core.domain.AjaxResult; |
| | | import com.zhitan.common.core.domain.entity.SysMenu; |
| | |
| | | { |
| | | AjaxResult ajax = AjaxResult.success(); |
| | | // 生成令牌 |
| | | String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(), |
| | | String token = ""; |
| | | if (loginBody.getGrantType() != null && !"".equals(loginBody.getGrantType())) { |
| | | token = loginService.loginByCode(loginBody.getSocialCode(), loginBody.getSocialState()); |
| | | } else { |
| | | token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(), |
| | | loginBody.getUuid()); |
| | | } |
| | | ajax.put(Constants.TOKEN, token); |
| | | return ajax; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取用户信息 |
| | |
| | | List<SysMenu> menus = menuService.selectMenuTreeByUserId(userId); |
| | | return AjaxResult.success(menuService.buildMenus(menus)); |
| | | } |
| | | /** |
| | | * 获取跳转URL |
| | | * |
| | | * @return 结果 |
| | | */ |
| | | @GetMapping("/binding") |
| | | public AjaxResult authBinding() { |
| | | |
| | | AuthRequest authRequest = SocialUtils.getAuthKeyloakRequest(); |
| | | String authorizeUrl = authRequest.authorize(Base64.encode(AuthStateUtils.createState(), StandardCharsets.UTF_8)); |
| | | return AjaxResult.success("操作成功", authorizeUrl); |
| | | } |
| | | |
| | | } |