开通课程: 查看状态 操作里的开通课程 开通后完成叶子节点 的操作 显示变为 两个横线--)
/*function :找到整个树并找到已购的课程 * @param: * */private void treeBuy(Integer cid, Integer level,boolean[] aryIsLastNode, boolean isBuyFlag) {int index = 0;List<Course> list = (List<Course>) coursedao.findByPid(cid);for (Course t : list) {/* * System.out.println("-----list:" + list.toString()); * System.out.println("-----t:" + t); * System.out.println("-----list.size():" + list.size()); */ String symbol = "";String symbolf = "";index++; // System.out.println("-----index:" + index);// 先画上级节点延续下来的"|"+空格,空格具体数目由层数决定//System.out.println("-----level:" + level);for (int lev = 0; lev < level; lev++) {if(aryIsLastNode[lev]==false)symbolf += "│";elsesymbolf += " ";}// 是否为最后一个节点if (index == list.size()) {symbol = "└";} else {symbol = "├";}String cname = symbolf + symbol + t.getCname();t.setCname(cname);//System.out.println("-----t:" + t.getCname());boolean bIsBuy = false;if (t.getLeaf() == 0) { //判断一下他的上级是否已经是被购买了if (!isBuyFlag){bIsBuy = stdCsd.findStdCourseByScId(mStdId, t.getCid());CreateCourseBuyRec(t, bIsBuy, bIsBuy);}else{CreateCourseBuyRec(t,true, false);}} else { //判断一下他的上级是否已经是被购买了if (!isBuyFlag){bIsBuy = stdCsd.findStdCourseByScId(mStdId, t.getCid());CreateCourseBuyRec(t, bIsBuy, bIsBuy);}else{CreateCourseBuyRec(t,true, false);}t.setLevel(level + 1);if(index==list.size()){aryIsLastNode[level]=true;}else{aryIsLastNode[level]=false;}treeBuy(t.getCid(), t.getLevel(),aryIsLastNode,bIsBuy);}}}public void CreateCourseBuyRec(Course cs, boolean isBuy, boolean isRoot){CourseIsBuy ss = new CourseIsBuy();ss.setCs(cs);ss.setBuy(isBuy);ss.setIsRootCourse(isRoot);ListBuyTree.add(ss);} public List<CourseIsBuy> findTreeForBuy(int stdId) { mStdId = stdId;l.clear();List<Course> list = (List<Course>) coursedao.findByPid(0);for (Course t : list) {if (t.getLeaf() != 0) {boolean bIsBuy = stdCsd.findStdCourseByScId(stdId, t.getCid());CreateCourseBuyRec(t, bIsBuy, bIsBuy); aryNodeStatus[0]=true;this.treeBuy(t.getCid(), 0, aryNodeStatus, bIsBuy);} else {boolean bIsBuy = stdCsd.findStdCourseByScId(stdId, t.getCid());CreateCourseBuyRec(t, bIsBuy, false);}}return ListBuyTree; }