package com.zcloud.personnel.positioning.persistence.repository.impl;

import com.zcloud.personnel.positioning.persistence.dataobject.FencePointDO;
import com.zcloud.personnel.positioning.persistence.mapper.FencePointMapper;
import com.zcloud.personnel.positioning.persistence.repository.FencePointRepository;
import com.zcloud.gbscommon.utils.PageQueryHelper;
import com.zcloud.gbscommon.utils.Query;
import com.alibaba.cola.dto.PageResponse;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.jjb.saas.framework.repository.common.PageHelper;
import com.jjb.saas.framework.repository.repo.impl.BaseRepositoryImpl;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * web-infrastructure
 *
 * @Author fangjiakai
 * @Date 2026-07-07
 */
@Service
@RequiredArgsConstructor
public class FencePointRepositoryImpl extends BaseRepositoryImpl<FencePointMapper, FencePointDO> implements FencePointRepository {
    private final FencePointMapper fencePointMapper;

    @Override
    public PageResponse<FencePointDO> listPage(Map<String, Object> params) {
        IPage<FencePointDO> iPage = new Query<FencePointDO>().getPage(params);
        QueryWrapper<FencePointDO> queryWrapper = new QueryWrapper<>();
        queryWrapper = PageQueryHelper.createPageQueryWrapper(queryWrapper, params);
        queryWrapper.orderByDesc("create_time");
        IPage<FencePointDO> result = fencePointMapper.selectPage(iPage, queryWrapper);
        return PageHelper.pageToResponse(result, result.getRecords());
    }
}
