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; + } + }