精华内容
下载资源
问答
  •  * 实现领域对象角色的所有业务管理函数.  * 通过泛型声明继承DefaultEntityManager,默认拥有CRUD管理函数及HibernateDao,Long>  * entityDao成员变量. 使用Spring annotation定义事务管理.  *  * @...

    package com.tempus.userCenter.service.authority;

    import java.util.ArrayList;
    import java.util.Collections;
    import java.util.List;

    import javax.servlet.http.HttpServletRequest;

    import org.directwebremoting.annotations.Param;
    import org.directwebremoting.annotations.RemoteMethod;
    import org.directwebremoting.annotations.RemoteProxy;
    import org.directwebremoting.spring.SpringCreator;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Service;
    import org.springframework.transaction.annotation.Transactional;

    import com.tempus.modules.dwr.util.Condition;
    import com.tempus.modules.dwr.util.DWRUtil;
    import com.tempus.modules.dwr.util.DwrBackParams;
    import com.tempus.modules.orm.Page;
    import com.tempus.modules.orm.PropertyFilter;
    import com.tempus.modules.orm.hibernate.EntityManager;
    import com.tempus.modules.web.struts2.Struts2Utils;
    import com.tempus.userCenter.dao.authority.ResourcesDao;
    import com.tempus.userCenter.dao.authority.UsersDao;
    import com.tempus.userCenter.entity.authority.Resources;
    import com.tempus.userCenter.entity.authority.Users;
    import com.tempus.userCenter.service.ServiceException;

    /**
     * 角色管理类.
     *
     * 实现领域对象角色的所有业务管理函数.
     * 通过泛型声明继承DefaultEntityManager,默认拥有CRUD管理函数及HibernateDao<Role,Long>
     * entityDao成员变量. 使用Spring annotation定义事务管理.
     *
     * @author andy
     */
    @Service
    @RemoteProxy(creator = SpringCreator.class, creatorParams = @Param(name = "beanName", value = "ResourcesManager"), name = "ResourcesManager")
    @Transactional
    public class ResourcesManager extends EntityManager<Resources, Long> {

     @Autowired
     ResourcesDao resourceDao;
     @Autowired
     UsersDao usersDao;

     @Override
     @RemoteMethod
     protected ResourcesDao getEntityDao() {
      return resourceDao;
     }

     /**
      * 查询用户权限
      *
      * @param userid
      * @param resources_type
      * @param functionLevel
      * @param status
      * @return
      */
     public List<Resources> findUserFunction(String userid,
       String resources_type, String functionLevel, String status) {
      String sql = "select tr.* from t_users t inner join t_users_roles ur on t.id=ur.user_id inner join t_roles_authorities ra on ra.role_id=ur.role_id"
        + " inner join t_resources_authorities rea on rea.authority_id=ra.authority_id inner join t_resources tr on tr.id = rea.resource_id where t.id='"
        + userid
        + "' and tr.resource_type='"
        + resources_type
        + "' and tr.function_level like '"
        + functionLevel
        + "%' and tr.status='" + status + "'";
      return getEntityDao().findBySql(sql);
     }

     public String geToolButtons(String userid, String resources_type,
       String functionLevel, String status) {
      List<Resources> buttonList = findUserFunction(userid, resources_type,
        functionLevel, status);
      Collections.sort(buttonList);
      return buttonHelper(buttonList);

     }
     public String geToolButtons(List<Resources> buttonList,String functionLevel)
     {  
      List<Resources> currentButtonList = new ArrayList<Resources>();
      try{
        for (Resources resources : buttonList) {
         if(resources.getFunctionLevel().startsWith(functionLevel)&&!currentButtonList.contains(resources))
         {
          currentButtonList.add(resources);
         }
        }
        
      }catch(Exception ex)
      {
       throw new ServiceException("会话已经超时,请重新登录!");
      }
      return buttonHelper(currentButtonList);

     }
     public String buttonHelper(List<Resources> buttonList)
     {
      StringBuffer buttonSbf = new StringBuffer();

      buttonSbf.append("<script language='JavaScript'>\n");
      buttonSbf.append("var tb = new Ext.Toolbar({});\n");
      
      for (int i = 0; i < buttonList.size(); i++) {
       buttonSbf.append("tb.addButton(\n");
       buttonSbf.append("new Ext.Toolbar.Button({\n");
       buttonSbf.append("text:'" + buttonList.get(i).getFunctionName()
         + "',\n");
       if ("新增".equals(buttonList.get(i).getFunctionName())) {
        buttonSbf.append("iconCls:'addIcon',\n");
        buttonSbf.append("handler:function(){addRecord(store);}\n");

       }
       if ("申请".equals(buttonList.get(i).getFunctionName())) {
        buttonSbf.append("iconCls:'addIcon',\n");
        buttonSbf.append("handler:function(){addRecord(store);}\n");
        
       }
       if ("查询".equals(buttonList.get(i).getFunctionName())) {
        buttonSbf.append("iconCls:'queryIcon',\n");
        buttonSbf.append("handler:function(){queryRecord(store);}\n");

       }

       if ("修改".equals(buttonList.get(i).getFunctionName())) {
        buttonSbf.append("iconCls:'editIcon',\n");
        buttonSbf.append("handler:function(){\n");
        buttonSbf
          .append("var selectionModel = grid.getSelectionModel();\n");
        buttonSbf
          .append("var record = selectionModel.getSelected();\n");
        buttonSbf.append("if ( record == undefined ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','请选择要修改的记录');\n");
        buttonSbf.append("return;}\n");
        buttonSbf
          .append("var selectedcount = parseInt(selectionModel.getCount());\n");
        buttonSbf.append("if ( selectedcount > 1 ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','只能选择一条记录');\n");
        buttonSbf.append("return;}\n");
        buttonSbf.append("var id = record.get(pk);\n");
        buttonSbf.append("updateRecord(store,id,record);}\n");
       }
       
       if ("层级配置".equals(buttonList.get(i).getFunctionName())) {
        buttonSbf.append("iconCls:'editIcon',\n");
        buttonSbf.append("handler:function(){\n");
        buttonSbf
          .append("var selectionModel = grid.getSelectionModel();\n");
        buttonSbf
          .append("var record = selectionModel.getSelected();\n");
        buttonSbf.append("if ( record == undefined ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','请选择要配置的记录');\n");
        buttonSbf.append("return;}\n");
        buttonSbf
          .append("var selectedcount = parseInt(selectionModel.getCount());\n");
        buttonSbf.append("if ( selectedcount > 1 ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','只能选择一条记录');\n");
        buttonSbf.append("return;}\n");
        buttonSbf.append("var id = record.get(pk);\n");
        buttonSbf.append("configRecord(store);}\n");
       }
       
       if ("生效".equals(buttonList.get(i).getFunctionName())) {
        buttonSbf.append("iconCls:'editIcon',\n");
        buttonSbf.append("handler:function(){\n");
        buttonSbf
          .append("var selectionModel = grid.getSelectionModel();\n");
        buttonSbf
          .append("var record = selectionModel.getSelected();\n");
        buttonSbf.append("if ( record == undefined ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','请选择要生效的记录');\n");
        buttonSbf.append("return;}\n");
        buttonSbf
          .append("var selectedcount = parseInt(selectionModel.getCount());\n");
        buttonSbf.append("if ( selectedcount > 1 ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','只能选择一条记录');\n");
        buttonSbf.append("return;}\n");
        
        buttonSbf
        .append("var items = selectionModel.selections.items;\n");
        buttonSbf.append("inureRecord(store,items);}\n");
       }
       
       if ("注销".equals(buttonList.get(i).getFunctionName())) {
        buttonSbf.append("iconCls:'editIcon',\n");
        buttonSbf.append("handler:function(){\n");
        buttonSbf
          .append("var selectionModel = grid.getSelectionModel();\n");
        buttonSbf
          .append("var record = selectionModel.getSelected();\n");
        buttonSbf.append("if ( record == undefined ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','请选择要注销的记录');\n");
        buttonSbf.append("return;}\n");
        buttonSbf
          .append("var selectedcount = parseInt(selectionModel.getCount());\n");
        buttonSbf.append("if ( selectedcount > 1 ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','只能选择一条记录');\n");
        buttonSbf.append("return;}\n");
        buttonSbf.append("var id = record.get(pk);\n");
        buttonSbf.append("writeoffRecord(store,id);}\n");
       }
       if ("激活".equals(buttonList.get(i).getFunctionName())) {
        buttonSbf.append("iconCls:'activeIcon',\n");
        buttonSbf.append("handler:function(){\n");
        buttonSbf
          .append("var selectionModel = grid.getSelectionModel();\n");
        buttonSbf
          .append("var record = selectionModel.getSelected();\n");
        buttonSbf.append("if ( record == undefined ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','请选择要激活的记录');\n");
        buttonSbf.append("return;}\n");
        buttonSbf
          .append("var selectedcount = parseInt(selectionModel.getCount());\n");
        buttonSbf.append("if ( selectedcount > 1 ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','只能选择一条记录');\n");
        buttonSbf.append("return;}\n");
        buttonSbf.append("var id = record.get(pk);\n");
        buttonSbf.append("activeRecord(store,id);}\n");
       }
       if ("删除".equals(buttonList.get(i).getFunctionName())) {
        buttonSbf.append("iconCls:'deleteIcon',\n");
        buttonSbf.append("handler:function(){\n");
        buttonSbf
          .append("var selectionModel = grid.getSelectionModel();\n");
        buttonSbf
          .append("var record = selectionModel.getSelected();\n");
        buttonSbf.append("if ( record == undefined ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','请选择要删除的记录');\n");
        buttonSbf.append("return;}\n");
        buttonSbf
          .append("var items = selectionModel.selections.items;\n");
        buttonSbf.append("deleteRecord(store,items);}\n");
       }
       if ("工单撤回".equals(buttonList.get(i).getFunctionName())) {
        buttonSbf.append("iconCls:'deleteIcon',\n");
        buttonSbf.append("handler:function(){\n");
        buttonSbf
          .append("var selectionModel = grid.getSelectionModel();\n");
        buttonSbf
          .append("var record = selectionModel.getSelected();\n");
        buttonSbf.append("if ( record == undefined ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','请选择要删除的记录');\n");
        buttonSbf.append("return;}\n");
        buttonSbf
          .append("var items = selectionModel.selections.items;\n");
        buttonSbf.append("withdrawRecord(store,items);}\n");
       }
       
       if ("撤回".equals(buttonList.get(i).getFunctionName())) {
        buttonSbf.append("iconCls:'deleteIcon',\n");
        buttonSbf.append("handler:function(){\n");
        buttonSbf
          .append("var selectionModel = grid.getSelectionModel();\n");
        buttonSbf
          .append("var record = selectionModel.getSelected();\n");
        buttonSbf.append("if ( record == undefined ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','请选择要撤回的工单');\n");
        buttonSbf.append("return;}\n");
        buttonSbf
          .append("var items = selectionModel.selections.items;\n");
        buttonSbf.append("withdrawsRecord(store,items);}\n");
       }
       if ("删 除".equals(buttonList.get(i).getFunctionName())) {
        buttonSbf.append("iconCls:'deleteIcon',\n");
        buttonSbf.append("handler:function(){\n");
        buttonSbf
          .append("var selectionModel = grid.getSelectionModel();\n");
        buttonSbf
          .append("var record = selectionModel.getSelected();\n");
        buttonSbf.append("if ( record == undefined ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','请选择要删除的记录');\n");
        buttonSbf.append("return;}\n");
        buttonSbf
          .append("var items = selectionModel.selections.items;\n");
        buttonSbf.append("deleteHistoryCent(store,items);}\n");
       }
       if ("撤销".equals(buttonList.get(i).getFunctionName())) {
        buttonSbf.append("iconCls:'deleteIcon',\n");
        buttonSbf.append("handler:function(){\n");
        buttonSbf
          .append("var selectionModel = grid.getSelectionModel();\n");
        buttonSbf
          .append("var record = selectionModel.getSelected();\n");
        buttonSbf.append("if ( record == undefined ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','请选择要撤销的记录');\n");
        buttonSbf.append("return;}\n");
        buttonSbf
          .append("var selectedcount = parseInt(selectionModel.getCount());\n");
        buttonSbf.append("if ( selectedcount > 1 ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','只能选择一条记录');\n");
        buttonSbf.append("return;}\n");
        buttonSbf.append("var id = record.get('id');\n");
        buttonSbf.append("dropRecord(store,id);}\n");
       }
       if ("营销审核".equals(buttonList.get(i).getFunctionName())) {
        buttonSbf.append("iconCls:'editIcon',\n");
        buttonSbf.append("handler:function(){\n");
        buttonSbf
          .append("var selectionModel = grid.getSelectionModel();\n");
        buttonSbf
          .append("var record = selectionModel.getSelected();\n");
        buttonSbf.append("if ( record == undefined ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','请选择要审核的记录');\n");
        buttonSbf.append("return;}\n");
        buttonSbf
          .append("var selectedcount = parseInt(selectionModel.getCount());\n");
        buttonSbf.append("if ( selectedcount > 1 ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','只能选择一条记录');\n");
        buttonSbf.append("return;}\n");
        buttonSbf.append("var id = record.get(pk);\n");
        buttonSbf.append("marketFunction(store,id);}\n");
       }
       if ("主管审核".equals(buttonList.get(i).getFunctionName())) {
        buttonSbf.append("iconCls:'editIcon',\n");
        buttonSbf.append("handler:function(){\n");
        buttonSbf
          .append("var selectionModel = grid.getSelectionModel();\n");
        buttonSbf
          .append("var record = selectionModel.getSelected();\n");
        buttonSbf.append("if ( record == undefined ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','请选择要审核的记录');\n");
        buttonSbf.append("return;}\n");
        buttonSbf
          .append("var selectedcount = parseInt(selectionModel.getCount());\n");
        buttonSbf.append("if ( selectedcount > 1 ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','只能选择一条记录');\n");
        buttonSbf.append("return;}\n");
        buttonSbf.append("var id = record.get(pk);\n");
        buttonSbf.append("marketFunction(store,id);}\n");
       }
       if ("审核".equals(buttonList.get(i).getFunctionName())) {
        buttonSbf.append("iconCls:'editIcon',\n");
        buttonSbf.append("handler:function(){\n");
        buttonSbf
          .append("var selectionModel = grid.getSelectionModel();\n");
        buttonSbf
          .append("var record = selectionModel.getSelected();\n");
        buttonSbf.append("if ( record == undefined ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','请选择要审核的记录');\n");
        buttonSbf.append("return;}\n");
        buttonSbf
          .append("var selectedcount = parseInt(selectionModel.getCount());\n");
        buttonSbf.append("if ( selectedcount > 1 ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','只能选择一条记录');\n");
        buttonSbf.append("return;}\n");
        buttonSbf.append("var id = record.get(pk);\n");
        buttonSbf.append("auditFunction(store,id);}\n");
       }
       if ("通过".equals(buttonList.get(i).getFunctionName())) {
        buttonSbf.append("iconCls:'editIcon',\n");
        buttonSbf.append("handler:function(){\n");
        buttonSbf
        .append("var selectionModel = grid.getSelectionModel();\n");
        buttonSbf
        .append("var record = selectionModel.getSelected();\n");
        buttonSbf.append("if ( record == undefined ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','请选择要审核的记录');\n");
        buttonSbf.append("return;}\n");
        buttonSbf
        .append("var selectedcount = parseInt(selectionModel.getCount());\n");
        buttonSbf.append("if ( selectedcount > 1 ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','只能选择一条记录');\n");
        buttonSbf.append("return;}\n");
        buttonSbf.append("var id = record.get(pk);\n");
        buttonSbf.append("auditFunction(store,id);}\n");
       }
     
       
       
       if ("导出".equals(buttonList.get(i).getFunctionName())) {
        buttonSbf.append("iconCls:'excelIcon',\n");
        buttonSbf.append("handler:function(){exportRecord(store);}\n");
       }
       if ("ERP导出".equals(buttonList.get(i).getFunctionName())) {
        buttonSbf.append("iconCls:'excelIcon',\n");
        buttonSbf.append("handler:function(){exportRecord(store);}\n");
       }
       if ("导入".equals(buttonList.get(i).getFunctionName())) {
        buttonSbf.append("iconCls:'excelIcon',\n");
        buttonSbf.append("handler:function(){importRecord(store);}\n");
       }
       if ("批量修改".equals(buttonList.get(i).getFunctionName())) {
        buttonSbf.append("iconCls:'excelIcon',\n");
        buttonSbf.append("handler:function(){importUpdate(store);}\n");
       }

       if ("打印".equals(buttonList.get(i).getFunctionName())) {
        buttonSbf.append("iconCls:'excelIcon',\n");
        buttonSbf.append("handler:function(){importRecord(store);}\n");
       }
       if ("异动".equals(buttonList.get(i).getFunctionName())) {
        buttonSbf.append("iconCls:'timeIcon',\n");
        buttonSbf.append("handler:function(){\n");
        buttonSbf
          .append("var selectionModel = grid.getSelectionModel();\n");
        buttonSbf
          .append("var record = selectionModel.getSelected();\n");
        buttonSbf.append("if ( record == undefined ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','请选择要查看异动的记录');\n");
        buttonSbf.append("return;}\n");
        buttonSbf
          .append("var selectedcount = parseInt(selectionModel.getCount());\n");
        buttonSbf.append("if ( selectedcount > 1 ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','只能选择一条记录');\n");
        buttonSbf.append("return;}\n");
        buttonSbf.append("var id = record.get(pk);\n");
        buttonSbf.append("changeRecord(store,id);}\n");
       }
       if ("流转轨迹".equals(buttonList.get(i).getFunctionName())) {
        buttonSbf.append("iconCls:'timeIcon',\n");
        buttonSbf.append("handler:function(){\n");
        buttonSbf.append("var selectionModel = grid.getSelectionModel();\n");
        buttonSbf.append("var record = selectionModel.getSelected();\n");
        buttonSbf.append("var recs=selectionModel.getSelections();\n");
        buttonSbf.append("if ( record == undefined ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','请选择要查看流转轨迹的记录');\n");
        buttonSbf.append("return;}\n");
        buttonSbf
          .append("var selectedcount = parseInt(selectionModel.getCount());\n");
        buttonSbf.append("if ( selectedcount > 1 ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','只能选择一条记录');\n");
        buttonSbf.append("return;}\n");
        buttonSbf.append("var id = recs[0].get('gdid');\n");
        buttonSbf.append("changeRecord(store,id);}\n");
       }
       if ("归档".equals(buttonList.get(i).getFunctionName())) {
        buttonSbf.append("iconCls:'editIcon',\n");
        buttonSbf.append("handler:function(){\n");
        buttonSbf.append("var selectionModel = grid.getSelectionModel();\n");
        buttonSbf.append("var record = selectionModel.getSelected();\n");
        buttonSbf.append("if ( record == undefined ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','请选择要归档的记录');\n"); 
        buttonSbf.append("return;}\n");
        buttonSbf.append("var items = selectionModel.selections.items;\n");
        buttonSbf.append("archiveRecord(store,items);}\n");
       }
       if ("工单分配".equals(buttonList.get(i).getFunctionName())) {
        buttonSbf.append("iconCls:'editIcon',\n");
        buttonSbf.append("handler:function(){\n");
        buttonSbf.append("var selectionModel = grid.getSelectionModel();\n");
        buttonSbf.append("var record = selectionModel.getSelected();\n");
        buttonSbf.append("if ( record == undefined ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','请选择要分配的工单');\n"); 
        buttonSbf.append("return;}\n");
        buttonSbf.append("var items = selectionModel.selections.items;\n");
        buttonSbf.append("assignRecord(store,items);}\n");
       }
       
       if ("更换客户经理".equals(buttonList.get(i).getFunctionName())) {
        buttonSbf.append("iconCls:'editIcon',\n");
        buttonSbf.append("handler:function(){\n");
        buttonSbf.append("var selectionModel = grid.getSelectionModel();\n");
        buttonSbf.append("var record = selectionModel.getSelected();\n");
        buttonSbf.append("if ( record == undefined ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','请选择要更换的客户');\n"); 
        buttonSbf.append("return;}\n");
        buttonSbf.append("var items = selectionModel.selections.items;\n");
        buttonSbf.append("assignRecord(store,items);}\n");
       }
       
       if ("客户回访维护".equals(buttonList.get(i).getFunctionName())) {
        buttonSbf.append("iconCls:'editIcon',\n");
        buttonSbf.append("handler:function(){\n");
        buttonSbf
          .append("var selectionModel = grid.getSelectionModel();\n");
        buttonSbf
          .append("var record = selectionModel.getSelected();\n");
        buttonSbf.append("if ( record == undefined ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','请选择客户');\n");
        buttonSbf.append("return;}\n");
        buttonSbf
          .append("var selectedcount = parseInt(selectionModel.getCount());\n");
        buttonSbf.append("if ( selectedcount > 1 ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','只能选择一条记录');\n");
        buttonSbf.append("return;}\n");
        buttonSbf.append("var id = record.get(pk);\n");
        buttonSbf.append("accessFunction(store,id);}\n");
       }
       
       if ("工单处理".equals(buttonList.get(i).getFunctionName())) {
        buttonSbf.append("iconCls:'editIcon',\n");
        buttonSbf.append("handler:function(){\n");
        buttonSbf
          .append("var selectionModel = grid.getSelectionModel();\n");
        buttonSbf
          .append("var record = selectionModel.getSelected();\n");
        buttonSbf.append("if ( record == undefined ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','请选择要处理的记录');\n");
        buttonSbf.append("return;}\n");
        buttonSbf
          .append("var selectedcount = parseInt(selectionModel.getCount());\n");
        buttonSbf.append("if ( selectedcount > 1 ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','只能选择一条记录');\n");
        buttonSbf.append("return;}\n");
        buttonSbf.append("var id = record.get(pk);\n");
        buttonSbf.append("dealRecord(store,id,record);}\n");
       }
       
       if ("工单审批".equals(buttonList.get(i).getFunctionName())) {
        buttonSbf.append("iconCls:'editIcon',\n");
        buttonSbf.append("handler:function(){\n");
        buttonSbf
          .append("var selectionModel = grid.getSelectionModel();\n");
        buttonSbf
          .append("var record = selectionModel.getSelected();\n");
        buttonSbf.append("if ( record == undefined ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','请选择要审批的记录');\n");
        buttonSbf.append("return;}\n");
        buttonSbf
          .append("var selectedcount = parseInt(selectionModel.getCount());\n");
        buttonSbf.append("if ( selectedcount > 1 ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','只能选择一条记录');\n");
        buttonSbf.append("return;}\n");
        buttonSbf.append("var id = record.get(pk);\n");
        buttonSbf.append("approveRecord(store,id,record);}\n");
       }
       
       
       if ("处理关闭".equals(buttonList.get(i).getFunctionName())) {
        buttonSbf.append("iconCls:'editIcon',\n");
        buttonSbf.append("handler:function(){\n");
        buttonSbf
          .append("var selectionModel = grid.getSelectionModel();\n");
        buttonSbf
          .append("var record = selectionModel.getSelected();\n");
        buttonSbf.append("if ( record == undefined ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','请选择要处理的记录');\n");
        buttonSbf.append("return;}\n");
        buttonSbf
          .append("var selectedcount = parseInt(selectionModel.getCount());\n");
        buttonSbf.append("if ( selectedcount > 1 ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','只能选择一条记录');\n");
        buttonSbf.append("return;}\n");
        buttonSbf.append("var id = record.get(pk);\n");
        buttonSbf.append("closeRecord(store,id,record);}\n");
       }
       
       if ("历史审批".equals(buttonList.get(i).getFunctionName())) {
        buttonSbf.append("iconCls:'queryIcon',\n");
        buttonSbf.append("handler:function(){\n");
        buttonSbf.append("queryHistoryRecord(store);}\n");
       }
       
       if ("常旅客".equals(buttonList.get(i).getFunctionName())) {
        buttonSbf.append("iconCls:'guestIcon',\n");
        buttonSbf.append("handler:function(){\n");
        buttonSbf
          .append("var selectionModel = grid.getSelectionModel();\n");
        buttonSbf
          .append("var record = selectionModel.getSelected();\n");
        buttonSbf.append("if ( record == undefined ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','请选择要查看常旅客的记录');\n");
        buttonSbf.append("return;}\n");
        buttonSbf
          .append("var selectedcount = parseInt(selectionModel.getCount());\n");
        buttonSbf.append("if ( selectedcount > 1 ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','只能选择一条记录');\n");
        buttonSbf.append("return;}\n");
        buttonSbf.append("var id = record.get(pk);\n");
        buttonSbf.append("guestFunction(store,id);}\n");
       }
       
       if ("消费明细".equals(buttonList.get(i).getFunctionName())) {
        buttonSbf.append("iconCls:'moneyIcon',\n");
        buttonSbf.append("handler:function(){\n");
        buttonSbf
          .append("var selectionModel = grid.getSelectionModel();\n");
        buttonSbf
          .append("var record = selectionModel.getSelected();\n");
        buttonSbf.append("if ( record == undefined ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','请选择要查看消费明细的记录');\n");
        buttonSbf.append("return;}\n");
        buttonSbf
          .append("var selectedcount = parseInt(selectionModel.getCount());\n");
        buttonSbf.append("if ( selectedcount > 1 ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','只能选择一条记录');\n");
        buttonSbf.append("return;}\n");
        buttonSbf.append("var id = record.get(pk);\n");
        buttonSbf.append("historyCentFunction(store,id);}\n");
       }
       
       if ("流转配置".equals(buttonList.get(i).getFunctionName())) {
        buttonSbf.append("iconCls:'moneyIcon',\n");
        buttonSbf.append("handler:function(){\n");
        buttonSbf
          .append("var selectionModel = grid.getSelectionModel();\n");
        buttonSbf
          .append("var record = selectionModel.getSelected();\n");
        buttonSbf.append("if ( record == undefined ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','请选择要流转配置的记录');\n");
        buttonSbf.append("return;}\n");
        buttonSbf
          .append("var selectedcount = parseInt(selectionModel.getCount());\n");
        buttonSbf.append("if ( selectedcount > 1 ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','只能选择一条记录');\n");
        buttonSbf.append("return;}\n");
        buttonSbf.append("var id = record.get(pk);\n");
        buttonSbf.append("turnConfigFunction(store,id);}\n");
       }
       
       if ("审批流程配置".equals(buttonList.get(i).getFunctionName())) {
        buttonSbf.append("iconCls:'moneyIcon',\n");
        buttonSbf.append("handler:function(){\n");
        buttonSbf
          .append("var selectionModel = grid.getSelectionModel();\n");
        buttonSbf
          .append("var record = selectionModel.getSelected();\n");
        buttonSbf.append("if ( record == undefined ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','请选择要配置的记录');\n");
        buttonSbf.append("return;}\n");
        buttonSbf
          .append("var selectedcount = parseInt(selectionModel.getCount());\n");
        buttonSbf.append("if ( selectedcount > 1 ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','只能选择一条记录');\n");
        buttonSbf.append("return;}\n");
        buttonSbf.append("var id = record.get(pk);\n");
        buttonSbf.append("approveConfigFunction(store,id);}\n");
       }
       
       if ("机票明细".equals(buttonList.get(i).getFunctionName())) {
        buttonSbf.append("iconCls:'flight',\n");
        buttonSbf.append("handler:function(){flightHistoryCentFunction();}\n");
       }
       
       if ("酒店明细".equals(buttonList.get(i).getFunctionName())) {
        buttonSbf.append("iconCls:'hotel',\n");
        buttonSbf.append("handler:function(){hotelHistoryCentFunction();}\n");
       }
       
       
       if ("其它明细".equals(buttonList.get(i).getFunctionName())) {
        buttonSbf.append("iconCls:'moneyIcon',\n");
        buttonSbf.append("handler:function(){othersHistoryCentFunction();}\n");
       }
       if ("短信邮件角色维护".equals(buttonList.get(i).getFunctionName())) {
        buttonSbf.append("iconCls:'rolesIcon',\n");
        buttonSbf.append("handler:function(){\n");
        buttonSbf
          .append("var selectionModel = grid.getSelectionModel();\n");
        buttonSbf
          .append("var record = selectionModel.getSelected();\n");
        buttonSbf.append("if ( record == undefined ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','请选择要查看的大客户');\n");
        buttonSbf.append("return;}\n");
        buttonSbf
          .append("var selectedcount = parseInt(selectionModel.getCount());\n");
        buttonSbf.append("if ( selectedcount > 1 ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','只能选择一条记录');\n");
        buttonSbf.append("return;}\n");
        buttonSbf.append("var id = record.get(pk);\n");
        buttonSbf.append("roleduanxin(store,id);}\n");
       }
       if ("人员批量添加".equals(buttonList.get(i).getFunctionName())) {
        buttonSbf.append("iconCls:'moneyIcon',\n");
        buttonSbf.append("handler:function(){\n");
        buttonSbf
          .append("var selectionModel = grid.getSelectionModel();\n");
        buttonSbf
          .append("var record = selectionModel.getSelected();\n");
        buttonSbf.append("if ( record == undefined ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','请选择要批量维护的角色');\n");
        buttonSbf.append("return;}\n");
        buttonSbf
          .append("var selectedcount = parseInt(selectionModel.getCount());\n");
        buttonSbf.append("if ( selectedcount > 1 ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','只能选择一条记录');\n");
        buttonSbf.append("return;}\n");
        buttonSbf.append("var id = record.get(pk);\n");
        buttonSbf.append("rolepiliang(store,id);}\n");
       }
       
       if ("工单流转".equals(buttonList.get(i).getFunctionName())) {
        buttonSbf.append("iconCls:'editIcon',\n");
        buttonSbf.append("handler:function(){\n");
        buttonSbf
          .append("var selectionModel = grid.getSelectionModel();\n");
        buttonSbf
          .append("var record = selectionModel.getSelected();\n");
        buttonSbf.append("if ( record == undefined ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','请选择要流转的记录');\n");
        buttonSbf.append("return;}\n");
        buttonSbf
          .append("var selectedcount = parseInt(selectionModel.getCount());\n");
        buttonSbf.append("if ( selectedcount > 1 ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','只能选择一条记录');\n");
        buttonSbf.append("return;}\n");
        buttonSbf
        .append("var items = selectionModel.selections.items;\n");
        buttonSbf.append("moveRecord(store,items);}\n");
       }
       
       if ("分配权限".equals(buttonList.get(i).getFunctionName())) {
        buttonSbf.append("iconCls:'editIcon',\n");
        buttonSbf.append("handler:function(){\n");
        buttonSbf
          .append("var selectionModel = grid.getSelectionModel();\n");
        buttonSbf
          .append("var record = selectionModel.getSelected();\n");
        buttonSbf.append("if ( record == undefined ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','请选择要分配权限的记录');\n");
        buttonSbf.append("return;}\n");
        buttonSbf
          .append("var selectedcount = parseInt(selectionModel.getCount());\n");
        buttonSbf.append("if ( selectedcount > 1 ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','只能选择一条记录');\n");
        buttonSbf.append("return;}\n");
        buttonSbf.append("var id = record.get(pk);\n");
        buttonSbf.append("assignFunction(store,id);}\n");
       }
       if ("服务分配".equals(buttonList.get(i).getFunctionName())) {
        buttonSbf.append("iconCls:'servingIcon',\n");
        buttonSbf.append("handler:function(){\n");
        // buttonSbf
        // .append("var selectionModel = grid.getSelectionModel();\n");
        // buttonSbf
        // .append("var record = selectionModel.getSelected();\n");
        // buttonSbf.append("if ( record == undefined ){\n");
        // buttonSbf.append("Ext.Msg.alert('系统提示','请选择要分配权限的记录');\n");
        // buttonSbf.append("return;}\n");
        // buttonSbf
        // .append("var selectedcount = parseInt(selectionModel.getCount());\n");
        // buttonSbf.append("if ( selectedcount > 1 ){\n");
        // buttonSbf.append("Ext.Msg.alert('系统提示','只能选择一条记录');\n");
        // buttonSbf.append("return;}\n");
        // buttonSbf.append("var id = record.get(pk);\n");
        buttonSbf.append("assignServing(store);}\n");
       }
       if ("个性服务".equals(buttonList.get(i).getFunctionName())) {
        buttonSbf.append("iconCls:'servingIcon',\n");
        buttonSbf.append("handler:function(){\n");
        buttonSbf.append("assignOnlyServing(store);}\n");
       }
       if ("重置密码".equals(buttonList.get(i).getFunctionName())) {
        buttonSbf.append("iconCls:'editIcon',\n");
        buttonSbf.append("handler:function(){\n");
        buttonSbf
          .append("var selectionModel = grid.getSelectionModel();\n");
        buttonSbf
          .append("var record = selectionModel.getSelected();\n");
        buttonSbf.append("if ( record == undefined ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','请选择要重置密码的人员');\n");
        buttonSbf.append("return;}\n");
        buttonSbf
          .append("var selectedcount = parseInt(selectionModel.getCount());\n");
        buttonSbf.append("if ( selectedcount > 1 ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','只能选择一条记录');\n");
        buttonSbf.append("return;}\n");
        buttonSbf.append("var id = record.get(pk);\n");
        buttonSbf.append("resetPwdFunction(store,id);}\n");
       }
       if ("分配角色".equals(buttonList.get(i).getFunctionName())) {
        buttonSbf.append("iconCls:'editIcon',\n");
        buttonSbf.append("handler:function(){\n");
        buttonSbf
          .append("var selectionModel = grid.getSelectionModel();\n");
        buttonSbf
          .append("var record = selectionModel.getSelected();\n");
        buttonSbf.append("if ( record == undefined ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','请选择要分配角色的人员');\n");
        buttonSbf.append("return;}\n");
        buttonSbf
          .append("var selectedcount = parseInt(selectionModel.getCount());\n");
        buttonSbf.append("if ( selectedcount > 1 ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','只能选择一条记录');\n");
        buttonSbf.append("return;}\n");
        buttonSbf.append("var id = record.get(pk);\n");
        buttonSbf.append("assignRolesFunction(store,id);}\n");
       }
       if ("积分".equals(buttonList.get(i).getFunctionName())) {
        buttonSbf.append("iconCls:'integralIcon',\n");
        buttonSbf.append("handler:function(){\n");
        buttonSbf
          .append("var selectionModel = grid.getSelectionModel();\n");
        buttonSbf
          .append("var record = selectionModel.getSelected();\n");
        buttonSbf.append("if ( record == undefined ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','请选择要维护积分的记录');\n");
        buttonSbf.append("return;}\n");
        buttonSbf
          .append("var selectedcount = parseInt(selectionModel.getCount());\n");
        buttonSbf.append("if ( selectedcount > 1 ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','只能选择一条记录');\n");
        buttonSbf.append("return;}\n");
        buttonSbf.append("var id = record.get(pk);\n");
        buttonSbf.append("integralManage(store,id);}\n");
       }
       
       if ("审核不通过".equals(buttonList.get(i).getFunctionName())) {
        buttonSbf.append("iconCls:'editIcon',\n");
        buttonSbf.append("handler:function(){\n");
        buttonSbf
          .append("var selectionModel = grid.getSelectionModel();\n");
        buttonSbf
          .append("var record = selectionModel.getSelected();\n");
        buttonSbf.append("if ( record == undefined ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','请选择要审核的投诉或建议');\n");
        buttonSbf.append("return;}\n");
        buttonSbf
          .append("var selectedcount = parseInt(selectionModel.getCount());\n");
        buttonSbf.append("if ( selectedcount > 1 ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','只能选择一条记录');\n");
        buttonSbf.append("return;}\n");
        buttonSbf.append("var id = record.get(pk);\n");
        buttonSbf.append("auditNotThrough(store,id,record);}\n");
       }
       
       if ("审核通过".equals(buttonList.get(i).getFunctionName())) {
        buttonSbf.append("iconCls:'editIcon',\n");
        buttonSbf.append("handler:function(){\n");
        buttonSbf
          .append("var selectionModel = grid.getSelectionModel();\n");
        buttonSbf
          .append("var record = selectionModel.getSelected();\n");
        buttonSbf.append("if ( record == undefined ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','请选择要审核的投诉或建议');\n");
        buttonSbf.append("return;}\n");
        buttonSbf
          .append("var selectedcount = parseInt(selectionModel.getCount());\n");
        buttonSbf.append("if ( selectedcount > 1 ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','只能选择一条记录');\n");
        buttonSbf.append("return;}\n");
        buttonSbf.append("var id = record.get(pk);\n");
        buttonSbf.append("auditThrough(store,id,record);}\n");
       }
       
       if ("已处理".equals(buttonList.get(i).getFunctionName())) {
        buttonSbf.append("iconCls:'editIcon',\n");
        buttonSbf.append("handler:function(){\n");
        buttonSbf
          .append("var selectionModel = grid.getSelectionModel();\n");
        buttonSbf
          .append("var record = selectionModel.getSelected();\n");
        buttonSbf.append("if ( record == undefined ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','请选择要处理的投诉或建议');\n");
        buttonSbf.append("return;}\n");
        buttonSbf
          .append("var selectedcount = parseInt(selectionModel.getCount());\n");
        buttonSbf.append("if ( selectedcount > 1 ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','只能选择一条记录');\n");
        buttonSbf.append("return;}\n");
        buttonSbf.append("var id = record.get(pk);\n");
        buttonSbf.append("auditFinish(store,id,record);}\n");
       }
       if ("导出日报".equals(buttonList.get(i).getFunctionName())) {
        buttonSbf.append("iconCls:'excelIcon',\n");
        buttonSbf.append("handler:function(){exportRecordDay(store);}\n");
       }
       if ("导出月报".equals(buttonList.get(i).getFunctionName())) {
        buttonSbf.append("iconCls:'excelIcon',\n");
        buttonSbf.append("handler:function(){exportRecord(store);}\n");
       }
       if ("成功".equals(buttonList.get(i).getFunctionName())) {
        buttonSbf.append("iconCls:'editIcon',\n");
        buttonSbf.append("handler:function(){\n");
        buttonSbf
          .append("var selectionModel = grid.getSelectionModel();\n");
        buttonSbf
          .append("var record = selectionModel.getSelected();\n");
        buttonSbf.append("if ( record == undefined ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','请选择要审核的记录');\n");
        buttonSbf.append("return;}\n");
    //    buttonSbf
    //      .append("var selectedcount = parseInt(selectionModel.getCount());\n");
    //    buttonSbf.append("if ( selectedcount > 1 ){\n");
    //    buttonSbf.append("Ext.Msg.alert('系统提示','只能选择一条记录');\n");
    //    buttonSbf.append("return;}\n");
    //    buttonSbf.append("var id = record.get(pk);\n");
    //    buttonSbf.append("auditSuccess(store,id);}\n");
        buttonSbf
        .append("var items = selectionModel.selections.items;\n");
        buttonSbf.append("auditSuccess(store,items);}\n");
       }
       if ("失败".equals(buttonList.get(i).getFunctionName())) {
        buttonSbf.append("iconCls:'editIcon',\n");
        buttonSbf.append("handler:function(){\n");
        buttonSbf
          .append("var selectionModel = grid.getSelectionModel();\n");
        buttonSbf
          .append("var record = selectionModel.getSelected();\n");
        buttonSbf.append("if ( record == undefined ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','请选择要审核的记录');\n");
        buttonSbf.append("return;}\n");
        buttonSbf
          .append("var selectedcount = parseInt(selectionModel.getCount());\n");
        buttonSbf.append("if ( selectedcount > 1 ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','只能选择一条记录');\n");
        buttonSbf.append("return;}\n");
        buttonSbf.append("var id = record.get(pk);\n");
        buttonSbf.append("auditFail(store,id);}\n");
       }
       if ("异常".equals(buttonList.get(i).getFunctionName())) {
        buttonSbf.append("iconCls:'editIcon',\n");
        buttonSbf.append("handler:function(){\n");
        buttonSbf
          .append("var selectionModel = grid.getSelectionModel();\n");
        buttonSbf
          .append("var record = selectionModel.getSelected();\n");
        buttonSbf.append("if ( record == undefined ){\n");
        buttonSbf.append("Ext.Msg.alert('系统提示','请选择要审核的记录');\n");
        buttonSbf.append("return;}\n");
    //    buttonSbf
    //      .append("var selectedcount = parseInt(selectionModel.getCount());\n");
    //    buttonSbf.append("if ( selectedcount > 1 ){\n");
    //    buttonSbf.append("Ext.Msg.alert('系统提示','只能选择一条记录');\n");
    //    buttonSbf.append("return;}\n");
    //    buttonSbf.append("var id = record.get(pk);\n");
    //    buttonSbf.append("auditSuccess(store,id);}\n");
        buttonSbf
        .append("var items = selectionModel.selections.items;\n");
        buttonSbf.append("auditException(store,items);}\n");
       }
       buttonSbf.append("}));\n");
       buttonSbf.append("tb.addSpacer();\n");
       buttonSbf.append("tb.addSeparator();\n");

      }
      buttonSbf.append("</script>\n");
      return buttonSbf.toString();
     }
     public String geToolReports(String userid, String resources_type,
       String functionLevel, String status) {
      HttpServletRequest request = Struts2Utils.getRequest();
      String path = request.getContextPath();
      List<Resources> reportList = findUserFunction(userid, resources_type,
        functionLevel, status);
      if (reportList.size() % 2 != 0) {
       Resources temp = new Resources();
       temp.setId(9999l);
       temp.setValue("");
       temp.setFunctionLevel(9999 + "");
       temp.setFunctionName("");
       reportList.add(temp);
      }

      Collections.sort(reportList);

      StringBuffer buttonSbf = new StringBuffer();
      buttonSbf.append("<br>");
      buttonSbf.append("<center>\n");
      buttonSbf
        .append("<div align=\"center\" style=\"width=100%;overflow=auto;overflow-y=hidden\">\n");
      buttonSbf.append("<table class=\"table_info\" width=\"100%\">\n");
      buttonSbf.append("<tr class=\"td_label\" align=\"center\">\n");
      buttonSbf.append("<td width=\"10%\" align=\"center\">序号</td>\n");
      buttonSbf.append("<td width=\"40%\" align=\"center\">报表</td>\n");
      buttonSbf.append("<td width=\"10%\" align=\"center\">序号</td>\n");
      buttonSbf.append("<td width=\"40%\" align=\"center\">报表</td>\n");
      buttonSbf.append("</tr>\n");

      for (int i = 0; i < reportList.size(); i++) {

       buttonSbf.append("   <tr align=\"center\">\n");
       buttonSbf.append(" <td  class=\"td_last\"> \n");
       buttonSbf.append(i + 1); // print index
       buttonSbf.append(" </td> \n");
       buttonSbf.append(" <td class=\"td_last\"> \n");
       //Resources func = (Resources) reportList.get(i);
       Resources tempFunc = (Resources) reportList.get(i++);
       buttonSbf.append("<a href=\"#\"  onClick=\"openWin('" + path
         + tempFunc.getValue() + "','" + tempFunc.getFunctionName()
         + "')\">" + tempFunc.getFunctionName() + "</a>");
       buttonSbf.append("</td>\n");
       if (i == reportList.size())
        break;
       buttonSbf.append(" <td class=\"td_last\"> \n");
       buttonSbf.append(i + 1); // print index
       buttonSbf.append(" </td> \n");
       buttonSbf.append(" <td class=\"td_last\"> \n");
       tempFunc = (Resources) reportList.get(i);
       buttonSbf.append("<a href=\"#\"  onClick=\"openWin('" + path
         + tempFunc.getValue() + "','" + tempFunc.getFunctionName()
         + "')\">" + tempFunc.getFunctionName() + "</a>");
       buttonSbf.append("</td>\n");
       buttonSbf.append(" </tr>\n");
      }
      buttonSbf.append("</table>\n");
      buttonSbf.append("</div>\n");
      buttonSbf.append("</center>\n");
      return buttonSbf.toString();

     }

     /**
      * DWR 检查functionLevel是否唯一.
      *
      * @return loginName在数据库中唯一或等于orgLoginName时返回true.
      */
     @Transactional(readOnly = true)
     @RemoteMethod
     public boolean isFunctionLevelUnique(String functionLevel,
       String orgFunctionLevel) {
      return resourceDao.isPropertyUnique("functionLevel", functionLevel,
        orgFunctionLevel);
     }

     /**
      * 用于DWR根据ID删除实体
      */
     @RemoteMethod
     public String dwrDelete(Long[] idArray) {
      String msg = "";
      for (int i = 0; i < idArray.length; i++) {
       getEntityDao().delete(idArray[i]);
      }
      msg = "删除成功!";
      return msg;
     }
     @Override
        @RemoteMethod
        @Transactional(readOnly = true)
        public Page<Resources> dwrListPageHQL(DwrBackParams params, String hql) {
            Page<Resources> page = new Page<Resources>();
            hql = "select new com.tempus.userCenter.entity.authority.Resources(id,resourceType,value,orderNum,functionName,functionLevel,description,status,functionEname,parentId) from Resources where 1=1 ";// 在这里拼HQL
            try {
                int pageSize = params.getLimit();
                int currentPage = params.getStart() / pageSize + 1;
                int queryflag = params.getQueryflag();
                String orderby = params.getOrderby();
                String orderDirection = params.getOrderdirection();
                if (queryflag == 1) {
                    List<Condition> conditions = params.getConditions();
                    List<PropertyFilter> filters = DWRUtil
                            .buildPropertyFilters(conditions);
                    Page<Users> argPage = new Page<Users>(currentPage, pageSize);
                    if (orderby != null) {
                        argPage.setOrderBy(orderby);// 设置排序参数
                        argPage.setOrder(orderDirection);// 设置排序方向 降序或者降序
                    }
                    StringBuffer sbHQL = new StringBuffer(hql);
                    List<Object> values = new ArrayList<Object>();
                    usersDao.buildFilterConditions(filters, sbHQL, values);
                    page = resourceDao.findPage(sbHQL.toString(), values.toArray(),
                            argPage);
                }
            } catch (Exception e) {
                logger.error("dwrListPageHQL列表查询出现异常",e);
            }
            return page;
        }
    }

     

     

    -----------------------------

    list。js

    /**
     * the entrance of the main function
     * @param store
     */
    var sm = new Ext.grid.CheckboxSelectionModel(); 

    String.prototype.Trim = function()    {    return this.replace(/(^\s*)|(\s*$)/g, "");    }
    function onLoad(params)
    {
     var w = Ext.get('list').getWidth();//面板宽度
        var h = Ext.get('search-panel').getHeight()-queryFormWidth-35;//面板高度
        var pagesize=15;
        var conditions=new Array();                   //use to save the query condtion
        if(params["pagesize"])
        {
            pagesize=params["pagesize"];
        }
        var title=params["title"];
        var div=params["div"];

        var gridParams=params["gridParams"];
        var queryCondition=params["queryCondition"];
        var gridconfig=new GridConfig(gridParams);
     var orderby=pk;//排序参数
     var orderdirection="asc";//升序 降序
        Ext.onReady(function() {   
      var MyRecord = Ext.data.Record.create(gridconfig.getRecord());   
         store = new Ext.data.Store({
                 proxy: new Ext.data.DWRProxy(eval(listOperater.list)),
                 reader: new Ext.data.ListRangeReader({root:'items',totalProperty: 'totalCount',id: 'id'}, MyRecord)
             });       
               
            var colM = gridconfig.getColumn();
            var pagingBar = new Ext.PagingToolbar({
             plugins:[new Ext.ux.Andrie.pPageSize(),new Ext.ux.ProgressBarPager()],          
                pageSize:pagesize,
                paramNames:{start:"start",limit:"limit",conditions:"conditions",orderby:"orderby"},
                store:store,
                displayInfo:true,
          emptyMsg: '没有数据',  
                beforePageText:"第",
                afterPageText:"页 共 {0} 页",
                displayMsg:'第 {0} 条到 {1} 条记录--共 {2} 条',         
                doLoad:function(C) {
                    var B = {},A = this.paramNames;               
                    B[A.start] = C;
                    B[A.limit] = this.pageSize;
                    B[A.conditions] = conditions;
                    B[A.queryflag] = 1;
                    B[A.orderby] = pk;
                    B[A.orderdirection] = "asc";
                    Ext.apply(B,{queryflag:queryflag,orderby:orderby,orderdirection:orderdirection});  // 强制 增加变量 增加查询标志参数
                    if (this.fireEvent("beforechange", this, B) !== false) {
                        this.store.load({params:B})
                    }
                }
            });
            grid = new Ext.grid.GridPanel({
                renderTo:div,
             autoWidth:true,
             height: h,
             sm:sm,
             viewConfig: { forceFit: true },
             autoScroll:false,
             stripeRows: true,
                renderTo: document.body,
                cm:colM,
           
                store:store,
          menuDisabled:true,
       resizable:false,
       trackMouseOver:false,
                bbar:pagingBar
            });
            grid.addListener('cellclick',function(grid, rowIndex, columnIndex, e)//添加单击复制事件
              {
               var record = grid.getStore().getAt(rowIndex); //Get the Record   
            var fieldName = grid.getColumnModel().getDataIndex(columnIndex); //Get field name   
            var data = record.get(fieldName);
            if(typeof(data)=="object")
            {         
             data=(data==null?"":Ext.util.Format.date(data.toString(), 'Y-m-d h:i:s'));         
            }
            if(typeof(data)=="number")
            {
             data+="";
            }
            if(data==undefined)
            {
             data="";
            }
              grid.getView().refresh();   
                 grid.getView().getCell(rowIndex,columnIndex).style.backgroundColor="#2561DE"; 
            window.clipboardData.setData("Text",data);
              }
            );
            //是否一进入就查询  在相对应的实体JS设置queryflag的值,默认为0(即不查询)
         
           if(queryflag==1)
           {
            queryRecord(store);     
           }

         
        
              var panel = new Ext.Panel({
              applyTo: 'search-panel',                         
              autoScroll:false,
              tbar:tb, 
              items: [queryForm,grid]
          });

     
        });

      //公用删除方法
        deleteRecord = function(store, items)
        {     
                Ext.MessageBox.confirm('提示框', '您确定要进行该操作?', function(btn) {
                    if (btn == 'yes')
                    {
                        var idArray = new Array();
                        for(var i=0;i<items.length;i++)
                        {
                         idArray.push(items[i].data[pk]);
                        }
                        eval(listOperater["deleteRecord"])(idArray, function(msg) //delete data
                        {
                            Ext.MessageBox.alert("信息:", msg);                 //display the back infomation
                            this.disabled = false;
                            store.reload();
                        });
                    }
                });
        }

        /**
         * query Box
         * @param store
         */
     
         queryRecord = function(store)
        {
           conditions=[];
           queryflag=1;//是否查询 避免进入页面就查询
        orderby = params["orderby"]=(params["orderby"]==undefined?pk:params["orderby"]);//排序字段
        orderdirection = params["orderdirection"]=(params["orderdirection"]==undefined?"desc":params["orderdirection"]);//排序方向
                 var queryConfig=new QueryConfig(queryCondition);
                             var querygrid=queryConfig.getQueryGrid();
                            var dataLength=querygrid.store.data.length;
                            var queryGridRds=querygrid.getStore().getRange(0,dataLength-1);
                            for(var i=0;i<queryGridRds.length;i++)
                            {                         
                                if(queryGridRds[i].get("operator"))
                                {
                                    conditions.push(queryGridRds[i].data);                             
                                }
                            }
                            fitFormValue(conditions);
                            store.load({params:{start:0,limit:pagesize,conditions:conditions,queryflag:queryflag,orderby:params["orderby"],orderdirection:params["orderdirection"]}});
     
        }
         //导出Excel
     exportRecord = function(store)
         {
            conditions=[];
            queryflag=1;//是否查询 避免进入页面就查询
         orderby = params["orderby"]=(params["orderby"]==undefined?pk:params["orderby"]);//排序字段
         orderdirection = params["orderdirection"]=(params["orderdirection"]==undefined?"desc":params["orderdirection"]);//排序方向
                  var queryConfig=new QueryConfig(queryCondition);
                              var querygrid=queryConfig.getQueryGrid();
                             var dataLength=querygrid.store.data.length;
                             var queryGridRds=querygrid.getStore().getRange(0,dataLength-1);
                             for(var i=0;i<queryGridRds.length;i++)
                             {                         
                                 if(queryGridRds[i].get("operator"))
                                 {
                                     conditions.push(queryGridRds[i].data);                             
                                 }
                             }
                             fitFormValue(conditions);
                             exportExcel(conditions); 
         }
         //导出Excel
     exportRecordDay = function(store)
         {
            conditions=[];
            queryflag=1;//是否查询 避免进入页面就查询
         orderby = params["orderby"]=(params["orderby"]==undefined?pk:params["orderby"]);//排序字段
         orderdirection = params["orderdirection"]=(params["orderdirection"]==undefined?"desc":params["orderdirection"]);//排序方向
                  var queryConfig=new QueryConfig(queryCondition);
                              var querygrid=queryConfig.getQueryGrid();
                             var dataLength=querygrid.store.data.length;
                             var queryGridRds=querygrid.getStore().getRange(0,dataLength-1);
                             for(var i=0;i<queryGridRds.length;i++)
                             {                         
                                 if(queryGridRds[i].get("operator"))
                                 {
                                     conditions.push(queryGridRds[i].data);                             
                                 }
                             }
                             fitFormValue(conditions);
                             exportExcelDay(conditions); 
         }
    }
     
    /**
     * 填充回传给DWR的字段值默认为Condition.firstvalue
     * @param {} conditionList
     */
    function fitFormValue(conditionList)
     {
      for(var i=0;i<conditionList.length;i++)
      {
       if(conditionList[i].name=="hidden")
       {
        continue;
       }
       for(var j=0;j<queryForm.getForm().items.length;j++)
       { 
        
        if(conditionList[i].columnName == queryForm.getForm().items.item(j).getName())
        {  
         var value =queryForm.getForm().items.item(j).getValue();
         if(conditionList[i].type=="Datetime")
         {
          conditionList[i].firstValue = Ext.util.Format.date(queryForm.getForm().items.item(j).getValue(), 'Y-m-d'); 
         }
         else if(conditionList[i].name=="radio")
         {
           conditionList[i].firstValue =queryForm.getForm().findField(conditionList[i].columnName).getGroupValue();      
         }
         else if(conditionList[i].operator=="DateBetween")
         {
          if(queryForm.getForm().items.item(j).getId().indexOf('from')!=-1)
           {       
           conditionList[i].firstValue = Ext.util.Format.date(queryForm.getForm().items.item(j).getValue(), 'Y-m-d');
           }
          else
          {
           conditionList[i].secondValue = Ext.util.Format.date(queryForm.getForm().items.item(j).getValue(), 'Y-m-d');
          }
         }
         else if((conditionList[i].operator=="Between"))
         {
          if(queryForm.getForm().items.item(j).getId().indexOf('from')!=-1)
          {
           conditionList[i].firstValue = value==null?value:String(value).Trim();
          }
          else
          {
            conditionList[i].secondValue = value==null?value:String(value).Trim();
          }
         }
         else
         {
          conditionList[i].firstValue = value==null?value:String(value).Trim();
         }
        }
       }
      }
     }
     
    /**
     * class gridConfig
     * @param gridParameters
     */
    function GridConfig(gridParameters)
    {
        this.key=new Array();
        this.type=new Array();
        this.header=new Array;
        this.ishref=new Array();
        this.width=new Array();
        if (typeof gridParameters=="object")
        {
            for(var i=0;i<gridParameters.length;i++)
            {         
                this.key[i]=gridParameters[i].name;
                this.type[i]=gridParameters[i].type;
                this.header[i]=gridParameters[i].header;
                this.ishref[i]=gridParameters[i].ishref;
                this.width[i]=gridParameters[i].width;
            }
            if(this.key.length>0)//获取主键
            {
             pk = this.key[0];
             
            }
        }
        else
        {
            Ext.alert("Error,the parameters is error");
        }
    }
    /**
     * define the  Record that be used to receive the data for the grid
     * @param Key
     */
    GridConfig.prototype.getRecord=function() {
        var key=this.key;
        var record = new Array();
        for (var i = 0; i <key.length; i++)
        {
            record[i] = {name:key[i]};
        }
       
        return record;
    }
    function showUrl(value, p, record)
    {  

      var id = (record.data[pk]);
      id = "'" + id + "'";
         //var returnv = '<a href='+viewUrl+'!view?id='+ id + ')">' + value + '</a>';
      var returnv = '<a href="#" οnclick="view(' + id + ')">' + value + '</a>';
       return returnv;
    }

    /**
     * define the column of the grid
     * @param Key
     */
    GridConfig.prototype.getColumn=function(){
        var key=this.key;
        var type=this.type;
        var header=this.header;
        var ishref = this.ishref;
        var width = this.width;
        var iscontent =this.iscontent;
        var j=2;
        var column = new Array();
        column[0] = new Ext.grid.RowNumberer();
        column[1] = sm;
        for (var i = 0; i < key.length; i++)
        {
            if(header[i]=="")
            {
            }
            else
            {
             if(width[i]==undefined)
             {
              width[i] =80;
             }
                if(type[i] == "String")
                {
                 if(ishref[i]=="true")
                 {
                  column[j] = {header:header[i],dataIndex:key[i],rsortable:true,width:width[i],editor:new Ext.form.TextField({}),renderer:showUrl};
                 }
                 else
                 {
                     column[j] = {header:header[i],dataIndex:key[i],sortable:true,width:width[i],editor:new Ext.form.TextField({})};
                 }
              
                }
                if(type[i] == "renderer")//列表字段需要特殊处理的,例如,根据标志(0,1)加图片显示的
                {
     
                  column[j] = {header:header[i],dataIndex:key[i],rsortable:true,width:width[i],renderer:renderer};
               
                }
                if(type[i] == "renderer1")//列表字段需要特殊处理的,例如,根据标志(0,1)加图片显示的--扩展1
                {
     
                  column[j] = {header:header[i],dataIndex:key[i],rsortable:true,width:width[i],renderer:renderer1};
               
                }
                if(type[i] == "renderer2")//列表字段需要特殊处理的,例如,根据标志(0,1)加图片显示的--扩展2
                {
     
                  column[j] = {header:header[i],dataIndex:key[i],rsortable:true,width:width[i],renderer:renderer2};
               
                }
                if(type[i] == "renderer3")//列表字段需要特殊处理的,例如,根据标志(0,1)加图片显示的--扩展3
                {
     
                  column[j] = {header:header[i],dataIndex:key[i],rsortable:true,width:width[i],renderer:renderer3};
               
                }
                if(type[i] == "Datetime")
                {
                 if(ishref[i]=="true")
                 {
                  column[j] = {header:header[i],dataIndex:key[i],sortable:true,width:width[i],renderer:new Ext.util.Format.dateRenderer('Y年m月d日 h:i:s A'),editor:new Ext.form.DateField({format:'Y-m-d h:i:s A'}),renderer:showUrl};
                 }
                 else
                 {
                     column[j] = {header:header[i],dataIndex:key[i],sortable:true,width:width[i],renderer:new Ext.util.Format.dateRenderer('Y年m月d日  h:i:s A'),editor:new Ext.form.DateField({format:'Y-m-d h:i:s A'})};
                 }
                   
                }
             if(type[i] == "Date")
                {
                 if(ishref[i]=="true")
                 {
                  column[j] = {header:header[i],dataIndex:key[i],sortable:true,width:width[i],renderer:new Ext.util.Format.dateRenderer('Y年m月d日'),editor:new Ext.form.DateField({format:'Y-m-d'}),renderer:showUrl};
                 }
                 else
                 {
                     column[j] = {header:header[i],dataIndex:key[i],sortable:true,width:width[i],renderer:new Ext.util.Format.dateRenderer('Y年m月d日'),editor:new Ext.form.DateField({format:'Y-m-d'})};
                 }
                   
                }
                if(type[i] == "Number")
                {
                 if(ishref[i]=="true")
                 {
                  column[j] = {header:header[i],dataIndex:key[i],sortable:true,width:width[i],editor:new Ext.form.NumberField({}),renderer:showUrl};
                 }
                 else
                 {
                     column[j] = {header:header[i],dataIndex:key[i],sortable:true,width:width[i],editor:new Ext.form.NumberField({})};
                 }               
                }
                if(type[i] == "LongString")
                {
                 if(ishref[i]=="true")
                 {
                  column[j] = {header:header[i],dataIndex:key[i],sortable:true,width:width[i],editor:new Ext.form.TextArea({}),renderer:showUrl};
                 }
                 else
                 {
                     column[j] = {header:header[i],dataIndex:key[i],sortable:true,width:width[i],editor:new Ext.form.TextArea({})};
                 }                     
                }
                j++;
            }
        }
       
        return  new Ext.grid.ColumnModel(column);
    }
    /**
     * define the items for the form which used to add a new record
     * @param Key
     */
    GridConfig.prototype.getFormItems=function ()
    {
        var key=this.key;
        var type=this.type;
        var header=this.header;
        var items = new Array();
        var j=0;
        for (var i = 0; i < key.length; i++)
        {
            if(header[i]=="")
            {
            }
            else
            {
                if(type[i] == "String")
                {
                    items[j] = {fieldLabel:header[i],name:key[i]};
                }
                if(type[i] == "Datetime")
                {
                    items[j] = {fieldLabel:header[i],name:key[i],xtype:'datefield',
                        renderer:Ext.util.Format.dateRenderer('Y/m/d'),
                        format:'Y/m/d'};
                }
                if(type[i] == "Number")
                {
                    items[j] = {fieldLabel:header[i],name:key[i],xtype:'numberfield'};
                }
                if(type[i] == "LongString")
                {
                    items[j] = {fieldLabel:header[i],name:key[i],xtype:'textarea'};
                }
                j++;
            }
        }
        return items;
    }
    /**
     * get the data for the form
     * @param Key
     */
    GridConfig.prototype.getAddRecord=function()
    {
        var key=this.key;
        var type=this.type;
        var header=this.header;
        var addRecord = new Object();
        for (var i = 0; i < key.length; i++)
        {
            if( header[i]!="")
            {
                if(type[i] == "Datetime")
                {
                    addRecord[key[i]] =new Date(Ext.get(key[i]).dom.value);
                }
                else
                {
                    addRecord[key[i]] = Ext.get(key[i]).dom.value;
                }
            }
        }
        return addRecord;
    }


    /**
     * class  query
     */
    function QueryConfig(data)
    {
        this.data=data;
        this.stringOp = new Ext.data.SimpleStore({
            fields: ['value','text'],
            data : [["","选择关系运算符"],['=','='],['<>','<>'],
                    ["like '|%'",'以...开头'],["like '%|'",'以...结尾'],["like '%|%'",'包含字符'],["not like '%|%'",'不包含字符'],
                    ['is null','空白'],['is not null','非空白']]
        });
        this.datetimeOp = new Ext.data.SimpleStore({
            fields: ['value','text'],
            data : [["","选择关系运算符"],['=','='],['<>','<>'],['<','<'],['<=','<='],['<','>'],['>=','>='],['is null','空白'],['is not null','非空白'],["between","between"]]
        });
        this.numberOp=this.datetimeOp;

    }

    QueryConfig.prototype.getOpStore=function(type){
        var _store;
        if(type=="String")
        {
            _store=this.stringOp;
        }else if(type=="Number")
        {
            _store=this.numberOp;
        }else if(type="Datetime")
        {
            _store=this.datetimeOp;
        }
        return _store;
    }
    /**
     * get the Editor for each column
     * @param type
     */
    QueryConfig.prototype.getEditor=function(type){
        var editor;
        if(type=="String")
        {
            editor=new Ext.form.TextField({});
        }
        else if(type=="Number")
        {
            editor=new Ext.form.NumberField({});
        }
        else if(type="Datetime")
        {
            editor=new Ext.form.DateField({fomat:"Y-m-d"});
        }
        return editor;
    }
    /**
     * init the query grid
     */
     
    QueryConfig.prototype.getQueryGrid=function(){
        var qeuryConfig=this;
        var stringeditor=new Ext.form.TextField({});
        var store=new Ext.data.SimpleStore({data:qeuryConfig.data,fields:["entity","type","columnName","operator","firstValue","secondValue","andOr","bracket","name"]});
        var colM=new Ext.grid.ColumnModel([
        {header:"字段名称",dataIndex:"name",sortable:true},
        {header:"运算符",dataIndex:"operator",editor:stringeditor},
        {header:"数值1",dataIndex:"firstValue",width:150,editor:stringeditor,renderer:displayValue},
        {header:"数值2",dataIndex:"secondValue",width:150,editor:stringeditor,renderer:displayValue},
        {header:"关系",dataIndex:"andOr",editor: new Ext.form.ComboBox({
            store: [["","请选择括号.."],["and","and"],["or","or"]],
            mode: 'local',
            triggerAction: 'all',
            valueField: 'value',
            displayField: 'text',
            editable: false
        })},
        {header:"括号",dataIndex:"bracket", hidden:true,editor: new Ext.form.ComboBox({
            store:[["","请选择括号.."],["(","("],[")",")"]],
            mode: 'local',
            triggerAction: 'all',
            valueField: 'value',
            displayField: 'text',
            editable: false
        })}
                ]);

        var grid = new Ext.grid.EditorGridPanel({
            id:"querygrid",
            title:"查询",
            autoHeight:true,
            width:700,
            cm:colM,
            clicksToEdit:1,
            store:store,
            selModel: new Ext.grid.RowSelectionModel({singleSelect:false}),
            autoExpandColumn:2
        });
        grid.on("beforeedit",function(e){
            var record=grid.getSelectionModel().getSelected();
            if (e.column==1)
            {
                var _store=qeuryConfig.getOpStore(record.get("type"));
                var Opcombox=new Ext.form.ComboBox({
                    store: _store,
                    mode: 'local',
                    triggerAction: 'all',
                    valueField: 'value',
                    displayField: 'text',
                    editable: false
                });
                grid.colModel.setEditor(e.column,new Ext.grid.GridEditor(Opcombox));
            }
            if (e.column==2)
            {
                var gridEditor2=qeuryConfig.getEditor(record.get("type"));
                if(getParamsNum(record.get("operator"))==0)
                {
                    grid.colModel.setEditor(e.column,new Ext.grid.GridEditor(null));
                }
                if(getParamsNum(record.get("operator"))==1||getParamsNum(record.get("operator"))==2)
                {
                    grid.colModel.setEditor(e.column,new Ext.grid.GridEditor(gridEditor2));
                }
            }
            if (e.column==3)
            {
                var gridEditor3=qeuryConfig.getEditor(record.get("type"));
                if(getParamsNum(record.get("operator"))==0||getParamsNum(record.get("operator"))==1)
                {
                    grid.colModel.setEditor(e.column,new Ext.grid.GridEditor(null));
                }
                if(getParamsNum(record.get("operator"))==2)
                {
                    grid.colModel.setEditor(e.column,new Ext.grid.GridEditor(gridEditor3));
                }
            }
        });

        grid.on("afteredit",function(e){
            var record=grid.getSelectionModel().getSelected();
            if (e.column==1)
            {
                if(getParamsNum(record.get("operator"))==0)
                {
                    record.set("firstValue","");
                    record.set("secondValue","");
                }
                if(getParamsNum(record.get("operator"))==1)
                {
                    record.set("secondValue","");
                }
            }
        });
        return grid;
    };
    /**
     * according the operator's type,we can get the amount of the params that used to query
     * @param operator
     */
    function getParamsNum(operator)
    {
        var ParamsNum;
        if(operator=="is null"||operator=="is not null"||operator=="")
        {
            ParamsNum = 0;
        }
        else if(operator=="between")
        {
            ParamsNum = 2;
        }
        else
        {
            ParamsNum =1 ;
        }
        return ParamsNum;
    }
    /**
     * format the date.
     * @param value
     */
    function displayValue(value)
    {
        var formatValue=value;
        if(formatValue.toString().indexOf("UTC")>=0)
        {
            var dt = new Date(formatValue);
            formatValue=dt.format('Y-m-d');
        }
        return formatValue;
    }

     

     

     

     

     

     


    /**
     * **************************************以下为自定义工具条,带每页显示的记录数下拉框******************************************************
     */

     

    Ext.namespace('Ext.ux.Andrie');  
     
     
     
    /** 
     
     * @class Ext.ux.Andrie.pPageSize 
     
     * @extends Ext.PagingToolbar 
     
     * A combobox control that glues itself to a PagingToolbar's pageSize configuration property. 
     
     * @constructor 
     
     * Create a new PageSize plugin. 
     
     * @param {Object} config Configuration options 
     
     * @author andy
     
     * @version 0.6 
     
     */ 
     
    Ext.ux.Andrie.pPageSize = function(config){  
     
        Ext.apply(this, config);  
     
    };  
     
     
     
    Ext.extend(Ext.ux.Andrie.pPageSize, Ext.util.Observable, {  
     
        /** 
     
         * @cfg {String} beforeText 
     
         * Text to display before the comboBox 
     
         */ 
     
        beforeText: '每页',  
     
          
     
        /** 
     
         * @cfg {String} afterText 
     
         * Text to display after the comboBox 
     
         */ 
     
        afterText: '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;记录',  
     
          
     
        /** 
     
         * @cfg {Mixed} addBefore 
     
         * Toolbar item(s) to add before the PageSizer 
     
         */ 
     
        addBefore: '-',  
     
          
     
        /** 
     
         * @cfg {Mixed} addAfter 
     
         * Toolbar item(s) to be added after the PageSizer 
     
         */ 
     
        addAfter: null,  
     
          
     
        /** 
     
         * @cfg {Bool} dynamic 
     
         * True for dynamic variations, false for static ones 
     
         */ 
     
        dynamic: false,  
     
          
     
        /** 
     
         * @cfg {Array} variations 
     
         * Variations used for determining pageSize options 
     
         */ 
     
        variations: [5, 10, 20, 50],  
     
          
     
        /** 
     
         * @cfg {Object} comboCfg 
     
         * Combo config object that overrides the defaults 
     
         */ 
     
        comboCfg: undefined,  
     
          
     
        init: function(pagingToolbar){  
     
            this.pagingToolbar = pagingToolbar;  
     
            this.pagingToolbar.pageSizeCombo = this;  
     
            this.pagingToolbar.setPageSize = this.setPageSize.createDelegate(this);  
     
            this.pagingToolbar.getPageSize = function(){  
     
                return this.pageSize;  
     
            }  
     
            this.pagingToolbar.on('render', this.onRender, this);  
     
        },  
     
          
     
        //private  
     
        addSize:function(value){  
     
            if (value>0){  
     
                this.sizes.push([value]);  
     
            }  
     
        },  
     
          
     
        //private  
     
        updateStore: function(){  
     
            if (this.dynamic) {  
     
                var middleValue = this.pagingToolbar.pageSize, start;  
     
                middleValue = (middleValue > 0) ? middleValue : 1;  
     
                this.sizes = [];  
     
                var v = this.variations;  
     
                for (var i = 0, len = v.length; i < len; i++) {  
     
                    this.addSize(middleValue - v[v.length - 1 - i]);  
     
                }  
                this.addToStore(middleValue);  
     
                for (var i = 0, len = v.length; i < len; i++) {  
     
                    this.addSize(middleValue + v[i]);  
     
                }  
     
            }else{  
     
                if (!this.staticSizes){  
     
                    this.sizes = [];  
     
                    var v = this.variations;  
     
                    var middleValue = 0;  
     
                    for (var i = 0, len = v.length; i < len; i++) {  
     
                        this.addSize(middleValue + v[i]);  
     
                    }  
     
                    this.staticSizes = this.sizes.slice(0);  
     
                }else{  
     
                    this.sizes = this.staticSizes.slice(0);  
     
                }  
     
            }  
     
            this.combo.store.loadData(this.sizes);  
     
            this.combo.collapse();  
     
            this.combo.setValue(this.pagingToolbar.pageSize);  
     
        },  
     
     
     
        setPageSize:function(value, forced){  
     
            var pt = this.pagingToolbar;  
     
            this.combo.collapse();  
     
            value = parseInt(value) || parseInt(this.combo.getValue());  
     
            value = (value>0)?value:1;  
     
            if (value == pt.pageSize){  
     
                return;  
     
            }/*else if (value < pt.pageSize){  
     
                pt.pageSize = value;  
     
                var ap = Math.round(pt.cursor/value)+1;  
     
                var cursor = (ap-1)*value;  
     
                var store = pt.store;  
     
                if (cursor > store.getTotalCount()) {  
     
                    this.pagingToolbar.pageSize = value;  
     
                    this.pagingToolbar.doLoad(cursor-value);  
     
                }else{  
     
                    store.suspendEvents();  
     
                    for (var i = 0, len = cursor - pt.cursor; i < len; i++) {  
     
                        store.remove(store.getAt(0));  
     
                    }  
     
                    while (store.getCount() > value) {  
     
                        store.remove(store.getAt(store.getCount() - 1));  
     
                    }  
     
                    store.resumeEvents();  
     
                    store.fireEvent('datachanged', store);  
     
                    pt.cursor = cursor;  
     
                    var d = pt.getPageData();  
     
                   // pt.afterTextEl.el.innerHTML = String.format(pt.afterPageText, d.pages);  
     
                    //pt.field.dom.value = ap;  
     
                    pt.first.setDisabled(ap == 1);  
     
                    pt.prev.setDisabled(ap == 1);  
     
                    pt.next.setDisabled(ap == d.pages);  
     
                    pt.last.setDisabled(ap == d.pages);  
     
                    pt.updateInfo();  
     
                }  
     
            }*/else{  
     
                this.pagingToolbar.pageSize = value;  
     
                this.pagingToolbar.doLoad(Math.floor(this.pagingToolbar.cursor/this.pagingToolbar.pageSize) * this.pagingToolbar.pageSize);  
     
            }  
     
            this.updateStore();  
     
        },  
     
          
     
        //private  
     
        onRender: function(){  
     
            this.combo = Ext.ComponentMgr.create(Ext.applyIf(this.comboCfg||{}, {  
     
                store:new Ext.data.SimpleStore({  
     
                    fields:['pageSize'],  
     
                    data:[]  
     
                }),  
     
                displayField:'pageSize',  
     
                valueField:'pageSize',  
     
                mode:'local',  
     
                triggerAction:'all',  
     
                width:50,  
     
                xtype:'combo' 
     
            }));  
     
            this.combo.on('select', this.setPageSize, this);  
     
            this.updateStore();  
     
              
     
            if (this.addBefore){  
     
                this.pagingToolbar.add(this.addBefore);  
     
            }  
     
            if (this.beforeText){  
     
                this.pagingToolbar.add(this.beforeText);  
     
            }  
     
            this.pagingToolbar.add(this.combo);  
     
            if (this.afterText){  
     
                this.pagingToolbar.add(this.afterText);  
     
            }  
     
            if (this.addAfter){  
     
                this.pagingToolbar.add(this.addAfter);  
     
            }  
     
        }  
     
    })

    ---------------

    jsp

    <%@ include file="/common/taglibs.jsp"%>
    <%@ page language="java" contentType="text/html; charset=utf-8"%>
    <title></title>
    <html>
     <script type="text/javascript">
     function user()
     {
      var paraArray=new Array(window,"hidden1","hidden2");
      window.showModalDialog("${ctx}/hr/users!codehelp",paraArray,"dialogWidth:650px;dialogHeight:500px;scroll:no;help:no;status:no;");
     }
     function sendpubnote(da)
     {
      window.showModalDialog("${ctx}/sms/message-reissue?sj="+da,"","dialogWidth:"+wMaster+50+"px;dialogHeight:300px;dialogLeft:"+left+"px; dialogTop:"+top+"px;scrollbars=no;status:no;help=0");   
     }

    </script>
     <script type="text/javascript" src="${ctx}/js/ext/DwrProxyCombobox.js"></script>
     <script type="text/javascript"
      src="${ctx}/dwr/interface/MemberInfosManager.js"></script>
     <script type="text/javascript"
      src="${ctx}/dwr/interface/MemberSourceManager.js"></script>
     <script type="text/javascript"
      src="${ctx}/dwr/interface/MemberLevelManager.js"></script>
     <script type="text/javascript"
      src="${ctx}/dwr/interface/InsureManager.js"></script>
     <script type="text/javascript"
      src="${ctx}/js/usercenter/member/member.js"></script>
     <script type="text/javascript">
        var wMaster = screen.width;
     var hMaster = screen.height;
        var wSlave_modal = screen.width/1.2;
     var hSlave_modal = screen.height/1.2;
     var left=(window.screen.width-wSlave_modal)/2;
     var top=(window.screen.height-hSlave_modal)/2;
           function addRecord(store)
             {
        window.showModalDialog("${ctx}/member/memberinfos!input?rnd="+Math.round(Math.random()*10000),window,"dialogWidth:"+wSlave_modal+"px;dialogHeight:"+hSlave_modal+"px;dialogLeft:"+left+"px; dialogTop:"+top+"px;scrollbars=yes;status:no;help=0;");   
           }
           function updateRecord(stroe,id,record)
           {
             
          var state = record.get('zt');  
          if(state==3){
           Ext.Msg.alert('系统提示','您选择的记录是已删除状态,不能修改');
                        return;
          }     
             window.showModalDialog("${ctx}/member/memberinfos!input?hyid="+id+"&rnd="+Math.round(Math.random()*10000),window,"dialogWidth:"+wSlave_modal+"px;dialogHeight:"+hSlave_modal+"px;dialogLeft:"+left+"px; dialogTop:"+top+"px;scrollbars=yes;status:no;help=0");
             //window.open("${ctx}/member/memberinfos!input?hyid="+id+"&rnd="+Math.round(Math.random()*10000));
           }
        function view(id)
        {
             //window.showModalDialog("${ctx}/member/memberinfos!view?hyid="+id+"&rnd="+Math.round(Math.random()*10000),window,"dialogWidth:"+wSlave_modal+"px;dialogHeight:"+hSlave_modal+"px;dialogLeft:"+left+"px; dialogTop:"+top+"px;scrollbars=yes;status:no;help=0");
          //window.open("${ctx}/member/memberinfos!view?hyid="+id+"&rnd="+Math.round(Math.random()*10000));
            parent.funtab.add({  
                      title:'查看会员资料详情&nbsp;&nbsp;&nbsp;&nbsp;' ,                       
                      iconCls: 'tabs',                    
                      margins:'0 4 4 0',  
                      autoHeight:true,  
                      autoScroll:true,  
                      autoWidth:true,  
                      closable:true,  
                      frame:true,  
                      html:'<iframe id="iframe_memberInfos" src="'+"${ctx}/member/memberinfos!view?hyid="+id+'" width="'+wSlave_modal+'" height="'+hSlave_modal+'" frameborder="0" scrolling="auto"></iframe>'
                }).show();
          
        } 
        function guestFunction (stroe,id)
        {      
          //var win=window.open("${ctx}/member/memberguestinfos?hyid="+id+"&functionLevel=130312&modelName=%E5%B8%B8%E6%97%85%E5%AE%A2%E7%AE%A1%E7%90%86&rnd="+Math.round(Math.random()*10000),"","fullscreen=1")
            parent.funtab.add({  
                      title:'常旅客维护&nbsp;&nbsp;&nbsp;&nbsp;',                       
                      iconCls : 'tabs',
          margins : '0 4 4 0',
          autoScroll : true,
             autoWidth : true,
          closable : true,
          frame : true,
                      html:'<iframe src="'+"${ctx}/member/memberguestinfos?hyid="+id+"&functionLevel=130312"+'" width="100%" height="100%" frameborder="0" scrolling="auto"></iframe>'
                }).show();
        }
        function historyCentFunction(stroe,id)
        {
          //window.showModalDialog("${ctx}/memberhistorycent/memberhistorycent?hyid="+id+"&orderType=1&functionLevel=130401&rnd="+Math.round(Math.random()*10000),"","dialogWidth:"+wMaster+"px;dialogHeight:"+hMaster+"px;dialogLeft:"+left+"px; dialogTop:"+top+"px;scrollbars=yes;status:no;help=0");
          //document.location="${ctx}/memberhistorycent/memberhistorycent?hyid=" + id + "&orderType=1&functionLevel=130401&modelName=%E6%9C%BA%E7%A5%A8%E6%98%8E%E7%BB%86%E7%AE%A1%E7%90%86";
          parent.funtab.add({  
                      title:'机票消费明细&nbsp;&nbsp;&nbsp;&nbsp;' ,                       
                      iconCls: 'tabs',                    
                      margins:'0 4 4 0',  
                      autoScroll:true,  
                      autoWidth:true,  
                      closable:true,  
                      frame:true,  
                      html:'<iframe src="'+"${ctx}/memberhistorycent/memberhistorycent?keyValue=" + id + "&memberKey=" + id + "&orderType=1&functionLevel=130401"+'" width="100%" height="100%" frameborder="0" scrolling="auto"></iframe>'
                }).show();
        }
        function integralManage(stroe,id)
        {
          window.showModalDialog("${ctx}/member/memberinfos!marketinput?hyid="+id+"&rnd="+Math.round(Math.random()*10000),"","dialogWidth:"+950+"px;dialogHeight:"+435+"px;dialogLeft:"+left+"px; dialogTop:"+top+"px;scrollbars=yes;status:no;help=0");
        }
       
         //导出到Excel   
         function exportExcel(conditions)
         {  
        MemberInfosManager.getHql(conditions,"from MemberInfos ",function(msg)
        {
           var headerStr = "hyid,会员ID,String;hyzcm,注册名,String;xm,会员姓名,String;dept.deptname,部门,String;"+
               "sj,手机,String;sj1,手机,String;hykhm,会员卡号,String;jtdh,联系电话,String;"+
               "kyjf,可用积分,String;ljjf,累计积分,String;zjhm,证件号码,String;zjhmPassport,护照,String;"+
               "zjhmHk,港澳通行证,String;zjhmOther,其它证件,String;"+
               "cjry,创建人,String;cjryName,创建人姓名,String;cjrq,注册时间,Date;"+
               "lxdz,联系地址,String;sfgm,是否购买保险,String;buyinsureName,购买保险类型,String;"+
               "sfzs,是否赠送保险,String;sendinsureName,赠送保险类型,String;post,岗位,String;bz,备注,String;";
           //Escape.unescape("utf-8");        
            window.open(encodeURI("${ctx}/member/memberinfos!exportExcel?hql="+msg+"&headerStr="+headerStr));   
           //  window.open("${ctx}/member/memberinfos!exportExcel?hql="+msg+"&headerStr="+headerStr);   
                   });
        }
               //导入
               function importRecord(store)
               {
                   window.showModalDialog("${ctx}/member/memberinfos!importExcel"+"?rnd="+Math.round(Math.random()*10000),"","dialogWidth:"+650+"px;dialogHeight:"+600+"px;dialogLeft:"+left+"px; dialogTop:"+top+"px;scrollbars=yes;status:no;help=0");
               }
                 function importUpdate(store)
               {
                   window.showModalDialog("${ctx}/member/memberinfos!updateExcel"+"?rnd="+Math.round(Math.random()*10000),"","dialogWidth:"+750+"px;dialogHeight:"+600+"px;dialogLeft:"+left+"px; dialogTop:"+top+"px;scrollbars=yes;status:no;help=0");
               }
              
               function changeRecord(store,id)
               {              
                 window.showModalDialog("${ctx}/system/log/syslog?sids="+id+"&tablename=member_infos&functionLevel=900115&modelName=%E8%A1%A8%E5%BC%82%E5%8A%A8%E7%9B%91%E6%8E%A7"+"&rnd="+Math.round(Math.random()*10000),"","dialogWidth:"+800+"px;dialogHeight:"+800+"px;dialogLeft:"+left+"px; dialogTop:"+top+"px;scrollbars=yes;status:no;help=0");
               }
              
    function newWindowsView(hyid)
    {
     window.open("${ctx}/member/memberinfos!view?hyid="+hyid+"&rnd="+Math.round(Math.random()*10000));
    }
        </script>


    </html>

     


     

    展开全文
  • EHcache模拟对象增删改查时缓存

    千次阅读 2015-06-09 13:09:00
    这里简答介绍EHcache的用法,以及写个小例子,模拟对象增删改查时,对象的缓存过程,对ehcache有过初步的了解。 ehcache元素属性: name:缓存名称 maxElementsInMemory:内存中最大缓存对象数 maxElementsOnDisk...
        EHcache二级缓存,谁用过Hibernate二级缓存的同学,对于二级缓存这东东都知道一二,是干嘛用的,在这不多说。这里简答介绍EHcache的用法,以及写个小例子,模拟对象增删改查时,对象的缓存过程,对ehcache有过初步的了解。
      ehcache元素属性:
    

    name:缓存名称
    maxElementsInMemory:内存中最大缓存对象数
    maxElementsOnDisk:硬盘中最大缓存对象数,若是0表示无穷大
    eternal:true表示对象永不过期,此时会忽略timeToIdleSeconds和timeToLiveSeconds属性,默认为false
    overflowToDisk:true表示当内存缓存的对象数目达到了maxElementsInMemory界限后,会把溢出的对象写到硬盘缓存中。注意:如果缓存的对象要写入到硬盘中的话,则该对象必须实现了Serializable接口才行。
    diskSpoolBufferSizeMB:磁盘缓存区大小,默认为30MB。每个Cache都应该有自己的一个缓存区
    diskPersistent:是否缓存虚拟机重启期数据
    diskExpiryThreadIntervalSeconds:磁盘失效线程运行时间间隔,默认为120秒
    timeToIdleSeconds: 设定允许对象处于空闲状态的最长时间,以秒为单位。当对象自从最近一次被访问后,如果处于空闲状态的时间超过了timeToIdleSeconds属性值,这个对象就会过期,EHCache将把它从缓存中清空。只有当eternal属性为false,该属性才有效。如果该属性值为0,则表示对象可以无限期地处于空闲状态
    timeToLiveSeconds:设定对象允许存在于缓存中的最长时间,以秒为单位。当对象自从被存放到缓存中后,如果处于缓存中的时间超过了 timeToLiveSeconds属性值,这个对象就会过期,EHCache将把它从缓存中清除。只有当eternal属性为false,该属性才有效。如果该属性值为0,则表示对象可以无限期地存在于缓存中。timeToLiveSeconds必须大于timeToIdleSeconds属性,才有意义
    memoryStoreEvictionPolicy:当达到maxElementsInMemory限制时,Ehcache将会根据指定的策略去清理内存。可选策略有:LRU(最近最少使用,默认策略)、FIFO(先进先出)、LFU(最少访问次数)

    ehcache配置常用的一些元素介绍完了,下面来个完整的简单例子看看。
    项目结构图:

    bean下的Studnet.java,School.java模拟领域对象,允许二级缓存缓存它们;如果配置中允许缓存数超过最大缓存数时,将对象写入磁盘的话,则领域对象需要实现序列化。
    dao模拟操作数据库,增删改查。
    database模拟数据库中的数据
    util工具对象,EHcacheUtil二级缓存工具,ehcache.xml配置文件.

    下面贴源码:
    ehcache.xml

    <?xml version="1.0" encoding="UTF-8"?>
    
    <ehcache>
    <!-- 指定一个文件目录,当EHCache把数据写到硬盘上时,将把数据写到这个文件目录下 -->  
    <diskStore path="java.io.tmpdir" /> 
     <!-- 必须要有defaultCache -->
      <defaultCache
          maxElementsInMemory="10000"
          eternal="false"
          timeToIdleSeconds="120"
          timeToLiveSeconds="120"
          diskSpoolBufferSizeMB="30"
          maxElementsOnDisk="10000000"
          overflowToDisk="false"
          diskExpiryThreadIntervalSeconds="120"> 
    
      </defaultCache>
    
      <cache name="student"
             maxElementsInMemory="100"
             maxElementsOnDisk="1000"
             eternal="false"
             timeToIdleSeconds="5"
             timeToLiveSeconds="5"
             overflowToDisk="false"
             memoryStoreEvictionPolicy="LFU">
      </cache>
    
      <cache name="school"
             maxElementsInMemory="100"
             maxElementsOnDisk="500"
             eternal="false"
             timeToIdleSeconds="240"
             timeToLiveSeconds="240"
             overflowToDisk="false"
             memoryStoreEvictionPolicy="LFU">
      </cache>
    
    </ehcache>
    
    Student.java
    package com.fei.bean;
    
    public class Student {
    
        private String code ;
        private String name;
    
        public Student() {
        }
    
        public Student(String code, String name) {
            super();
            this.code = code;
            this.name = name;
        }
    
        public String getCode() {
            return code;
        }
    
        public void setCode(String code) {
            this.code = code;
        }
    
        public String getName() {
            return name;
        }
    
        public void setName(String name) {
            this.name = name;
        }
    
        public Student clone(){
            return new Student(this.code,this.name);
        }
    }
    
    School.java
    
    package com.fei.bean;
    //如果需要将对象缓存到磁盘,则对象需要序列化
    public class School {
    
        private String code;
        private String name;
    
        public School() {
    
        }
    
        public School(String code, String name) {
            super();
            this.code = code;
            this.name = name;
        }
    
        public String getCode() {
            return code;
        }
    
        public void setCode(String code) {
            this.code = code;
        }
    
        public String getName() {
            return name;
        }
    
        public void setName(String name) {
            this.name = name;
        }
    
        public School clone(){
            return new School(this.code,this.name);
        }
    }
    
    
    StudentDao.java
    package com.fei.dao;
    
    import com.fei.bean.Student;
    import com.fei.database.StudentDB;
    import com.fei.util.EHcacheUtil;
    
    public class StudentDao {
    
        private static final String CACHE_NAME = "student";
        /**
         * 先从缓存获取,缓存没有,再从数据库中拿
         */
        public Student get(String code){
            Student s = null;
            s =(Student) EHcacheUtil.getInstance().get(CACHE_NAME,code);
            if(s == null ) {
                System.out.println("缓存中找不到"+code+"的学生");
            }else{
                System.out.println("缓存中找到了"+code+"的学生");
                return s;
            }
            s = StudentDB.get(code);
            //放入缓存
            EHcacheUtil.getInstance().put(CACHE_NAME, code, s);
            return s;
        }
        /**
         * 更新时,删除缓存(或者也更新缓存)
         */
        public void update(Student s){
            EHcacheUtil.getInstance().remove(CACHE_NAME, s.getCode());
            StudentDB.update(s);
        }
        /**
         * 删除,删除缓存,删除数据库
         */
        public void delete(Student s){
            EHcacheUtil.getInstance().remove(CACHE_NAME, s.getCode());
            StudentDB.delete(s);
        }
        /**
         * 增加,添加到缓存,添加到数据库
         */
        public void add(Student s){
            EHcacheUtil.getInstance().remove(CACHE_NAME, s.getCode());
            StudentDB.insert(s);
        }
    
    }
    SchoolDB.java
    package com.fei.database;
    
    import java.util.HashMap;
    import java.util.Map;
    
    import com.fei.bean.School;
    /**
     * 模拟数据库的增删改查
     *
     */
    public class SchoolDB {
    
        public static Map<String,School> schools = new HashMap<String , School>();
        static{
            schools.put("s001",new School("s001","魏国"));
            schools.put("s002",new School("s002","吴国"));
            schools.put("s003",new School("s003","蜀国"));
        }
    
        public static School get(String code){
            School s = schools.get(code);
            return s != null ? s.clone() : null;
        }
    
        public static void insert(School s){
            schools.put(s.getCode(), s);
        }
        public static void update(School s){
            School tempS = schools.get(s.getCode());
            tempS.setName(s.getName());
        }
        public static void delete(School s){
            schools.remove(s.getCode());
        }
    }
    
    StudentDB.java
    package com.fei.database;
    
    import java.util.HashMap;
    import java.util.Map;
    
    import com.fei.bean.Student;
    /**
     * 模拟数据库的增删改查
     *
     */
    public class StudentDB {
    
        public static Map<String,Student> students = new HashMap<String,Student>();
        static{
            students.put("0001",new Student("0001","貂蝉"));
            students.put("0002",new Student("0002","赵飞燕"));
            students.put("0003",new Student("0003","小乔"));
        }
    
        public static Student get(String code){
            Student s = students.get(code);
            return s != null ? s.clone() : null;
        }
        public static void insert(Student s){
            students.put(s.getCode(), s);
        }
        public static void update(Student s){
            Student tempS = students.get(s.getCode());
            tempS.setName(s.getName());
        }
        public static void delete(Student s){
            students.remove(s.getCode());
        }
    }
    
    EHcacheUtil.java
    package com.fei.util;
    
    import net.sf.ehcache.Cache;
    import net.sf.ehcache.CacheManager;
    import net.sf.ehcache.Element;
    /**
     *cacheManager:缓存管理器,以前是只允许单例的,不过现在也可以多实例了
     *cache:缓存管理器内可以放置若干cache,存放数据的实质,所有cache都实现了Ehcache接口
     *element:单条缓存数据的组成单位
     * @author Administrator
     *
     */
    public class EHcacheUtil {
    
        private static final String path = "ehcache.xml";
    
        private static EHcacheUtil ehcacheUtil;
    
        private CacheManager manager; 
    
        private EHcacheUtil(){
            manager = CacheManager.create(EHcacheUtil.class.getResourceAsStream(path));
        }
    
        public synchronized static EHcacheUtil getInstance(){
            if(ehcacheUtil == null){
                return new EHcacheUtil();
            }
            return ehcacheUtil;
        }
    
        public void put(String cacheName, String key, Object value) {  
            Cache cache = getCache(cacheName);  
            Element element = new Element(key, value);  
            cache.put(element);  
        }  
    
        public Object get(String cacheName, String key) {  
            Cache cache = manager.getCache(cacheName);  
            Element element = cache.get(key);  
            return element == null ? null : element.getObjectValue();  
        }  
    
        public void remove(String cacheName, String key) {  
            Cache cache = manager.getCache(cacheName);  
            cache.remove(key);  
        }  
    
        public Cache getCache(String cacheName){
            Cache cache = manager.getCache(cacheName);
            if(cache == null){
                throw new RuntimeException("根据cacheName="+cacheName+"无法获取到对于的cache!请检查配置文件"+path);
            }
            return cache;
        }
    }
    
    EHcacheTest.java
    package com.fei;
    
    import net.sf.ehcache.Cache;
    
    import com.fei.bean.School;
    import com.fei.bean.Student;
    import com.fei.dao.SchoolDao;
    import com.fei.dao.StudentDao;
    import com.fei.database.StudentDB;
    import com.fei.util.EHcacheUtil;
    
    public class EHcacheTest {
    
        private static StudentDao studentDao = new StudentDao();
        private static SchoolDao schoolDao = new SchoolDao();
    
        public static void main(String[] args) {
    //      test01();
    //      test02();
    //      test03();
    //      test04();
        }
        /**
         * 测试1
         * 2次查询同一个对象    
         *     期待:第一次缓存中不存在,第二次缓存中存在
         */
        private static void test01(){
            studentDao.get("0001");
            studentDao.get("0001");
        }
        /**
         * 查询2次,更新对象,再查询2次,
         *    期待:第一次缓存中不存在,第二次缓存中存在,第三次缓存中不存在,第四次缓存中存在
         */
        private static void test02(){
            schoolDao.get("s001");
            School s = schoolDao.get("s001");
            s.setName(s.getName()+"aaa");
            schoolDao.update(s);
            schoolDao.get("s001");
            s = schoolDao.get("s001");
            System.out.println("学校名称:"+s.getName());
        }
        /**
         * 测试3
         * 4次查询学生,第二次查询后线程休息10秒   
         * 期待:第一次缓存中不存在,第二次缓存中存在,第三次缓存中不存在,第四次缓存中存在
         * 
         */
        private static void test03(){
            studentDao.get("0001");
            studentDao.get("0001");
            try {
                Thread.currentThread().sleep(10000);
            } catch (Exception e) {
                e.printStackTrace();
            }
            studentDao.get("0001");
            studentDao.get("0001");
        }
        /**
         * 测试4
         * 4次查询学生
         * 期待:第一次缓存中不存在,第二次缓存中存在,第三次缓存中存在,第四次缓存中存在
         */
        private static void test04(){
            studentDao.get("0001");
            studentDao.get("0001");
            studentDao.get("0001");
            studentDao.get("0001");
        }
    }

    运行test01()的结果:
    缓存中找不到0001的学生
    缓存中找到了0001的学生

    运行test02()的结果
    缓存中找不到s001的学校
    缓存中找到了s001的学校
    缓存中找不到s001的学校
    缓存中找到了s001的学校
    学校名称:魏国aaa

    运行test03()的结果:
    缓存中找不到0001的学生
    缓存中找到了0001的学生
    缓存中找不到0001的学生
    缓存中找到了0001的学生

    运行test04()的结果:
    缓存中找不到0001的学生
    缓存中找到了0001的学生
    缓存中找到了0001的学生
    缓存中找到了0001的学生

    展开全文
  • 常用的增删改查命名规约 1、阿里命名规范 Service/Dao层命名规约 1) 获取单个对象的方法用 get 做前缀。 2) 获取多个对象的方法用 list 做前缀。 3) 获取统计值的方法用 count 做前缀。 4) 插入的方法用 save...

    目录

    常用的增删改查命名规约

    1、阿里命名规范

    Service/Dao 层命名规约

    领域模型命名规约

    2、自己常用规范


    常用的增删改查命名规约

    1、阿里命名规范

    Service/Dao 层命名规约

    1) 获取单个对象的方法用 get 做前缀。
    2) 获取多个对象的方法用 list 做前缀。
    3) 获取统计值的方法用 count 做前缀。
    4) 插入的方法用 save(推荐)或 insert 做前缀。
    5) 删除的方法用 remove(推荐)或 delete 做前缀。
    6) 修改的方法用 update 做前缀。

    领域模型命名规约

    1) 数据对象:xxxDO,xxx 即为数据表名。
    2) 数据传输对象:xxxDTO,xxx 为业务领域相关的名称。
    3) 展示对象:xxxVO,xxx 一般为网页名称。
    4) POJO 是 DO/DTO/BO/VO 的统称,禁止命名成 xxxPOJO。

    2、自己常用规范

    Service 接口命名

    • create
    • delete
    • update
    • query
    • findById
    • findByXXX
    • findXXXList

    Dao 接口命名

    • insert
    • delete
    • update
    • select
    • batchInsert
    • selectOne
    • selectById
    • batchUpdate
    • deleteById
    展开全文
  • document.title "小潘同学的博客_DaulFrank_CSDN博客-Java,Mysql,JavaWeb领域博主" document.title="小蓝" "小蓝
  • 前提 class Person { String name Integer age ... 通过map传参创建领域对象,实现保存 def p = new Person(name: "Fred", age: 40, lastVisit: new Date()) p.save() 读取 grails自动的会给领域

    前提

    class Person {
        String name
        Integer age
        Date lastVisit
    }


    创建

      通过map传参创建领域类对象,实现保存

    def p = new Person(name: "Fred", age: 40, lastVisit: new Date())
    p.save()

    读取

    grails自动的会给领域类增加id属性,通过id可以从数据库获取领域类对象。

    def p = Person.get(1)
    assert 1 == p.id
    通过get()方法可以从数据库获取id为1的Person对象,也可以使用read()方法通过只读状态加载该对象。

    def p = Person.read(1)
    另外,也可以通过load()方法加载对象。

    def p = Person.load(1)

    load()方法没有获取到相应id,则抛出异常。


    更新

    更新实例对象,修改其属性,调用sava()方法

    def p = Person.get(1)
    p.name = "Bob"
    p.save()

    删除

    删除一个实例,调用delete()方法

    def p = Person.get(1)
    p.delete()


     
    

    展开全文
  • Django连接数据库增删改查操作

    千次阅读 2019-07-11 22:26:04
    settings.py文件第58行为如下 将最后一行注释,并添加STATICFILES_DIRS=(os.path.join(BASE_DIR, ‘static’),) 特别注意,元组内只有元素,必须要加逗号 3、app下models.py文件写数据库模型 from django.db ...
  • Vue 30分钟搞定前端增删改查

    万次阅读 多人点赞 2018-02-11 16:45:41
    JS组件系列——又一款MVVM组件:Vue(一:30分钟搞定前端增删改查)阅读目录一、MVVM大比拼二、Vue常用网址三、Vue基础入门1、MVVM图例2、第一个Vue实例3、双向绑定四、常用指令1、v-text、v-html指令2、v-model指令...
  • Spring 基于ORacle JPA的增删改查

    千次阅读 2018-04-12 17:45:59
    * 上面继承了泛型接口 需要两个参数 一个仓库的领域对象类型 一个是ID的属性 */ //通过id所有的 List<Book> findAllById(int id); //找到某对象的id Book findDataById(int id); } 6 、在 ...
  • ActiveRecord模式进行增删改查 1、ActiveRecord 模式介绍 ActiveRecord(活动记录),是一种领域模型模式,特点是一个模型类对应关系型数据库中的一个表,而模型类的一个实例对应表中的一行记录。 ActiveRecord ...
  • 这里简答介绍EHcache的用法,以及写个小例子,模拟对象增删改查时,对象的缓存过程,对ehcache有过初步的了解。   ehcache元素属性: name:缓存名称 maxElementsInMemory:内存中最大缓存对象数  ...
  • 软件方法(下)分析和设计第8章连载[20210816更新]分析 之 分析类图——知识篇小马乖乖 2021-8-13 11:03书上说不要增删改查用例,我总觉得既然系统保存数据,肯定会有对数据增删改查的用例,为什么不列出来呢?...
  • 使用Hibernate框架完成对客户的增删改查的操作
  • 来源:飞鸽传书帮助我们实现增删改查(CRUD)即可 数据访问层:飞鸽传书很多人对数据访问层的职责的理解相对狭隘,认为我们的数据访问层只要飞鸽传书帮助我们实现增删改查(CRUD)即可,其实数据访问层远非我们想象...
  • PDMS实现与MSSQL关系型数据库的增删改查
  • Java语言实现顺序表的增删改查

    千次阅读 2018-06-02 16:19:22
    线性表的用途广泛,应用于信息检索、存储管理、模拟技术和通信领域。软件工程的初学者可能会忽视数据结构这门课程,而把更多的精力集中在高级语言的课程上,其实这是一个很严重的误解。本篇是我个人对于线性表的初步...
  • lucene索引的增删改查/lucene索引维护

    千次阅读 2017-10-07 23:54:43
    [1] \r\n未来,爱奇艺将在多元化的内容储备、个性化的产品体验、定制化营销服务领域继续发力,引领视频体验革命。不断提升连接人与服务的能力,更好的改变人们的生活。[' ); 导入jar包,其中数据库的驱动我导入...
  • 这个系统仅给刚开始学习ASP.NET MVC的新手参考的。 了解怎么使用Model,控制器,数据库实体和MVC2和MVC3在写法上的区别,转变使用控件的观念。 系统虽小,但基体架构...控制反转,模块区域化,工厂模式,领域对象等。
  • 作为后端开发,永远重复着「增删改查」,这些基础的操作占据了自己大部分工作时间,看到其他人成为技术大牛,而个人技术水平永远停在原地,也会很迷茫......需要学习的仅仅如此吗?当你工作久了...
  • python中sqlite3对数据库的增删改查

    万次阅读 多人点赞 2017-07-24 17:08:42
    Python自带一个轻量级的关系型数据库SQLite。这一数据库使用SQL语言。SQLite作为后端数据库,可以搭配Python...SQLite还在其它领域有广泛的应用,比如HTML5和移动端。Python标准库中的sqlite3提供该数据库的接口。
  • ——创建文件 ——修改文件 ——查询文件 ——删除文件 结尾 前言 目前,Golang 可以认为是服务器开发语言发展的趋势之一,特别是在流媒体服务器开发中,已经占有一席之地。很多音视频技术服务提供商也大多...
  • 通常,在同一个页面上实现增删改查,会通过弹出框实现异步的添加和修改,这很好。但有些时候,是不希望在页面上弹出框的,我们可能会想到Knockoutjs,它能以MVVM模式实现同一个页面上的增删改查,再辅以knockout....
  • MongoDB从立地到成佛(介绍、安装、增删改查)

    千次阅读 多人点赞 2020-09-21 21:30:55
    目录 课程导学 第一关 MongoDB介绍 1.1 非关系型数据库 1.2 MongoDB的特点 1.3 MongoDB的应用场景 第二关 MongoDB安装和表结构 2.1 MongoDB的安装 2.2 MongoDB的表结构 第三关 MongoDB的增删改查 3.1 MongoDB插入 ...
  • 如果直接就是 findBy… 返回的就是定义Respository时指定的领域对象集合 这里一个新方法,是为了通过type来查询 也不需要写入sql映射,用来做对比。假如要所有的列表信息,直接在service中实现就行,dao层都不用写...
  • Android储存---SQLite数据库的简单使用,实现增删改查

    千次阅读 热门讨论 2016-09-15 12:36:53
    它是D.RichardHipp建立的公有领域项目。它的设计目标是嵌入式的,而且目前已经在很多嵌入式产品中使用了它,它占用资源非常的低,在嵌入式设备中,可能只需要几百K的内存就够了。它能够支持Wi...
  • 接下来,我们需要在controller类中的queryItems方法绑定ItemsQueryVo对象(即包装类型pojo对象) 原来的queryItems方法 @RequestMapping("/queryItems") public ModelAndView queryItems() throws Exception{ List...
  • 一、DAO模式简介 ...DAO模式实际上是两个模式的组合,即Data Accessor (数据访问者)模式和 Active Domain Object(领域对象)模式。Data Accessor 模式实现了数据访问和业务逻辑的分离;Active Domain O
  • 经过交流,了解到他大学学的是计算机系,毕业之后进入外包公司,目前已工作两年了,工作内容主要是增删改查,每天有做不完的项目,经常需要加班,就这样日复一日地重复地造着轮子。 最近得到了一个互联网公司的面试...
  • 阅读目录 ...1、v-text、v-html指令2、v-model指令3、v-if、v-else指令4、v-show指令5、v-for指令6、v-once指令7、v-bind指令8、v-on指令9、实例一:30分钟搞定增删改查10、实例二:带分页的表格 五、总结
  •  (1) 在我们.NET领域,会有很多人认为EF的效率不是很高,那是为什么呢?因为我们看到最后EF还是生成SQL语句来执行的,所以EF本身性能损失也就是对实体集合的修改,然后根据edmx的定义最终生成SQL语句这段时间浪费了...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 16,366
精华内容 6,546
关键字:

增删改查领域对象