Commit 2bb22ccb authored by renjie's avatar renjie

操作日志

parent 319323e5
package com.edgec.browserbackend.browser.domain;
import com.edgec.browserbackend.browser.dto.LoginHistoryDto;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import java.time.Instant;
......@@ -10,6 +11,8 @@ import java.time.format.DateTimeFormatter;
@Document(collection = "loginhistory")
public class LoginHistory {
@Id
private String id;
private String account;
private String nickname;
private String loginIp;
......@@ -37,6 +40,14 @@ public class LoginHistory {
}
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getNickname() {
return nickname;
}
......
package com.edgec.browserbackend.browser.domain;
import com.edgec.browserbackend.browser.dto.OperationHistoryDto;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import java.time.LocalDateTime;
......@@ -9,6 +10,8 @@ import java.time.format.DateTimeFormatter;
@Document(collection = "operationhistory")
public class OperationHistory {
@Id
private String id;
private String account;
private String nickname;
private String loginIp;
......@@ -39,6 +42,14 @@ public class OperationHistory {
}
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getAccount() {
return account;
}
......
......@@ -39,7 +39,7 @@ public class HistoryServiceImpl implements HistoryService {
if (account == null)
throw new ClientRequestException(AccountErrorCode.NAMENOTEXIST);
int num = loginHistoryRepository.countByAccount(username);
if (num > 10000)
if (num > 10)
loginHistoryRepository.delete(loginHistoryRepository.findFirstByAccount(username));
LoginHistory loginHistory = new LoginHistory(loginHistoryDto);
loginHistory.setLoginTime(Instant.now().toEpochMilli());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment