From 174e4aadb97c533fbf819be8f750ac4aea6f09fa Mon Sep 17 00:00:00 2001 From: wanglei <34475144@qqcom> Date: Wed, 15 Oct 2025 17:05:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8E=A5=E5=8F=A3=E4=BD=BF?= =?UTF-8?q?=E7=94=A8radixtree=E8=BF=9B=E8=A1=8C=E8=BF=87=E6=BB=A4=E9=AA=8C?= =?UTF-8?q?=E8=AF=81=E5=B9=B6=E8=B0=83=E7=94=A8=E5=85=B6=E5=AE=83=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E7=B1=BB=E5=87=BD=E6=95=B0=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- conf/nginx.conf | 7 ++++--- src/api/system/user.lua | 18 ++++++----------- src/service/system/user.lua | 14 ++++++++++--- src/test/testOrm.lua | 40 +------------------------------------ 4 files changed, 22 insertions(+), 57 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index b6c330c..bb81f30 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -7,10 +7,9 @@ events { } http { - lua_package_path '$profix/src/?/?.lua;$profix/src/?.lua;;'; - lua_package_cpath '$profix/src/share/lib/?.so;;'; + lua_package_path '$prefix/src/?/?.lua;$prefix/src/?.lua;/home/frankly/work/AuthPlatform/src/?.lua;/home/frankly/work/AuthPlatform/src/?/?.lua;;'; + lua_package_cpath '$prefix/src/share/lib/?.so;;'; - include system/user.conf # Path of the file with trusted CA certificates. #lua_ssl_trusted_certificate /etc/ssl/certs/ca-certificates.crt; @@ -25,5 +24,7 @@ http { log_not_found off; access_log off; } + + include 'system/user.conf'; } } \ No newline at end of file diff --git a/src/api/system/user.lua b/src/api/system/user.lua index ba1578a..c36e851 100644 --- a/src/api/system/user.lua +++ b/src/api/system/user.lua @@ -4,17 +4,11 @@ --- DateTime: 2025/9/25 08:19 --- -local db_config = require('config.database') -local pgmoon = require('share.pgmoonn') +local _M = {} --- 创建一个新的连接 -local conn = pgmoon.new(db_config.postgres) +--获取所有用户信息 +function _M.get_allusers() --- 连接到数据库 -conn:connect(function(err) - if err then - print("Error connecting to database: ", err) - else - print("Connected to the PostgreSQL server.") - end -end) \ No newline at end of file +end + +return _M \ No newline at end of file diff --git a/src/service/system/user.lua b/src/service/system/user.lua index 55a52d5..8c3db65 100644 --- a/src/service/system/user.lua +++ b/src/service/system/user.lua @@ -1,10 +1,12 @@ --- --- Generated by EmmyLua(https://github.com/EmmyLua) ---- Created by admin. +--- Created by . --- DateTime: 2025/9/25 08:19 --- 业务逻辑 -local db_config = require('config.database') -local pgmoon = require('share.pgmoonn') +local cjson = require('cjson') +local pgmoon = require('pgmoon'); + +local _M = {} -- 创建一个新的连接 local conn = pgmoon.new(db_config.postgres) @@ -17,3 +19,9 @@ conn:connect(function(err) print("Connected to the PostgreSQL server.") end end) + +function _M.getAllUser() + +end + +return _M \ No newline at end of file diff --git a/src/test/testOrm.lua b/src/test/testOrm.lua index 8d31909..a14ec7f 100644 --- a/src/test/testOrm.lua +++ b/src/test/testOrm.lua @@ -27,7 +27,7 @@ local API = require("LuaORM.API") -- 2. Configure the ORM API.ORM:initialize({ - connection = "LuaSQL/postgres", + connection = "LuaSQL/PostgreSQL", database = { databaseName = "postgres", userName = "postgres", @@ -397,41 +397,3 @@ end local timePassed = os.clock() - startTimeStamp print("\nExecution took " .. timePassed .. " seconds") - -return - ------------------------------ REQUIRE -------------------------------- -local Table = require("orm.model") -local fields = require("orm.tools.fields") - ------------------------------ CREATE TABLE -------------------------------- - -local User = Table({ - __tablename__ = "user", - username = fields.CharField({max_length = 100, unique = true}), - password = fields.CharField({max_length = 50, unique = true}), - age = fields.IntegerField({max_length = 2, null = true}), - job = fields.CharField({max_length = 50, null = true}), - time_create = fields.DateTimeField({null = true}) -}) - ------------------------------ CREATE DATA -------------------------------- -local user = User({ - id = 1, - username = "zhangsan", - password = "123456", - time_create = os.time() -}) - ---user:save() -ngx.say("User " .. user.username .. " has id " .. user.id) --- User Bob Smith has id 1 - ------------------------------ GET DATA -------------------------------- -local first_user = User.get:first() -ngx.print("First user name is: " .. first_user.username) --- First user name is: First user - -local users = User.get:all() -ngx.print("We get " .. users:count() .. " users") --- We get 5 users