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.FireCheckListStatisticDO;
import com.zcloud.fire.check.persistence.dataobject.FireCheckListUserDO;
import com.zcloud.fire.check.persistence.mapper.FireCheckListUserMapper;
import com.zcloud.fire.check.persistence.repository.FireCheckListUserRepository;
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-11 15:32:50
 */
@Service
@RequiredArgsConstructor
public class FireCheckListUserRepositoryImpl extends BaseRepositoryImpl<FireCheckListUserMapper, FireCheckListUserDO> implements FireCheckListUserRepository {
    private final FireCheckListUserMapper fireCheckListUserMapper;

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

    @Override
    public void deleteByFireCheckListId(String fireCheckListId) {
        QueryWrapper<FireCheckListUserDO> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("fire_check_id", fireCheckListId);
        fireCheckListUserMapper.delete(queryWrapper);
    }

    @Override
    public List<FireCheckListUserDO> getListUserNameByFireCheckIdList(List<String> fireCheckIdList) {
        return fireCheckListUserMapper.getListUserNameByFireCheckIdList(fireCheckIdList);
    }

    @Override
    public List<FireCheckListStatisticDO> getListUserStatisticByFireCheckIdList(List<String> fireCheckIdList) {
        return fireCheckListUserMapper.getListUserStatisticByFireCheckIdList(fireCheckIdList);
    }



    @Override
    public List<FireCheckListUserDO> getListUserByFireCheckIdList(List<String> fireCheckIdList) {
        return fireCheckListUserMapper.getListUserByFireCheckIdList(fireCheckIdList);
    }

    @Override
    public List<FireCheckListUserDO> getListByFireCheckId(String fireCheckId) {
        return fireCheckListUserMapper.getListByFireCheckId(fireCheckId);

    }

    @Override
    public List<FireCheckListUserDO> getListUserIdByFireCheckIdList(List<String> fireCheckIdList) {
        return fireCheckListUserMapper.getListUserIdByFireCheckIdList(fireCheckIdList);
    }
}

