zoukankan      html  css  js  c++  java
  • 递归

    使用递归实现删除

     1 //删除
     2     public String dictionaryDel(){
     3         try {
     4             if (ids != null && !"".equals(ids)) {
     5                 
     6                 String[] split = ids.split(",");
     7                 
     8                 for(String id:split){
     9                     utilService.updateAll("update Dictionary d set d.isDele=1 where d.id="+id);
    10                     dictionarySet(id);
    11                 }
    12                 for(String id:split){
    13                     Dictionary dictionaryOld = (Dictionary) this.utilService.getObjectById(Dictionary.class, Integer.parseInt(id));
    14                     if(dictionaryOld.getFkDicId()!=0){
    15                         int count=utilService.getHqlCount("from Dictionary d where d.isDele=0 and d.fkDicId="+dictionaryOld.getFkDicId());
    16                         if(count==0){
    17                             Dictionary dictionaryP = (Dictionary) this.utilService.getObjectById(Dictionary.class, dictionaryOld.getFkDicId());
    18                             dictionaryP.setIsLeaf(1);
    19                             utilService.update(dictionaryP);
    20                         }
    21                     }
    22                 }
    23             }
    24             return dictionaryList();
    25         } catch (Exception e) {
    26             e.printStackTrace();
    27         }
    28         return ERROR;
    29     }
    30     private void dictionarySet(String id)throws Exception {
    31         List<Dictionary> dictionaries=(List<Dictionary>) utilService.getHqlAll("from Dictionary d where d.isDele=0 and d.fkDicId="+id);
    32         if(dictionaries!=null&&dictionaries.size()>0){
    33             for(Dictionary dictionary:dictionaries){
    34                 utilService.updateAll("update Dictionary d set d.isDele=1 where d.id="+dictionary.getId());
    35                 dictionarySet(dictionary.getId().toString());
    36             }
    37         }
    38     }
    View Code

    数据库

  • 相关阅读:
    历史上的今天:3月1日
    用Windows Live Writer远程更新wordpress博客
    二月只有28天
    办公也可云概念
    FLASH做的画图板
    FLASH鼠标跟随特效
    silverlight应该以什么面孔见人?
    飞信Fetion 开发资料及下载
    收藏一个数学的C++算法的好博客
    下载网站资源共享
  • 原文地址:https://www.cnblogs.com/yang1018/p/7201494.html
Copyright © 2011-2022 走看看