diff --git a/kernel-d-i18n/i18n-business/src/main/java/cn/stylefeng/roses/kernel/i18n/modular/controller/TranslationController.java b/kernel-d-i18n/i18n-business/src/main/java/cn/stylefeng/roses/kernel/i18n/modular/controller/TranslationController.java index db55fd9dc..5b9900458 100644 --- a/kernel-d-i18n/i18n-business/src/main/java/cn/stylefeng/roses/kernel/i18n/modular/controller/TranslationController.java +++ b/kernel-d-i18n/i18n-business/src/main/java/cn/stylefeng/roses/kernel/i18n/modular/controller/TranslationController.java @@ -85,7 +85,7 @@ public class TranslationController { */ @GetResource(name = "新增多语言配置", path = "/i18n/page") public ResponseData page(TranslationRequest translationRequest) { - PageResult page = this.translationService.getPage(translationRequest); + PageResult page = this.translationService.findPage(translationRequest); return new SuccessResponseData(page); } diff --git a/kernel-d-i18n/i18n-business/src/main/java/cn/stylefeng/roses/kernel/i18n/modular/service/TranslationService.java b/kernel-d-i18n/i18n-business/src/main/java/cn/stylefeng/roses/kernel/i18n/modular/service/TranslationService.java index 9e785ee0c..407c42850 100644 --- a/kernel-d-i18n/i18n-business/src/main/java/cn/stylefeng/roses/kernel/i18n/modular/service/TranslationService.java +++ b/kernel-d-i18n/i18n-business/src/main/java/cn/stylefeng/roses/kernel/i18n/modular/service/TranslationService.java @@ -52,15 +52,6 @@ public interface TranslationService extends IService, TranslationPe */ Translation detail(TranslationRequest translationRequest); - /** - * 查询-详情-按实体对象 - * - * @param translationRequest 参数对象 - * @author chenjinlong - * @date 2021/1/26 12:52 - */ - Translation detailBy(TranslationRequest translationRequest); - /** * 查询-列表-按实体对象 * @@ -68,7 +59,7 @@ public interface TranslationService extends IService, TranslationPe * @author chenjinlong * @date 2021/1/26 12:52 */ - List listBy(TranslationRequest translationRequest); + List findList(TranslationRequest translationRequest); /** * 查询-列表-分页-按实体对象 @@ -77,7 +68,6 @@ public interface TranslationService extends IService, TranslationPe * @author chenjinlong * @date 2021/1/26 12:52 */ - PageResult getPage(TranslationRequest translationRequest); - + PageResult findPage(TranslationRequest translationRequest); } diff --git a/kernel-d-i18n/i18n-business/src/main/java/cn/stylefeng/roses/kernel/i18n/modular/service/impl/TranslationServiceImpl.java b/kernel-d-i18n/i18n-business/src/main/java/cn/stylefeng/roses/kernel/i18n/modular/service/impl/TranslationServiceImpl.java index aae8a1359..c8a9f113f 100644 --- a/kernel-d-i18n/i18n-business/src/main/java/cn/stylefeng/roses/kernel/i18n/modular/service/impl/TranslationServiceImpl.java +++ b/kernel-d-i18n/i18n-business/src/main/java/cn/stylefeng/roses/kernel/i18n/modular/service/impl/TranslationServiceImpl.java @@ -37,50 +37,45 @@ public class TranslationServiceImpl extends ServiceImpl queryWrapper = this.createWrapper(translationRequest); + return this.getOne(queryWrapper, false); } @Override - public Translation detailBy(TranslationRequest translationRequest) { - List list = this.listBy(translationRequest); - if (list.isEmpty()) { - return null; - } - return list.get(0); - } - - @Override - public List listBy(TranslationRequest translationRequest) { + public List findList(TranslationRequest translationRequest) { LambdaQueryWrapper queryWrapper = this.createWrapper(translationRequest); return this.list(queryWrapper); } @Override - public PageResult getPage(TranslationRequest translationRequest) { + public PageResult findPage(TranslationRequest translationRequest) { LambdaQueryWrapper wrapper = createWrapper(translationRequest); Page page = this.page(PageFactory.defaultPage(), wrapper); return PageResultFactory.createPageResult(page); @@ -101,12 +96,10 @@ public class TranslationServiceImpl extends ServiceImpl createWrapper(TranslationRequest translationRequest) { LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + Long tranId = translationRequest.getTranId(); String tranCode = translationRequest.getTranCode(); String tranName = translationRequest.getTranName(); String tranLanguageCode = translationRequest.getTranLanguageCode(); + // SQL条件拼接 + queryWrapper.eq(ObjectUtil.isNotEmpty(tranId), Translation::getTranId, tranId); queryWrapper.like(ObjectUtil.isNotEmpty(tranCode), Translation::getTranCode, tranCode); queryWrapper.like(ObjectUtil.isNotEmpty(tranName), Translation::getTranName, tranName); queryWrapper.eq(ObjectUtil.isNotEmpty(tranLanguageCode), Translation::getTranLanguageCode, tranLanguageCode); - // 排序 + + // 按翻译编码倒序排列 queryWrapper.orderByDesc(Translation::getTranCode); return queryWrapper; } - /** - * 更新对应常量 + * 更新翻译的缓存 * - * @param translation * @author chenjinlong * @date 2021/1/26 13:45 */ private void saveContext(Translation translation) { + TranslationEnum translationEnum = TranslationEnum.getValue(translation.getTranLanguageCode()); + + // 没有对应的语种,不添加到context + if (translationEnum == null) { + return; + } + TranslationDict translationDict = TranslationDictFactory.createTranslationDict(translationEnum, translation); TranslationContext.me().addTranslationDict(translationDict); }