From 9c79f5dfd64f19205c37650723e0b393a3e4c7cf Mon Sep 17 00:00:00 2001 From: Liyanjun Date: Sat, 1 Jul 2023 13:49:39 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=9A=E7=94=A8=E8=8E=B7=E5=8F=96=E4=B8=AD?= =?UTF-8?q?=E6=96=87=E6=8B=BC=E9=9F=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dict/modular/controller/DictController.java | 11 +++++++++++ .../kernel/dict/modular/service/DictService.java | 8 ++++++++ .../dict/modular/service/impl/DictServiceImpl.java | 8 ++++++++ 3 files changed, 27 insertions(+) diff --git a/kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/controller/DictController.java b/kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/controller/DictController.java index b7b4f9bf1..e31297206 100644 --- a/kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/controller/DictController.java +++ b/kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/controller/DictController.java @@ -144,4 +144,15 @@ public class DictController { return new SuccessResponseData<>(); } + /** + * 通用获取中文拼音 + *

+ * + * @author liyanjun + * @since 2023/7/01 10:31 + */ + @GetResource(name = "通用获取中文拼音", path = "/common/getPinyin") + public ResponseData getPinyin(String name) { + return new SuccessResponseData<>( this.dictService.getPinyin(name)); + } } diff --git a/kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/service/DictService.java b/kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/service/DictService.java index 19732c0a4..aceff1980 100644 --- a/kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/service/DictService.java +++ b/kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/service/DictService.java @@ -111,4 +111,12 @@ public interface DictService extends IService, DictApi { */ void updateDictTree(DictRequest dictRequest); + /** + * 通用获取中文拼音 + *

+ * + * @author liyanjun + * @since 2023/7/01 10:31 + */ + String getPinyin(String name) ; } diff --git a/kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/service/impl/DictServiceImpl.java b/kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/service/impl/DictServiceImpl.java index bc2ab779f..b5c1df86b 100644 --- a/kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/service/impl/DictServiceImpl.java +++ b/kernel-s-dict/dict-business/src/main/java/cn/stylefeng/roses/kernel/dict/modular/service/impl/DictServiceImpl.java @@ -435,4 +435,12 @@ public class DictServiceImpl extends ServiceImpl implements } } + @Override + public String getPinyin(String name) { + if(ObjectUtil.isNotEmpty(name)) { + name=pinYinApi.parseEveryPinyinFirstLetter(name); + } + return name; + } + }