78 lines
2.0 KiB
Lua
78 lines
2.0 KiB
Lua
|
|
---
|
||
|
|
--- 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
|