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循环 将集合的变量不断遍历
随机推荐
- Linux 内核版本,Ubuntu版本的查看
查看内核版本 1) cat /proc/version [root@a ~]# cat /proc/version Linux version 2.6.18-194.el5 (mockbuild@x ...
- 关于Unity中的光照(四)
渲染路径和颜色空间 1:Unity光影效果可以通过设置 渲染路径和颜色空间;2: 渲染路径: 光照到物体表面,物体着色的时候,算上光的颜色的时候有这么几种光照的着色方式,计算着色的方式 forward ...
- 如何能够通过代码来重启Android手机?
String cmd = "su -c reboot";//让手机从启 try { Runtime.getRuntime().exec(cmd); } catch (IOExcep ...
- (笔记)linux 进程和线程的区别
进程:进程是程序执行时的一个实例,即它是程序已经执行到课中程度的数据结构的汇集.从内核的观点看,进程的目的就是担当分配系统资源(CPU时间.内存等)的基本单位. 线程:线程是进程的一个执行流,是CPU ...
- SpringMVC系列(七)视图解析器和视图
在springmvc.xml里面配置视图解析器 <!-- 配置视图解析器: 如何把 handler 方法返回值解析为实际的物理视图 --> <bean class="org ...
- [原创]Allegro 导入DXF文件,保留布好的线路信息
最近智能钥匙产品开发过程中,由于结构装配尺寸的偏差,需要对电路PCB外框OUTLINE进行缩小调整,并且USB插座定位孔改变. Allegro软件在线性绘制方面是有严重缺陷的,想绘制一个异形的板框比较 ...
- 原版的WEB认证客户端,提供源代码,让用户自行编译
今天在翻找文件,偶尔发现这个文件,就把源代码发给大家吧. 有需要的,可以尽管改,程序在D7下编译 下载地址:下载地址1
- iptables filter表小案例
案例1:把80端口,22端口,21端口放行 22端口指定IP访问,其它IP拒绝. shell脚本实现: [root@centos7 ~]# vim /usr/local/sbin/iptables.s ...
- 配置IDEA Scala环境
http://snglw.blog.51cto.com/5832405/1634595
- 获取GridView中RowCommand的当前索引行(转)
获取GridView中RowCommand的当前索引行 前台添加一模版列,里面添加一个LinkButton 前台 (如果在后台代码中用e.CommandArgument取值的话前台代码就必须在按钮中设 ...