Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
D
dsk-operate-sys-cscec
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
fulixin
dsk-operate-sys-cscec
Commits
db1a1367
Commit
db1a1367
authored
Nov 13, 2023
by
施翔轲
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
角色管理新增权限字符自动生成功能
parent
faca6d41
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
91 additions
and
3 deletions
+91
-3
SysRoleController.java
...java/com/dsk/web/controller/system/SysRoleController.java
+5
-1
pom.xml
dsk-common/pom.xml
+6
-0
Chinese2PinyinUtils.java
...c/main/java/com/dsk/common/utils/Chinese2PinyinUtils.java
+67
-0
vue.config.js
dsk-operate-ui/vue.config.js
+2
-1
SysRole.java
dsk-system/src/main/java/com/dsk/system/domain/SysRole.java
+1
-1
pom.xml
pom.xml
+10
-0
No files found.
dsk-admin/src/main/java/com/dsk/web/controller/system/SysRoleController.java
View file @
db1a1367
...
...
@@ -5,6 +5,7 @@ import com.dsk.common.annotation.Log;
import
com.dsk.common.core.controller.BaseController
;
import
com.dsk.common.core.domain.PageQuery
;
import
com.dsk.common.core.domain.R
;
import
com.dsk.common.utils.Chinese2PinyinUtils
;
import
com.dsk.system.domain.SysDept
;
import
com.dsk.system.domain.SysRole
;
import
com.dsk.system.domain.SysUser
;
...
...
@@ -81,13 +82,16 @@ public class SysRoleController extends BaseController {
@PostMapping
public
R
<
Void
>
add
(
@Validated
@RequestBody
SysRole
role
)
{
roleService
.
checkRoleAllowed
(
role
);
//应产品经理强!烈!要求,让后台自动生成权限字符,为方便后期排查bug,经考虑后将角色名的拼音设置为权限字符
role
.
setRoleKey
(
Chinese2PinyinUtils
.
toLowerPinyin
(
role
.
getRoleName
()));
if
(!
roleService
.
checkRoleNameUnique
(
role
))
{
return
R
.
fail
(
"新增角色'"
+
role
.
getRoleName
()
+
"'失败,角色名称已存在"
);
}
else
if
(!
roleService
.
checkRoleKeyUnique
(
role
))
{
return
R
.
fail
(
"新增角色'"
+
role
.
getRoleName
()
+
"'失败,角色权限已存在"
);
}
return
toAjax
(
roleService
.
insertRole
(
role
));
}
/**
...
...
dsk-common/pom.xml
View file @
db1a1367
...
...
@@ -187,6 +187,12 @@
<scope>
compile
</scope>
</dependency>
<!--中文转拼音-->
<dependency>
<groupId>
com.belerweb
</groupId>
<artifactId>
pinyin4j
</artifactId>
</dependency>
</dependencies>
</project>
dsk-common/src/main/java/com/dsk/common/utils/Chinese2PinyinUtils.java
0 → 100644
View file @
db1a1367
package
com
.
dsk
.
common
.
utils
;
import
net.sourceforge.pinyin4j.PinyinHelper
;
import
net.sourceforge.pinyin4j.format.HanyuPinyinCaseType
;
import
net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat
;
import
net.sourceforge.pinyin4j.format.HanyuPinyinToneType
;
import
net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination
;
/**
* 中文转拼音工具类
*
* @author sxk
* @date 2023.11.13
*/
public
class
Chinese2PinyinUtils
{
/**
* 中文转小写拼音
* @param chinese 待转义中文
* @return 转义后的拼音
*/
public
static
String
toLowerPinyin
(
String
chinese
)
{
StringBuilder
pinyin
=
new
StringBuilder
();
HanyuPinyinOutputFormat
format
=
new
HanyuPinyinOutputFormat
();
format
.
setCaseType
(
HanyuPinyinCaseType
.
LOWERCASE
);
format
.
setToneType
(
HanyuPinyinToneType
.
WITHOUT_TONE
);
char
[]
chars
=
chinese
.
toCharArray
();
for
(
char
c
:
chars
)
{
try
{
String
[]
arr
=
PinyinHelper
.
toHanyuPinyinStringArray
(
c
,
format
);
if
(
arr
==
null
||
arr
.
length
==
0
)
{
pinyin
.
append
(
c
);
}
else
{
pinyin
.
append
(
arr
[
0
]);
}
}
catch
(
BadHanyuPinyinOutputFormatCombination
e
)
{
e
.
printStackTrace
();
}
}
return
pinyin
.
toString
();
}
/**
* 中文转大写拼音
* @param chinese 待转义中文
* @return 转义后的拼音
*/
public
static
String
toUpperPinyin
(
String
chinese
)
{
StringBuilder
pinyin
=
new
StringBuilder
();
HanyuPinyinOutputFormat
format
=
new
HanyuPinyinOutputFormat
();
format
.
setCaseType
(
HanyuPinyinCaseType
.
UPPERCASE
);
format
.
setToneType
(
HanyuPinyinToneType
.
WITHOUT_TONE
);
char
[]
chars
=
chinese
.
toCharArray
();
for
(
char
c
:
chars
)
{
try
{
String
[]
arr
=
PinyinHelper
.
toHanyuPinyinStringArray
(
c
,
format
);
if
(
arr
==
null
||
arr
.
length
==
0
)
{
pinyin
.
append
(
c
);
}
else
{
pinyin
.
append
(
arr
[
0
]);
}
}
catch
(
BadHanyuPinyinOutputFormatCombination
e
)
{
e
.
printStackTrace
();
}
}
return
pinyin
.
toString
();
}
}
dsk-operate-ui/vue.config.js
View file @
db1a1367
...
...
@@ -37,7 +37,8 @@ module.exports = {
target
:
`http://47.104.91.229:9099/prod-api`
,
//测试
// target: `https://szhapi.jiansheku.com`,//线上
// target: `http://122.9.160.122:9011`, //线上
// target: `http://192.168.0.165:9098`,//施
// target: `http://192.168.0.165:9098`,//施-无线
// target: `http://192.168.60.46:9098`,//施-有线
// target: `http://192.168.60.6:9098`,//谭
changeOrigin
:
true
,
pathRewrite
:
{
...
...
dsk-system/src/main/java/com/dsk/system/domain/SysRole.java
View file @
db1a1367
...
...
@@ -51,7 +51,7 @@ public class SysRole extends TenantEntity {
* 角色权限
*/
@ExcelProperty
(
value
=
"角色权限"
)
@NotBlank
(
message
=
"权限字符不能为空"
)
//
@NotBlank(message = "权限字符不能为空")
@Size
(
min
=
0
,
max
=
100
,
message
=
"权限字符长度不能超过{max}个字符"
)
private
String
roleKey
;
...
...
pom.xml
View file @
db1a1367
...
...
@@ -48,6 +48,9 @@
<aws-java-sdk-s3.version>
1.12.400
</aws-java-sdk-s3.version>
<!-- SMS 配置 -->
<sms4j.version>
2.2.0
</sms4j.version>
<!--中文转拼音-->
<pinyin4j.version>
2.5.1
</pinyin4j.version>
</properties>
<profiles>
...
...
@@ -324,6 +327,13 @@
<version>
${dsk-operate-sys.version}
</version>
</dependency>
<!--中文转拼音-->
<dependency>
<groupId>
com.belerweb
</groupId>
<artifactId>
pinyin4j
</artifactId>
<version>
${pinyin4j.version}
</version>
</dependency>
</dependencies>
</dependencyManagement>
...
...
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