package com.zcloud.domain.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.domain.persistence.dataobject.DomainGroupUserDO;
import com.zcloud.domain.persistence.mapper.DomainGroupUserMapper;
import com.zcloud.domain.persistence.repository.DomainGroupUserRepository;
import com.zcloud.gbscommon.utils.PageQueryHelper;
import com.zcloud.gbscommon.utils.Query;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

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

/**
 * web-infrastructure
 *
 * @Author zhaokai
 * @Date 2026-01-27 11:29:43
 */
@Service
@RequiredArgsConstructor
public class DomainGroupUserRepositoryImpl extends BaseRepositoryImpl<DomainGroupUserMapper, DomainGroupUserDO> implements DomainGroupUserRepository {
    private final DomainGroupUserMapper domainGroupUserMapper;

    @Override
    public PageResponse<DomainGroupUserDO> listPage(Map<String, Object> params) {
        IPage<DomainGroupUserDO> iPage = new Query<DomainGroupUserDO>().getPage(params);

        IPage<DomainGroupUserDO> result = domainGroupUserMapper.listPage(iPage, params);
        return PageHelper.pageToResponse(result, result.getRecords());
    }

    @Override
    public void deleteByDomainGroupId(String domainGroupId) {

        remove(new QueryWrapper<DomainGroupUserDO>().eq("domain_group_id", domainGroupId));
    }

    @Override
    public List<DomainGroupUserDO> getListByGroupId(String domainGroupId) {
        return domainGroupUserMapper.getListByGroupId(domainGroupId);
    }
}

