package com.zcloud.fire.check.persistence.repository.impl;

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 com.zcloud.fire.check.persistence.dataobject.FireCheckRecordUserDO;
import com.zcloud.fire.check.persistence.mapper.FireCheckRecordUserMapper;
import com.zcloud.fire.check.persistence.repository.FireCheckRecordUserRepository;
import com.zcloud.gbscommon.utils.PageQueryHelper;
import com.zcloud.gbscommon.utils.Query;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

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

/**
 * web-infrastructure
 *
 * @Author zhaokai
 * @Date 2025-12-12 11:12:04
 */
@Service
@RequiredArgsConstructor
public class FireCheckRecordUserRepositoryImpl extends BaseRepositoryImpl<FireCheckRecordUserMapper, FireCheckRecordUserDO> implements FireCheckRecordUserRepository {
    private final FireCheckRecordUserMapper fireCheckRecordUserMapper;

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

    @Override
    public List<FireCheckRecordUserDO> getListByFireRecordId(String fireRecordId) {
        QueryWrapper<FireCheckRecordUserDO> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("fire_record_id", fireRecordId);
        return fireCheckRecordUserMapper.selectList(queryWrapper);
    }
}

