freemarker传map类型,遍历list取值

<#if firstType.childList??&& firstType.childList?size gt 0>
			  <#assign y=0 />
			  <#assign varietylist1='varietylist' />
			  <#list firstType.childList as secoendType>
				  <#assign y=secoendType.id />
				  <#if varietyMap?exists>
					  <#list varietyMap?keys as key>
						  <#if key==(varietylist1+y)>
							  <#if varietyMap[key]??&&varietyMap[key]?size gt 0>
        					
  • ${(secoendType.name)!}

  • <#if firstType.childList??&& firstType.childList?size gt 0>
    				<#assign x=0 />
    				<#assign varietylist='varietylist' />
    				<#list firstType.childList as secoendType>
    					<#assign x=secoendType.id />
    							<#if varietyMap?exists>
    								<#list varietyMap?keys as key>
                                        <#if key==(varietylist+x)>
    									<#if varietyMap[key]??&&varietyMap[key]?size gt 0>
                                        



    <#if typelist??&& typelist?size gt 0>
    	  <#list typelist as firstType>
        	
      <#if firstType.childList??&& firstType.childList?size gt 0> <#assign y=0 /> <#assign varietylist1='varietylist' /> <#list firstType.childList as secoendType> <#assign y=secoendType.id /> <#if varietyMap?exists> <#list varietyMap?keys as key> <#if key==(varietylist1+y)> <#if varietyMap[key]??&&varietyMap[key]?size gt 0>
    • ${(secoendType.name)!}
    <#if firstType.childList??&& firstType.childList?size gt 0> <#assign x=0 /> <#assign varietylist='varietylist' /> <#list firstType.childList as secoendType> <#assign x=secoendType.id /> <#if varietyMap?exists> <#list varietyMap?keys as key> <#if key==(varietylist+x)> <#if varietyMap[key]??&&varietyMap[key]?size gt 0>


     //查询该企业下的顶级分类和有产品的二级分类
        public void getVarietyTypes(Long id,Result result){
            String key = CacheHelper.buildKey(CacheConstant.TOP_TYPE_LIST+id);
            List typeList = (List) CacheHelper.get(CacheType.FIVE_MINUTE_STORE.getValue(), key);
            if (typeList == null) {
                ArtVarietyType typeSearch = new ArtVarietyType();
                typeSearch.setParentId(0L);
                typeSearch.setDeleteFlag(Flag.FALSE.getValue());
                typeSearch.setPcFlag(Flag.TRUE.getValue());
                typeSearch.setOrderBy(" updated_at DESC ");
                typeList = artVarietyTypeDao.findAll(typeSearch);
                CacheHelper.put(CacheType.FIVE_MINUTE_STORE.getValue(), key, typeList);
            }
            Map> varietyMap = null;
            if (!typeList.isEmpty()) {
                String mapkey = CacheHelper.buildKey(CacheConstant.MAP_EXCHANGE_TYPE_LIST + id);
                varietyMap = (Map>) CacheHelper.get(CacheType.FIVE_MINUTE_STORE.getValue(), mapkey);
                if (varietyMap == null) {
                    varietyMap=new HashMap>();
                    for (ArtVarietyType type : typeList) {
                        //type.setChildSize(CHILD_SIZE);
                        List childList = type.getChildList();
                        if (!childList.isEmpty()) {
                            int count=0;
                            List newchildList=new ArrayList();
                            for (ArtVarietyType childType : childList) {
                                if(CHILD_SIZE==count){
                                    type.setChildList(newchildList);
                                    CacheHelper.put(CacheType.FIVE_MINUTE_STORE.getValue(), key, typeList);
                                    break;
                                }
                                ArtVariety variety = new ArtVariety();
                                variety.setDeleteFlag(Flag.FALSE.getValue());
                                variety.setAuditFlag(Flag.TRUE.getValue());
                                variety.setPageSize(VARIETY_SIZE);
                                List list = artVarietyTypeDao.recursionChildren(new Long[]{childType.getId()});
                                list.add(childType.getId());
                                variety.setTypeIdList(list);
                                variety.setArtExchangeId(id);
                                List templist=artVarietyDao.findPage(variety).getResult();
                                if(templist!=null&&!templist.isEmpty()) {
                                    varietyMap.put("varietylist" + childType.getId(), artVarietyDao.findPage(variety).getResult());
                                    count++;
                                    newchildList.add(childType);
                                }
                            }
                        }
                    }
                    CacheHelper.put(CacheType.FIVE_MINUTE_STORE.getValue(), mapkey, varietyMap);
                }
    
            }
            result.setModel("typelist", typeList);
            result.setModel("varietyMap", varietyMap);
        }


    你可能感兴趣的:(freemark)