UNPKG

will-core

Version:
60 lines (59 loc) 2.43 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.NotifyConfig = void 0; const will_sql_1 = require("will-sql"); class NotifyConfig { async getConfigValue(db, category, colname, context) { let result = ""; let knsql = new will_sql_1.KnSQL(); knsql.append("select colvalue from tconfig where category='").append(category).append("' and colname='").append(colname).append("' "); let rs = await knsql.executeQuery(db, context); if (rs && rs.rows.length > 0) { result = rs.rows[0].colvalue; } return result; } async getConfigCategory(db, category, context) { let result = {}; let knsql = new will_sql_1.KnSQL(); knsql.append("select colname,colvalue from tconfig where category='").append(category).append("' "); let rs = await knsql.executeQuery(db, context); if (rs && rs.rows.length > 0) { for (let row of rs.rows) { result[row.colname] = row.colvalue; } } return result; } async getApproveURL(db, context) { return await this.getConfigValue(db, "CONFIGURATION", "APPROVE_URL", context); } async getActivateURL(db, context) { return await this.getConfigValue(db, "CONFIGURATION", "ACTIVATE_URL", context); } async getConfigTemplate(db, template, templatetype, context) { let result = undefined; let knsql = new will_sql_1.KnSQL(); knsql.append("select subjecttitle,contents,contexts from ttemplate "); knsql.append("where template='").append(template).append("' and templatetype='").append(templatetype).append("' "); let rs = await knsql.executeQuery(db, context); if (rs && rs.rows.length > 0) { let row = rs.rows[0]; result = { subjecttitle: row.subjecttitle, contents: row.contents, contexts: row.contexts }; } return result; } async isVerifyConfig(db, category, colname, context) { let result = false; let colvalue = await this.getConfigValue(db, category, colname, context); if (colvalue && colvalue.trim().toLowerCase() == "true") { result = true; } return result; } } exports.NotifyConfig = NotifyConfig;