Search in sources :

Example 1 with InstallService

use of com.zrlog.service.InstallService in project zrlog by 94fzb.

the class InstallController method installZrlog.

/**
 * 数据库检查通过后,根据填写信息,执行数据表,表数据的初始化
 */
public void installZrlog() {
    String home = getRequest().getScheme() + "://" + getRequest().getHeader("host") + getRequest().getContextPath() + "/";
    Map<String, String> dbConn = (Map<String, String>) JFinal.me().getServletContext().getAttribute("dbConn");
    Map<String, String> configMsg = new HashMap<>();
    configMsg.put("title", getPara("title"));
    configMsg.put("second_title", getPara("second_title"));
    configMsg.put("username", getPara("username"));
    configMsg.put("password", getPara("password"));
    configMsg.put("email", getPara("email"));
    configMsg.put("home", home);
    if (new InstallService(PathKit.getWebRootPath() + "/WEB-INF", dbConn, configMsg).install()) {
        render("/install/success.jsp");
        ZrLogConfig config = (ZrLogConfig) JFinal.me().getServletContext().getAttribute("config");
        // 通知启动插件,配置库连接等操作
        config.installFinish();
    }
}
Also used : HashMap(java.util.HashMap) ZrLogConfig(com.zrlog.web.config.ZrLogConfig) Map(java.util.Map) HashMap(java.util.HashMap) InstallService(com.zrlog.service.InstallService)

Example 2 with InstallService

use of com.zrlog.service.InstallService in project zrlog by 94fzb.

the class InstallController method testDbConn.

/**
 * 检查数据库是否可以正常连接使用,无法连接时给出相应的提示
 */
public void testDbConn() {
    Map<String, String> dbConn = new HashMap<>();
    dbConn.put("jdbcUrl", "jdbc:mysql://" + getPara("dbhost") + ":" + getPara("port") + "/" + getPara("dbname") + "?&characterEncoding=UTF-8");
    dbConn.put("user", getPara("dbuser"));
    dbConn.put("password", getPara("dbpwd"));
    dbConn.put("driverClass", "com.mysql.jdbc.Driver");
    JFinal.me().getServletContext().setAttribute("dbConn", dbConn);
    TestConnectDbResult testConnectDbResult = new InstallService(PathKit.getWebRootPath() + "/WEB-INF", dbConn).testDbConn();
    if (testConnectDbResult.getError() != 0) {
        setAttr("errorMsg", "[Error-" + testConnectDbResult.getError() + "] - " + I18NUtil.getStringFromRes("connectDbError_" + testConnectDbResult.getError()));
        index();
    } else {
        render("/install/message.jsp");
    }
}
Also used : HashMap(java.util.HashMap) TestConnectDbResult(com.zrlog.common.type.TestConnectDbResult) InstallService(com.zrlog.service.InstallService)

Aggregations

InstallService (com.zrlog.service.InstallService)2 HashMap (java.util.HashMap)2 TestConnectDbResult (com.zrlog.common.type.TestConnectDbResult)1 ZrLogConfig (com.zrlog.web.config.ZrLogConfig)1 Map (java.util.Map)1