package com.community.huiju.service.impl;

import com.community.huiju.dao.TaSysMenuImgMapper;
import com.community.huiju.dao.TaSysMenuMapper;
import com.community.huiju.model.TaSysMenu;
import com.community.huiju.model.TaSysMenuImg;
import com.community.huiju.service.MenuServiceI;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author FXF
 * @date 2018-11-05
 */
@Service("menuService")
public class MenuServiceImpl implements MenuServiceI {
	
	@Autowired
	private TaSysMenuMapper taSysMenuMapper;
	
	@Autowired
	private TaSysMenuImgMapper taSysMenuImgMapper;
	
	/**
	 * 获取菜单列表
	 * @param communityId
	 * @return
	 */
	@Override
	public List<TaSysMenu> getMenuList(Integer communityId) {
		//获取菜单列表
		List<TaSysMenu> menuList = taSysMenuMapper.selectByCommunity(communityId);
		menuList.stream().forEach(menu -> {
			List<TaSysMenuImg> menuImgList = taSysMenuImgMapper.selectByMenuId(menu.getId());
			menu.setMenuImgList(menuImgList);
		});
		return menuList;
	}
}
