package com.zcloud.primeport.persistence.repository.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zcloud.primeport.domain.enums.MenuEnum;
import com.zcloud.primeport.persistence.dataobject.ClosedAreaCarApplyDO;
import com.zcloud.primeport.persistence.mapper.ClosedAreaCarApplyMapper;
import com.zcloud.primeport.persistence.repository.ClosedAreaCarApplyRepository;
import com.alibaba.cola.dto.PageResponse;
import com.jjb.saas.framework.repository.common.PageHelper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.jjb.saas.framework.repository.repo.impl.BaseRepositoryImpl;
import com.zcloud.primeport.plan.mjDevice.dto.TwoLevelCar;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;
import java.util.Map;

/**
 * web-infrastructure
 *
 * @Author dearLin
 * @Date 2026-03-20 10:07:15
 */
@Service
@RequiredArgsConstructor
public class ClosedAreaCarApplyRepositoryImpl extends BaseRepositoryImpl<ClosedAreaCarApplyMapper, ClosedAreaCarApplyDO> implements ClosedAreaCarApplyRepository {
    private final ClosedAreaCarApplyMapper closedAreaCarApplyMapper;

    @Override
    public PageResponse<ClosedAreaCarApplyDO> listPage(Map<String, Object> params) {
        Page<Map<String, Object>> page = new Page<>(Integer.parseInt(params.get("pageIndex").toString()),
                Integer.parseInt(params.get("pageSize").toString()));
        page.setOptimizeJoinOfCountSql(false);
        String menuPerms = "";
        if (!org.springframework.util.ObjectUtils.isEmpty(params.get("menuPath"))) {
            menuPerms = MenuEnum.getMenuKeyByPath(params.get("menuPath").toString());
        }
        IPage<ClosedAreaCarApplyDO> result = closedAreaCarApplyMapper.listPage(page, params, menuPerms);
        return PageHelper.pageToResponse(result, result.getRecords());
    }

    @Override
    public List<TwoLevelCar> getFgsCarToDay(String licenceNo) {
        return closedAreaCarApplyMapper.getFgsCarToDay(licenceNo);
    }

    @Override
    public List<TwoLevelCar> dockTmpCarLevelTwo(String licenceNo) {
        return closedAreaCarApplyMapper.dockTmpCarLevelTwo(licenceNo);
    }
}

