Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
browser-backend
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
Administrator
browser-backend
Commits
db14ea11
Commit
db14ea11
authored
Mar 16, 2020
by
renjie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
随机密码修改
parent
022c79f8
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
74 additions
and
16 deletions
+74
-16
WebSecurityConfig.java
...m/edgec/browserbackend/auth/config/WebSecurityConfig.java
+1
-1
ShopController.java
...gec/browserbackend/browser/controller/ShopController.java
+4
-3
IpResourceServiceImpl.java
...erbackend/browser/service/Impl/IpResourceServiceImpl.java
+43
-8
ShopServiceImpl.java
.../browserbackend/browser/service/Impl/ShopServiceImpl.java
+1
-1
FileUtil.java
.../java/com/edgec/browserbackend/common/utils/FileUtil.java
+9
-3
batchAdd.xlsx
src/main/resources/batchAdd.xlsx
+0
-0
uploadtest.html
src/main/resources/static/uploadtest.html
+16
-0
No files found.
src/main/java/com/edgec/browserbackend/auth/config/WebSecurityConfig.java
View file @
db14ea11
...
...
@@ -32,7 +32,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
public
void
configure
(
WebSecurity
web
)
throws
Exception
{
web
.
ignoring
()
.
antMatchers
(
"/user/authCode"
,
"/user/signUp"
,
.
antMatchers
(
"/user/authCode"
,
"/user/signUp"
,
"/shop/multiadd"
,
"/user/reset*"
);
}
...
...
src/main/java/com/edgec/browserbackend/browser/controller/ShopController.java
View file @
db14ea11
...
...
@@ -47,9 +47,10 @@ public class ShopController {
}
@RequestMapping
(
value
=
"/multiadd"
,
method
=
RequestMethod
.
POST
)
@ResponseBody
public
List
<
String
>
addShops
(
Principal
principal
,
@RequestParam
(
"file"
)
MultipartFile
file
)
{
ResultDto
resultDto
=
new
ResultDto
();
String
name
=
file
.
getOriginalFilename
();
String
name
=
file
.
getOriginalFilename
();
if
(
name
.
length
()<
6
||
!
name
.
substring
(
name
.
length
()-
5
).
equals
(
".xlsx"
)){
resultDto
.
setStatus
(-
1
);
Map
<
String
,
Object
>
statusInfo
=
new
HashMap
<>();
...
...
@@ -57,9 +58,9 @@ public class ShopController {
statusInfo
.
put
(
"message"
,
"文件格式错误"
);
resultDto
.
setStatusInfo
(
statusInfo
);
}
try
{
shopService
.
addShops
(
principal
.
getName
(),
file
);
String
username
=
"13192253730"
;
shopService
.
addShops
(
username
,
file
);
}
catch
(
ClientRequestException
|
IOException
e
)
{
resultDto
.
setStatus
(-
1
);
Map
<
String
,
Object
>
statusInfo
=
new
HashMap
<>();
...
...
src/main/java/com/edgec/browserbackend/browser/service/Impl/IpResourceServiceImpl.java
View file @
db14ea11
...
...
@@ -101,14 +101,49 @@ public class IpResourceServiceImpl implements IpResourceService {
return
headers
;
}
public
static
String
makeRandomPassword
(
int
len
){
char
charr
[]
=
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
.
toCharArray
();
StringBuilder
sb
=
new
StringBuilder
();
Random
r
=
new
Random
();
for
(
int
x
=
0
;
x
<
len
;
++
x
)
{
sb
.
append
(
charr
[
r
.
nextInt
(
charr
.
length
)]);
public
static
String
genRandom
(
int
srcFlag
,
int
length
)
{
String
retStr
=
""
;
String
strTable
=
""
;
switch
(
srcFlag
)
{
case
1
:
strTable
=
"1234567890"
;
break
;
case
2
:
strTable
=
"1234567890abcdefghijklmnopqrstuvwxyz"
;
break
;
case
3
:
strTable
=
"12345678901234567890abcdefghijkmnpqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
;
break
;
case
4
:
strTable
=
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
;
break
;
case
5
:
strTable
=
"abcdefghijklmnopqrstuvwxyz"
;
break
;
default
:
strTable
=
"1234567890abcdefghijkmnpqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
;
break
;
}
return
sb
.
toString
();
int
len
=
strTable
.
length
();
boolean
bDone
=
true
;
do
{
retStr
=
""
;
int
count
=
0
;
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
double
dblR
=
Math
.
random
()
*
len
;
int
intR
=
(
int
)
Math
.
floor
(
dblR
);
char
c
=
strTable
.
charAt
(
intR
);
if
((
'0'
<=
c
)
&&
(
c
<=
'9'
))
{
count
++;
}
retStr
+=
strTable
.
charAt
(
intR
);
}
if
(
count
>=
2
)
{
bDone
=
false
;
}
}
while
(
bDone
);
return
retStr
;
}
private
IpChargeRequestDto
buildIpChargeRequestDto
(
IpResourceRequestDto
request
,
int
chargeType
)
{
...
...
@@ -162,7 +197,7 @@ public class IpResourceServiceImpl implements IpResourceService {
if
(
StringUtils
.
isNotBlank
(
ipResourceRequestDto
.
getPassword
()))
password
=
ipResourceRequestDto
.
getPassword
();
else
password
=
makeRandomPassword
(
16
);
password
=
genRandom
(
3
,
12
);
map
.
put
(
"loginPassword"
,
password
);
map
.
put
(
"startscript"
,
startscript
);
map
.
put
(
"ipkeptperiod"
,
ipResourceRequestDto
.
getIpkeptperiod
());
...
...
src/main/java/com/edgec/browserbackend/browser/service/Impl/ShopServiceImpl.java
View file @
db14ea11
...
...
@@ -102,7 +102,7 @@ public class ShopServiceImpl implements ShopService {
@Override
public
List
<
String
>
addShops
(
String
username
,
MultipartFile
file
)
throws
IOException
{
List
<
Object
>
list
=
FileUtil
.
readExcel
(
file
.
getInputStream
());
logger
.
error
(
list
.
toString
());
return
null
;
}
...
...
src/main/java/com/edgec/browserbackend/common/utils/FileUtil.java
View file @
db14ea11
package
com
.
edgec
.
browserbackend
.
common
.
utils
;
import
com.edgec.browserbackend.browser.ErrorCode.BrowserErrorCode
;
import
com.edgec.browserbackend.common.commons.error.ClientRequestException
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.poi.hssf.usermodel.HSSFWorkbook
;
import
org.apache.poi.ss.usermodel.*
;
...
...
@@ -83,20 +85,24 @@ public class FileUtil {
//总列数
int
colLength
=
row
.
getLastCellNum
();
//得到指定的单元格
Cell
cell
=
row
.
getCell
(
0
);
Cell
cell
=
row
.
getCell
(
0
);
;
for
(
int
i
=
2
;
i
<
rowLength
;
i
++)
{
row
=
sheet
.
getRow
(
i
);
for
(
int
j
=
0
;
j
<
colLength
;
j
++)
{
cell
=
row
.
getCell
(
j
);
// System.out.println(cell);
if
(
cell
==
null
)
throw
new
ClientRequestException
(
BrowserErrorCode
.
INFORMATIONNOTCOMPELETE
);
if
(
cell
!=
null
)
{
String
cellValue
=
cell
.
getRichStringCellValue
().
getString
();
Object
cellValue
=
getCellFormatValue
(
cell
);
if
(
StringUtils
.
isNotBlank
(
cellValue
.
toString
()))
log
.
error
(
cellValue
.
toString
());
}
}
}
}
catch
(
Exception
e
)
{
log
.
error
(
"parse excel file error :"
,
e
);
throw
new
ClientRequestException
(
BrowserErrorCode
.
INFORMATIONNOTCOMPELETE
);
}
return
list
;
}
...
...
src/main/resources/batchAdd.xlsx
View file @
db14ea11
No preview for this file type
src/main/resources/static/uploadtest.html
0 → 100644
View file @
db14ea11
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"UTF-8"
>
<title>
Title
</title>
</head>
<body>
<h1>
成功页面。。。
</h1>
<form
action=
"/shop/multiadd"
method=
"post"
enctype=
"multipart/form-data"
>
<p>
文件上传
</p>
<input
type=
"file"
name=
"file"
>
<p><input
type=
"submit"
value=
"提交"
></p>
</form>
</body>
</html>
\ No newline at end of file
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