|
|
@ -78,9 +78,11 @@ public class TchLoginLogAndStuListServiceImpl implements TchLoginLogAndStuListSe
|
|
|
|
//loginTimeLast 都不为 null 的情况
|
|
|
|
//loginTimeLast 都不为 null 的情况
|
|
|
|
|
|
|
|
|
|
|
|
TchLoginLogExample example = new TchLoginLogExample();
|
|
|
|
TchLoginLogExample example = new TchLoginLogExample();
|
|
|
|
|
|
|
|
example.setOrderByClause("exit_time_last desc");
|
|
|
|
example.createCriteria().andUserIdEqualTo(loginLogDTO.getUserId()).andSchoolIdEqualTo(loginLogDTO.getSchoolId());
|
|
|
|
example.createCriteria().andUserIdEqualTo(loginLogDTO.getUserId()).andSchoolIdEqualTo(loginLogDTO.getSchoolId());
|
|
|
|
List<TchLoginLog> tchLoginLogList = tchLoginLogMapper.selectByExample(example);
|
|
|
|
List<TchLoginLog> tchLoginLogList = tchLoginLogMapper.selectByExample(example);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (tchLoginLogList.isEmpty()) { //首次登录
|
|
|
|
if (tchLoginLogList.isEmpty()) { //首次登录
|
|
|
|
|
|
|
|
|
|
|
|
TchLoginLog tchLoginLog = TchLoginLog.builder()
|
|
|
|
TchLoginLog tchLoginLog = TchLoginLog.builder()
|
|
|
@ -102,28 +104,35 @@ public class TchLoginLogAndStuListServiceImpl implements TchLoginLogAndStuListSe
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
|
|
//多次登录
|
|
|
|
//多次登录
|
|
|
|
TchLoginLog tchLoginLogOld = tchLoginLogList.get(0);
|
|
|
|
TchLoginLog tchLoginLogOld = tchLoginLogList.get(0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//防止未下线多次登陆
|
|
|
|
|
|
|
|
if (tchLoginLogOld.getExitTimeLast() == null || tchLoginLogOld.getOnline() == (byte)1)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return new ResultEntity<>(HttpStatus.OK, "success");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//累计登录天数 和登录时间判断时间是否为同一天,不相同就是登录+1
|
|
|
|
//累计登录天数 和登录时间判断时间是否为同一天,不相同就是登录+1
|
|
|
|
//最近一次登录
|
|
|
|
//最近一次登录
|
|
|
|
LocalDateTime localDateTime = Convert.toLocalDateTime(tchLoginLogOld.getLoginTimeLast());
|
|
|
|
LocalDateTime localDateTime = Convert.toLocalDateTime(tchLoginLogOld.getLoginTimeLast());
|
|
|
|
//这一次登录
|
|
|
|
//这一次登录
|
|
|
|
LocalDateTime newlocalDateTime = Convert.toLocalDateTime(loginLogDTO.getLoginTimeLast());
|
|
|
|
LocalDateTime newlocalDateTime = Convert.toLocalDateTime(loginLogDTO.getLoginTimeLast());
|
|
|
|
|
|
|
|
|
|
|
|
//判断是否为同一天
|
|
|
|
// 判断是否为同一天
|
|
|
|
if (!localDateTime.equals(newlocalDateTime)) {
|
|
|
|
if (!localDateTime.toLocalDate().equals(newlocalDateTime.toLocalDate())) {
|
|
|
|
tchLoginLogOld.setTotalLoginDays(tchLoginLogOld.getTotalLoginDays() + 1);
|
|
|
|
tchLoginLogOld.setTotalLoginDays(tchLoginLogOld.getTotalLoginDays() + 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
tchLoginLogOld.setLoginTimeLast(loginLogDTO.getLoginTimeLast());
|
|
|
|
tchLoginLogOld.setLoginTimeLast(loginLogDTO.getLoginTimeLast());
|
|
|
|
//在线状态
|
|
|
|
//在线状态
|
|
|
|
tchLoginLogOld.setOnline((byte) 1);
|
|
|
|
tchLoginLogOld.setOnline((byte) 1);
|
|
|
|
tchLoginLogOld.setLoginIp(ip);
|
|
|
|
tchLoginLogOld.setLoginIp(ip);
|
|
|
|
tchLoginLogOld.setIpOwnerLocation(ipAddress);
|
|
|
|
tchLoginLogOld.setIpOwnerLocation(ipAddress);
|
|
|
|
|
|
|
|
tchLoginLogOld.setId(null);
|
|
|
|
|
|
|
|
tchLoginLogOld.setExitTimeLast(null);
|
|
|
|
tchLoginLogMapper.updateByPrimaryKey(tchLoginLogOld);
|
|
|
|
tchLoginLogMapper.insertSelective(tchLoginLogOld);
|
|
|
|
return new ResultEntity<>(HttpStatus.OK, "success");
|
|
|
|
return new ResultEntity<>(HttpStatus.OK, "success");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -132,7 +141,9 @@ public class TchLoginLogAndStuListServiceImpl implements TchLoginLogAndStuListSe
|
|
|
|
if (loginLogDTO.getExitTimeLast() != null) {
|
|
|
|
if (loginLogDTO.getExitTimeLast() != null) {
|
|
|
|
|
|
|
|
|
|
|
|
TchLoginLogExample example = new TchLoginLogExample();
|
|
|
|
TchLoginLogExample example = new TchLoginLogExample();
|
|
|
|
|
|
|
|
example.setOrderByClause("exit_time_last desc");
|
|
|
|
example.createCriteria().andUserIdEqualTo(loginLogDTO.getUserId()).andSchoolIdEqualTo(loginLogDTO.getSchoolId());
|
|
|
|
example.createCriteria().andUserIdEqualTo(loginLogDTO.getUserId()).andSchoolIdEqualTo(loginLogDTO.getSchoolId());
|
|
|
|
|
|
|
|
|
|
|
|
List<TchLoginLog> tchLoginLogList = tchLoginLogMapper.selectByExample(example);
|
|
|
|
List<TchLoginLog> tchLoginLogList = tchLoginLogMapper.selectByExample(example);
|
|
|
|
|
|
|
|
|
|
|
|
if (tchLoginLogList.isEmpty()) { //首次登录
|
|
|
|
if (tchLoginLogList.isEmpty()) { //首次登录
|
|
|
|