Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
datamanage
Overview
Overview
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
shenjinzhu
datamanage
Commits
ea51b12a
Commit
ea51b12a
authored
Feb 06, 2018
by
shenjinzhu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
登录部分错误修复,检索时间简短。
parent
5b34e2f0
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
52 additions
and
34 deletions
+52
-34
src/main/java/com/zhiwei/manage/dao/DataDaoImpl.java
+2
-3
src/main/java/com/zhiwei/manage/service/CrawTemplateService.java
+2
-0
src/main/java/com/zhiwei/manage/service/CrawTemplateServiceImpl.java
+5
-0
src/main/java/com/zhiwei/manage/service/DataServiceImpl.java
+1
-2
src/main/java/com/zhiwei/manage/servlet/DataController.java
+7
-1
src/main/java/com/zhiwei/manage/servlet/PersonController.java
+35
-28
No files found.
src/main/java/com/zhiwei/manage/dao/DataDaoImpl.java
View file @
ea51b12a
...
@@ -278,7 +278,7 @@ public class DataDaoImpl implements DataDao {
...
@@ -278,7 +278,7 @@ public class DataDaoImpl implements DataDao {
int
year
=
c
.
get
(
Calendar
.
YEAR
);
int
year
=
c
.
get
(
Calendar
.
YEAR
);
int
month
=
c
.
get
(
Calendar
.
MONTH
)
+
1
;
int
month
=
c
.
get
(
Calendar
.
MONTH
)
+
1
;
return
(
int
)
mongo2
.
count
(
Query
.
query
(
Criteria
.
where
(
"time"
).
gte
(
startTime
).
lt
(
endTime
).
and
(
"type"
).
is
(
source
)),
return
(
int
)
mongo2
.
count
(
Query
.
query
(
Criteria
.
where
(
"time"
).
gte
(
startTime
).
lt
(
endTime
).
and
(
"type"
).
is
(
source
)),
EasyNews
.
class
,
"net_media_"
+
year
+
(
month
>
9
?
""
+
month
:
"0"
+
month
));
"net_media_"
+
year
+
(
month
>
9
?
""
+
month
:
"0"
+
month
));
}
}
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
...
@@ -314,8 +314,7 @@ public class DataDaoImpl implements DataDao {
...
@@ -314,8 +314,7 @@ public class DataDaoImpl implements DataDao {
c
.
setTime
(
startTime
);
c
.
setTime
(
startTime
);
int
year
=
c
.
get
(
Calendar
.
YEAR
);
int
year
=
c
.
get
(
Calendar
.
YEAR
);
int
month
=
c
.
get
(
Calendar
.
MONTH
)
+
1
;
int
month
=
c
.
get
(
Calendar
.
MONTH
)
+
1
;
return
(
int
)
mongo2
.
count
(
Query
.
query
(
Criteria
.
where
(
"time"
).
gte
(
startTime
).
lt
(
endTime
).
and
(
"type"
).
is
(
type
)),
return
(
int
)
mongo2
.
count
(
Query
.
query
(
Criteria
.
where
(
"time"
).
gte
(
startTime
).
lt
(
endTime
).
and
(
"type"
).
is
(
type
)),
"net_media_"
+
year
+
(
month
>
9
?
""
+
month
:
"0"
+
month
));
EasyNews
.
class
,
"net_media_"
+
year
+
(
month
>
9
?
""
+
month
:
"0"
+
month
));
}
}
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
...
...
src/main/java/com/zhiwei/manage/service/CrawTemplateService.java
View file @
ea51b12a
...
@@ -9,4 +9,6 @@ public interface CrawTemplateService {
...
@@ -9,4 +9,6 @@ public interface CrawTemplateService {
public
List
<
CrawTemplate
>
findAll
();
public
List
<
CrawTemplate
>
findAll
();
public
String
findPt
(
String
spyId
);
public
String
findPt
(
String
spyId
);
public
String
getSpIdByConfigName
(
String
tempName
);
}
}
src/main/java/com/zhiwei/manage/service/CrawTemplateServiceImpl.java
View file @
ea51b12a
...
@@ -47,4 +47,9 @@ public class CrawTemplateServiceImpl implements CrawTemplateService {
...
@@ -47,4 +47,9 @@ public class CrawTemplateServiceImpl implements CrawTemplateService {
return
pt
;
return
pt
;
}
}
@Override
public
String
getSpIdByConfigName
(
String
tempName
)
{
return
crawDao
.
getSpIdByConfigName
(
tempName
);
}
}
}
src/main/java/com/zhiwei/manage/service/DataServiceImpl.java
View file @
ea51b12a
...
@@ -87,8 +87,7 @@ public class DataServiceImpl implements DataService {
...
@@ -87,8 +87,7 @@ public class DataServiceImpl implements DataService {
@Override
@Override
public
int
findByTempName
(
Date
startTime
,
Date
endTime
,
String
tempName
)
{
public
int
findByTempName
(
Date
startTime
,
Date
endTime
,
String
tempName
)
{
String
spId
=
crd
.
getSpIdByConfigName
(
tempName
);
return
dataDao
.
findBySpId
(
startTime
,
endTime
,
tempName
);
return
dataDao
.
findBySpId
(
startTime
,
endTime
,
spId
);
}
}
@Override
@Override
...
...
src/main/java/com/zhiwei/manage/servlet/DataController.java
View file @
ea51b12a
...
@@ -28,6 +28,7 @@ import com.zhiwei.manage.bean.Channel;
...
@@ -28,6 +28,7 @@ import com.zhiwei.manage.bean.Channel;
import
com.zhiwei.manage.bean.Data
;
import
com.zhiwei.manage.bean.Data
;
import
com.zhiwei.manage.bean.EasyNews
;
import
com.zhiwei.manage.bean.EasyNews
;
import
com.zhiwei.manage.bean.JsonResult
;
import
com.zhiwei.manage.bean.JsonResult
;
import
com.zhiwei.manage.service.CrawTemplateService
;
import
com.zhiwei.manage.service.DataService
;
import
com.zhiwei.manage.service.DataService
;
import
com.zhiwei.manage.service.ServerService
;
import
com.zhiwei.manage.service.ServerService
;
import
com.zhiwei.manage.util.Change
;
import
com.zhiwei.manage.util.Change
;
...
@@ -43,6 +44,8 @@ public class DataController {
...
@@ -43,6 +44,8 @@ public class DataController {
private
DataService
dataService
;
private
DataService
dataService
;
@Autowired
@Autowired
private
ServerService
serverService
;
private
ServerService
serverService
;
@Autowired
private
CrawTemplateService
crService
;
@RequestMapping
(
value
=
"/getData"
,
produces
=
"application/json;charset=utf-8"
)
@RequestMapping
(
value
=
"/getData"
,
produces
=
"application/json;charset=utf-8"
)
@ResponseBody
@ResponseBody
...
@@ -93,6 +96,9 @@ public class DataController {
...
@@ -93,6 +96,9 @@ public class DataController {
String
source
=
""
;
String
source
=
""
;
List
<
Data
>
list
=
new
ArrayList
<
Data
>();
List
<
Data
>
list
=
new
ArrayList
<
Data
>();
startd
.
add
(
Calendar
.
HOUR
,
-
8
);
startd
.
add
(
Calendar
.
HOUR
,
-
8
);
endTime
.
add
(
Calendar
.
HOUR
,
-
7
);
ds
.
add
(
Calendar
.
HOUR
,
-
6
);
String
spid
=
crService
.
getSpIdByConfigName
((
String
)
map
.
get
(
"tempName"
));
while
(
endTime
.
getTime
().
before
(
ds
.
getTime
()))
{
while
(
endTime
.
getTime
().
before
(
ds
.
getTime
()))
{
endTime
.
add
(
Calendar
.
HOUR
,
1
);
endTime
.
add
(
Calendar
.
HOUR
,
1
);
int
count
=
0
;
int
count
=
0
;
...
@@ -105,7 +111,7 @@ public class DataController {
...
@@ -105,7 +111,7 @@ public class DataController {
count
=
dataService
.
findBySourceFromLibrary
(
startd
.
getTime
(),
endTime
.
getTime
(),
source
);
count
=
dataService
.
findBySourceFromLibrary
(
startd
.
getTime
(),
endTime
.
getTime
(),
source
);
}
else
{
}
else
{
source
=
(
String
)
map
.
get
(
"tempName"
);
source
=
(
String
)
map
.
get
(
"tempName"
);
count
=
dataService
.
findByTempName
(
startd
.
getTime
(),
endTime
.
getTime
(),
s
ource
);
count
=
dataService
.
findByTempName
(
startd
.
getTime
(),
endTime
.
getTime
(),
s
pid
);
}
}
}
}
Data
data
=
new
Data
();
Data
data
=
new
Data
();
...
...
src/main/java/com/zhiwei/manage/servlet/PersonController.java
View file @
ea51b12a
package
com
.
zhiwei
.
manage
.
servlet
;
package
com
.
zhiwei
.
manage
.
servlet
;
import
java.io.UnsupportedEncodingException
;
import
java.net.URLEncoder
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -29,13 +31,16 @@ public class PersonController {
...
@@ -29,13 +31,16 @@ public class PersonController {
@RequestMapping
(
value
=
"/login"
,
produces
=
"application/json;charset=utf-8"
)
@RequestMapping
(
value
=
"/login"
,
produces
=
"application/json;charset=utf-8"
)
@ResponseBody
@ResponseBody
public
String
login
(
HttpServletRequest
req
,
HttpServletResponse
res
,
@RequestBody
Map
<
String
,
Object
>
map
)
{
public
String
login
(
HttpServletRequest
req
,
HttpServletResponse
res
,
@RequestBody
Map
<
String
,
Object
>
map
)
{
boolean
isRemember
=
(
boolean
)
map
.
get
(
"isRemember"
);
boolean
isRemember
=
(
boolean
)
map
.
get
(
"isRemember"
);
String
username
=
(
String
)
map
.
get
(
"username"
);
String
username
=
(
String
)
map
.
get
(
"username"
);
String
password
=
(
String
)
map
.
get
(
"password"
);
String
password
=
(
String
)
map
.
get
(
"password"
);
Person
p
=
personService
.
login
(
username
,
password
);
Person
p
=
personService
.
login
(
username
,
password
);
if
(
p
!=
null
)
{
if
(
p
!=
null
)
{
Cookie
cookie
=
new
Cookie
(
username
,
username
);
Cookie
cookie
;
try
{
username
=
URLEncoder
.
encode
(
username
,
"utf-8"
);
cookie
=
new
Cookie
(
"username"
,
username
);
res
.
addCookie
(
cookie
);
res
.
addCookie
(
cookie
);
cookie
.
setMaxAge
(
1000
*
60
*
60
);
cookie
.
setMaxAge
(
1000
*
60
*
60
);
cookie
.
setPath
(
"/"
);
cookie
.
setPath
(
"/"
);
...
@@ -44,17 +49,21 @@ public class PersonController {
...
@@ -44,17 +49,21 @@ public class PersonController {
p
.
setPassword
(
""
);
p
.
setPassword
(
""
);
JsonResult
result
=
new
JsonResult
(
true
,
200
,
"登录成功"
,
p
);
JsonResult
result
=
new
JsonResult
(
true
,
200
,
"登录成功"
,
p
);
return
JSON
.
toJSONString
(
result
);
return
JSON
.
toJSONString
(
result
);
}
catch
(
UnsupportedEncodingException
e
)
{
e
.
printStackTrace
();
JsonResult
result
=
new
JsonResult
(
false
,
200
,
"登录失败"
,
""
);
return
JSON
.
toJSONString
(
result
);
}
}
else
{
}
else
{
JsonResult
result
=
new
JsonResult
(
false
,
200
,
"登录失败"
,
""
);
JsonResult
result
=
new
JsonResult
(
false
,
200
,
"登录失败"
,
""
);
return
JSON
.
toJSONString
(
result
);
return
JSON
.
toJSONString
(
result
);
}
}
}
}
@RequestMapping
(
value
=
"/leave"
,
produces
=
"application/json;charset=utf-8"
)
@RequestMapping
(
value
=
"/leave"
,
produces
=
"application/json;charset=utf-8"
)
@ResponseBody
@ResponseBody
public
String
leave
(
HttpServletRequest
req
,
HttpServletResponse
res
,
@RequestBody
Map
<
String
,
Object
>
map
)
{
public
String
leave
(
HttpServletRequest
req
,
HttpServletResponse
res
,
@RequestBody
Map
<
String
,
Object
>
map
)
{
String
username
=
(
String
)
map
.
get
(
"username"
);
String
username
=
(
String
)
map
.
get
(
"username"
);
Cookie
[]
cookies
=
req
.
getCookies
();
Cookie
[]
cookies
=
req
.
getCookies
();
for
(
Cookie
cookie
:
cookies
)
{
for
(
Cookie
cookie
:
cookies
)
{
if
(
cookie
.
getName
().
equals
(
username
))
{
if
(
cookie
.
getName
().
equals
(
username
))
{
...
@@ -77,58 +86,56 @@ public class PersonController {
...
@@ -77,58 +86,56 @@ public class PersonController {
return
JSON
.
toJSONString
(
result
);
return
JSON
.
toJSONString
(
result
);
}
}
@RequestMapping
(
value
=
"/getPerson"
,
produces
=
"application/json;charset=utf-8"
)
@RequestMapping
(
value
=
"/getPerson"
,
produces
=
"application/json;charset=utf-8"
)
@ResponseBody
@ResponseBody
public
String
getPersonByUser
(
HttpServletResponse
res
,
HttpServletRequest
req
,
@RequestBody
Map
<
String
,
Object
>
map
)
{
public
String
getPersonByUser
(
HttpServletResponse
res
,
HttpServletRequest
req
,
String
username
=(
String
)
map
.
get
(
"username"
);
@RequestBody
Map
<
String
,
Object
>
map
)
{
int
pageSize
=(
int
)
map
.
get
(
"pageSize"
);
String
username
=
(
String
)
map
.
get
(
"username"
);
int
pageNo
=(
int
)
map
.
get
(
"pageNo"
);
int
pageSize
=
(
int
)
map
.
get
(
"pageSize"
);
int
lv
=(
int
)
map
.
get
(
"lv"
);
int
pageNo
=
(
int
)
map
.
get
(
"pageNo"
);
int
lv
=
(
int
)
map
.
get
(
"lv"
);
if
(
username
==
null
||
username
.
equals
(
""
))
{
if
(
username
==
null
||
username
.
equals
(
""
))
{
PageEty
page
=
personService
.
findAll
(
pageNo
,
pageSize
,
lv
);
PageEty
page
=
personService
.
findAll
(
pageNo
,
pageSize
,
lv
);
JsonResult
result
=
new
JsonResult
(
true
,
200
,
"获取成功"
,
page
);
JsonResult
result
=
new
JsonResult
(
true
,
200
,
"获取成功"
,
page
);
return
JSON
.
toJSONString
(
result
);
return
JSON
.
toJSONString
(
result
);
}
else
{
}
else
{
PageEty
page
=
personService
.
findByUserName
(
username
,
pageNo
,
pageSize
,
lv
);
PageEty
page
=
personService
.
findByUserName
(
username
,
pageNo
,
pageSize
,
lv
);
JsonResult
result
=
new
JsonResult
(
true
,
200
,
"获取成功"
,
page
);
JsonResult
result
=
new
JsonResult
(
true
,
200
,
"获取成功"
,
page
);
return
JSON
.
toJSONString
(
result
);
return
JSON
.
toJSONString
(
result
);
}
}
}
}
@RequestMapping
(
value
=
"/updatePerson"
,
produces
=
"application/json;charset=utf-8"
)
@RequestMapping
(
value
=
"/updatePerson"
,
produces
=
"application/json;charset=utf-8"
)
@ResponseBody
@ResponseBody
public
String
updatePerson
(
@RequestBody
Person
person
){
public
String
updatePerson
(
@RequestBody
Person
person
)
{
boolean
b
=
personService
.
update
(
person
);
boolean
b
=
personService
.
update
(
person
);
JsonResult
result
=
new
JsonResult
(
b
?
true
:
false
,
200
,
b
?
"操作成功"
:
"操作失败"
,
""
);
JsonResult
result
=
new
JsonResult
(
b
?
true
:
false
,
200
,
b
?
"操作成功"
:
"操作失败"
,
""
);
return
JSON
.
toJSONString
(
result
);
return
JSON
.
toJSONString
(
result
);
}
}
@RequestMapping
(
value
=
"/deletePerson"
,
produces
=
"application/json;charset=utf-8"
)
@RequestMapping
(
value
=
"/deletePerson"
,
produces
=
"application/json;charset=utf-8"
)
@ResponseBody
@ResponseBody
public
String
deletePerson
(
@RequestBody
Map
<
String
,
Object
>
map
){
public
String
deletePerson
(
@RequestBody
Map
<
String
,
Object
>
map
)
{
List
<
String
>
deleteList
=
(
List
<
String
>)
map
.
get
(
"personId"
);
List
<
String
>
deleteList
=
(
List
<
String
>)
map
.
get
(
"personId"
);
boolean
b
=
personService
.
delete
(
deleteList
);
boolean
b
=
personService
.
delete
(
deleteList
);
JsonResult
result
=
new
JsonResult
(
b
?
true
:
false
,
200
,
b
?
"操作成功"
:
"操作失败"
);
JsonResult
result
=
new
JsonResult
(
b
?
true
:
false
,
200
,
b
?
"操作成功"
:
"操作失败"
);
return
JSON
.
toJSONString
(
result
);
return
JSON
.
toJSONString
(
result
);
}
}
@RequestMapping
(
value
=
"/savePerson"
,
produces
=
"application/json;charset=utf-8"
)
@RequestMapping
(
value
=
"/savePerson"
,
produces
=
"application/json;charset=utf-8"
)
@ResponseBody
@ResponseBody
public
String
savePerson
(
HttpServletRequest
req
,
@RequestBody
Person
person
)
{
public
String
savePerson
(
HttpServletRequest
req
,
@RequestBody
Person
person
)
{
Cookie
[]
cookies
=
req
.
getCookies
();
Cookie
[]
cookies
=
req
.
getCookies
();
for
(
Cookie
cookie
:
cookies
)
{
for
(
Cookie
cookie
:
cookies
)
{
System
.
out
.
println
(
cookie
.
getName
());
System
.
out
.
println
(
cookie
.
getName
());
if
(
cookie
.
getName
().
equals
(
person
.
getUsername
()))
{
if
(
cookie
.
getName
().
equals
(
person
.
getUsername
()))
{
JsonResult
result
=
new
JsonResult
(
false
,
200
,
"该用户在线,不允许删除"
);
JsonResult
result
=
new
JsonResult
(
false
,
200
,
"该用户在线,不允许删除"
);
return
JSON
.
toJSONString
(
result
);
return
JSON
.
toJSONString
(
result
);
}
}
}
}
boolean
b
=
personService
.
insert
(
person
);
boolean
b
=
personService
.
insert
(
person
);
JsonResult
result
=
new
JsonResult
(
b
?
true
:
false
,
200
,
"操作成功"
,
""
);
JsonResult
result
=
new
JsonResult
(
b
?
true
:
false
,
200
,
"操作成功"
,
""
);
return
JSON
.
toJSONString
(
result
);
return
JSON
.
toJSONString
(
result
);
}
}
}
}
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