package com.mosty.bkzx.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mosty.base.model.dto.bkzx.XdxxQuery;
import com.mosty.bkzx.mapper.XdxxMapper;
import com.mosty.bkzx.service.XdxxService;
import com.mosty.common.token.UserInfo;
import com.mosty.common.token.UserInfoManager;
import com.mosty.common.util.PermissionsUtil;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
@AllArgsConstructor
public class XdxxServiceImpl implements XdxxService {

    private final XdxxMapper xdxxMapper;

    @Override
    public IPage<Map<String, Object>> queryXdxxBYSzfh(XdxxQuery dto) {
        Map<String, Object> map = new HashMap<>();
        map.put("pageIndex", (dto.getPageCurrent() - 1) * dto.getPageSize());
        map.put("pageSize", dto.getPageSize());
        map.put("dto", dto);
        int count = this.xdxxMapper.queryXdxxBYSzfhCount(map);
        List<Map<String, Object>> list = this.xdxxMapper.queryXdxxBYSzfh(map);
        IPage<Map<String, Object>> page = new Page<>(dto.getPageCurrent(), dto.getPageSize());
        page.setTotal(count);
        page.setRecords(list);
        return page;
    }

    @Override
    public IPage<Map<String, Object>> xdrylb(XdxxQuery dto) {
        Map<String, Object> map = new HashMap<>();
        map.put("pageIndex", (dto.getPageCurrent() - 1) * dto.getPageSize());
        map.put("pageSize", dto.getPageSize());
        map.put("dto", dto);
        int count = this.xdxxMapper.xdrylbCount(map);
        List<Map<String, Object>> list = this.xdxxMapper.xdrylb(map);
        IPage<Map<String, Object>> page = new Page<>(dto.getPageCurrent(), dto.getPageSize());
        page.setTotal(count);
        page.setRecords(list);
        return page;
    }

    @Override
    public List<Map<String, Object>> xdrytj(XdxxQuery dto) {
        Map<String, Object> map = new HashMap<>();
        map.put("dto", dto);
        return this.xdxxMapper.xdrytj(map);
    }

    @Override
    public IPage<Map<String, Object>> xdxxlb(XdxxQuery dto) {
        Map<String, Object> map = new HashMap<>();
        map.put("pageIndex", (dto.getPageCurrent() - 1) * dto.getPageSize());
        map.put("pageSize", dto.getPageSize());
        map.put("dto", dto);
        int count = this.xdxxMapper.xdxxlbCount(map);
        List<Map<String, Object>> list = this.xdxxMapper.xdxxlb(map);
        IPage<Map<String, Object>> page = new Page<>(dto.getPageCurrent(), dto.getPageSize());
        page.setTotal(count);
        page.setRecords(list);
        return page;
    }

    @Override
    public List<Map<String, Object>> xdxxtj(XdxxQuery dto) {
        Map<String, Object> map = new HashMap<>();
        map.put("dto", dto);
        return this.xdxxMapper.xdxxtj(map);
    }
}
