Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
L
loit-build-common
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
loit-Infrastructure
loit-build-common
Commits
2a83d909
提交
2a83d909
authored
1月 16, 2021
作者:
chenshiying
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[新增] gitlab 新增用户
上级
36278fa0
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
200 行增加
和
0 行删除
+200
-0
pom.xml
loit-build-component/loit-build-gitlab-user/pom.xml
+31
-0
gitlabUser.sh
...uild-component/loit-build-gitlab-user/shell/gitlabUser.sh
+12
-0
CreateUser.java
...ab-user/src/main/java/com.loit.build.user/CreateUser.java
+63
-0
PinyinUtil.java
...ab-user/src/main/java/com.loit.build.user/PinyinUtil.java
+79
-0
userNames.txt
...t/loit-build-gitlab-user/src/main/resources/userNames.txt
+13
-0
pom.xml
loit-build-component/pom.xml
+2
-0
没有找到文件。
loit-build-component/loit-build-gitlab-user/pom.xml
0 → 100644
浏览文件 @
2a83d909
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<parent>
<artifactId>
loit-build-component
</artifactId>
<groupId>
com.timeloit.project
</groupId>
<version>
1.0-SNAPSHOT
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
loit-build-gitlab-user
</artifactId>
<dependencies>
<dependency>
<groupId>
com.belerweb
</groupId>
<artifactId>
pinyin4j
</artifactId>
<version>
2.5.0
</version>
</dependency>
<dependency>
<groupId>
org.apache.commons
</groupId>
<artifactId>
commons-lang3
</artifactId>
</dependency>
</dependencies>
</project>
\ No newline at end of file
loit-build-component/loit-build-gitlab-user/shell/gitlabUser.sh
0 → 100644
浏览文件 @
2a83d909
#!/bin/bash
#批量创建gitlab用户
userinfo
=
"userinfo.txt"
while
read
line
do
password
=
`
echo
$line
|
awk
'{print $1}'
`
mail
=
`
echo
$line
|
awk
'{print $2}'
`
username
=
`
echo
$line
|
awk
'{print $3}'
`
name
=
`
echo
$line
|
awk
'{print $4}'
`
curl
-d
"skip_confirmation=True&password=
$password
&email=
$mail
&username=
$username
&name=
$name
&private_token=cPY2AxrQwHdjnyto7Y_H"
"http://39.100.254.140:12011/api/v4/users"
done
<
$userinfo
loit-build-component/loit-build-gitlab-user/src/main/java/com.loit.build.user/CreateUser.java
0 → 100644
浏览文件 @
2a83d909
package
com
.
loit
.
build
.
user
;
import
java.io.*
;
import
java.util.ArrayList
;
import
java.util.List
;
public
class
CreateUser
{
public
static
final
String
USER_NAMES_FILE_PATH
=
"userNames.txt"
;
private
static
List
<
String
>
nameList
=
new
ArrayList
<>();
public
static
void
readTxtFile
(
String
filePath
)
{
try
{
String
encoding
=
"UTF-8"
;
File
file
=
new
File
(
filePath
);
if
(
file
.
isFile
()
&&
file
.
exists
())
{
//判断文件是否存在
InputStreamReader
read
=
new
InputStreamReader
(
new
FileInputStream
(
file
),
encoding
);
//考虑到编码格式
BufferedReader
bufferedReader
=
new
BufferedReader
(
read
);
String
lineTxt
=
null
;
while
((
lineTxt
=
bufferedReader
.
readLine
())
!=
null
)
{
nameList
.
add
(
lineTxt
);
}
read
.
close
();
}
else
{
System
.
out
.
println
(
"找不到指定的文件"
);
}
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"读取文件内容出错"
);
}
StringBuffer
sbuf
=
new
StringBuffer
();
for
(
String
name
:
nameList
)
{
String
nameTemp
=
PinyinUtil
.
getPinyin
(
name
).
replaceAll
(
" "
,
""
);
sbuf
.
append
(
"12345678 "
).
append
(
getEmail
(
name
)).
append
(
" "
).
append
(
nameTemp
).
append
(
" "
).
append
(
name
).
append
(
System
.
getProperty
(
"line.separator"
));
}
printInfo
(
sbuf
.
toString
());
}
public
static
String
getEmail
(
String
name
)
{
StringBuffer
sbuf
=
new
StringBuffer
();
String
first
=
name
.
substring
(
0
,
1
);
String
second
=
name
.
substring
(
1
,
name
.
length
());
sbuf
.
append
(
PinyinUtil
.
getPinyin
(
first
)).
append
(
PinyinUtil
.
getPinyinInitials
(
second
));
sbuf
.
append
(
"@timeloit.com"
);
return
sbuf
.
toString
();
}
private
static
void
printInfo
(
String
content
)
{
System
.
out
.
println
(
content
);
}
public
static
void
main
(
String
argv
[])
{
String
path
=
CreateUser
.
class
.
getClassLoader
().
getResource
(
USER_NAMES_FILE_PATH
).
getPath
();
readTxtFile
(
path
);
}
}
\ No newline at end of file
loit-build-component/loit-build-gitlab-user/src/main/java/com.loit.build.user/PinyinUtil.java
0 → 100644
浏览文件 @
2a83d909
package
com
.
loit
.
build
.
user
;
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.HanyuPinyinVCharType
;
import
net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination
;
import
org.apache.commons.lang3.StringUtils
;
public
class
PinyinUtil
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
System
.
out
.
println
(
getPinyin
(
"阴晓光"
));
System
.
out
.
println
(
getPinyinInitials
(
"阴晓光"
));
}
/**
* 将汉字转换为全拼
*
* @param text 文本
* @return {@link String}
*/
public
static
String
getPinyin
(
String
text
)
{
String
separator
=
" "
;
char
[]
chars
=
text
.
toCharArray
();
HanyuPinyinOutputFormat
format
=
new
HanyuPinyinOutputFormat
();
// 设置大小写
format
.
setCaseType
(
HanyuPinyinCaseType
.
LOWERCASE
);
// 设置声调表示方法
format
.
setToneType
(
HanyuPinyinToneType
.
WITHOUT_TONE
);
// 设置字母u表示方法
format
.
setVCharType
(
HanyuPinyinVCharType
.
WITH_V
);
String
[]
s
;
String
rs
=
StringUtils
.
EMPTY
;
try
{
StringBuilder
sb
=
new
StringBuilder
();
for
(
int
i
=
0
;
i
<
chars
.
length
;
i
++)
{
// 判断是否为汉字字符
if
(
String
.
valueOf
(
chars
[
i
]).
matches
(
"[\\u4E00-\\u9FA5]+"
))
{
s
=
PinyinHelper
.
toHanyuPinyinStringArray
(
chars
[
i
],
format
);
if
(
s
!=
null
)
{
sb
.
append
(
s
[
0
]).
append
(
separator
);
continue
;
}
}
sb
.
append
(
String
.
valueOf
(
chars
[
i
]));
if
((
i
+
1
>=
chars
.
length
)
||
String
.
valueOf
(
chars
[
i
+
1
]).
matches
(
"[\\u4E00-\\u9FA5]+"
))
{
sb
.
append
(
separator
);
}
}
rs
=
sb
.
substring
(
0
,
sb
.
length
()
-
1
);
}
catch
(
BadHanyuPinyinOutputFormatCombination
e
)
{
e
.
printStackTrace
();
}
return
rs
;
}
/**
* 获取汉字首字母
*
* @param text 文本
* @return {@link String}
*/
public
static
String
getPinyinInitials
(
String
text
)
{
StringBuilder
sb
=
new
StringBuilder
();
for
(
int
i
=
0
;
i
<
text
.
length
();
i
++)
{
char
ch
=
text
.
charAt
(
i
);
String
[]
s
=
PinyinHelper
.
toHanyuPinyinStringArray
(
ch
);
if
(
s
!=
null
)
{
sb
.
append
(
s
[
0
].
charAt
(
0
));
}
else
{
sb
.
append
(
ch
);
}
}
return
sb
.
toString
();
}
}
\ No newline at end of file
loit-build-component/loit-build-gitlab-user/src/main/resources/userNames.txt
0 → 100644
浏览文件 @
2a83d909
阴晓光
胡文奇
帅威
李实现
李杰
李克勤
顾士龙
邸博
任宁宁
王建明
高峰
王昌顺
\ No newline at end of file
loit-build-component/pom.xml
浏览文件 @
2a83d909
...
...
@@ -20,6 +20,7 @@
<module>
sharding-keygen-leaf
</module>
<module>
loit-keygen-leaf-zk
</module>
<module>
loit-keygen-leaf-config
</module>
<module>
loit-build-gitlab-user
</module>
</modules>
</project>
\ No newline at end of file
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论