diff --git a/conf/auth/auth.conf b/conf/auth/auth.conf deleted file mode 100644 index f4820c5..0000000 --- a/conf/auth/auth.conf +++ /dev/null @@ -1,4 +0,0 @@ -#API接口文件 -location /api/auth { - content_by_lua_file '${APP_PATH}/src/api/auth/auth.lua'; -} \ No newline at end of file diff --git a/conf/nginx.conf b/conf/nginx.conf index 9e44a0b..32ef0ea 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -33,15 +33,10 @@ http { ## 应用路径 set $APP_PATH '/home/frankly/work/AuthPlatform'; - #登录认证配置 - include 'auth/auth.conf'; + + #access_by_lua_file '${APP_PATH}/src/auth/jwt-auth.lua'; #数据列表配置 - include 'system/account.conf'; - include 'system/application.conf'; - include 'system/department.conf'; - include 'system/permission.conf'; - include 'system/role.conf'; - include 'system/user.conf'; + include 'system/system.conf'; #测试接口配置 location /testSQL { @@ -52,7 +47,7 @@ http { } #jwt验证进行测试 location /api/test { - access_by_lua_file '${APP_PATH}/src/util/jwt-auth.lua'; + access_by_lua_file '${APP_PATH}/src/auth/jwt-auth.lua'; proxy_pass http://192.168.147.1:3000; } } diff --git a/conf/system/account.conf b/conf/system/account.conf deleted file mode 100644 index 2180dd7..0000000 --- a/conf/system/account.conf +++ /dev/null @@ -1,4 +0,0 @@ -#API接口文件 -location /api/system/accounts { - content_by_lua_file '${APP_PATH}/src/api/system/account.lua'; -} \ No newline at end of file diff --git a/conf/system/application.conf b/conf/system/application.conf deleted file mode 100644 index ca81c71..0000000 --- a/conf/system/application.conf +++ /dev/null @@ -1,4 +0,0 @@ -#API接口文件 -location /api/system/applications { - content_by_lua_file '${APP_PATH}/src/api/system/application.lua'; -} \ No newline at end of file diff --git a/conf/system/department.conf b/conf/system/department.conf deleted file mode 100644 index b8f8439..0000000 --- a/conf/system/department.conf +++ /dev/null @@ -1,4 +0,0 @@ -#API接口文件 -location /api/system/organizations { - content_by_lua_file '${APP_PATH}/src/api/system/organization.lua'; -} \ No newline at end of file diff --git a/conf/system/permission.conf b/conf/system/permission.conf deleted file mode 100644 index 73c9dea..0000000 --- a/conf/system/permission.conf +++ /dev/null @@ -1,4 +0,0 @@ -#API接口文件 -location /api/system/permissions { - content_by_lua_file '${APP_PATH}/src/api/system/permission.lua'; -} \ No newline at end of file diff --git a/conf/system/role.conf b/conf/system/role.conf deleted file mode 100644 index 180bc6c..0000000 --- a/conf/system/role.conf +++ /dev/null @@ -1,4 +0,0 @@ -#API接口文件 -location /api/system/roles { - content_by_lua_file '${APP_PATH}/src/api/system/role.lua'; -} \ No newline at end of file diff --git a/conf/system/user.conf b/conf/system/user.conf deleted file mode 100644 index 587f16e..0000000 --- a/conf/system/user.conf +++ /dev/null @@ -1,4 +0,0 @@ -#API接口文件 -location /api/system/users { - content_by_lua_file '${APP_PATH}/src/api/system/user.lua'; -} \ No newline at end of file diff --git a/src/dao/account.lua b/src/dao/account.lua index 0a8de22..55fa76e 100644 --- a/src/dao/account.lua +++ b/src/dao/account.lua @@ -61,9 +61,8 @@ function _M.addSystemAccount(jsonData) --键值为id产生uuid数据值,增加到json中 jsonData.id = helpers.getUuid() - local ret = helpers.convert_json(jsonData) -- 创建一个账户 - return accountModel:create('{'..ret..'}') + return accountModel:create(jsonData) end --删除账户信息到数据表 diff --git a/src/dao/application.lua b/src/dao/application.lua index 8ffb90c..99733b2 100644 --- a/src/dao/application.lua +++ b/src/dao/application.lua @@ -76,9 +76,8 @@ function _M.addSystemApplication(jsonData) end --键值为id产生uuid数据值,增加到json中 jsonData.id = helpers.getUuid() - local ret = helpers.convert_json(jsonData) -- 创建一个应用 - return applicationModel:create('{'..ret..'}') + return applicationModel:create(jsonData) end --删除应用信息到数据表 diff --git a/src/dao/department.lua b/src/dao/department.lua index 2af2fe7..0f0cf2d 100644 --- a/src/dao/department.lua +++ b/src/dao/department.lua @@ -60,9 +60,8 @@ function _M.addSystemDepartment(jsonData) end --键值为id产生uuid数据值,增加到json中 jsonData.id = helpers.getUuid() - local ret = helpers.convert_json(jsonData) -- 创建一个组织架构 - return departmentModel:create('{'..ret..'}') + return departmentModel:create(jsonData) end --删除组织架构信息到数据表 diff --git a/src/dao/permission.lua b/src/dao/permission.lua index 6a043b3..36200b7 100644 --- a/src/dao/permission.lua +++ b/src/dao/permission.lua @@ -68,9 +68,8 @@ function _M.addSystemPermission(jsonData) --键值为id产生uuid数据值,增加到json中 jsonData.id = helpers.getUuid() - local ret = helpers.convert_json(jsonData) -- 创建一个权限 - return permissionModel:create('{'..ret..'}') + return permissionModel:create(jsonData) end --删除权限信息到数据表 diff --git a/src/dao/role.lua b/src/dao/role.lua index 34bde81..0a3d7e5 100644 --- a/src/dao/role.lua +++ b/src/dao/role.lua @@ -61,9 +61,8 @@ function _M.addSystemRole(jsonData) --键值为id产生uuid数据值,增加到json中 jsonData.id = helpers.getUuid() - local ret = helpers.convert_json(jsonData) -- 创建一个角色 - return roleModel:create('{'..ret..'}') + return roleModel:create(jsonData) end --删除角色信息到数据表 diff --git a/src/dao/user.lua b/src/dao/user.lua index 777cb31..59847a6 100644 --- a/src/dao/user.lua +++ b/src/dao/user.lua @@ -42,13 +42,16 @@ end --增加用户信息到数据表 function _M.addSystemUser(jsonData) + if jsonData == nil or jsonData == "" then + return 0x000001, nil + end --解析json中的键和数据值 local userName = jsonData['username'] local phone = jsonData['phone'] local email = jsonData['email'] --根据用户、手机号、邮箱进行验证用户是否存在 - local code, res = userModel:where("username", "=", userName):where("phone", "=", phone):where("email", "=", email):get() + local code, res = userModel:where("username", "=", userName):orwhere("phone", "=", phone):orwhere("email", "=", email):get() if code ~= 0 then return 0x000001,res end @@ -63,9 +66,8 @@ function _M.addSystemUser(jsonData) --键值为id产生uuid数据值,增加到json中 jsonData.id = helpers.getUuid() - local ret = helpers.convert_json(jsonData) -- 创建一个用户 - return userModel:create('{'..ret..'}') + return userModel:create(jsonData) end --删除用户信息到数据表 diff --git a/src/service/system/user.lua b/src/service/system/user.lua index 5475ab9..0e953c4 100644 --- a/src/service/system/user.lua +++ b/src/service/system/user.lua @@ -43,7 +43,9 @@ function _M.addSystemUser() return end --ngx.say(body_data) - local code, ret = userDao.addSystemUser(cjson.decode(body_data)) + local jsonData = cjson.decode(body_data) + --ngx.say(jsonData) + local code, ret = userDao.addSystemUser(jsonData) local result = resp:json(code, ret) resp:send(result) end diff --git a/src/util/response.lua b/src/util/response.lua index 6f33ccd..deefcb3 100644 --- a/src/util/response.lua +++ b/src/util/response.lua @@ -16,13 +16,13 @@ function _M:json(status, message, data, http_status) --end msg = error_code[status] end - local response = {status=status, msg=msg, data=data,timestamp=os.time()} - if not response.status then - response.status = -1 + local response = {code=status, msg=msg, result=data,timestamp=os.time()} + if not response.code then + response.code = -1 response.message = 'not find status code' end return { - status = response_status, + code = response_status, headers = {content_type = 'application/json; charset=UTF-8'}, body = cjson.encode(response) } @@ -34,13 +34,13 @@ function _M:json(status, data, http_status) local response_status = http_status or ngx.OK msg = error_code[status] - local response = {status=status, msg=msg, data=data,timestamp=os.time()} - if not response.status then - response.status = -1 + local response = {code=status, msg=msg, result=data,timestamp=os.time()} + if not response.code then + response.code = -1 response.message = 'not find status code' end return { - status = response_status, + code = response_status, headers = {content_type = 'application/json; charset=UTF-8'}, body = cjson.encode(response) } @@ -48,7 +48,7 @@ end function _M:raw(http_status, http_body) return { - status = http_status, + code = http_status, headers = {}, body = http_body, timestamp = os.time() @@ -57,7 +57,7 @@ end function _M:error(http_status, http_headers, http_body) return { - status = http_status, + code = http_status, headers = http_headers, body = http_body, timestamp = ngx.now() @@ -65,7 +65,7 @@ function _M:error(http_status, http_headers, http_body) end function _M:send(response) - ngx.status = response.status + ngx.status = response.code if response.headers ~= nil then for name, value in pairs(response.headers) do ngx.header[name] = value diff --git a/src/util/status.lua b/src/util/status.lua index 3b28c75..15499a1 100644 --- a/src/util/status.lua +++ b/src/util/status.lua @@ -37,5 +37,6 @@ return { [0x010009] = '重置密码失败,用户不存在', [0x01000A] = '获取用户信息失败,用户未登录', [0x01000B] = '获取用户信息失败,用户不存在', - [0x01000C] = '修改用户信息失败,用户不存在', + [0x01000C] = '添加用户信息失败,用户已存在', + [0x01000D] = '修改用户信息失败,用户不存在', } \ No newline at end of file