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

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")
@ApiOperation(value = "按条件查询资源")
public ResultBean findSysLocaleResource(@RequestBody CloudPagerModel<SysLocaleResource> 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")
@ -1089,52 +1123,52 @@ public class WhiteController extends CoreBaseController {
Map<String, Object> resultMap = new HashMap<>();
try {
String json = JSON.toJSONString(model, SerializerFeature.WriteClassName);
resultMap.put("json",json);
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);
}
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<String> 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<SysUser> userList = userService.findSysUserByLoginName(userLoginNameList);
if(ObjectUtils.isEmpty(userList)){
if (ObjectUtils.isEmpty(userList)) {
return ResultBean.fail("登录用户名没有对应的账号");
}
List<String> phoneNumberList =userList.stream().map(SysUser::getUserPhone).filter(StringUtils::isNotBlank).distinct().collect(Collectors.toList());
if(ObjectUtils.isEmpty(userList)){
List<String> phoneNumberList = userList.stream().map(SysUser::getUserPhone).filter(StringUtils::isNotBlank).distinct().collect(Collectors.toList());
if (ObjectUtils.isEmpty(userList)) {
return ResultBean.fail("登录用户名没有对应的手机号");
}
dingSendBatchRequestModel.setPhoneNumberList(phoneNumberList);
@ -1146,15 +1180,17 @@ public class WhiteController extends CoreBaseController {
*
*/
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<String> 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) {

@ -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<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