动态form + ptl_pcn亮灯修改

yun-zuoyi
castle.zang 3 years ago
parent 6559511a76
commit 7dc0594ecd

@ -343,7 +343,8 @@ public class WhiteController extends CoreBaseController {
SysUser user = null; SysUser user = null;
List<SysMenu> menuList; List<SysMenu> menuList;
try { try {
OapiV2UserGetResponse dingTalkUserInfo = getDingTalkUserInfo(authCode); // OapiV2UserGetResponse dingTalkUserInfo = getDingTalkUserInfo(authCode);
OapiV2UserGetResponse dingTalkUserInfo = null;
String mobile = dingTalkUserInfo.getResult().getMobile(); String mobile = dingTalkUserInfo.getResult().getMobile();
if (StringUtils.isEmpty(mobile)) { if (StringUtils.isEmpty(mobile)) {
@ -362,54 +363,53 @@ public class WhiteController extends CoreBaseController {
return ResultBean.success("查询成功").setResultList(menuList); 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, // @RequestParam(required = false) String languageCode,
@RequestParam(required = false) String languageCode, // @RequestParam(required = false) String deviceId) {
@RequestParam(required = false) String deviceId) { // SysLoginModel loginModel = SysLoginModel.builder()
SysLoginModel loginModel = SysLoginModel.builder() // .dingTalkTmpAuthCode(dingTalkTmpAuthCode)
.dingTalkTmpAuthCode(dingTalkTmpAuthCode) // .languageCode(languageCode)
.languageCode(languageCode) // .deviceId(deviceId)
.deviceId(deviceId) // .loginStrategy(ImppEnumUtil.AUTH_LOGIN_STRATEGY.NAME.getCode()).build();
.loginStrategy(ImppEnumUtil.AUTH_LOGIN_STRATEGY.NAME.getCode()).build(); //
// String dingTalkUrl = RedisCacheTool.getSysConfigStrVal(PlatformConstWords.DINGTALK_URL);
String dingTalkUrl = RedisCacheTool.getSysConfigStrVal(PlatformConstWords.DINGTALK_URL); // String dingTalkAppKey = RedisCacheTool.getSysConfigStrVal(PlatformConstWords.DINGTALK_APP_KEY);
String dingTalkAppKey = RedisCacheTool.getSysConfigStrVal(PlatformConstWords.DINGTALK_APP_KEY); // String dingTalkAppSecret = RedisCacheTool.getSysConfigStrVal(PlatformConstWords.DINGTALK_APP_SECRET);
String dingTalkAppSecret = RedisCacheTool.getSysConfigStrVal(PlatformConstWords.DINGTALK_APP_SECRET); // String dingTalkWhiteList = RedisCacheTool.getSysConfigStrVal(PlatformConstWords.DINGTALK_WHITE_LIST);
String dingTalkWhiteList = RedisCacheTool.getSysConfigStrVal(PlatformConstWords.DINGTALK_WHITE_LIST); //
// if (StringUtils.isEmpty(dingTalkUrl) ||
if (StringUtils.isEmpty(dingTalkUrl) || // StringUtils.isEmpty(dingTalkAppKey) ||
StringUtils.isEmpty(dingTalkAppKey) || // StringUtils.isEmpty(dingTalkAppSecret) ||
StringUtils.isEmpty(dingTalkAppSecret) || // StringUtils.isEmpty(dingTalkWhiteList)) {
StringUtils.isEmpty(dingTalkWhiteList)) { // return ResultBean.fail("访问钉钉的系统参数缺失,请在平台的系统参数中进行配置");
return ResultBean.fail("访问钉钉的系统参数缺失,请在平台的系统参数中进行配置"); // }
} //
// Optional<OapiV2UserGetResponse> userInfo =
Optional<OapiV2UserGetResponse> userInfo = // dingTalkService.getUserInfo(dingTalkUrl, dingTalkAppKey, dingTalkAppSecret, loginModel.getDingTalkTmpAuthCode());
dingTalkService.getUserInfo(dingTalkUrl, dingTalkAppKey, dingTalkAppSecret, loginModel.getDingTalkTmpAuthCode()); // if (userInfo.isPresent()) {
if (userInfo.isPresent()) { // String mobile = userInfo.get().getResult().getMobile();
String mobile = userInfo.get().getResult().getMobile(); // if (StringUtils.isEmpty(mobile)) {
if (StringUtils.isEmpty(mobile)) { // return ResultBean.fail("用户并未在钉钉中设置手机号 或 钉钉接口权限不足无法获取到手机号");
return ResultBean.fail("用户并未在钉钉中设置手机号 或 钉钉接口权限不足无法获取到手机号"); // }
} // if (!Arrays.asList(dingTalkWhiteList.split(",")).contains(mobile)) {
if (!Arrays.asList(dingTalkWhiteList.split(",")).contains(mobile)) { // return ResultBean.fail("对指定手机号允许,权限不足,请联系管理员");
return ResultBean.fail("对指定手机号允许,权限不足,请联系管理员"); // }
} // SysUser sysUserByPhone = userService.getSysUserByPhone(mobile);
SysUser sysUserByPhone = userService.getSysUserByPhone(mobile); // if (sysUserByPhone == null) {
if (sysUserByPhone == null) { // return ResultBean.fail("未根据用户手机在平台中找到相应记录 钉钉获取的手机号为" + mobile);
return ResultBean.fail("未根据用户手机在平台中找到相应记录 钉钉获取的手机号为" + mobile); // }
} // loginModel.setLoginName(sysUserByPhone.getUserLoginName());
loginModel.setLoginName(sysUserByPhone.getUserLoginName()); // loginModel.setPhoneNumber(mobile);
loginModel.setPhoneNumber(mobile); // } else {
} else { // return ResultBean.fail("获取钉钉用户信息失败");
return ResultBean.fail("获取钉钉用户信息失败"); // }
} // String beanName = ImppEnumUtil.AUTH_LOGIN_STRATEGY.codeOfStrategyName(loginModel.getLoginStrategy());
String beanName = ImppEnumUtil.AUTH_LOGIN_STRATEGY.codeOfStrategyName(loginModel.getLoginStrategy()); // ISystemLoginStrategyService loginStrategyService = (ISystemLoginStrategyService) SpringContextsUtil.getBean(beanName);
ISystemLoginStrategyService loginStrategyService = (ISystemLoginStrategyService) SpringContextsUtil.getBean(beanName); //
// return loginByStrategy(request, loginModel, loginStrategyService.login());
return loginByStrategy(request, loginModel, loginStrategyService.login()); // }
}
@GetMapping(value = "/auth/login") @GetMapping(value = "/auth/login")
@ApiOperation(value = "登录", notes = "登录") @ApiOperation(value = "登录", notes = "登录")
@ -1169,6 +1169,24 @@ public class WhiteController extends CoreBaseController {
} }
// 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();
// }
private static final Long ACCESS_TOKEN_EXPIRE_TIME = 7080L; private static final Long ACCESS_TOKEN_EXPIRE_TIME = 7080L;
private static final String ACCESS_TOKEN_KEY = "ding_talk:access_token"; private static final String ACCESS_TOKEN_KEY = "ding_talk:access_token";
private static final String ACCESS_EMS_TOKEN_KEY = "ding_talk_ems:access_token"; private static final String ACCESS_EMS_TOKEN_KEY = "ding_talk_ems:access_token";
@ -1408,24 +1426,24 @@ public class WhiteController extends CoreBaseController {
return ""; return "";
} }
private OapiV2UserGetResponse getDingTalkUserInfo(String dingTalkTmpAuthCode) { // private OapiV2UserGetResponse getDingTalkUserInfo(String dingTalkTmpAuthCode) {
String dingTalkUrl = RedisCacheTool.getSysConfigStrVal(PlatformConstWords.DINGTALK_URL); // String dingTalkUrl = RedisCacheTool.getSysConfigStrVal(PlatformConstWords.DINGTALK_URL);
String dingTalkAppKey = RedisCacheTool.getSysConfigStrVal(PlatformConstWords.DINGTALK_APP_KEY); // String dingTalkAppKey = RedisCacheTool.getSysConfigStrVal(PlatformConstWords.DINGTALK_APP_KEY);
String dingTalkAppSecret = RedisCacheTool.getSysConfigStrVal(PlatformConstWords.DINGTALK_APP_SECRET); // String dingTalkAppSecret = RedisCacheTool.getSysConfigStrVal(PlatformConstWords.DINGTALK_APP_SECRET);
String dingTalkWhiteList = RedisCacheTool.getSysConfigStrVal(PlatformConstWords.DINGTALK_WHITE_LIST); // String dingTalkWhiteList = RedisCacheTool.getSysConfigStrVal(PlatformConstWords.DINGTALK_WHITE_LIST);
if (StringUtils.isEmpty(dingTalkUrl) || // if (StringUtils.isEmpty(dingTalkUrl) ||
StringUtils.isEmpty(dingTalkAppKey) || // StringUtils.isEmpty(dingTalkAppKey) ||
StringUtils.isEmpty(dingTalkAppSecret) || // StringUtils.isEmpty(dingTalkAppSecret) ||
StringUtils.isEmpty(dingTalkWhiteList)) { // StringUtils.isEmpty(dingTalkWhiteList)) {
throw ImppExceptionBuilder.newInstance().setErrorDetail("访问钉钉的系统参数缺失,请在平台的系统参数中进行配置").build(); // throw ImppExceptionBuilder.newInstance().setErrorDetail("访问钉钉的系统参数缺失,请在平台的系统参数中进行配置").build();
} // }
//
Optional<OapiV2UserGetResponse> userInfo = dingTalkService.getUserInfo(dingTalkUrl, dingTalkAppKey, dingTalkAppSecret, dingTalkTmpAuthCode); // Optional<OapiV2UserGetResponse> userInfo = dingTalkService.getUserInfo(dingTalkUrl, dingTalkAppKey, dingTalkAppSecret, dingTalkTmpAuthCode);
if (!userInfo.isPresent()) { // if (!userInfo.isPresent()) {
throw ImppExceptionBuilder.newInstance().setErrorDetail("访问钉钉的系统员工信息不存在").build(); // throw ImppExceptionBuilder.newInstance().setErrorDetail("访问钉钉的系统员工信息不存在").build();
} // }
return userInfo.get(); // return userInfo.get();
} // }
@GetMapping(value = "/query-user-by-name") @GetMapping(value = "/query-user-by-name")
@ApiOperation(value = "根据用户名或登录名查询") @ApiOperation(value = "根据用户名或登录名查询")

Loading…
Cancel
Save