增加组织架构相关业务文件,并修改文件中需要的接口,实现查询、增加、删除和修改数据表功能,对其它文件不正确的注释进行修改
This commit is contained in:
parent
25b36f6e52
commit
80c9e55d98
78
src/api/system/organization.lua
Normal file
78
src/api/system/organization.lua
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
---
|
||||
--- Generated by EmmyLua(https://github.com/EmmyLua)
|
||||
--- Created by admin.
|
||||
--- DateTime: 2025/10/28 10:05
|
||||
---
|
||||
|
||||
local _M = {}
|
||||
|
||||
local dao = require("service.system.organization")
|
||||
local resp = require("util.response")
|
||||
local validator = require("util.validator")
|
||||
|
||||
--获取所有组织架构信息
|
||||
function _M.get_allorganization()
|
||||
local code,ret = dao.getAllOrganization()
|
||||
local result = resp:json(code, ret)
|
||||
resp:send(result)
|
||||
end
|
||||
|
||||
--根据组织id获取组织架构信息
|
||||
function _M.get_organization(m)
|
||||
local id = m.id
|
||||
local code,ret = dao.getOrganization(id)
|
||||
local result = resp:json(code, ret)
|
||||
resp:send(result)
|
||||
end
|
||||
|
||||
--根据组织id添加组织架构信息
|
||||
function _M.add_organization()
|
||||
--获取请求头并进行校验
|
||||
if validator.checkReqHeader() == false then
|
||||
local result = resp:json(0x000001)
|
||||
resp:send(result)
|
||||
return
|
||||
end
|
||||
--读取请求体的数据
|
||||
ngx.req.read_body()
|
||||
--获取请求数据
|
||||
local body_data = ngx.req.get_body_data()
|
||||
--判断请求体数据是否为空
|
||||
if body_data == nil then
|
||||
local result = resp:json(0x000001)
|
||||
resp:send(result)
|
||||
return
|
||||
end
|
||||
--ngx.say(body_data)
|
||||
local code, ret = dao.addOrganization(body_data)
|
||||
local result = resp:json(code, ret)
|
||||
resp:send(result)
|
||||
end
|
||||
|
||||
--根据组织id删除组织架构信息
|
||||
function _M.delete_organization(m)
|
||||
local id = m.id
|
||||
local code, ret = dao.deleteOrganization(id)
|
||||
local result = resp:json(code, ret)
|
||||
resp:send(result)
|
||||
end
|
||||
|
||||
--根据组织id删除组织架构信息
|
||||
function _M.update_organization(m)
|
||||
local id = m.id
|
||||
--读取请求体的数据
|
||||
ngx.req.read_body()
|
||||
--获取请求数据
|
||||
local body_data = ngx.req.get_body_data()
|
||||
--判断请求体数据是否为空
|
||||
if body_data == nil then
|
||||
local result = resp:json(0x000001)
|
||||
resp:send(result)
|
||||
return
|
||||
end
|
||||
local code, ret = dao.updateOrganization(id, body_data)
|
||||
local result = resp:json(code, ret)
|
||||
resp:send(result)
|
||||
end
|
||||
|
||||
return _M
|
||||
12
src/model/organization.lua
Normal file
12
src/model/organization.lua
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
---
|
||||
--- Generated by EmmyLua(https://github.com/EmmyLua)
|
||||
--- Created by admin.
|
||||
--- DateTime: 2025/10/28 10:14
|
||||
--- 数据表模型文件
|
||||
|
||||
--引用使用的库文件
|
||||
local Model = require("util.model")
|
||||
|
||||
--创建一个数据表相关的模型
|
||||
local Organization = Model:new('tbl_organization')
|
||||
return Organization
|
||||
|
|
@ -1,25 +1,25 @@
|
|||
---
|
||||
--- Generated by EmmyLua(https://github.com/EmmyLua)
|
||||
--- Created by .
|
||||
--- DateTime: 2025/9/25 08:19
|
||||
--- 业务逻辑 对用户数据表进行数据表业务处理
|
||||
--- DateTime: 2025/9/25 08:25
|
||||
--- 业务逻辑 对账户数据表进行数据表业务处理
|
||||
local validator = require("util.validator")
|
||||
local helpers = require("util.helpers")
|
||||
local account = require("model.account")
|
||||
|
||||
local _M = {}
|
||||
|
||||
-- 查询数据表中的所有账号信息
|
||||
-- 查询数据表中的所有账户信息
|
||||
function _M.getAllAccount()
|
||||
return account:all()
|
||||
end
|
||||
|
||||
--根据账号id获取账号信息
|
||||
--根据账户id获取账户信息
|
||||
function _M.getAccount(id)
|
||||
return account.find(id)
|
||||
end
|
||||
|
||||
--增加账号信息到数据表
|
||||
--增加账户信息到数据表
|
||||
function _M.addAccount(jsonData)
|
||||
--验证数据的正确性,错误时返回
|
||||
local success, result = validator.checkJson(jsonData)
|
||||
|
|
@ -31,7 +31,7 @@ function _M.addAccount(jsonData)
|
|||
for key, value in pairs(result) do
|
||||
if key == "name" then name = value end
|
||||
end
|
||||
--根据账号进行验证是否存在
|
||||
--根据账户进行验证是否存在
|
||||
local code, res = account:where("name", "=", name):get()
|
||||
if code ~= 0 then
|
||||
return 0x000001, res
|
||||
|
|
@ -42,25 +42,25 @@ function _M.addAccount(jsonData)
|
|||
num = num + 1
|
||||
end
|
||||
end
|
||||
--账号存在时返回账号已经存在
|
||||
--账户存在时返回账户已经存在
|
||||
if num <= 0 then
|
||||
return 0x01000C, nil
|
||||
end
|
||||
--键值为id产生uuid数据值,增加到json中
|
||||
result.id = helpers.getUuid()
|
||||
local ret = helpers.convert_json(result)
|
||||
-- 创建一个账号
|
||||
-- 创建一个账户
|
||||
return account:create('{'..ret..'}')
|
||||
end
|
||||
|
||||
--增加账号信息到数据表
|
||||
--删除账户信息到数据表
|
||||
function _M.deleteAccount(id)
|
||||
return account:delete(id)
|
||||
end
|
||||
|
||||
--更新账号信息到数据表
|
||||
--更新账户信息到数据表
|
||||
function _M.updateAccount(id, jsonData)
|
||||
--根据账号id进行验证账号是否存在
|
||||
--根据账户id进行验证账户是否存在
|
||||
local code, res = account:find(id)
|
||||
if code ~= 0 then
|
||||
return 0x000001, res
|
||||
|
|
@ -71,7 +71,7 @@ function _M.updateAccount(id, jsonData)
|
|||
num = num + 1
|
||||
end
|
||||
end
|
||||
--账号不存在返回错误
|
||||
--账户不存在返回错误
|
||||
if num <= 0 then
|
||||
return 0x01000C, nil
|
||||
end
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ function _M.addApplication(jsonData)
|
|||
return application:create('{'..ret..'}')
|
||||
end
|
||||
|
||||
--增加应用信息到数据表
|
||||
--删除应用信息到数据表
|
||||
function _M.deleteApplication(id)
|
||||
return application:delete(id)
|
||||
end
|
||||
|
|
|
|||
87
src/service/system/organization.lua
Normal file
87
src/service/system/organization.lua
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
---
|
||||
--- Generated by EmmyLua(https://github.com/EmmyLua)
|
||||
--- Created by .
|
||||
--- DateTime: 2025/9/28 10:22
|
||||
--- 业务逻辑 对组织架构数据表进行数据表业务处理
|
||||
local validator = require("util.validator")
|
||||
local helpers = require("util.helpers")
|
||||
local organization = require("model.organization")
|
||||
|
||||
local _M = {}
|
||||
|
||||
-- 查询数据表中的所有组织架构信息
|
||||
function _M.getAllOrganization()
|
||||
return organization:all()
|
||||
end
|
||||
|
||||
--根据组织架构id获取组织架构信息
|
||||
function _M.getOrganization(id)
|
||||
return organization.find(id)
|
||||
end
|
||||
|
||||
--增加组织架构息到数据表
|
||||
function _M.addOrganization(jsonData)
|
||||
--验证数据的正确性,错误时返回
|
||||
local success, result = validator.checkJson(jsonData)
|
||||
if success == false then
|
||||
return 0x000001, result
|
||||
end
|
||||
--解析json中的键和数据值
|
||||
local name = ""
|
||||
for key, value in pairs(result) do
|
||||
if key == "name" then name = value end
|
||||
end
|
||||
--根据组织架构进行验证是否存在
|
||||
local code, res = organization:where("name", "=", name):get()
|
||||
if code ~= 0 then
|
||||
return 0x000001, res
|
||||
end
|
||||
local num = 0
|
||||
for _, row in ipairs(res) do
|
||||
for key, value in pairs(row) do
|
||||
num = num + 1
|
||||
end
|
||||
end
|
||||
--组织架构存在时返回组织架构已经存在
|
||||
if num <= 0 then
|
||||
return 0x01000C, nil
|
||||
end
|
||||
--键值为id产生uuid数据值,增加到json中
|
||||
result.id = helpers.getUuid()
|
||||
local ret = helpers.convert_json(result)
|
||||
-- 创建一个组织架构
|
||||
return organization:create('{'..ret..'}')
|
||||
end
|
||||
|
||||
--删除组织架构信息到数据表
|
||||
function _M.deleteOrganization(id)
|
||||
return organization:delete(id)
|
||||
end
|
||||
|
||||
--更新组织架构信息到数据表
|
||||
function _M.updateOrganization(id, jsonData)
|
||||
--根据组织架构id进行验证组织架构是否存在
|
||||
local code, res = organization:find(id)
|
||||
if code ~= 0 then
|
||||
return 0x000001, res
|
||||
end
|
||||
local num = 0
|
||||
for _, row in ipairs(res) do
|
||||
for key, value in pairs(row) do
|
||||
num = num + 1
|
||||
end
|
||||
end
|
||||
--账号不存在返回错误
|
||||
if num <= 0 then
|
||||
return 0x01000C, nil
|
||||
end
|
||||
--验证数据的正确性,错误时返回
|
||||
local success, result = validator.checkJson(jsonData)
|
||||
if success == false then
|
||||
return 0x000001, result
|
||||
end
|
||||
--对数据内容进行更新
|
||||
return organization:where('id', '=', id):update(jsonData)
|
||||
end
|
||||
|
||||
return _M
|
||||
|
|
@ -60,7 +60,7 @@ function _M.addPermission(jsonData)
|
|||
return permission:create('{'..ret..'}')
|
||||
end
|
||||
|
||||
--增加权限信息到数据表
|
||||
--删除权限信息到数据表
|
||||
function _M.deletePermission(id)
|
||||
return permission:delete(id)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ function _M.addRole(jsonData)
|
|||
return role:create('{'..ret..'}')
|
||||
end
|
||||
|
||||
--增加角色信息到数据表
|
||||
--删除角色信息到数据表
|
||||
function _M.deleteRole(id)
|
||||
return role:delete(id)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ function _M.addUser(jsonData)
|
|||
return user:create('{'..ret..'}')
|
||||
end
|
||||
|
||||
--增加用户信息到数据表
|
||||
--删除用户信息到数据表
|
||||
function _M.deleteUser(id)
|
||||
return user:delete(id)
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user