package com.agileboot.system.log.dto;

import cn.hutool.core.util.StrUtil;
import com.agileboot.common.mybatis.core.page.PageQuery;
import com.agileboot.system.log.entity.SysLoginInfo;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.Data;

/**
 * @author valarchie
 */
@Data
public class LoginLogQuery extends PageQuery<SysLoginInfo> {

    private String ipAddress;
    private String status;
    private String username;

    @Override
    public LambdaQueryWrapper<SysLoginInfo> toQueryWrapper() {
        return Wrappers.lambdaQuery(SysLoginInfo.class)
                .like(StrUtil.isNotEmpty(ipAddress), SysLoginInfo::getIpAddress, ipAddress)
                .eq(StrUtil.isNotEmpty(status), SysLoginInfo::getStatus, status)
                .like(StrUtil.isNotEmpty(username), SysLoginInfo::getUsername, username);
    }
}
