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
319323e5
Commit
319323e5
authored
Mar 24, 2020
by
renjie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
操作日志
parent
97bc113a
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
0 deletions
+14
-0
LoginHistoryRepository.java
...serbackend/browser/repository/LoginHistoryRepository.java
+4
-0
OperationHistoryRepository.java
...ackend/browser/repository/OperationHistoryRepository.java
+4
-0
HistoryServiceImpl.java
...owserbackend/browser/service/Impl/HistoryServiceImpl.java
+6
-0
No files found.
src/main/java/com/edgec/browserbackend/browser/repository/LoginHistoryRepository.java
View file @
319323e5
...
...
@@ -6,7 +6,11 @@ import org.springframework.data.domain.Pageable;
import
org.springframework.data.mongodb.repository.MongoRepository
;
public
interface
LoginHistoryRepository
extends
MongoRepository
<
LoginHistory
,
String
>
{
LoginHistory
findFirstByAccount
(
String
account
);
Page
<
LoginHistory
>
findByAdministratorOrderByLoginTime
(
String
administrator
,
Pageable
pageable
);
Page
<
LoginHistory
>
findByAccountOrderByLoginTime
(
String
account
,
Pageable
pageable
);
int
countByAccount
(
String
account
);
}
src/main/java/com/edgec/browserbackend/browser/repository/OperationHistoryRepository.java
View file @
319323e5
...
...
@@ -6,6 +6,10 @@ import org.springframework.data.domain.Pageable;
import
org.springframework.data.mongodb.repository.MongoRepository
;
public
interface
OperationHistoryRepository
extends
MongoRepository
<
OperationHistory
,
String
>
{
OperationHistory
findFirstByAccount
(
String
account
);
Page
<
OperationHistory
>
findByAdministratorOrderByOperationTimeDesc
(
String
administrator
,
Pageable
pageable
);
Page
<
OperationHistory
>
findByAccountOrderByOperationTimeDesc
(
String
account
,
Pageable
pageable
);
int
countByAccount
(
String
account
);
}
src/main/java/com/edgec/browserbackend/browser/service/Impl/HistoryServiceImpl.java
View file @
319323e5
...
...
@@ -38,6 +38,9 @@ public class HistoryServiceImpl implements HistoryService {
Account
account
=
accountRepository
.
findById
(
username
).
orElse
(
null
);
if
(
account
==
null
)
throw
new
ClientRequestException
(
AccountErrorCode
.
NAMENOTEXIST
);
int
num
=
loginHistoryRepository
.
countByAccount
(
username
);
if
(
num
>
10000
)
loginHistoryRepository
.
delete
(
loginHistoryRepository
.
findFirstByAccount
(
username
));
LoginHistory
loginHistory
=
new
LoginHistory
(
loginHistoryDto
);
loginHistory
.
setLoginTime
(
Instant
.
now
().
toEpochMilli
());
loginHistory
.
setAccount
(
username
);
...
...
@@ -54,6 +57,9 @@ public class HistoryServiceImpl implements HistoryService {
Account
account
=
accountRepository
.
findById
(
username
).
orElse
(
null
);
if
(
account
==
null
)
throw
new
ClientRequestException
(
AccountErrorCode
.
NAMENOTEXIST
);
int
num
=
operationHistoryRepository
.
countByAccount
(
username
);
if
(
num
>
10000
)
operationHistoryRepository
.
delete
(
operationHistoryRepository
.
findFirstByAccount
(
username
));
OperationHistory
operationHistory
=
new
OperationHistory
(
operationHistoryDto
);
operationHistory
.
setOperationTime
(
Instant
.
now
().
toEpochMilli
());
operationHistory
.
setAccount
(
username
);
...
...
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