package com.chushang.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.chushang.common.mybatis.page.CommonParam;
import com.chushang.system.entity.po.SysDictType;
import com.chushang.system.entity.po.SysLoginInfo;
import com.chushang.system.entity.po.SysPost;
import com.chushang.system.mapper.SysLoginInfoMapper;
import com.chushang.system.service.SysLoginInfoService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class SysLoginInfoServiceImpl extends ServiceImpl<SysLoginInfoMapper, SysLoginInfo> implements SysLoginInfoService {

    @Override
    public LambdaQueryWrapper<SysLoginInfo> buildWrapper(SysLoginInfo loginInfo, CommonParam commonParam) {
        return new QueryWrapper<SysLoginInfo>()
                .orderBy(true, "asc".equals(commonParam.getIsAsc()), commonParam.getOrderBy())
                .lambda()
                .eq(null != loginInfo.getInfoId(), SysLoginInfo::getInfoId, loginInfo.getInfoId())
                .eq(StringUtils.isNotEmpty(loginInfo.getUserName()), SysLoginInfo::getUserName, loginInfo.getUserName())
                .eq(StringUtils.isNotEmpty(loginInfo.getIpaddr()), SysLoginInfo::getIpaddr, loginInfo.getIpaddr())
                .eq(null != loginInfo.getStatus(), SysLoginInfo::getStatus, loginInfo.getStatus());
    }
}
