SysDictDataMapper.xml

    <select id="selectAllDictData" resultMap="SysDictDataResult">
		<include refid="selectDictDataVo"></include>
	</select>

SysDictDataMapper.java

    /**
     * 查询所有的字典数据
     * @return 字典数据集合信息
     */
    public List<SysDictData> selectAllDictData();

ISysDictDataService

/**
     * 查询全部的字典数据并生成Map字典方便查阅
     * @return 以dict_type为key的map数据集
     */
    public HashMap<String, ArrayList<SysDictData>> getAllDictDataMap();

SysDictDataServiceImpl

 /**
     * 查询全部的字典数据并生成Map字典方便查阅
     * @return 以dict_type为key的map数据集
     */
    @Override
    public HashMap<String, ArrayList<SysDictData>> getAllDictDataMap() {
        List<SysDictData> sysDictDataList = dictDataMapper.selectAllDictData();
        HashMap<String, ArrayList<SysDictData>> resultMap = new HashMap<String, ArrayList<SysDictData>>();

        for (SysDictData d:sysDictDataList) {
            ArrayList<SysDictData> list;
            if(resultMap.get(d.getDictType())!=null){
                list=resultMap.get(d.getDictType());
            }else{
                list = new ArrayList<SysDictData>();
            }
            list.add(d);
            resultMap.put(d.getDictType(),list);
        }

        return resultMap;
    }
Logo

快速构建 Web 应用程序

更多推荐