package com.xjrsoft.module.system.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.yulichang.base.MPJBaseServiceImpl;
import com.xjrsoft.module.evaluate.mapper.EvaluateTemplateMapper;
import com.xjrsoft.module.evaluate.vo.EvaluateTemplatePageVo;
import com.xjrsoft.module.system.dto.AddXjrMenuDeptRelationDto;
import com.xjrsoft.module.system.dto.XjrMenuDeptRelationPageDto;
import com.xjrsoft.module.system.entity.XjrMenuDeptRelation;
import com.xjrsoft.module.system.mapper.XjrMenuDeptRelationMapper;
import com.xjrsoft.module.system.service.IXjrMenuDeptRelationService;
import com.xjrsoft.module.system.vo.XjrMenuDeptRelationPageVo;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;

/**
* @title: 菜单部门关联表
* @Author brealinxx
* @Date: 2024-04-09
* @Version 1.0
*/
@Service
@AllArgsConstructor
public class XjrMenuDeptRelationServiceImpl extends MPJBaseServiceImpl<XjrMenuDeptRelationMapper, XjrMenuDeptRelation> implements IXjrMenuDeptRelationService {
    private final XjrMenuDeptRelationMapper xjrMenuDeptRelationMapper;

    @Override
    public Page<XjrMenuDeptRelationPageVo> getPage(Page<XjrMenuDeptRelationPageDto> page, XjrMenuDeptRelationPageDto dto) {
        List<String> deptIds = new ArrayList<>();
        if (dto.getDepts() != null && !dto.getDepts().isEmpty()) {
            deptIds = Arrays.asList(dto.getDepts().split(","));
        }

        return xjrMenuDeptRelationMapper.getPage(page, deptIds);
    }
}
