Dorado 7 : 14.3.1.2 准备后台服务

步骤1:在com.bstek.dorado.sample.standardlesson.service包中新建DeptService.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.SlDeptDao;
import com.bstek.dorado.sample.standardlesson.entity.SlDept;
@Component
public class DeptService {
    @Resource
    private SlDeptDao slDeptDao;
    
    @DataProvider
    public Collection<SlDept> getTopDept(){
        return slDeptDao.find("from SlDept where slDept.deptId is null");
    }
}

从代码看很简单仅仅就是返回了上级部门字段为空的部门信息即顶层部门信息,而对应下级部门信息则通过Hibernate的配置@OneToMany(fetch = FetchType.LAZY, mappedBy = "slDept")自动完成数据加载工作