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
7605fbad
Commit
7605fbad
authored
Mar 24, 2020
by
renjie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
操作日志
parent
2bb22ccb
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
9 deletions
+14
-9
LoginHistoryRepository.java
...serbackend/browser/repository/LoginHistoryRepository.java
+4
-2
OperationHistoryRepository.java
...ackend/browser/repository/OperationHistoryRepository.java
+2
-2
HistoryServiceImpl.java
...owserbackend/browser/service/Impl/HistoryServiceImpl.java
+8
-5
No files found.
src/main/java/com/edgec/browserbackend/browser/repository/LoginHistoryRepository.java
View file @
7605fbad
...
...
@@ -5,12 +5,14 @@ import org.springframework.data.domain.Page;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.mongodb.repository.MongoRepository
;
import
java.util.List
;
public
interface
LoginHistoryRepository
extends
MongoRepository
<
LoginHistory
,
String
>
{
LoginHistory
findFirstByAccount
(
String
account
);
Page
<
LoginHistory
>
findByAdministrator
OrderByLoginTime
(
String
administrator
,
Pageable
pageable
);
Page
<
LoginHistory
>
findByAdministrator
AndLoginTimeGreaterThanOrderByLoginTime
(
String
administrator
,
long
time
,
Pageable
pageable
);
Page
<
LoginHistory
>
findByAccount
OrderByLoginTime
(
String
account
,
Pageable
pageable
);
Page
<
LoginHistory
>
findByAccount
AndLoginTimeGreaterThanOrderByLoginTime
(
String
account
,
long
time
,
Pageable
pageable
);
int
countByAccount
(
String
account
);
}
src/main/java/com/edgec/browserbackend/browser/repository/OperationHistoryRepository.java
View file @
7605fbad
...
...
@@ -8,8 +8,8 @@ import org.springframework.data.mongodb.repository.MongoRepository;
public
interface
OperationHistoryRepository
extends
MongoRepository
<
OperationHistory
,
String
>
{
OperationHistory
findFirstByAccount
(
String
account
);
Page
<
OperationHistory
>
findByAdministrator
OrderByOperationTimeDesc
(
String
administrator
,
Pageable
pageable
);
Page
<
OperationHistory
>
findByAccount
OrderByOperationTimeDesc
(
String
account
,
Pageable
pageable
);
Page
<
OperationHistory
>
findByAdministrator
AndOperationTimeGreaterThanOrderByOperationTimeDesc
(
String
administrator
,
long
time
,
Pageable
pageable
);
Page
<
OperationHistory
>
findByAccount
AndOperationTimeGreaterThanOrderByOperationTimeDesc
(
String
account
,
long
time
,
Pageable
pageable
);
int
countByAccount
(
String
account
);
}
src/main/java/com/edgec/browserbackend/browser/service/Impl/HistoryServiceImpl.java
View file @
7605fbad
...
...
@@ -17,6 +17,7 @@ import org.springframework.data.domain.Pageable;
import
org.springframework.stereotype.Service
;
import
java.time.Instant
;
import
java.time.ZoneOffset
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -39,7 +40,7 @@ public class HistoryServiceImpl implements HistoryService {
if
(
account
==
null
)
throw
new
ClientRequestException
(
AccountErrorCode
.
NAMENOTEXIST
);
int
num
=
loginHistoryRepository
.
countByAccount
(
username
);
if
(
num
>
10
)
if
(
num
>
10
000
)
loginHistoryRepository
.
delete
(
loginHistoryRepository
.
findFirstByAccount
(
username
));
LoginHistory
loginHistory
=
new
LoginHistory
(
loginHistoryDto
);
loginHistory
.
setLoginTime
(
Instant
.
now
().
toEpochMilli
());
...
...
@@ -83,10 +84,11 @@ public class HistoryServiceImpl implements HistoryService {
Pageable
pageable
=
PageRequest
.
of
(
historyListRequestDto
.
getPage
(),
historyListRequestDto
.
getAmount
());
HistoryPageResultDto
historyPageResultDto
=
new
HistoryPageResultDto
();
Page
<
LoginHistory
>
loginHistoryPage
;
long
time
=
Instant
.
now
().
atZone
(
ZoneOffset
.
UTC
).
minusDays
(
historyListRequestDto
.
getDay
()).
toInstant
().
toEpochMilli
();
if
(
account
.
getParent
()
==
null
)
{
loginHistoryPage
=
loginHistoryRepository
.
findByAdministrator
OrderByLoginTime
(
userna
me
,
pageable
);
loginHistoryPage
=
loginHistoryRepository
.
findByAdministrator
AndLoginTimeGreaterThanOrderByLoginTime
(
username
,
ti
me
,
pageable
);
}
else
{
loginHistoryPage
=
loginHistoryRepository
.
findByAccount
OrderByLoginTime
(
userna
me
,
pageable
);
loginHistoryPage
=
loginHistoryRepository
.
findByAccount
AndLoginTimeGreaterThanOrderByLoginTime
(
username
,
ti
me
,
pageable
);
}
List
<
LoginHistoryDto
>
loginHistoryDtoList
=
new
ArrayList
<>();
...
...
@@ -114,10 +116,11 @@ public class HistoryServiceImpl implements HistoryService {
Pageable
pageable
=
PageRequest
.
of
(
historyListRequestDto
.
getPage
(),
historyListRequestDto
.
getAmount
());
HistoryPageResultDto
historyPageResultDto
=
new
HistoryPageResultDto
();
Page
<
OperationHistory
>
operationHistories
;
long
time
=
Instant
.
now
().
atZone
(
ZoneOffset
.
UTC
).
minusDays
(
historyListRequestDto
.
getDay
()).
toInstant
().
toEpochMilli
();
if
(
account
.
getParent
()
==
null
)
{
operationHistories
=
operationHistoryRepository
.
findByAdministrator
OrderByOperationTimeDesc
(
userna
me
,
pageable
);
operationHistories
=
operationHistoryRepository
.
findByAdministrator
AndOperationTimeGreaterThanOrderByOperationTimeDesc
(
username
,
ti
me
,
pageable
);
}
else
{
operationHistories
=
operationHistoryRepository
.
findByAccount
OrderByOperationTimeDesc
(
userna
me
,
pageable
);
operationHistories
=
operationHistoryRepository
.
findByAccount
AndOperationTimeGreaterThanOrderByOperationTimeDesc
(
username
,
ti
me
,
pageable
);
}
List
<
OperationHistoryDto
>
operationHistoryDtos
=
new
ArrayList
<>();
...
...
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