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

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.yulichang.base.MPJBaseServiceImpl;
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 java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
* @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);
    }
}
