UNPKG

accesstoken

Version:

get accesstoken for weixin_qy and save it to mysql

25 lines 639 B
var config = require("./config"); var mysqlUtils = require("./mysqlUtils"); var accesstoken = { set: function(db) { if (db) { config.host = db.host; config.port = db.port; config.database = db.database; config.user = db.user; config.pwd = db.pwd; return this; } else { return null; } }, get: function(corpId, agentId, callback) { var sql = `select * from t_token where 1=1 and corpId= '${corpId}' and agentId=${agentId}`; if (callback && typeof callback === "function") { mysqlUtils.query(sql, function(err, vals, fields) { callback(err, vals, fields); }); } } } module.exports = accesstoken;