package cn.com.ty.lift.system.user.service.impl;

import cn.com.ty.lift.system.user.dao.entity.UserLogin;
import cn.com.ty.lift.system.user.dao.mapper.UserLoginMapper;
import cn.com.ty.lift.system.user.service.IUserLoginService;
import cn.com.ty.lift.system.utils.CommonUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 用户登录记录表 服务实现类
 * </p>
 *
 * @author wang-hai-cheng
 * @since 2019-12-10
 */
@Service
public class UserLoginService extends ServiceImpl<UserLoginMapper, UserLogin> implements IUserLoginService {

    @Override
    public boolean saveLoginInfo(HttpServletRequest request, Long userId){
        UserLogin userLogin = new UserLogin();
        userLogin.setUserId(userId);
        userLogin.setIp(CommonUtil.getIpAddress(request));
        //添加登录记录
        return this.save(userLogin);
    }

}
