refactor: Translation接口函数修改为translate

This commit is contained in:
dhb52 2023-10-10 09:11:10 +08:00
parent 7544ae318c
commit 18c567e98e
6 changed files with 6 additions and 6 deletions

View File

@ -13,5 +13,5 @@ public interface TranslationInterface<T> {
* @param key 需要被翻译的键(不为空)
* @return 返回键对应的值
*/
T translation(Object key, String other);
T translate(Object key, String other);
}

View File

@ -46,7 +46,7 @@ public class TranslationHandler extends JsonSerializer<Object> implements Contex
gen.writeNull();
return;
}
Object result = trans.translation(value, translation.other());
Object result = trans.translate(value, translation.other());
gen.writeObject(result);
} else {
gen.writeObject(value);

View File

@ -20,7 +20,7 @@ public class DeptNameTranslationImpl implements TranslationInterface<String> {
private final DeptService deptService;
@Override
public String translation(Object key, String other) {
public String translate(Object key, String other) {
return deptService.selectDeptNameByIds(key.toString());
}
}

View File

@ -21,7 +21,7 @@ public class DictTypeTranslationImpl implements TranslationInterface<String> {
private final DictService dictService;
@Override
public String translation(Object key, String other) {
public String translate(Object key, String other) {
if (key instanceof String && StringUtils.isNotBlank(other)) {
return dictService.getDictLabel(other, key.toString());
}

View File

@ -20,7 +20,7 @@ public class OssUrlTranslationImpl implements TranslationInterface<String> {
private final OssService ossService;
@Override
public String translation(Object key, String other) {
public String translate(Object key, String other) {
return ossService.selectUrlByIds(key.toString());
}
}

View File

@ -20,7 +20,7 @@ public class UserNameTranslationImpl implements TranslationInterface<String> {
private final UserService userService;
@Override
public String translation(Object key, String other) {
public String translate(Object key, String other) {
if (key instanceof Long) {
return userService.selectUserNameById((Long) key);
}