/*
 * Author: wangjian
 * 生成ServiceImpl
 */
package com.tofly.base.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tofly.base.entity.Department;
import com.tofly.base.mapper.DepartmentMapper;
import com.tofly.base.service.DepartmentService;
import com.tofly.base.service.SourcedicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 部门表
 *
 * @author admin
 * @date Thu Oct 10 00:00:00 CST 2019
 */
@Service("departmentService")
public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Department> implements DepartmentService {
    
    @Autowired
    private SourcedicService sourcedicService;
    
    @Override
    public List<Map> listSourceByDept(Long departmentId) {
        List<Map<String,Object>> sourcedicList=sourcedicService.listMaps();
        List<Map> reList=new ArrayList<>();
        Map m=new HashMap(),map;
        m.put("departmentId",departmentId);
        for(Map map1:sourcedicList){
            m.put("pid",map1.get("id"));
            map1.put("funs",baseMapper.listSourceByDept(m));
            reList.add(map1);
        };
        
        return reList;
    }

    @Override
    public List<Department> subList(Long id, String returnSelf) {
        return baseMapper.subList(id,returnSelf);
    }
}
