a158 8 bulan lalu
induk
melakukan
290dab81d4

+ 1 - 1
target/fwutils/config.lua

@@ -1,6 +1,6 @@
 return {
     -- 服务器ID,如果REDIS或MYSQL与其它服务公用必须更改此参数,要求唯一
-    server_id = "ADMIN_1",
+    server_id = "STUDENT_1",
     
     path = {
         -- 字节码路径

+ 11 - 1
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

+ 28 - 0
target/fwutils/funs.lua

@@ -143,6 +143,34 @@ M.menu_top = function()
         </nav>
     ]]
 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)
     for key, value in pairs(M) do
         if type(value) == "function" and key ~= "functions" and key ~= "get_all_functions" then

+ 1 - 1
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)

+ 6 - 9
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