|
|
@ -313,6 +313,31 @@ public class WhiteController extends CoreBaseController {
|
|
|
|
return Optional.ofNullable(data);
|
|
|
|
return Optional.ofNullable(data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping(value = "/auth/dingtalk/auth")
|
|
|
|
|
|
|
|
@ApiOperation(value = "鉴权", notes = "鉴权")
|
|
|
|
|
|
|
|
public ResultBean authByPhoneNumber(@RequestParam String authCode) {
|
|
|
|
|
|
|
|
SysUser user = null;
|
|
|
|
|
|
|
|
List<SysMenu> menuList;
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
OapiV2UserGetResponse dingTalkUserInfo = getDingTalkUserInfo(authCode);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String mobile = dingTalkUserInfo.getResult().getMobile();
|
|
|
|
|
|
|
|
if (StringUtils.isEmpty(mobile)) {
|
|
|
|
|
|
|
|
return ResultBean.fail("用户并未在钉钉中设置手机号 或 钉钉接口权限不足无法获取到手机号");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
user = userService.getSysUserByPhone(mobile);
|
|
|
|
|
|
|
|
if (user == null) {
|
|
|
|
|
|
|
|
return ResultBean.fail("未根据用户手机在平台中找到相应记录 钉钉获取的手机号为" + mobile);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
userService.packUser(user);
|
|
|
|
|
|
|
|
menuList = user.getMenuList();
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
LOGGER.error("用户鉴权失败:{},e:{}", user, e.getMessage());
|
|
|
|
|
|
|
|
return ResultBean.fail("对指定手机号允许,权限不足,请联系管理员");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return ResultBean.success("查询成功").setResultList(menuList);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@GetMapping(value = "/auth/dingtalk/login")
|
|
|
|
@GetMapping(value = "/auth/dingtalk/login")
|
|
|
|
@ApiOperation(value = "登录", notes = "登录")
|
|
|
|
@ApiOperation(value = "登录", notes = "登录")
|
|
|
|
public ResultBean loginByPhoneNumber(HttpServletRequest request, String dingTalkTmpAuthCode,
|
|
|
|
public ResultBean loginByPhoneNumber(HttpServletRequest request, String dingTalkTmpAuthCode,
|
|
|
@ -991,4 +1016,23 @@ public class WhiteController extends CoreBaseController {
|
|
|
|
return sysUserController.updateBatchStatusByUserLoginNames(userLoginNames,status);
|
|
|
|
return sysUserController.updateBatchStatusByUserLoginNames(userLoginNames,status);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private OapiV2UserGetResponse getDingTalkUserInfo(String dingTalkTmpAuthCode) {
|
|
|
|
|
|
|
|
String dingTalkUrl = RedisCacheTool.getSysConfigStrVal(PlatformConstWords.DINGTALK_URL);
|
|
|
|
|
|
|
|
String dingTalkAppKey = RedisCacheTool.getSysConfigStrVal(PlatformConstWords.DINGTALK_APP_KEY);
|
|
|
|
|
|
|
|
String dingTalkAppSecret = RedisCacheTool.getSysConfigStrVal(PlatformConstWords.DINGTALK_APP_SECRET);
|
|
|
|
|
|
|
|
String dingTalkWhiteList = RedisCacheTool.getSysConfigStrVal(PlatformConstWords.DINGTALK_WHITE_LIST);
|
|
|
|
|
|
|
|
if (StringUtils.isEmpty(dingTalkUrl) ||
|
|
|
|
|
|
|
|
StringUtils.isEmpty(dingTalkAppKey) ||
|
|
|
|
|
|
|
|
StringUtils.isEmpty(dingTalkAppSecret) ||
|
|
|
|
|
|
|
|
StringUtils.isEmpty(dingTalkWhiteList)) {
|
|
|
|
|
|
|
|
throw ImppExceptionBuilder.newInstance().setErrorDetail("访问钉钉的系统参数缺失,请在平台的系统参数中进行配置").build();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Optional<OapiV2UserGetResponse> userInfo = dingTalkService.getUserInfo(dingTalkUrl, dingTalkAppKey, dingTalkAppSecret, dingTalkTmpAuthCode);
|
|
|
|
|
|
|
|
if (!userInfo.isPresent()) {
|
|
|
|
|
|
|
|
throw ImppExceptionBuilder.newInstance().setErrorDetail("访问钉钉的系统员工信息不存在").build();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return userInfo.get();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|