新增只查询首页翻译资源的接口

yun-zuoyi
nies 3 years ago
parent 32ba3f92ff
commit 26dc6a070c

@ -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<String, Object> 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") @PostMapping(value = "/sys-locale-resource/query")
@ApiOperation(value = "按条件查询资源") @ApiOperation(value = "按条件查询资源")
public ResultBean findSysLocaleResource(@RequestBody CloudPagerModel<SysLocaleResource> pagerModel) { public ResultBean findSysLocaleResource(@RequestBody CloudPagerModel<SysLocaleResource> pagerModel) {
@ -873,7 +906,7 @@ public class WhiteController extends CoreBaseController {
ValidatorBean.checkNotNull(newPwd, "新密码不能为空"); ValidatorBean.checkNotNull(newPwd, "新密码不能为空");
ValidatorBean.checkNotNull(loginName, "用户名不能为空"); ValidatorBean.checkNotNull(loginName, "用户名不能为空");
if (password.equals(newPwd)){ if (password.equals(newPwd)) {
return ResultBean.fail("新旧密码不能相同"); return ResultBean.fail("新旧密码不能相同");
} }
@ -1077,6 +1110,7 @@ public class WhiteController extends CoreBaseController {
/** /**
* fastJosn * fastJosn
*
* @return * @return
*/ */
@GetMapping(value = "/fastjson") @GetMapping(value = "/fastjson")
@ -1088,53 +1122,53 @@ public class WhiteController extends CoreBaseController {
model.setUserLoginName("test"); model.setUserLoginName("test");
Map<String, Object> resultMap = new HashMap<>(); Map<String, Object> resultMap = new HashMap<>();
try { try {
String json = JSON.toJSONString(model, SerializerFeature.WriteClassName); String json = JSON.toJSONString(model, SerializerFeature.WriteClassName);
resultMap.put("json",json); resultMap.put("json", json);
JSON.parse(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) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
if (e.getCause() != null){ if (e.getCause() != null) {
resultMap.put("error",e.getCause().getMessage()); resultMap.put("error", e.getCause().getMessage());
}else { } else {
resultMap.put("error",e.getMessage()); 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 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";
/** /**
* *
*
* @param dingSendBatchRequestModel * @param dingSendBatchRequestModel
* @return * @return
*/ */
@PostMapping(value = "/dingRobot/sendBatchRequestByUserLoginName") @PostMapping(value = "/dingRobot/sendBatchRequestByUserLoginName")
@ApiOperation(value = "根据登录用户名 钉钉单聊机器人批量发送消息", notes = "根据登录用户名 钉钉单聊机器人批量发送消息") @ApiOperation(value = "根据登录用户名 钉钉单聊机器人批量发送消息", notes = "根据登录用户名 钉钉单聊机器人批量发送消息")
public ResultBean singleRobotsendBatchRequestByUserLoginName(@RequestBody DingSendBatchRequestModel dingSendBatchRequestModel ) { public ResultBean singleRobotsendBatchRequestByUserLoginName(@RequestBody DingSendBatchRequestModel dingSendBatchRequestModel) {
if(ObjectUtils.isEmpty(dingSendBatchRequestModel)){ if (ObjectUtils.isEmpty(dingSendBatchRequestModel)) {
return ResultBean.fail("消息内容不能为空"); return ResultBean.fail("消息内容不能为空");
} }
if(ObjectUtils.isEmpty(dingSendBatchRequestModel.getUserLoginNameList())){ if (ObjectUtils.isEmpty(dingSendBatchRequestModel.getUserLoginNameList())) {
return ResultBean.fail("登录用户名不能为空"); return ResultBean.fail("登录用户名不能为空");
} }
List<String> userLoginNameList = dingSendBatchRequestModel.getUserLoginNameList(); List<String> userLoginNameList = dingSendBatchRequestModel.getUserLoginNameList();
userLoginNameList = userLoginNameList.stream().filter(StringUtils::isNotBlank).distinct().collect(Collectors.toList()); userLoginNameList = userLoginNameList.stream().filter(StringUtils::isNotBlank).distinct().collect(Collectors.toList());
if(ObjectUtils.isEmpty(userLoginNameList)){ if (ObjectUtils.isEmpty(userLoginNameList)) {
return ResultBean.fail("登录用户名不能为空"); return ResultBean.fail("登录用户名不能为空");
} }
List<SysUser> userList = userService.findSysUserByLoginName(userLoginNameList); List<SysUser> userList = userService.findSysUserByLoginName(userLoginNameList);
if(ObjectUtils.isEmpty(userList)){ if (ObjectUtils.isEmpty(userList)) {
return ResultBean.fail("登录用户名没有对应的账号"); return ResultBean.fail("登录用户名没有对应的账号");
} }
List<String> phoneNumberList =userList.stream().map(SysUser::getUserPhone).filter(StringUtils::isNotBlank).distinct().collect(Collectors.toList()); List<String> phoneNumberList = userList.stream().map(SysUser::getUserPhone).filter(StringUtils::isNotBlank).distinct().collect(Collectors.toList());
if(ObjectUtils.isEmpty(userList)){ if (ObjectUtils.isEmpty(userList)) {
return ResultBean.fail("登录用户名没有对应的手机号"); return ResultBean.fail("登录用户名没有对应的手机号");
} }
dingSendBatchRequestModel.setPhoneNumberList(phoneNumberList); 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 * @param dingSendBatchRequestModel
* @return * @return
*/ */
@PostMapping(value = "/dingRobot/sendBatchRequest") @PostMapping(value = "/dingRobot/sendBatchRequest")
@ApiOperation(value = "根据手机号 钉钉单聊机器人批量发送消息", notes = "根据手机号 钉钉单聊机器人批量发送消息") @ApiOperation(value = "根据手机号 钉钉单聊机器人批量发送消息", notes = "根据手机号 钉钉单聊机器人批量发送消息")
public ResultBean singleRobotsendBatchRequest(@RequestBody DingSendBatchRequestModel dingSendBatchRequestModel ) { public ResultBean singleRobotsendBatchRequest(@RequestBody DingSendBatchRequestModel dingSendBatchRequestModel) {
if(ObjectUtils.isEmpty(dingSendBatchRequestModel)){ if (ObjectUtils.isEmpty(dingSendBatchRequestModel)) {
return ResultBean.fail("消息内容不能为空"); return ResultBean.fail("消息内容不能为空");
} }
List<String> phoneNumberList = dingSendBatchRequestModel.getPhoneNumberList(); List<String> phoneNumberList = dingSendBatchRequestModel.getPhoneNumberList();
@ -1188,8 +1224,8 @@ public class WhiteController extends CoreBaseController {
ResultBean result = getDingUserIdByPhoneNumber(el, batchSendOTOHeaders.xAcsDingtalkAccessToken); ResultBean result = getDingUserIdByPhoneNumber(el, batchSendOTOHeaders.xAcsDingtalkAccessToken);
if (result.isSuccess()) { if (result.isSuccess()) {
userIdList.add((String) result.getResultObject()); userIdList.add((String) result.getResultObject());
}else{ } else {
LOGGER.info("手机号:{}没法获取的钉钉用户id",el); LOGGER.info("手机号:{}没法获取的钉钉用户id", el);
} }
}); });
@ -1265,15 +1301,15 @@ public class WhiteController extends CoreBaseController {
req.setMobile(phoneNumber); req.setMobile(phoneNumber);
// req.setMobile("13298408382"); // req.setMobile("13298408382");
OapiV2UserGetbymobileResponse rsp = client.execute(req, accessToken); 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.fail("根据手机号无法获取用户id");
} }
return ResultBean.success("获取用户id成功").setResultObject(rsp.getResult().getUserid()); return ResultBean.success("获取用户id成功").setResultObject(rsp.getResult().getUserid());
} catch (ApiException e) { } catch (ApiException e) {
LOGGER.error("调用钉钉根据手机号获取用户id发生异常:",e); LOGGER.error("调用钉钉根据手机号获取用户id发生异常:", e);
return ImppExceptionBuilder.newInstance().buildExceptionResult(e); return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
} catch (Exception e) { } catch (Exception e) {
LOGGER.error("调用钉钉根据手机号获取用户id发生异常:",e); LOGGER.error("调用钉钉根据手机号获取用户id发生异常:", e);
return ImppExceptionBuilder.newInstance().buildExceptionResult(e); return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
} }
} }
@ -1345,12 +1381,12 @@ public class WhiteController extends CoreBaseController {
@GetMapping(value = "/query-user-by-name") @GetMapping(value = "/query-user-by-name")
@ApiOperation(value = "根据用户名或登录名查询") @ApiOperation(value = "根据用户名或登录名查询")
public ResultBean queryUserByName(String userLoginName,String userName ,Pager pager) { public ResultBean queryUserByName(String userLoginName, String userName, Pager pager) {
try { try {
if (ObjectUtils.isEmpty(pager)) { if (ObjectUtils.isEmpty(pager)) {
pager = Pager.defaultPager(); 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) { } catch (ImppBusiException busExcep) {
return ResultBean.fail(busExcep); return ResultBean.fail(busExcep);
} catch (Exception e) { } catch (Exception e) {

@ -696,4 +696,35 @@ public class SysLocaleResourceController extends CoreBaseController {
return ImppExceptionBuilder.newInstance().buildExceptionResult(e); 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<Object, Object> 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);
}
}
} }

Loading…
Cancel
Save