|
|
|
@ -4,15 +4,13 @@ import cn.estsh.i3plus.core.api.iservice.base.ISynchronizedService;
|
|
|
|
|
import cn.estsh.i3plus.core.api.iservice.base.ISystemInitService;
|
|
|
|
|
import cn.estsh.i3plus.core.api.iservice.base.ISystemLoginStrategyService;
|
|
|
|
|
import cn.estsh.i3plus.core.api.iservice.busi.*;
|
|
|
|
|
import cn.estsh.i3plus.core.api.iservice.dto.SysMenuDTO;
|
|
|
|
|
import cn.estsh.i3plus.core.apiservice.controller.busi.*;
|
|
|
|
|
import cn.estsh.i3plus.core.apiservice.util.MailUtil;
|
|
|
|
|
import cn.estsh.i3plus.core.apiservice.util.SysUserPasswordUtil;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.exception.ImppExceptionEnum;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.tool.JsonUtilTool;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.tool.ServletRequestTool;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.tool.StringTool;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.tool.TimeTool;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.tool.*;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.util.CommonConstWords;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.util.PlatformConstWords;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.annotation.AnnoIgnoreLog;
|
|
|
|
@ -24,6 +22,7 @@ import cn.estsh.i3plus.pojo.base.common.Pager;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.ImppEnumUtil;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.ResourceEnumUtil;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.util.BeanMapUtils;
|
|
|
|
|
import cn.estsh.i3plus.pojo.model.common.CloudPagerModel;
|
|
|
|
|
import cn.estsh.i3plus.pojo.model.common.ImppEmail;
|
|
|
|
|
import cn.estsh.i3plus.pojo.model.common.ImppSmsContent;
|
|
|
|
@ -62,12 +61,14 @@ import com.google.common.cache.CacheBuilder;
|
|
|
|
|
import com.taobao.api.ApiException;
|
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
import jodd.bean.BeanUtil;
|
|
|
|
|
import jodd.util.StringUtil;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.apache.shiro.authc.*;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.util.ObjectUtils;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
@ -169,6 +170,9 @@ public class WhiteController extends CoreBaseController {
|
|
|
|
|
@Autowired
|
|
|
|
|
private SysFileController sysFileController;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private ICoreMemTreeService memTreeService;
|
|
|
|
|
|
|
|
|
|
private Cache<String, Integer> unsavedLocaleResSwitch = CacheBuilder.newBuilder()
|
|
|
|
|
.maximumSize(1)
|
|
|
|
|
.expireAfterWrite(1, TimeUnit.MINUTES)
|
|
|
|
@ -191,6 +195,7 @@ public class WhiteController extends CoreBaseController {
|
|
|
|
|
@ApiOperation(value = "查询可用语言", notes = "查询可用语言")
|
|
|
|
|
public ResultBean getSystemInfo() {
|
|
|
|
|
try {
|
|
|
|
|
LOGGER.info("调用了/system-info");
|
|
|
|
|
return ResultBean.success("操作成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode()).setResultList(configService.findSystemInfoConfig());
|
|
|
|
|
} catch (ImppBusiException busExcep) {
|
|
|
|
|
return ResultBean.fail(busExcep);
|
|
|
|
@ -1328,6 +1333,7 @@ public class WhiteController extends CoreBaseController {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取accessToken
|
|
|
|
|
*
|
|
|
|
@ -1373,7 +1379,6 @@ public class WhiteController extends CoreBaseController {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private OapiV2UserGetResponse getDingTalkUserInfo(String dingTalkTmpAuthCode) {
|
|
|
|
|
String dingTalkUrl = RedisCacheTool.getSysConfigStrVal(PlatformConstWords.DINGTALK_URL);
|
|
|
|
|
String dingTalkAppKey = RedisCacheTool.getSysConfigStrVal(PlatformConstWords.DINGTALK_APP_KEY);
|
|
|
|
@ -1407,4 +1412,92 @@ public class WhiteController extends CoreBaseController {
|
|
|
|
|
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取登录用户功能权限信息
|
|
|
|
|
*
|
|
|
|
|
* @param dingTalkTmpAuthCode
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@GetMapping(value = "/find-menu-list")
|
|
|
|
|
@ApiOperation(value = "获取登录用户功能权限信息", notes = "获取首页权限信息")
|
|
|
|
|
public ResultBean findHomeList(HttpServletRequest request,@RequestParam String dingTalkTmpAuthCode, @RequestParam(required = false)String mobile) {
|
|
|
|
|
try {
|
|
|
|
|
if (Objects.isNull(dingTalkTmpAuthCode)) {
|
|
|
|
|
return ResultBean.fail("操作失败").setCode(ResourceEnumUtil.MESSAGE.FAIL.getCode()).setErrorMsg("授权码不能为空");
|
|
|
|
|
}
|
|
|
|
|
// 根据dingTalkTmpAuthCode 获取 平台的用户信息
|
|
|
|
|
SysUser sysUser = getUserInfo(dingTalkTmpAuthCode);
|
|
|
|
|
if (sysUser == null && !Objects.isNull(mobile)) {
|
|
|
|
|
LOGGER.info("code未查询到用默认");
|
|
|
|
|
sysUser = userService.getSysUserByPhone(mobile);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(sysUser == null) {
|
|
|
|
|
return ResultBean.fail("操作失败").setCode(ResourceEnumUtil.MESSAGE.FAIL.getCode()).setErrorMsg("用户信息不存在");
|
|
|
|
|
}
|
|
|
|
|
Long startTime = System.currentTimeMillis();
|
|
|
|
|
List<SysMenu> menuList = memTreeService.packTreeDingSysMenuByUserId(sysUser.getId());
|
|
|
|
|
Long menuSelectTime = System.currentTimeMillis();
|
|
|
|
|
LOGGER.info("第一段耗时:{}", menuSelectTime - startTime);
|
|
|
|
|
List<SysMenu> syslist = memTreeService.packTreeSysMenuByParentIdAndMenuType(menuList, CommonConstWords.SYSTEM_MENU_ROOT_ID, CommonEnumUtil.METHOD_LEVEL.PLUGIN.getValue());
|
|
|
|
|
LOGGER.info("第二段耗时:{}", System.currentTimeMillis() - menuSelectTime);
|
|
|
|
|
|
|
|
|
|
List<SysMenuDTO> resList = memTreeService.packTreeToDto(syslist);
|
|
|
|
|
|
|
|
|
|
if (resList != null && resList.size() > 0) {
|
|
|
|
|
// 翻译第一级
|
|
|
|
|
resList.forEach(menu -> menu.setName(LocaleUtils.getLocaleRes("MENU_" + menu.getName())));
|
|
|
|
|
// 内存排序 Sort 降序 code 升序
|
|
|
|
|
resList.sort(Comparator.comparing(SysMenuDTO::getMenuSort).reversed().thenComparing(SysMenuDTO::getMenuCode));
|
|
|
|
|
return ResultBean.success("操作成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode()).setResultList(resList);
|
|
|
|
|
} else {
|
|
|
|
|
return ResultBean.fail("操作失败").setCode(ResourceEnumUtil.MESSAGE.FAIL.getCode()).setErrorMsg("菜单信息不存在");
|
|
|
|
|
}
|
|
|
|
|
} catch (ImppBusiException busExcep) {
|
|
|
|
|
return ResultBean.fail(busExcep);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* 获取用户信息
|
|
|
|
|
* getUserInfo
|
|
|
|
|
* @param dingTalkTmpAuthCode
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private SysUser getUserInfo(String dingTalkTmpAuthCode) {
|
|
|
|
|
|
|
|
|
|
SysUser sysUser = null;
|
|
|
|
|
|
|
|
|
|
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)) {
|
|
|
|
|
//todo errorcode 需要修改
|
|
|
|
|
ImppExceptionBuilder.newInstance().setErrorCode("0000431").setErrorDetail("访问钉钉的系统参数缺失,请在平台的系统参数中进行配置");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
Optional<OapiV2UserGetResponse> userInfo =
|
|
|
|
|
dingTalkService.getUserInfo(dingTalkUrl, dingTalkAppKey, dingTalkAppSecret, dingTalkTmpAuthCode);
|
|
|
|
|
if (userInfo.isPresent()) {
|
|
|
|
|
String mobile = userInfo.get().getResult().getMobile();
|
|
|
|
|
if (StringUtils.isEmpty(mobile)) {
|
|
|
|
|
ImppExceptionBuilder.newInstance().setErrorCode("0000431").setErrorDetail("用户并未在钉钉中设置手机号 或 钉钉接口权限不足无法获取到手机号");
|
|
|
|
|
}
|
|
|
|
|
if (!Arrays.asList(dingTalkWhiteList.split(",")).contains(mobile)) {
|
|
|
|
|
ImppExceptionBuilder.newInstance().setErrorCode("0000431").setErrorDetail("对指定手机号允许,权限不足,请联系管理员");
|
|
|
|
|
}
|
|
|
|
|
sysUser = userService.getSysUserByPhone(mobile);
|
|
|
|
|
if (sysUser == null) {
|
|
|
|
|
ImppExceptionBuilder.newInstance().setErrorCode("0000431").setErrorDetail("未根据用户手机在平台中找到相应记录 钉钉获取的手机号为\" + mobile");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return sysUser;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|