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.DomainDepartmentUserDO;
import com.zcloud.domain.persistence.mapper.DomainDepartmentUserMapper;
import com.zcloud.domain.persistence.repository.DomainDepartmentUserRepository;
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:09
 */
@Service
@RequiredArgsConstructor
public class DomainDepartmentUserRepositoryImpl extends BaseRepositoryImpl<DomainDepartmentUserMapper, DomainDepartmentUserDO> implements DomainDepartmentUserRepository {
    private final DomainDepartmentUserMapper domainDepartmentUserMapper;

    @Override
    public PageResponse<DomainDepartmentUserDO> listPage(Map<String, Object> params) {
        IPage<DomainDepartmentUserDO> iPage = new Query<DomainDepartmentUserDO>().getPage(params);
        IPage<DomainDepartmentUserDO> result = domainDepartmentUserMapper.listPage(iPage, params);
        return PageHelper.pageToResponse(result, result.getRecords());
    }

    @Override
    public void deleteByDomainDepartmentId(String domainDepartmentId) {

        remove(new QueryWrapper<DomainDepartmentUserDO>().eq("domain_department_id", domainDepartmentId));
    }

    @Override
    public List<DomainDepartmentUserDO> getListByDomainDepartmentId(String domainDepartmentId) {
        return domainDepartmentUserMapper.getListByDomainDepartmentId(domainDepartmentId);
    }
}

