package com.ruoyi.system.service.impl;

import com.mybatisflex.solon.service.impl.ServiceImpl;
import com.ruoyi.common.constants.CacheConstant;
import com.ruoyi.common.utils.RedisUtil;
import com.ruoyi.system.domain.SysLoginLog;
import com.ruoyi.system.mapper.SysLoginLogMapper;
import com.ruoyi.system.service.ISysLoginLogService;
import org.noear.solon.annotation.Component;
import org.noear.solon.annotation.Inject;

/**
 * 登录日志 服务层实现
 * @author ruoyi
 */
@Component
public class SysLoginLogServiceImpl extends ServiceImpl<SysLoginLogMapper, SysLoginLog> implements ISysLoginLogService {

    @Inject
    SysLoginLogMapper sysLoginLogMapper;

    @Inject
    RedisUtil redisUtil;

    /**
     * 解锁用户登录状态
     * @param userName
     * @return
     */
    @Override
    public void unlock(String userName) {
        redisUtil.deleteCacheObject(CacheConstant.LOGIN_ERROR_KEY + userName);
    }

    /**
     * 清空登录日志
     */
    @Override
    public void clean() {
        sysLoginLogMapper.clean();
    }

}
