List 集合的N层遍历
package com.j1.cms.model; import java.io.Serializable; import java.util.List; /** * Created by wangchuanfu on 17/5/25. */ public class EcHomePageTemplate implements Serializable{ private static final long serialVersionUID = 1L; private Integer templateId; private Integer tabId; private Integer templateTypeId; private Integer orderNum; private String templateName; private String more ; private Integer moreLinkType; private String moreLinkValue; private String templateTypeName; private List<EcHomePageTemplateItem> itemList; public void setTemplateId(Integer templateId) { this.templateId = templateId; } public void setTabId(Integer tabId) { this.tabId = tabId; } public void setTemplateTypeId(Integer templateTypeId) { this.templateTypeId = templateTypeId; } public void setOrderNum(Integer orderNum) { this.orderNum = orderNum; } public void setTemplateName(String templateName) { this.templateName = templateName; } public void setMore(String more) { this.more = more; } public void setMoreLinkType(Integer moreLinkType) { this.moreLinkType = moreLinkType; } public void setMoreLinkValue(String moreLinkValue) { this.moreLinkValue = moreLinkValue; } public void setTemplateTypeName(String templateTypeName) { this.templateTypeName = templateTypeName; } public void setItemList(List<EcHomePageTemplateItem> itemList) { this.itemList = itemList; } public Integer getTemplateId() { return templateId; } public Integer getTabId() { return tabId; } public Integer getTemplateTypeId() { return templateTypeId; } public Integer getOrderNum() { return orderNum; } public String getTemplateName() { return templateName; } public String getMore() { return more; } public Integer getMoreLinkType() { return moreLinkType; } public String getMoreLinkValue() { return moreLinkValue; } public String getTemplateTypeName() { return templateTypeName; } public List<EcHomePageTemplateItem> getItemList() { return itemList; } }
package com.j1.cms.model; import java.io.Serializable; import java.util.List; /** * Created by wangchuanfu on 17/5/25. */ public class EcHomePageTemplateItem implements Serializable{ private static final long serialVersionUID = 1L; private Integer templateItemId; private String templateItemName; private Integer linkType; private String linkValue; private String adPicture; private Integer parentId; private Integer tabId; private Integer templateTypeId; private String linkValueSupplement; public String getLinkValueSupplement() { return linkValueSupplement; } public void setLinkValueSupplement(String linkValueSupplement) { this.linkValueSupplement = linkValueSupplement; } public Integer getTemplateTypeId() { return templateTypeId; } public void setTemplateTypeId(Integer templateTypeId) { this.templateTypeId = templateTypeId; } public Integer getTabId() { return tabId; } public void setTabId(Integer tabId) { this.tabId = tabId; } private List<EcHomePageTemplateItem> subItemList; public void setTemplateItemId(Integer templateItemId) { this.templateItemId = templateItemId; } public void setTemplateItemName(String templateItemName) { this.templateItemName = templateItemName; } public void setLinkType(Integer linkType) { this.linkType = linkType; } public void setLinkValue(String linkValue) { this.linkValue = linkValue; } public void setAdPicture(String adPicture) { this.adPicture = adPicture; } public void setParentId(Integer parentId) { this.parentId = parentId; } public void setSubItemList(List<EcHomePageTemplateItem> subItemList) { this.subItemList = subItemList; } public Integer getTemplateItemId() { return templateItemId; } public String getTemplateItemName() { return templateItemName; } public Integer getLinkType() { return linkType; } public String getLinkValue() { return linkValue; } public String getAdPicture() { return adPicture; } public Integer getParentId() { return parentId; } public List<EcHomePageTemplateItem> getSubItemList() { return subItemList; } }
package com.j1.cms.model; import com.j1.base.model.BaseBO; /** * Created by wangchuanfu on 17/5/20. */ public class EcTemolateItem extends BaseBO { /** * 将Model 合并到EcTemolateItem中,用于接口查询返回数据,保证数据的完整性 */ private Integer templateId; private Integer tabId; private Integer templateTypeId; private Integer orderNum; private String templateName; private String more ; private Integer moreLinkType; private String moreLinkValue; private String tabName; private Integer stateNum ; private String onlineTime; private String offlineTime; private Integer templateItemId; private String templateItemName; private Integer linkType; private String linkValue; private String adPicture; private Integer resolutionWidth; private Integer resolutionHeight; private Integer parentId ; public void setTemplateId(Integer templateId) { this.templateId = templateId; } public void setTabId(Integer tabId) { this.tabId = tabId; } public void setTemplateTypeId(Integer templateTypeId) { this.templateTypeId = templateTypeId; } public void setOrderNum(Integer orderNum) { this.orderNum = orderNum; } public void setTemplateName(String templateName) { this.templateName = templateName; } public void setMore(String more) { this.more = more; } public void setMoreLinkType(Integer moreLinkType) { this.moreLinkType = moreLinkType; } public void setMoreLinkValue(String moreLinkValue) { this.moreLinkValue = moreLinkValue; } public void setTabName(String tabName) { this.tabName = tabName; } public void setStateNum(Integer stateNum) { this.stateNum = stateNum; } public void setOnlineTime(String onlineTime) { this.onlineTime = onlineTime; } public void setOfflineTime(String offlineTime) { this.offlineTime = offlineTime; } public void setTemplateItemId(Integer templateItemId) { this.templateItemId = templateItemId; } public void setTemplateItemName(String templateItemName) { this.templateItemName = templateItemName; } public void setLinkType(Integer linkType) { this.linkType = linkType; } public void setLinkValue(String linkValue) { this.linkValue = linkValue; } public void setAdPicture(String adPicture) { this.adPicture = adPicture; } public void setResolutionWidth(Integer resolutionWidth) { this.resolutionWidth = resolutionWidth; } public void setResolutionHeight(Integer resolutionHeight) { this.resolutionHeight = resolutionHeight; } public void setParentId(Integer parentId) { this.parentId = parentId; } public Integer getTemplateId() { return templateId; } public Integer getTabId() { return tabId; } public Integer getTemplateTypeId() { return templateTypeId; } public Integer getOrderNum() { return orderNum; } public String getTemplateName() { return templateName; } public String getMore() { return more; } public Integer getMoreLinkType() { return moreLinkType; } public String getMoreLinkValue() { return moreLinkValue; } public String getTabName() { return tabName; } public Integer getStateNum() { return stateNum; } public String getOnlineTime() { return onlineTime; } public String getOfflineTime() { return offlineTime; } public Integer getTemplateItemId() { return templateItemId; } public String getTemplateItemName() { return templateItemName; } public Integer getLinkType() { return linkType; } public String getLinkValue() { return linkValue; } public String getAdPicture() { return adPicture; } public Integer getResolutionWidth() { return resolutionWidth; } public Integer getResolutionHeight() { return resolutionHeight; } public Integer getParentId() { return parentId; } @Override public String toString() { return "EcTemolateItem{" + "templateId=" + templateId + ", tabId=" + tabId + ", templateTypeId=" + templateTypeId + ", orderNum=" + orderNum + ", templateName='" + templateName + '\'' + ", more='" + more + '\'' + ", moreLinkType=" + moreLinkType + ", moreLinkValue='" + moreLinkValue + '\'' + ", tabName='" + tabName + '\'' + ", stateNum=" + stateNum + ", onlineTime='" + onlineTime + '\'' + ", offlineTime='" + offlineTime + '\'' + ", templateItemId=" + templateItemId + ", templateItemName='" + templateItemName + '\'' + ", linkType=" + linkType + ", linkValue='" + linkValue + '\'' + ", adPicture='" + adPicture + '\'' + ", resolutionWidth=" + resolutionWidth + ", resolutionHeight=" + resolutionHeight + ", parentId=" + parentId + '}'; } }
package com.j1.soa.resource.cms.service.oracle; import com.j1.base.dto.ServiceMessage; import com.j1.cms.model.EcHomePageTab; import com.j1.cms.model.EcHomePageTemplate; import com.j1.cms.model.EcHomePageTemplateItem; import com.j1.cms.model.EcTemolateItem; import com.j1.item.model.Goods; import com.j1.soa.common.service.BaseServiceImpl; import com.j1.soa.resource.cms.api.EcHomePageTempLateService; import com.j1.soa.resource.cms.dao.oracle.EcHomePageTempLateMapper; import org.springframework.beans.factory.annotation.Autowired; import java.util.ArrayList; import java.util.List; /** * Created by wangchuanfu on 17/5/20. */ public class EcHomePageTempLateServiceImpl extends BaseServiceImpl implements EcHomePageTempLateService { @Autowired private EcHomePageTempLateMapper ecHomePageTempLateMapper; public ServiceMessage<EcHomePageTab> getTableListById( Integer tabId) { try{ if(tabId ==null){ return super.returnParamsError("param is null"); } /** * 根据tabId 查询对应的tab */ EcHomePageTab ecHomePageTab= new EcHomePageTab(); ecHomePageTab.setTabId(tabId); //查看tab下有无模板数据 List<EcHomePageTemplate> templateList = ecHomePageTempLateMapper.queryAdList(tabId); if(templateList != null && templateList.size() > 0){ for (EcHomePageTemplate template : templateList){ //查询tab下的模板数据,父级数据 EcHomePageTemplateItem item = new EcHomePageTemplateItem(); item.setTabId(tabId); item.setTemplateTypeId(template.getTemplateTypeId()); item.setParentId(0); /*List<EcHomePageTemplateItem> itemList = ecHomePageTempLateMapper.queryTemplateItemList(item); List<EcHomePageTemplateItem> childItemList = new ArrayList<EcHomePageTemplateItem>(); if(itemList != null && itemList.size() > 0) { for (EcHomePageTemplateItem teplate : itemList) { //查看父级下面有没有子集数据 item.setParentId(teplate.getTemplateId()); childItemList = ecHomePageTempLateMapper.queryTemplateItemList(item); teplate.setSubItemList(childItemList); } template.setItemList(itemList); }*/ List<EcHomePageTemplateItem> itemList =getItemList(item); if(itemList != null && itemList.size() > 0){ template.setItemList(itemList); } } ecHomePageTab.setTemplateList(templateList); }else{ return super.returnNoResult("not result"); } return super.returnCorrectResult("search is success!", ecHomePageTab); }catch(Exception e){ return super.returnException(e); } } private List<EcHomePageTemplateItem> getItemList(EcHomePageTemplateItem item){ List<EcHomePageTemplateItem> itemList = ecHomePageTempLateMapper.queryTemplateItemList(item); List<EcHomePageTemplateItem> childItemList = new ArrayList<EcHomePageTemplateItem>(); if(itemList != null && itemList.size() > 0) { for (EcHomePageTemplateItem teplate : itemList) { //如果配置的链接类型为商品编码,前台则需要取linkValueSupplement //查看父级下面有没有子集数据 item.setParentId(teplate.getTemplateItemId()); childItemList = getItemList(item); if(childItemList != null && childItemList.size() > 0){ teplate.setSubItemList(childItemList); } } } return itemList; } /** * 查询tab信息 * @return */ @Override public ServiceMessage<List<EcHomePageTab>> queryTable() { try{ List<EcHomePageTab> tabs= ecHomePageTempLateMapper.queryTable(); if(tabs.size()>0|| tabs!=null){ return super.returnCorrectResult("success!", tabs); }else{ return super.returnNoResult("not result"); } }catch(Exception e){ return super.returnException(e); } } }
" ?> -mapper.dtd" > <mapper namespace="com.j1.soa.resource.cms.dao.oracle.EcHomePageTempLateMapper"> <resultMap id="ecTemolateItemRes" type="com.j1.cms.model.EcTemolateItem"> <result column="template_item_name" property="templateItemName" /> <result column="link_type" property="linkType" /> <result column="link_value" property="linkValue" /> <result column="ad_picture" property="adPicture" /> <result column="template_name" property="templateName" /> <result column="tab_name" property="tabName" /> </resultMap> <resultMap id="ecHomePageTemplateResult" type="com.j1.cms.model.EcHomePageTemplate"> <result column="template_item_name" property="templateTypeName" /> <result column="template_type_id" property="templateTypeId" /> <result column="TEMPLATE_NAME" property="templateName"/> </resultMap> <resultMap id="ecHomePageTemplateItemResult" type="com.j1.cms.model.EcHomePageTemplateItem"> <result column="TEMPLATE_ITEM_ID" property="templateItemId" /> <result column="TEMPLATE_ITEM_NAME" property="templateItemName" /> <result column="LINK_TYPE" property="linkType" /> <result column="LINK_VALUE" property="linkValue" /> <result column="AD_PICTURE" property="adPicture" /> <result column="PARENT_ID" property="parentId" /> <result column="TEMPLATE_ID" property="templateId" /> <result column="TEMPLATE_NAME" property="templateName" /> <result column="PARENT_ID" property="parentId" /> <result column="RESOLUTION_HEIGHT" property="resolutionHeight" /> <result column="RESOLUTION_WIDTH" property="resolutionWidth" /> <result column="LINK_VALUE_SUPPLEMENT" property="linkValueSupplement" /> </resultMap> <select id="getEcTemolateItemById" resultMap="ecTemolateItemRes" parameterType="com.j1.cms.model.EcTemolateItem"> select ehti.template_item_name, ehti.link_type, ehti.link_value, ehti.ad_picture, eht.ORDER_NUM, eht.template_name, ehta.tab_name from EC_HOMEPAGE_TEMPLATE_ITEM ehti LEFT JOIN EC_HOMEPAGE_TEMPLATE eht on ehti.template_id=eht.template_id left JOIN EC_HOMEPAGE_TAB ehta on ehta.tab_id=eht.tab_id <if test="templateItemId != null"> and ehti.template_Item_Id =#{templateItemId,jdbcType=DECIMAL} </if> and ehti.is_delete='N' and eht.is_delete='N' and ehta.is_delete='N' order by ehta.order_num ,ehta.add_time DESC </select> <resultMap id="ecTemolateItemResult" type="com.j1.cms.model.EcTemolateItem" extends="ecTemolateItemRes"> <result column="tab_name" property="tabName" /> <result column="tab_id" property="tabId" /> </resultMap> <!-- 查询tab信息 --> <select id="queryTable" resultMap="ecTemolateItemResult"> select eht.TAB_ID,eht.TAB_NAME from EC_HOMEPAGE_TAB eht WHERE eht.IS_DELETE = 'N' <![CDATA[ AND eht.STATE_NUM <> 1 AND TO_DATE(eht.ONLINE_TIME,'YYYY/MM/DD hh24:mi:ss') <= SYSDATE AND TO_DATE(eht.OFFLINE_TIME,'YYYY/MM/DD hh24:mi:ss') >= SYSDATE ]]> ORDER BY eht.ORDER_NUM </select> <!-- 根据tabId 查询出对应的广告位 --> <select id ="queryAdList" resultMap= "ecHomePageTemplateResult" parameterType="java.lang.Integer"> select b.TEMPLATE_TYPE_ID, b.TEMPLATE_TYPE_NAME, c.TEMPLATE_NAME from EC_HOMEPAGE_TAB a , EC_HOMEPAGE_TEMPLATE_TYPE b, EC_HOMEPAGE_TEMPLATE c where a.TAB_ID=c.TAB_ID AND b.TEMPLATE_TYPE_ID=c.TEMPLATE_TYPE_ID AND c.TAB_ID =#{tabId,jdbcType=DECIMAL} AND a.IS_DELETE = 'N' AND b.IS_DELETE = 'N' AND c.IS_DELETE = 'N' ORDER BY c.ORDER_NUM </select> <!-- 根据广告位数据查询出所有的主数据 --> <select id = "queryTemplateItemList" resultMap="ecHomePageTemplateItemResult" parameterType="com.j1.cms.model.EcHomePageTemplateItem"> SELECT b.TEMPLATE_ITEM_ID, b.TEMPLATE_ITEM_NAME, b.AD_PICTURE, b.LINK_TYPE, b.LINK_VALUE, b.PARENT_ID, b.LINK_VALUE_SUPPLEMENT FROM EC_HOMEPAGE_TEMPLATE_ITEM b LEFT JOIN EC_HOMEPAGE_TEMPLATE c ON c.TEMPLATE_ID = b.TEMPLATE_ID WHERE c.TEMPLATE_TYPE_ID = #{templateTypeId,jdbcType=DECIMAL} AND c.TAB_ID = #{tabId,jdbcType=DECIMAL} AND b.PARENT_ID = #{parentId,jdbcType=DECIMAL} ORDER BY c.ORDER_NUM,b.TEMPLATE_ITEM_ID </select> </mapper>
package com.j1.cms.model; import java.io.Serializable; import java.util.List; /** * Created by wangchuanfu on 17/5/25. */ public class EcHomePageTab implements Serializable{ private static final long serialVersionUID = 1L; private Integer tabId; private String tabName; private Integer orderNum; private Integer stateNum ; private String onlineTime; private String offlineTime; private List<EcHomePageTemplate> templateList; private List<Integer> tabIds; public Integer getTabId() { return tabId; } public String getTabName() { return tabName; } public Integer getOrderNum() { return orderNum; } public Integer getStateNum() { return stateNum; } public String getOnlineTime() { return onlineTime; } public String getOfflineTime() { return offlineTime; } public List<EcHomePageTemplate> getTemplateList() { return templateList; } public List<Integer> getTabIds() { return tabIds; } public void setTabId(Integer tabId) { this.tabId = tabId; } public void setTabName(String tabName) { this.tabName = tabName; } public void setOrderNum(Integer orderNum) { this.orderNum = orderNum; } public void setStateNum(Integer stateNum) { this.stateNum = stateNum; } public void setOnlineTime(String onlineTime) { this.onlineTime = onlineTime; } public void setOfflineTime(String offlineTime) { this.offlineTime = offlineTime; } public void setTemplateList(List<EcHomePageTemplate> templateList) { this.templateList = templateList; } public void setTabIds(List<Integer> tabIds) { this.tabIds = tabIds; } }
List 集合的N层遍历的更多相关文章
- 第16章 List集合的总结和遍历
第16章 List集合的总结和遍历 1.重构设计 根据Vector类,ArrayList类,和LinkedList类所具有的存储特点以及拥有的方法入手,发现共性往上抽取. 共同特点: 1.允许元素重复 ...
- Java:集合for高级循环遍历
增强for循环: 格式:for(变量数据类型 要遍历的变量 :元素所在数组(集合)名称) 也即 for(Type element: array或collection) 使用foreach遍历集合: 只 ...
- Java基础知识强化之集合框架笔记12:Collection集合存储字符串并遍历
1. Collection集合存储字符串并遍历 分析: (1)创建集合对象 (2)创建字符串对象 (3)把字符串对象添加到集合中 (4)遍历集合 2. 代码示例: package cn.itcast ...
- Java基础知识强化之集合框架笔记08:Collection集合自定义对象并遍历案例(使用迭代器)
1. Collection集合自定义对象并遍历案例(使用迭代器) (1)首先定义一个Student.java,如下: package com.himi.collectionIterator; publ ...
- 【Leetcode】二叉树层遍历算法
需求: 以层遍历一棵二叉树,二叉树的结点结构如下 struct tree_node{ struct tree_node *lc; struct tree_node *rc; int data; }; ...
- 二叉树遍历(flist)(已知中序和按层遍历,求先序 )
问题 F: 二叉树遍历(flist) 时间限制: 1 Sec 内存限制: 128 MB提交: 11 解决: 9[提交][状态][讨论版][命题人:quanxing][Edit] [TestData ...
- 集合 数组 定义 转换 遍历 Arrays API MD
Markdown版本笔记 我的GitHub首页 我的博客 我的微信 我的邮箱 MyAndroidBlogs baiqiantao baiqiantao bqt20094 baiqiantao@sina ...
- 李洪强iOS经典面试题35-按层遍历二叉树的节点
李洪强iOS经典面试题35-按层遍历二叉树的节点 问题 给你一棵二叉树,请按层输出其的节点值,即:按从上到下,从左到右的顺序. 例如,如果给你如下一棵二叉树: 3 / \ 9 20 ...
- 每个分组函数相当于一个for循环 将集合的变量不断遍历
每个分组函数相当于一个for循环 将集合的变量不断遍历
随机推荐
- UDP丢包原因
一.主要丢包原因 1.接收端处理时间过长导致丢包:调用recv方法接收端收到数据后,处理数据花了一些时间,处理完后再次调用recv方法,在这二次调用间隔里,发过来的包可能丢失.对于这种情况可以修改接收 ...
- VISUAL STUDIO 2012下的OPENCV 2.4.7安装过程
邮箱已经收到了Visual Studio 2013的升级通知,但是很多软件如OpenCV.Qt等都只有VS2012的预编译库,还是懒得升级了(除非VS支持C++11了). 网上搜了一些VS2012(或 ...
- listview item 动画
http://blog.csdn.net/lixiaodaoaaa/article/details/8284246 先看实现的效果如下: 演示效果如上: 上面的列表是GridView 要给这个Gr ...
- 【5】JVM-垃圾收集器
通过学习了解到现在商用的JVM中的垃圾收集采用的是分代收集算法,即针对不同年代采用不同的收集算法.在JVM中,GC主要作用于堆内存中,堆内存又被划分为新生代和老年代,由于新生代对象绝大多数是朝生夕死, ...
- Spring JDBC更新数据
以下示例将展示如何使用Spring jdbc执行更新数据库表的记录,这里演示如何更新student表中指定条件的记录. 语法: String updateQuery = "update St ...
- Ubuntu -- 安装、卸载程序的命令
通过sudo apt-get install xxxx 安装软件后,总是无法卸载干净,这里以Apache 为例,提供方法:首先sudo apt-get remove apache2再sudo apt- ...
- Python装饰器、metaclass、abc模块学习笔记
(博客原创作品,转载请注明出处!) 最近接触到了Python中的decorator,metaclass,abc Module,six.add_metaclass等内容,这里做一个简单的笔记. 主要资源 ...
- 使用 ML Pipeline 构建机器学习工作流
http://www.ibm.com/developerworks/cn/opensource/os-cn-spark-practice5/
- Backlight当前行背景高亮显示
下载地址:https://github.com/limejelly/Backlight-for-XCode PS:Xcode 8.0 默认支持了 跟VVDocumenter规范注释生成器的安装方式一样 ...
- LoadRunner javavuser错误排查
Loadrunner 9.5/11 使用java 开发vsuer script需要的环境配置 本文从两个方面来讲:windows 32位操作系统:windows 64 操作系统开始之前,先说下java ...