Search in sources :

Example 1 with Dao

use of org.axe.annotation.persistence.Dao in project Axe by DongyuCai.

the class HomeController method home.

@Request(value = "", method = RequestMethod.GET)
public void home(@RequestParam("token") String token, HttpServletRequest request, HttpServletResponse response) {
    String contextPath = request.getContextPath();
    StringBuilder html = new StringBuilder();
    html.append("<!DOCTYPE html>");
    html.append("<html>");
    html.append("<head>");
    html.append("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />");
    html.append("<title>axe homepage</title>");
    html.append("<script type=\"text/javascript\">");
    html.append("var refreshInt = setInterval(\"refresh()\",1000*60);");
    html.append("function refresh(){");
    html.append("window.location = \"" + contextPath + "/axe?token=" + token + "\";");
    html.append("}");
    html.append("</script>");
    html.append("</head>");
    html.append("<body>");
    html.append("<table width=\"100%\">");
    html.append("<tr><td align=\"right\">");
    if (ConfigHelper.getAxeSignIn()) {
        html.append("<a style=\"font-size: 15px;color: #AE0000\" href=\"" + contextPath + "/axe/sign-out?token=" + token + "\"><b>退出</b></a>");
    }
    html.append("&nbsp;<a style=\"font-size: 15px;color: #AE0000\" href=\"" + contextPath + "/axe?token=" + token + "\"><b>首页</b></a>");
    html.append("</td></tr>");
    html.append("<tr><td align=\"center\"><font size=\"28\">欢迎使用 Axe!</font></td></tr>");
    html.append("");
    html.append("<!--系统运行 概览-->");
    html.append("<tr><td><table cellspacing=\"0px\"><tr><td style=\"background-color: #AE0000\">");
    html.append("&nbsp;<font color=\"white\"><b>系统运行-概览</b></font>&nbsp;");
    html.append("</td></tr></table></td></tr>");
    html.append("");
    html.append("<tr><td height=\"2px\" style=\"background-color:#AE0000\"></td></tr>");
    html.append("<tr><td>");
    html.append("<table width=\"100%\">");
    html.append("<tr style=\"background-color: #F0F0F0;\">");
    html.append("<td align=\"left\">&nbsp;</td>");
    html.append("<td align=\"left\"><b>启动时间</b></td>");
    html.append("<td align=\"left\"><b>运行时长</b></td>");
    html.append("</tr>");
    html.append("<tr>");
    html.append("<td align=\"left\">&nbsp;</td>");
    Date startupTime = FrameworkStatusHelper.getStartupTime();
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    html.append("<td align=\"left\">" + sdf.format(startupTime) + "</td>");
    long runTimeSec = (System.currentTimeMillis() - startupTime.getTime()) / 1000;
    String runTime = "";
    if (runTimeSec < 60) {
        runTime = runTimeSec + "秒";
    } else {
        long runTimeMin = runTimeSec / 60;
        if (runTimeMin < 60) {
            runTimeSec = runTimeSec - (runTimeMin * 60);
            runTime = runTimeMin + "分" + runTimeSec + "秒";
        } else {
            long runTimeHour = runTimeMin / 60;
            if (runTimeHour < 24) {
                runTimeMin = runTimeMin - runTimeHour * 60;
                runTimeSec = runTimeSec - ((runTimeHour * 60) + runTimeMin) * 60;
                runTime = runTimeHour + "时" + runTimeMin + "分" + runTimeSec + "秒";
            } else {
                long runTimeDay = runTimeHour / 24;
                runTimeHour = runTimeHour - (runTimeDay * 24);
                runTimeMin = runTimeMin - ((runTimeDay * 24) + runTimeHour) * 60;
                runTimeSec = runTimeSec - ((((runTimeDay * 24) + runTimeHour) * 60) + runTimeMin) * 60;
                runTime = runTimeDay + "天" + runTimeHour + "时" + runTimeMin + "分" + runTimeSec + "秒";
            }
        }
    }
    html.append("<td align=\"left\">" + runTime + "</td>");
    html.append("</tr>");
    html.append("</table>");
    html.append("</td></tr><tr><td>&nbsp;</td></tr>");
    html.append("");
    html.append("<!--系统参数-->");
    html.append("<tr><td><table cellspacing=\"0px\"><tr><td style=\"background-color: #AE0000\">");
    html.append("&nbsp;<font color=\"white\"><b>系统参数 axe.properties</b></font>&nbsp;");
    html.append("</td><td>&nbsp;</td><td style=\"background-color: #007500;cursor: pointer;\" onclick=\"window.location='" + contextPath + "/axe/axe.properties?token=" + token + "'\">");
    html.append("&nbsp;<font color=\"white\"><b>编辑</b></font>&nbsp;");
    html.append("</td><td>&nbsp;</td><td style=\"background-color: #007500;cursor: pointer;\" onclick=\"window.location='" + contextPath + "/axe/refresh-config?token=" + token + "'\">");
    html.append("&nbsp;<font color=\"white\"><b>重载 axe.properties 配置</b></font>&nbsp;");
    html.append("</td></tr></table></td></tr>");
    html.append("");
    html.append("<tr><td height=\"2px\" style=\"background-color:#AE0000\"></td></tr>");
    html.append("<tr><td>");
    html.append("<table width=\"100%\">");
    html.append("<tr style=\"background-color: #F0F0F0;\">");
    html.append("<td align=\"left\">&nbsp;</td>");
    html.append("<td align=\"left\"><b>参数-键</b></td>");
    html.append("<td align=\"left\"><b>参数-值</b></td>");
    html.append("<td align=\"left\"><b>参数描述</b></td>");
    html.append("</tr>");
    html.append("<tr>");
    html.append("<td align=\"left\">&nbsp;</td>");
    html.append("<td align=\"left\">axe.home</td>");
    html.append("<td align=\"left\">" + ConfigHelper.getAxeHome() + "</td>");
    html.append("<td align=\"left\">是否开启/axe的访问</td>");
    html.append("</tr>");
    html.append("<tr>");
    html.append("<td align=\"left\">&nbsp;</td>");
    html.append("<td align=\"left\">axe.email</td>");
    html.append("<td align=\"left\">" + ConfigHelper.getAxeEmail() + "</td>");
    html.append("<td align=\"left\">系统异常、密码找回邮件通知地址</td>");
    html.append("</tr>");
    html.append("<tr>");
    html.append("<td align=\"left\">&nbsp;</td>");
    html.append("<td align=\"left\">axe.signin</td>");
    html.append("<td align=\"left\">" + ConfigHelper.getAxeSignIn() + "</td>");
    html.append("<td align=\"left\">是否开启/axe的登录访问</td>");
    html.append("</tr>");
    html.append("<tr>");
    html.append("<td align=\"left\">&nbsp;</td>");
    html.append("<td align=\"left\">axe.classhelper.keep</td>");
    html.append("<td align=\"left\">" + ConfigHelper.getAxeClassHelperKeep() + "</td>");
    html.append("<td align=\"left\">启动后是否释放ClassHelper的内存(释放后ClassHelper不可再用)</td>");
    html.append("</tr>");
    html.append("<tr>");
    html.append("<td align=\"left\">&nbsp;</td>");
    html.append("<td align=\"left\">jdbc.driver</td>");
    html.append("<td align=\"left\">" + ConfigHelper.getJdbcDriver() + "</td>");
    html.append("<td align=\"left\">jdbc-driver</td>");
    html.append("</tr>");
    html.append("<tr>");
    html.append("<td align=\"left\">&nbsp;</td>");
    html.append("<td align=\"left\">jdbc.url</td>");
    html.append("<td align=\"left\">" + ConfigHelper.getJdbcUrl() + "</td>");
    html.append("<td align=\"left\">jdbc-url</td>");
    html.append("</tr>");
    html.append("<tr>");
    html.append("<td align=\"left\">&nbsp;</td>");
    html.append("<td align=\"left\">jdbc.username</td>");
    html.append("<td align=\"left\">" + ConfigHelper.getJdbcUsername() + "</td>");
    html.append("<td align=\"left\">jdbc-username</td>");
    html.append("</tr>");
    html.append("<tr>");
    html.append("<td align=\"left\">&nbsp;</td>");
    html.append("<td align=\"left\">jdbc.password</td>");
    html.append("<td align=\"left\">" + ConfigHelper.getJdbcPassword() + "</td>");
    html.append("<td align=\"left\">jdbc-password</td>");
    html.append("</tr>");
    html.append("<tr>");
    html.append("<td align=\"left\">&nbsp;</td>");
    html.append("<td align=\"left\">jdbc.datasource</td>");
    html.append("<td align=\"left\">" + ConfigHelper.getJdbcDatasource() + "</td>");
    html.append("<td align=\"left\">指定DataSource数据源实现类</td>");
    html.append("</tr>");
    html.append("<tr>");
    html.append("<td align=\"left\">&nbsp;</td>");
    html.append("<td align=\"left\">app.base_package</td>");
    html.append("<td align=\"left\">" + ConfigHelper.getAppBasePackage() + "</td>");
    html.append("<td align=\"left\">指定框架扫描的包路径</td>");
    html.append("</tr>");
    html.append("<tr>");
    html.append("<td align=\"left\">&nbsp;</td>");
    html.append("<td align=\"left\">app.jsp_path</td>");
    html.append("<td align=\"left\">" + ConfigHelper.getAppJspPath() + "</td>");
    html.append("<td align=\"left\">指定jsp存放路径</td>");
    html.append("</tr>");
    html.append("<tr>");
    html.append("<td align=\"left\">&nbsp;</td>");
    html.append("<td align=\"left\">app.asset_path</td>");
    html.append("<td align=\"left\">" + ConfigHelper.getAppAssetPath() + "</td>");
    html.append("<td align=\"left\">指定静态文件(html、js、css、图片等)存放路径</td>");
    html.append("</tr>");
    html.append("<tr>");
    html.append("<td align=\"left\">&nbsp;</td>");
    html.append("<td align=\"left\">app.upload_limit</td>");
    html.append("<td align=\"left\">" + ConfigHelper.getAppUploadLimit() + "</td>");
    html.append("<td align=\"left\">文件上传限制单次文件大小,单位M,默认0不限制</td>");
    html.append("</tr>");
    html.append("</table>");
    html.append("</td></tr><tr><td>&nbsp;</td></tr>");
    html.append("");
    html.append("<!--MVC 概览-->");
    html.append("<tr><td><table cellspacing=\"0px\"><tr><td style=\"background-color: #AE0000\">");
    html.append("&nbsp;<font color=\"white\"><b>MVC-概览</b></font>&nbsp;");
    html.append("</td></tr></table></td></tr>");
    html.append("");
    html.append("<tr><td height=\"2px\" style=\"background-color:#AE0000\"></td></tr>");
    html.append("<tr><td>");
    html.append("<table width=\"100%\">");
    html.append("<tr>");
    html.append("<td align=\"center\"><a href=\"" + contextPath + "/axe/filter?token=" + token + "\">Filter</a> x" + FilterHelper.getSortedFilterList().size() + "</td>");
    html.append("<td align=\"center\"><a href=\"" + contextPath + "/axe/interceptor?token=" + token + "\">Interceptor</a> x" + InterceptorHelper.getInterceptorMap().size() + "</td>");
    String controllerSize = "?";
    String serviceSize = "?";
    String tnsPointCount = "?";
    String daoSize = "?";
    if (ConfigHelper.getAxeClassHelperKeep()) {
        controllerSize = ClassHelper.getControllerClassSet().size() + "";
        Set<Class<?>> serviceClassSet = ClassHelper.getServiceClassSet();
        serviceSize = serviceClassSet.size() + "";
        int count = 0;
        for (Class<?> serviceClass : serviceClassSet) {
            List<Method> methods = ReflectionUtil.getMethodByAnnotation(serviceClass, Tns.class);
            if (CollectionUtil.isNotEmpty(methods)) {
                count = count + methods.size();
            }
        }
        tnsPointCount = count + "";
        daoSize = ClassHelper.getClassSetByAnnotation(Dao.class).size() + "";
    }
    html.append("<td align=\"center\"><a href=\"" + contextPath + "/axe/controller?token=" + token + "\">Controller</a> x" + controllerSize + "</td>");
    html.append("<td align=\"center\"><a href=\"" + contextPath + "/axe/action?token=" + token + "\">Action</a> x" + ControllerHelper.getActionList().size() + "</td>");
    html.append("<td align=\"center\">Service x" + serviceSize + "</td>");
    html.append("<td align=\"center\"><a href=\"" + contextPath + "/axe/tns?token=" + token + "\">Tns point </a> x" + tnsPointCount + "</td>");
    html.append("<td align=\"center\"><a href=\"" + contextPath + "/axe/dao?token=" + token + "\">Dao</a> x" + daoSize + "</td>");
    html.append("<td align=\"center\">Table</a> x" + TableHelper.getEntityClassMap().size() + "</td>");
    html.append("<td align=\"center\"><a href=\"" + contextPath + "/axe/dataSource?token=" + token + "\">DataSource</a> x" + DataSourceHelper.getDataSourceAll().size() + "</td>");
    html.append("</tr>");
    html.append("</table>");
    html.append("</td></tr><tr><td>&nbsp;</td></tr>");
    html.append("");
    html.append("</table>");
    html.append("</body>");
    html.append("</html>");
    printHtml(response, html.toString());
}
Also used : Dao(org.axe.annotation.persistence.Dao) Method(java.lang.reflect.Method) RequestMethod(org.axe.constant.RequestMethod) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) HttpServletRequest(javax.servlet.http.HttpServletRequest) Request(org.axe.annotation.mvc.Request)

Aggregations

Method (java.lang.reflect.Method)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 Request (org.axe.annotation.mvc.Request)1 Dao (org.axe.annotation.persistence.Dao)1 RequestMethod (org.axe.constant.RequestMethod)1