• 04BaseRoleServlet


     1 package edu.must.uh.servlet;
     2 import java.util.List;
     3 import java.util.Map;
     4 import javax.servlet.annotation.WebServlet;
     5 import javax.servlet.http.HttpServletRequest;
     6 import javax.servlet.http.HttpServletResponse;
     7 import edu.must.uh.bean.BaseRole;
     8 import edu.must.uh.impl.BaseRoleImpl;
     9 import edu.must.uh.util.BeanUtils;
    10 import edu.must.uh.util.R;
    11 import edu.must.uh.util.ServletUtils;
    12 import edu.must.uh.util.Tools;
    13 import edu.must.uh.util.ToolsOfString;  
    14  
    15 @WebServlet("/BaseRoleServlet") 
    16 public class BaseRoleServlet  extends  BaseServlet {
    17  
    18     /**
    19      * 
    20      */
    21   private static final long serialVersionUID = 1L;
    22   
    23   
    24  BaseRoleImpl iBaseRoleimpl = new BaseRoleImpl(); 
    25  public Object getTableJson(HttpServletRequest request, HttpServletResponse response) throws Exception 
    26  { 
    27    iBaseRoleimpl._PageBean =pageBean;
    28    Map<String, Object> searchcondition = ServletUtils.getsearchcondition(request);
    29    List<Map<String, Object>> data = iBaseRoleimpl.getList(searchcondition,"");
    30    Integer countInteger  = iBaseRoleimpl.getCountList(searchcondition,"");
    31    return R.succ(data,countInteger); 
    32  }   
    33  public Object ExistField(HttpServletRequest request, HttpServletResponse response) throws Exception 
    34  {
    35      String keyValue = ToolsOfString.conveString(request.getParameter("keyValue"));
    36      String controlId = ToolsOfString.conveString(request.getParameter("controlId")); 
    37      String  keydata = ToolsOfString.conveString(request.getParameter(controlId)); 
    38      keydata = new String(keydata.getBytes("ISO-8859-1"), "UTF-8");
    39      String keywordSQL ="";
    40      if(Tools.notEmpty(keyValue)) {
    41          keywordSQL = "AND RoleId <> '" + keyValue +"' ";   
    42      }  
    43      List<Map<String, Object>> data = iBaseRoleimpl.getList(null, "AND "+controlId+" ='"+keydata+"'" + keywordSQL);     
    44      return R.succ(data.size() == 0);
    45  }
    46  
    47  public Object saveForm(HttpServletRequest request, HttpServletResponse response) throws Exception 
    48  { 
    49     String keyValue = ToolsOfString.conveString(request.getParameter("keyValue")); 
    50     BaseRole bean = new BaseRole(); 
    51     BeanUtils.transRequest2Bean(request, bean); 
    52     
    53     Integer ires = 0;
    54     if(Tools.notEmpty(keyValue)) { 
    55         bean.setRoleId(keyValue);
    56         ires = iBaseRoleimpl.update(bean, keyValue) ;
    57     } else {
    58         bean.setRoleId(Tools.getUUID32()); 
    59         ires = iBaseRoleimpl.save(bean) ;
    60     }
    61 
    62     if(ires == 0) {       
    63         return R.fail(); 
    64     } else { 
    65       return R.succ(); 
    66     }  
    67  }  
    68  
    69  public Object batchDel(HttpServletRequest request, HttpServletResponse response) throws Exception 
    70  { 
    71     String idsStr = ToolsOfString.conveString(request.getParameter("idsStr")); 
    72     String[] idsStrList = idsStr.split(",");
    73     for (int i = 0; i < idsStrList.length; i++) {
    74         BaseRole bean = new BaseRole(); 
    75         bean.setDeleteMark(1);
    76         iBaseRoleimpl.update(bean,idsStrList[i]);
    77     }   
    78     return R.succ(); 
    79    
    80  }  
    81  
    82  public Object delForm(HttpServletRequest request, HttpServletResponse response) throws Exception 
    83  { 
    84     String keyValue = ToolsOfString.conveString(request.getParameter("value")); 
    85     BaseRole bean = new BaseRole(); 
    86     bean.setDeleteMark(1);
    87     Integer ires = iBaseRoleimpl.update(bean,keyValue);
    88     if(ires == 1) { 
    89        return R.succ(); 
    90     } else { 
    91       return R.fail(); 
    92     }  
    93  }  
    94 }
  • 相关阅读:
    自定义word快捷键,设置插入图片快捷键
    python使用ftplib做ftp操作
    各浏览器的userAgent对照表
    python判断字符串
    python判断字符串
    apache日志信息详解
    apache日志信息详解
    apache日志信息详解
    linux 下 读取某个文件的某一行或者某几行
    linux 下 读取某个文件的某一行或者某几行
  • 原文地址:https://www.cnblogs.com/chuangjie1988/p/14694477.html
Copyright © 2020-2023  润新知