diff --git a/target/fwutils/config.lua b/target/fwutils/config.lua index 6554169..6cc7b4e 100644 --- a/target/fwutils/config.lua +++ b/target/fwutils/config.lua @@ -1,6 +1,6 @@ return { -- 服务器ID,如果REDIS或MYSQL与其它服务公用必须更改此参数,要求唯一 - server_id = "ADMIN_1", + server_id = "STUDENT_1", path = { -- 字节码路径 diff --git a/target/fwutils/develop/function/template.lua b/target/fwutils/develop/function/template.lua index 594af92..f699808 100644 --- a/target/fwutils/develop/function/template.lua +++ b/target/fwutils/develop/function/template.lua @@ -239,8 +239,18 @@ M.replace = function (content) local key = prefix ~= "" and (prefix .. "." .. k) or k if type(v) == "table" then flatten_kvs(v, key, out) - else + elseif type(v) == "string" then out[key] = v + elseif type(v) == "number" then + if math.type and math.type(v) == "integer" then + out[key] = string.format("%d", v) + elseif math.floor(v) == v then + out[key] = string.format("%d", v) + else + out[key] = tostring(v) + end + else + out[key] = tostring(v) end end return out diff --git a/target/fwutils/funs.lua b/target/fwutils/funs.lua index 816adc0..ccf8da7 100644 --- a/target/fwutils/funs.lua +++ b/target/fwutils/funs.lua @@ -143,6 +143,34 @@ M.menu_top = function() ]] end +M.teacher_photos = function() + require("app.app") + local conn = db_conn() + local edu_id = edu_id() + local edu_teacher = require("app.function.edu_teacher") + local edu_setting = require("app.function.edu_setting") + local teacher_info = edu_teacher.get_by_id(pint("id"),edu_id,conn) + if teacher_info == nil then + conn:close() + return "" + end + local domain_assets = edu_setting.get_assets_domain(edu_id,conn) + local photos = cjson.decode(teacher_info.photo) + local content = "
" + for i,v in ipairs(photos) do + if type(v) == "string" then + content = content..[[
+
+ +
+
+ ]] + end + end + conn:close() + return content + -- return "

卧槽

" +end M.regist = function(env) for key, value in pairs(M) do if type(value) == "function" and key ~= "functions" and key ~= "get_all_functions" then diff --git a/target/submail/sms.lua b/target/submail/sms.lua index 557d0eb..f56426c 100644 --- a/target/submail/sms.lua +++ b/target/submail/sms.lua @@ -1,5 +1,5 @@ local M = {} -local httpclient = require("fwutils.httpclient") +local httpclient = require("httpclient") local sms_url = "https://api-v4.mysubmail.com/sms/xsend" local sms_world_url = "https://api-v4.mysubmail.com/internationalsms/xsend" M.send = function(phone,appid,appkey,signature,template_code,vars) diff --git a/target/tencent/wxofficial.lua b/target/tencent/wxofficial.lua index 0e1a71d..e953b52 100644 --- a/target/tencent/wxofficial.lua +++ b/target/tencent/wxofficial.lua @@ -1,8 +1,7 @@ require("app.app") local http = require("socket.http") local ltn12 = require("ltn12") -local httpclient = require("fwutils.httpclient") -local cache = require("fwutils.cache") +local httpclient = require("httpclient") local M = {} @@ -20,7 +19,7 @@ M.url_auth = "https://open.weixin.qq.com/connect/oauth2/authorize" -- 模板消息 M.url_template_message = "https://api.weixin.qq.com/cgi-bin/message/template/send" -- 获取 access_token -M.get_access_token = function(appid, appsecret) +M.get_access_token = function(appid, appsecret,rds) -- local value = cache.get_json("wxofficial_info") -- if value then -- -- 是否距离过期至少还有5分钟 @@ -38,10 +37,9 @@ M.get_access_token = function(appid, appsecret) end - - -- 先检查有没有过期 - local cache_data = cache.get_json(tostring("wxofficial_info_"..appid)) + local cache_data = rds:get("wxofficial_info_"..appid) if cache_data then + cache_data = cjson.decode(cache_data) if cache_data.update_time and cache_data.access_token then -- 检查是否过期 if os.time() - cache_data.update_time < 7200 then @@ -51,7 +49,6 @@ M.get_access_token = function(appid, appsecret) end - local result, data = httpclient.get(M.url_get_access_token .. "&appid=" .. appid .. "&secret=" .. appsecret) if not result then return false, data @@ -64,10 +61,10 @@ M.get_access_token = function(appid, appsecret) -- 更新 - cache.set_json(tostring("wxofficial_info_"..appid),{ + rds:setex("wxofficial_info_"..appid,7200,cjson.encode({ update_time = os.time(), access_token = body.access_token - }) + })) return true,body.access_token