1
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
return {
|
return {
|
||||||
-- 服务器ID,如果REDIS或MYSQL与其它服务公用必须更改此参数,要求唯一
|
-- 服务器ID,如果REDIS或MYSQL与其它服务公用必须更改此参数,要求唯一
|
||||||
server_id = "ADMIN_1",
|
server_id = "STUDENT_1",
|
||||||
|
|
||||||
path = {
|
path = {
|
||||||
-- 字节码路径
|
-- 字节码路径
|
||||||
|
|||||||
@@ -239,8 +239,18 @@ M.replace = function (content)
|
|||||||
local key = prefix ~= "" and (prefix .. "." .. k) or k
|
local key = prefix ~= "" and (prefix .. "." .. k) or k
|
||||||
if type(v) == "table" then
|
if type(v) == "table" then
|
||||||
flatten_kvs(v, key, out)
|
flatten_kvs(v, key, out)
|
||||||
else
|
elseif type(v) == "string" then
|
||||||
out[key] = v
|
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
|
||||||
end
|
end
|
||||||
return out
|
return out
|
||||||
|
|||||||
@@ -143,6 +143,34 @@ M.menu_top = function()
|
|||||||
</nav>
|
</nav>
|
||||||
]]
|
]]
|
||||||
end
|
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 = "<div><div class='home-img'><img src='"..domain_assets.."/".. teacher_info.avatar.."' class='img-fluid bg-img' alt=''></div></div>"
|
||||||
|
for i,v in ipairs(photos) do
|
||||||
|
if type(v) == "string" then
|
||||||
|
content = content..[[<div>
|
||||||
|
<div class="home-img">
|
||||||
|
<img src="]]..domain_assets.."/"..v..[[" class="img-fluid bg-img" alt="">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
]]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
conn:close()
|
||||||
|
return content
|
||||||
|
-- return "<h1>卧槽</h1>"
|
||||||
|
end
|
||||||
M.regist = function(env)
|
M.regist = function(env)
|
||||||
for key, value in pairs(M) do
|
for key, value in pairs(M) do
|
||||||
if type(value) == "function" and key ~= "functions" and key ~= "get_all_functions" then
|
if type(value) == "function" and key ~= "functions" and key ~= "get_all_functions" then
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
local M = {}
|
local M = {}
|
||||||
local httpclient = require("fwutils.httpclient")
|
local httpclient = require("httpclient")
|
||||||
local sms_url = "https://api-v4.mysubmail.com/sms/xsend"
|
local sms_url = "https://api-v4.mysubmail.com/sms/xsend"
|
||||||
local sms_world_url = "https://api-v4.mysubmail.com/internationalsms/xsend"
|
local sms_world_url = "https://api-v4.mysubmail.com/internationalsms/xsend"
|
||||||
M.send = function(phone,appid,appkey,signature,template_code,vars)
|
M.send = function(phone,appid,appkey,signature,template_code,vars)
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
require("app.app")
|
require("app.app")
|
||||||
local http = require("socket.http")
|
local http = require("socket.http")
|
||||||
local ltn12 = require("ltn12")
|
local ltn12 = require("ltn12")
|
||||||
local httpclient = require("fwutils.httpclient")
|
local httpclient = require("httpclient")
|
||||||
local cache = require("fwutils.cache")
|
|
||||||
|
|
||||||
|
|
||||||
local M = {}
|
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"
|
M.url_template_message = "https://api.weixin.qq.com/cgi-bin/message/template/send"
|
||||||
-- 获取 access_token
|
-- 获取 access_token
|
||||||
M.get_access_token = function(appid, appsecret)
|
M.get_access_token = function(appid, appsecret,rds)
|
||||||
-- local value = cache.get_json("wxofficial_info")
|
-- local value = cache.get_json("wxofficial_info")
|
||||||
-- if value then
|
-- if value then
|
||||||
-- -- 是否距离过期至少还有5分钟
|
-- -- 是否距离过期至少还有5分钟
|
||||||
@@ -38,10 +37,9 @@ M.get_access_token = function(appid, appsecret)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local cache_data = rds:get("wxofficial_info_"..appid)
|
||||||
-- 先检查有没有过期
|
|
||||||
local cache_data = cache.get_json(tostring("wxofficial_info_"..appid))
|
|
||||||
if cache_data then
|
if cache_data then
|
||||||
|
cache_data = cjson.decode(cache_data)
|
||||||
if cache_data.update_time and cache_data.access_token then
|
if cache_data.update_time and cache_data.access_token then
|
||||||
-- 检查是否过期
|
-- 检查是否过期
|
||||||
if os.time() - cache_data.update_time < 7200 then
|
if os.time() - cache_data.update_time < 7200 then
|
||||||
@@ -51,7 +49,6 @@ M.get_access_token = function(appid, appsecret)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
local result, data = httpclient.get(M.url_get_access_token .. "&appid=" .. appid .. "&secret=" .. appsecret)
|
local result, data = httpclient.get(M.url_get_access_token .. "&appid=" .. appid .. "&secret=" .. appsecret)
|
||||||
if not result then
|
if not result then
|
||||||
return false, data
|
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(),
|
update_time = os.time(),
|
||||||
access_token = body.access_token
|
access_token = body.access_token
|
||||||
})
|
}))
|
||||||
return true,body.access_token
|
return true,body.access_token
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user