package cn.qinys.platform.upms.api.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import cn.qinys.platform.entity.upms.GatewayLog;
import cn.qinys.platform.upms.api.mapper.GatewayLogMapper;
import cn.qinys.platform.upms.api.req.GatewayLogPageReq;
import cn.qinys.platform.upms.api.resp.GatewayLogPageResp;
import cn.qinys.platform.upms.api.service.IGatewayService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;



/**
 * Description:
 *
 * @author tanlie
 * Date: 2024/4/26 17:32
 */
@Service
public class GatewayServiceImpl implements IGatewayService {

    @Resource
    GatewayLogMapper logMapper;

    @Override
    public Page<GatewayLogPageResp> getPage(GatewayLogPageReq req) {
        Page<GatewayLog> page = new Page<>(req.getCurrent(), req.getSize());
        QueryWrapper<GatewayLog> wrapper = new QueryWrapper<>();
        wrapper.eq(StringUtils.hasLength(req.getUserMobile()),"user_mobile",req.getUserMobile());
        wrapper.like(StringUtils.hasLength(req.getToken()),"token",req.getToken());
        wrapper.like(StringUtils.hasLength(req.getRequestPath()),"request_path",req.getRequestPath());
        wrapper.orderByDesc("id");
        return logMapper.selectLogPage(page,wrapper);
    }
}
