mirror of
https://github.com/dromara/RuoYi-Vue-Plus.git
synced 2025-09-23 23:09:47 +08:00
add 新增 翻译模块 部门名称翻译
update 优化 部门业务增加缓存逻辑
This commit is contained in:
@ -10,16 +10,21 @@ public interface TransConstant {
|
||||
/**
|
||||
* 用户id转账号
|
||||
*/
|
||||
String USER_ID_TO_NAME = "userIdToName";
|
||||
String USER_ID_TO_NAME = "user_id_to_name";
|
||||
|
||||
/**
|
||||
* 部门id转名称
|
||||
*/
|
||||
String DEPT_ID_TO_NAME = "dept_id_to_name";
|
||||
|
||||
/**
|
||||
* 字典type转label
|
||||
*/
|
||||
String DICT_TYPE_TO_LABEL = "dictTypeToLabel";
|
||||
String DICT_TYPE_TO_LABEL = "dict_type_to_label";
|
||||
|
||||
/**
|
||||
* ossId转url
|
||||
*/
|
||||
String OSS_ID_TO_URL = "ossIdToUrl";
|
||||
String OSS_ID_TO_URL = "oss_id_to_url";
|
||||
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ public interface TranslationInterface {
|
||||
/**
|
||||
* 翻译
|
||||
*
|
||||
* @param key 需要被翻译的键
|
||||
* @param key 需要被翻译的键(不为空)
|
||||
* @return 返回键对应的值
|
||||
*/
|
||||
String translation(Object key, String other);
|
||||
|
@ -0,0 +1,30 @@
|
||||
package com.ruoyi.common.translation.core.impl;
|
||||
|
||||
import com.ruoyi.common.core.service.DeptService;
|
||||
import com.ruoyi.common.translation.annotation.TranslationType;
|
||||
import com.ruoyi.common.translation.constant.TransConstant;
|
||||
import com.ruoyi.common.translation.core.TranslationInterface;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 部门翻译实现
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@Component
|
||||
@AllArgsConstructor
|
||||
@TranslationType(type = TransConstant.DEPT_ID_TO_NAME)
|
||||
public class DeptNameTranslationImpl implements TranslationInterface {
|
||||
|
||||
private final DeptService deptService;
|
||||
|
||||
public String translation(Object key, String other) {
|
||||
if (key instanceof String ids) {
|
||||
return deptService.selectDeptNameByIds(ids);
|
||||
} else if (key instanceof Long id) {
|
||||
return deptService.selectDeptNameByIds(id.toString());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user