package com.jwipc.sys.logic.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jwipc.page.PageUtil;
import com.jwipc.page.PageView;
import com.jwipc.sys.entity.EmailLog;
import com.jwipc.sys.entity.UserLogin;
import com.jwipc.sys.logic.EmailLogLogic;
import com.jwipc.sys.logic.LoginLogLogic;
import com.jwipc.sys.model.po.EmailLogPO;
import com.jwipc.sys.model.po.UserLoginPO;
import com.jwipc.sys.model.query.EmailLogQuery;
import com.jwipc.sys.model.query.LoginLogQuery;
import com.jwipc.sys.service.IEmailLogService;
import com.jwipc.sys.service.IUserLoginService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author shenyang.ou
 * @date 2024/1/30 9:27
 * @desc 邮件日志
 */
@Service
@RequiredArgsConstructor
public class LoginLogLogicImpl implements LoginLogLogic {

    private final IUserLoginService userLoginService;

    @Override
    public PageView findByPage(LoginLogQuery query) {
        final Page<UserLogin> dbPage = PageUtil.toPage(query);
        List<UserLoginPO> userLoginPOS = userLoginService.findPageByQuery(dbPage, query);
        return PageUtil.getPV(userLoginPOS, dbPage.getTotal());
    }
}
