Dorado 7 : 22.3.1.2 准备后台服务

步骤1:在com.bstek.dorado.sample.standardlesson.service包中新建MenuService.java,代码如下:

package com.bstek.dorado.sample.standardlesson.service;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.Resource;
import org.springframework.stereotype.Component;
import com.bstek.dorado.annotation.DataProvider;
import com.bstek.dorado.sample.standardlesson.dao.SlMenuDao;
import com.bstek.dorado.sample.standardlesson.entity.SlMenu;
@Component
public class MenuService {
    @Resource
    private SlMenuDao slMenuDao;
    
    @DataProvider
    public Collection<SlMenu> getTopMenu(){
        return slMenuDao.find("from SlMenu where slMenu.menuId is null");
    }
    
    @DataProvider
    public Collection<SlMenu> getMenuByParentId(Integer parentId){
        if(null != parentId){
            String hql = "from SlMenu where slMenu.menuId = :menuId";
            Map param = new HashMap();
            param.put("menuId", parentId);
            return slMenuDao.find(hql, param);
        }else{
            return null;
        }
    }
}