Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
C
chnmuseum-party
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
liqin
chnmuseum-party
Commits
807713a4
Commit
807713a4
authored
Jun 01, 2021
by
nie'hong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
拼音工具类识别多音字正确拼音
parent
6410a400
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
15 deletions
+28
-15
PinYinUtil.java
src/main/java/cn/chnmuseum/party/common/util/PinYinUtil.java
+25
-12
RoleController.java
...ava/cn/chnmuseum/party/web/controller/RoleController.java
+3
-3
No files found.
src/main/java/cn/chnmuseum/party/common/util/PinYinUtil.java
View file @
807713a4
...
...
@@ -8,6 +8,8 @@ import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
import
net.sourceforge.pinyin4j.format.HanyuPinyinToneType
;
import
net.sourceforge.pinyin4j.format.HanyuPinyinVCharType
;
import
net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination
;
import
org.apache.commons.lang3.RegExUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
java.util.ArrayList
;
...
...
@@ -27,7 +29,7 @@ public class PinYinUtil {
* @return 中文对应的拼音
*/
public
static
String
getPinYin
(
String
chinese
,
Boolean
firstWord
,
Boolean
appendNonChinese
)
{
//
6月1日修改前
/*
6月1日修改前
//汉语拼音输出格式
HanyuPinyinOutputFormat pinyinOutputFormat = new HanyuPinyinOutputFormat();
//大小写设置 大写
...
...
@@ -63,19 +65,30 @@ public class PinYinUtil {
}
}
}
return
stringBuilder
.
toString
();
return stringBuilder.toString();
*/
// 6月1日修改后
// try {
// Pinyin pinyin = new Pinyin();
// String test = pinyin.translateWithSepNoMark(chinese);
// System.out.println(test);
// } catch (PinyinException e) {
// e.printStackTrace();
// }
// return null;
String
pinyinString
=
new
String
();
try
{
// 是否需要将英文字符和拼音拼接
if
(
appendNonChinese
)
{
chinese
=
RegExUtils
.
replaceAll
(
chinese
,
"[a-zA-Z]"
,
""
);
}
Pinyin
pinyin
=
new
Pinyin
();
if
(
firstWord
)
{
// 拼音首字母
pinyinString
=
pinyin
.
translateFirstChar
(
chinese
);
}
else
{
// 拼音全拼
String
withSepNoMark
=
pinyin
.
translateWithSepNoMark
(
chinese
,
""
);
// 将字符串中的'ü'替换为'v’
pinyinString
=
withSepNoMark
.
replace
(
"ü"
,
"v"
);
}
}
catch
(
PinyinException
e
)
{
e
.
printStackTrace
();
}
// 转为大写
return
pinyinString
.
toUpperCase
();
}
//
}
src/main/java/cn/chnmuseum/party/web/controller/RoleController.java
View file @
807713a4
...
...
@@ -652,9 +652,9 @@ public class RoleController extends BaseController {
ew
.
eq
(
"is_deleted"
,
0
);
ew
.
eq
(
"status"
,
1
);
// 不要这三个单位管理员 统计管理员 互动审核员
//
ew.ne("alias", "dwgly");
//
ew.ne("alias", "tjgly");
//
ew.ne("alias", "hdshy");
ew
.
ne
(
"alias"
,
"dwgly"
);
ew
.
ne
(
"alias"
,
"tjgly"
);
ew
.
ne
(
"alias"
,
"hdshy"
);
ew
.
orderByAsc
(
"sortorder"
);
ew
.
orderByDesc
(
"create_time"
);
List
<
Role
>
list
=
roleService
.
list
(
ew
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment