12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- local skynet = require "skynet"
- local s = require "service"
- local tools = require "tools"
- local cjson = require "cjson"
- local mysql = require "skynet.db.mysql"
- local back_response = require "back_response"
- local urllib = require "http.url"
- local crypt = require "skynet.crypt"
- local tg_temp_app = require "tg_temp_app"
- local tg_platform = require "tg_platform"
- local tg_zhanghu = require "tg_zhanghu"
- local tg_max_zhuanhua = require "tg_max_zhuanhua"
- local user = require "user"
- local tg_app = require "tg_app"
- local tg_main = require "tg_main"
- local db_filter_config = require "db_filter_config"
- local push_msg = require "push_msg"
- local filter_task = require "filter_task"
- local status_200 = 200
- local CMD = {
-
- }
- CMD["tg_temp_app"] = tg_temp_app;
- CMD["tg_platform"] = tg_platform;
- CMD["tg_zhanghu"] = tg_zhanghu;
- CMD["tg_max_zhuanhua"] = tg_max_zhuanhua;
- CMD["tg_app"] = tg_app;
- CMD["user"] = user;
- CMD["tg_main"] = tg_main;
- CMD["db_filter_config"] = db_filter_config;
- CMD["push_msg"] = push_msg;
- CMD["filter_task"] = filter_task;
- function run(target,fun,msg_body,fd)
- if target~=nil and fun~=nil and target[fun]~=nil then
- local isok,data,total = target[fun](msg_body)
- if isok then
- if data~=nil then
- if total~=nil then
- tools.response(fd,status_200,cjson.encode({code=10000,data=data,total=total}))
- else
- tools.response(fd,status_200,cjson.encode({code=10000,data=data}))
- end
-
- else
- tools.response(fd,status_200,cjson.encode({code=10000,msg="OK!"}))
- end
- else
- tools.response(fd,status_200,cjson.encode({code=10001,msg=data}))
- end
- else
- return tools.response(fd,status_200,{code=10002,msg="没找到方法!"})
- end
- end
- CMD.api = function(msg_body,fd)
- if msg_body~=nil and msg_body~="" then
- if CMD[msg_body['cmd']] then
- run(CMD[msg_body['cmd']],msg_body['fun'],msg_body['data'],fd)
- end
- end
- end
- CMD.ws_push_msg = function(msg_body)
- CMD['push_msg'].push(msg_body.cmd,msg_body.data)
- end
- --接口end
- s.resp.on_recv = function (source, fd, msg_id, msg_body)
- if CMD[msg_id]~=nil then
- tools.dump(msg_body)
- CMD[msg_id](cjson.decode(msg_body),fd)
- end
- end
- s.init = function()
-
- end
- s.start(...)
|