diff --git a/modules/i3plus-core-apiservice/src/main/java/cn/estsh/i3plus/core/apiservice/controller/base/WhiteController.java b/modules/i3plus-core-apiservice/src/main/java/cn/estsh/i3plus/core/apiservice/controller/base/WhiteController.java index 423b839..3abe2f3 100644 --- a/modules/i3plus-core-apiservice/src/main/java/cn/estsh/i3plus/core/apiservice/controller/base/WhiteController.java +++ b/modules/i3plus-core-apiservice/src/main/java/cn/estsh/i3plus/core/apiservice/controller/base/WhiteController.java @@ -514,6 +514,39 @@ public class WhiteController extends CoreBaseController { } } + + /** + * 获取首页所需要的翻译资源 + * 目前只有三个 + * + * @param languageCode + * @return + */ + @GetMapping(value = "/find-indexpage-language-resource") + @ApiOperation(value = "获取首页所需的翻译资源") + public ResultBean findInexPageResourceByLanguageCode(String languageCode) { + try { + + ValidatorBean.checkNotNull(languageCode, "语言代码不能为空"); + if (sysLocaleLanguageService.getSysLocaleLanguageByCode(languageCode) == null) { + throw ImppExceptionBuilder.newInstance() + .setSystemID(CommonEnumUtil.SOFT_TYPE.CORE.getCode()) + .setErrorCode(ImppExceptionEnum.VARIFY_EXCEPTION.getCode()) + .setErrorDetail("语言不存在") + .build(); + } + Map indexMap = new HashMap<>(); + indexMap.put("记住密码", redisRes.getHash(CommonConstWords.REDIS_PREFIX_CACHE_LANGUAGE_WEB + ":" + languageCode + ":1", "记住密码")); + indexMap.put("自动登录", redisRes.getHash(CommonConstWords.REDIS_PREFIX_CACHE_LANGUAGE_WEB + ":" + languageCode + ":1", "自动登录")); + indexMap.put("登录", redisRes.getHash(CommonConstWords.REDIS_PREFIX_CACHE_LANGUAGE_WEB + ":" + languageCode + ":1", "登录")); + return ResultBean.success("操作成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode()).setResultMap(indexMap); + } catch (ImppBusiException busExcep) { + return ResultBean.fail(busExcep); + } catch (Exception e) { + return ImppExceptionBuilder.newInstance().buildExceptionResult(e); + } + } + @PostMapping(value = "/sys-locale-resource/query") @ApiOperation(value = "按条件查询资源") public ResultBean findSysLocaleResource(@RequestBody CloudPagerModel pagerModel) { @@ -873,7 +906,7 @@ public class WhiteController extends CoreBaseController { ValidatorBean.checkNotNull(newPwd, "新密码不能为空"); ValidatorBean.checkNotNull(loginName, "用户名不能为空"); - if (password.equals(newPwd)){ + if (password.equals(newPwd)) { return ResultBean.fail("新旧密码不能相同"); } @@ -1077,6 +1110,7 @@ public class WhiteController extends CoreBaseController { /** * 获取fastJosn配置并测试 + * * @return */ @GetMapping(value = "/fastjson") @@ -1088,53 +1122,53 @@ public class WhiteController extends CoreBaseController { model.setUserLoginName("test"); Map resultMap = new HashMap<>(); try { - String json = JSON.toJSONString(model, SerializerFeature.WriteClassName); - resultMap.put("json",json); + String json = JSON.toJSONString(model, SerializerFeature.WriteClassName); + resultMap.put("json", json); JSON.parse(json); - resultMap.put("parseredJosn",json); + resultMap.put("parseredJosn", json); - resultMap.put("config",JSON.toJSONString(config)); + resultMap.put("config", JSON.toJSONString(config)); } catch (Exception e) { e.printStackTrace(); - if (e.getCause() != null){ - resultMap.put("error",e.getCause().getMessage()); - }else { - resultMap.put("error",e.getMessage()); + if (e.getCause() != null) { + resultMap.put("error", e.getCause().getMessage()); + } else { + resultMap.put("error", e.getMessage()); } } - return ResultBean.success().setResultMap(resultMap); + return ResultBean.success().setResultMap(resultMap); } - private static final Long ACCESS_TOKEN_EXPIRE_TIME = 7080L; private static final String ACCESS_TOKEN_KEY = "ding_talk:access_token"; /** * 钉钉单聊机器人批量发送消息 + * * @param dingSendBatchRequestModel * @return */ @PostMapping(value = "/dingRobot/sendBatchRequestByUserLoginName") @ApiOperation(value = "根据登录用户名 钉钉单聊机器人批量发送消息", notes = "根据登录用户名 钉钉单聊机器人批量发送消息") - public ResultBean singleRobotsendBatchRequestByUserLoginName(@RequestBody DingSendBatchRequestModel dingSendBatchRequestModel ) { - if(ObjectUtils.isEmpty(dingSendBatchRequestModel)){ + public ResultBean singleRobotsendBatchRequestByUserLoginName(@RequestBody DingSendBatchRequestModel dingSendBatchRequestModel) { + if (ObjectUtils.isEmpty(dingSendBatchRequestModel)) { return ResultBean.fail("消息内容不能为空"); } - if(ObjectUtils.isEmpty(dingSendBatchRequestModel.getUserLoginNameList())){ + if (ObjectUtils.isEmpty(dingSendBatchRequestModel.getUserLoginNameList())) { return ResultBean.fail("登录用户名不能为空"); } - List userLoginNameList = dingSendBatchRequestModel.getUserLoginNameList(); + List userLoginNameList = dingSendBatchRequestModel.getUserLoginNameList(); userLoginNameList = userLoginNameList.stream().filter(StringUtils::isNotBlank).distinct().collect(Collectors.toList()); - if(ObjectUtils.isEmpty(userLoginNameList)){ + if (ObjectUtils.isEmpty(userLoginNameList)) { return ResultBean.fail("登录用户名不能为空"); } List userList = userService.findSysUserByLoginName(userLoginNameList); - if(ObjectUtils.isEmpty(userList)){ + if (ObjectUtils.isEmpty(userList)) { return ResultBean.fail("登录用户名没有对应的账号"); } - List phoneNumberList =userList.stream().map(SysUser::getUserPhone).filter(StringUtils::isNotBlank).distinct().collect(Collectors.toList()); - if(ObjectUtils.isEmpty(userList)){ + List phoneNumberList = userList.stream().map(SysUser::getUserPhone).filter(StringUtils::isNotBlank).distinct().collect(Collectors.toList()); + if (ObjectUtils.isEmpty(userList)) { return ResultBean.fail("登录用户名没有对应的手机号"); } dingSendBatchRequestModel.setPhoneNumberList(phoneNumberList); @@ -1145,16 +1179,18 @@ public class WhiteController extends CoreBaseController { /** * 批量发送的最大值 */ - private final int MAX_DINGROBOT_SEND_NUM = 1000; + private final int MAX_DINGROBOT_SEND_NUM = 1000; + /** * 钉钉单聊机器人批量发送消息 + * * @param dingSendBatchRequestModel * @return */ @PostMapping(value = "/dingRobot/sendBatchRequest") @ApiOperation(value = "根据手机号 钉钉单聊机器人批量发送消息", notes = "根据手机号 钉钉单聊机器人批量发送消息") - public ResultBean singleRobotsendBatchRequest(@RequestBody DingSendBatchRequestModel dingSendBatchRequestModel ) { - if(ObjectUtils.isEmpty(dingSendBatchRequestModel)){ + public ResultBean singleRobotsendBatchRequest(@RequestBody DingSendBatchRequestModel dingSendBatchRequestModel) { + if (ObjectUtils.isEmpty(dingSendBatchRequestModel)) { return ResultBean.fail("消息内容不能为空"); } List phoneNumberList = dingSendBatchRequestModel.getPhoneNumberList(); @@ -1188,8 +1224,8 @@ public class WhiteController extends CoreBaseController { ResultBean result = getDingUserIdByPhoneNumber(el, batchSendOTOHeaders.xAcsDingtalkAccessToken); if (result.isSuccess()) { userIdList.add((String) result.getResultObject()); - }else{ - LOGGER.info("手机号:{}没法获取的钉钉用户id",el); + } else { + LOGGER.info("手机号:{}没法获取的钉钉用户id", el); } }); @@ -1265,15 +1301,15 @@ public class WhiteController extends CoreBaseController { req.setMobile(phoneNumber); // req.setMobile("13298408382"); OapiV2UserGetbymobileResponse rsp = client.execute(req, accessToken); - if (ObjectUtils.isEmpty(rsp)||ObjectUtils.isEmpty(rsp.getResult()) || StringUtils.isBlank(rsp.getResult().getUserid())){ + if (ObjectUtils.isEmpty(rsp) || ObjectUtils.isEmpty(rsp.getResult()) || StringUtils.isBlank(rsp.getResult().getUserid())) { return ResultBean.fail("根据手机号无法获取用户id"); } return ResultBean.success("获取用户id成功").setResultObject(rsp.getResult().getUserid()); } catch (ApiException e) { - LOGGER.error("调用钉钉根据手机号获取用户id发生异常:",e); + LOGGER.error("调用钉钉根据手机号获取用户id发生异常:", e); return ImppExceptionBuilder.newInstance().buildExceptionResult(e); } catch (Exception e) { - LOGGER.error("调用钉钉根据手机号获取用户id发生异常:",e); + LOGGER.error("调用钉钉根据手机号获取用户id发生异常:", e); return ImppExceptionBuilder.newInstance().buildExceptionResult(e); } } @@ -1345,12 +1381,12 @@ public class WhiteController extends CoreBaseController { @GetMapping(value = "/query-user-by-name") @ApiOperation(value = "根据用户名或登录名查询") - public ResultBean queryUserByName(String userLoginName,String userName ,Pager pager) { + public ResultBean queryUserByName(String userLoginName, String userName, Pager pager) { try { if (ObjectUtils.isEmpty(pager)) { pager = Pager.defaultPager(); } - return ResultBean.success("操作成功").setListPager(sysUserService.findSysUserByName(userLoginName,userName,pager)).setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode()); + return ResultBean.success("操作成功").setListPager(sysUserService.findSysUserByName(userLoginName, userName, pager)).setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode()); } catch (ImppBusiException busExcep) { return ResultBean.fail(busExcep); } catch (Exception e) { diff --git a/modules/i3plus-core-apiservice/src/main/java/cn/estsh/i3plus/core/apiservice/controller/busi/SysLocaleResourceController.java b/modules/i3plus-core-apiservice/src/main/java/cn/estsh/i3plus/core/apiservice/controller/busi/SysLocaleResourceController.java index 9cc0849..756f74e 100644 --- a/modules/i3plus-core-apiservice/src/main/java/cn/estsh/i3plus/core/apiservice/controller/busi/SysLocaleResourceController.java +++ b/modules/i3plus-core-apiservice/src/main/java/cn/estsh/i3plus/core/apiservice/controller/busi/SysLocaleResourceController.java @@ -696,4 +696,35 @@ public class SysLocaleResourceController extends CoreBaseController { return ImppExceptionBuilder.newInstance().buildExceptionResult(e); } } + + @GetMapping(value = "/find-web-resource-by-language-code") + @ApiOperation(value = "根据语言代码查询web端翻译资源") + public ResultBean findSysLocaleResourceByLanguageCode(String languageCode) { + try { + startMultiService(); + + ValidatorBean.checkNotNull(languageCode, "语言代码不能为空"); + if (sysLocaleLanguageService.getSysLocaleLanguageByCode(languageCode) == null) { + throw ImppExceptionBuilder.newInstance() + .setSystemID(CommonEnumUtil.SOFT_TYPE.CORE.getCode()) + .setErrorCode(ImppExceptionEnum.VARIFY_EXCEPTION.getCode()) + .setErrorDetail("语言不存在") + .build(); + } + + // 从缓存获取语言信息 + Map resourceMap = + redisRes.getHashMap(CommonConstWords.REDIS_PREFIX_CACHE_LANGUAGE_WEB + ":" + languageCode); + if (resourceMap == null || resourceMap.size() == 0) { + systemInitService.putAndLoadSysLocaleLanguage(); + resourceMap = redisRes.getHashMap(CommonConstWords.REDIS_PREFIX_CACHE_LANGUAGE_WEB + ":" + languageCode); + } + + return ResultBean.success("操作成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode()).setResultMap(resourceMap); + } catch (ImppBusiException busExcep) { + return ResultBean.fail(busExcep); + } catch (Exception e) { + return ImppExceptionBuilder.newInstance().buildExceptionResult(e); + } + } }