package com.lovenav.service.serviceImpl;

import com.lovenav.dao.LoginLogsDao;
import com.lovenav.entity.LoginLogs;
import com.lovenav.service.LoginLogsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class LoginLogsServiceImpl implements LoginLogsService {
    @Autowired
    LoginLogsDao loginLogsDao;
    @Override
    public String addLoginLogs(LoginLogs loginLogs) {
        Date date=new Date();
        loginLogs.setLoginTime(date);
        if (loginLogsDao.selectAlreadyExist(loginLogs.getUserId())==null){
            if (loginLogsDao.insertSelective(loginLogs)!=1){
                return "登录日志更新成功！";
            }
        }else {
            if (loginLogsDao.updateByUserId(loginLogs)!=1){
                return "登录日志更新失败！";
            }
        }
        return "更新登录日志失败";
    }
}
