Commit 6aae1d14 authored by renjie's avatar renjie

修改account字段为username

parent 45c586c7
......@@ -13,7 +13,7 @@ import java.time.format.DateTimeFormatter;
public class LoginHistory {
@Id
private String id;
private String account;
private String username;
private String nickname;
private String loginIp;
private String loginPlace;
......@@ -26,7 +26,7 @@ public class LoginHistory {
public LoginHistory(LoginHistoryDto loginHistoryDto) {
if (loginHistoryDto.getAccount() != null)
this.account = loginHistoryDto.getAccount();
this.username = loginHistoryDto.getAccount();
if (loginHistoryDto.getNickname() != null)
this.nickname = loginHistoryDto.getNickname();
if (loginHistoryDto.getLoginIp() != null)
......@@ -72,12 +72,12 @@ public class LoginHistory {
this.loginIp = loginIp;
}
public String getAccount() {
return account;
public String getUsername() {
return username;
}
public void setAccount(String account) {
this.account = account;
public void setUsername(String username) {
this.username = username;
}
public long getLoginTime() {
......
......@@ -12,7 +12,7 @@ import java.time.format.DateTimeFormatter;
public class OperationHistory {
@Id
private String id;
private String account;
private String username;
private String nickname;
private String loginIp;
private String loginPlace;
......@@ -26,7 +26,7 @@ public class OperationHistory {
public OperationHistory(OperationHistoryDto operationHistoryDto) {
if (operationHistoryDto.getAccount() != null)
this.account = operationHistoryDto.getAccount();
this.username = operationHistoryDto.getAccount();
if (operationHistoryDto.getNickname() != null)
this.nickname = operationHistoryDto.getNickname();
if (operationHistoryDto.getLoginIp() != null)
......@@ -50,12 +50,12 @@ public class OperationHistory {
this.id = id;
}
public String getAccount() {
return account;
public String getUsername() {
return username;
}
public void setAccount(String account) {
this.account = account;
public void setUsername(String username) {
this.username = username;
}
public long getOperationTime() {
......
......@@ -21,8 +21,8 @@ public class LoginHistoryDto {
}
public LoginHistoryDto(LoginHistory loginHistory) {
if (loginHistory.getAccount() != null)
this.account = loginHistory.getAccount();
if (loginHistory.getUsername() != null)
this.account = loginHistory.getUsername();
if (loginHistory.getNickname() != null)
this.nickname = loginHistory.getNickname();
if (loginHistory.getLoginIp() != null)
......
......@@ -21,8 +21,8 @@ public class OperationHistoryDto {
}
public OperationHistoryDto(OperationHistory operationHistory) {
if (operationHistory.getAccount() != null)
this.account = operationHistory.getAccount();
if (operationHistory.getUsername() != null)
this.account = operationHistory.getUsername();
if (operationHistory.getNickname() != null)
this.nickname = operationHistory.getNickname();
if (operationHistory.getLoginIp() != null)
......
......@@ -8,11 +8,11 @@ import org.springframework.data.mongodb.repository.MongoRepository;
import java.util.List;
public interface LoginHistoryRepository extends MongoRepository<LoginHistory, String> {
LoginHistory findFirstByAccount(String account);
LoginHistory findFirstByUsername(String username);
Page<LoginHistory> findByAdministratorAndLoginTimeGreaterThanOrderByLoginTime(String administrator, long time, Pageable pageable);
Page<LoginHistory> findByAccountAndLoginTimeGreaterThanOrderByLoginTime(String account, long time, Pageable pageable);
Page<LoginHistory> findByUsernameAndLoginTimeGreaterThanOrderByLoginTime(String username, long time, Pageable pageable);
int countByAccount(String account);
int countByUsername(String username);
}
......@@ -6,10 +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);
OperationHistory findFirstByUsername(String username);
Page<OperationHistory> findByAdministratorAndOperationTimeGreaterThanOrderByOperationTimeDesc(String administrator, long time, Pageable pageable);
Page<OperationHistory> findByAccountAndOperationTimeGreaterThanOrderByOperationTimeDesc(String account, long time, Pageable pageable);
Page<OperationHistory> findByUsernameAndOperationTimeGreaterThanOrderByOperationTimeDesc(String username, long time, Pageable pageable);
int countByAccount(String account);
int countByUsername(String username);
}
......@@ -39,12 +39,12 @@ 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);
int num = loginHistoryRepository.countByUsername(username);
if (num > 10000)
loginHistoryRepository.delete(loginHistoryRepository.findFirstByAccount(username));
loginHistoryRepository.delete(loginHistoryRepository.findFirstByUsername(username));
LoginHistory loginHistory = new LoginHistory(loginHistoryDto);
loginHistory.setLoginTime(Instant.now().toEpochMilli());
loginHistory.setAccount(username);
loginHistory.setUsername(username);
if (account.getParent() == null)
loginHistory.setAdministrator(username);
else
......@@ -58,12 +58,12 @@ 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);
int num = operationHistoryRepository.countByUsername(username);
if (num > 10000)
operationHistoryRepository.delete(operationHistoryRepository.findFirstByAccount(username));
operationHistoryRepository.delete(operationHistoryRepository.findFirstByUsername(username));
OperationHistory operationHistory = new OperationHistory(operationHistoryDto);
operationHistory.setOperationTime(Instant.now().toEpochMilli());
operationHistory.setAccount(username);
operationHistory.setUsername(username);
operationHistory.setNickname(account.getNickname());
if (account.getParent() == null)
operationHistory.setAdministrator(username);
......@@ -88,7 +88,7 @@ public class HistoryServiceImpl implements HistoryService {
if (account.getParent() == null) {
loginHistoryPage = loginHistoryRepository.findByAdministratorAndLoginTimeGreaterThanOrderByLoginTime(username, time, pageable);
} else {
loginHistoryPage = loginHistoryRepository.findByAccountAndLoginTimeGreaterThanOrderByLoginTime(username, time, pageable);
loginHistoryPage = loginHistoryRepository.findByUsernameAndLoginTimeGreaterThanOrderByLoginTime(username, time, pageable);
}
List<LoginHistoryDto> loginHistoryDtoList = new ArrayList<>();
......@@ -120,7 +120,7 @@ public class HistoryServiceImpl implements HistoryService {
if (account.getParent() == null) {
operationHistories = operationHistoryRepository.findByAdministratorAndOperationTimeGreaterThanOrderByOperationTimeDesc(username, time, pageable);
} else {
operationHistories = operationHistoryRepository.findByAccountAndOperationTimeGreaterThanOrderByOperationTimeDesc(username, time, pageable);
operationHistories = operationHistoryRepository.findByUsernameAndOperationTimeGreaterThanOrderByOperationTimeDesc(username, time, pageable);
}
List<OperationHistoryDto> operationHistoryDtos = new ArrayList<>();
......
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