package com.hai.user.service.impl;

import com.hai.dao.HighUserLoginLogMapper;
import com.hai.entity.HighUserLoginLog;
import com.hai.entity.HighUserLoginLogExample;
import com.hai.user.service.UserLoginLogService;
import org.apache.commons.collections4.MapUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @className: UserLoginLogServiceImpl
 * @author: HuRui
 * @date: 2022/10/25
 **/
@Service("userLoginLogService")
public class UserLoginLogServiceImpl implements UserLoginLogService {

    @Resource
    private HighUserLoginLogMapper userLoginLogMapper;

    @Override
    public List<HighUserLoginLog> getUserLoginLogList(Map<String, Object> param) {
        HighUserLoginLogExample example = new HighUserLoginLogExample();
        HighUserLoginLogExample.Criteria criteria = example.createCriteria().andStatusNotEqualTo(0);

        if (MapUtils.getLong(param, "userId") != null) {
            criteria.andUserIdEqualTo(MapUtils.getLong(param, "userId"));
        }

        example.setOrderByClause("create_time desc");
        return userLoginLogMapper.selectByExample(example);
    }
}
