init.lua 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. local skynet = require "skynet"
  2. local s = require "service"
  3. local tools = require "tools"
  4. local cjson = require "cjson"
  5. local mysql = require "skynet.db.mysql"
  6. local back_response = require "back_response"
  7. local urllib = require "http.url"
  8. local crypt = require "skynet.crypt"
  9. local tg_temp_app = require "tg_temp_app"
  10. local tg_platform = require "tg_platform"
  11. local tg_zhanghu = require "tg_zhanghu"
  12. local tg_max_zhuanhua = require "tg_max_zhuanhua"
  13. local user = require "user"
  14. local tg_app = require "tg_app"
  15. local tg_main = require "tg_main"
  16. local db_filter_config = require "db_filter_config"
  17. local push_msg = require "push_msg"
  18. local filter_task = require "filter_task"
  19. local fq_book = require "fq_book"
  20. local book_black_list = require "book_black_list"
  21. local video_titles = require "video_titles"
  22. local pull_data_config = require "pull_data_config"
  23. local pull_data_status = require "pull_data_status"
  24. local video_applet_product = require "video_applet_product"
  25. local filter_data = require "filter_data"
  26. local video_material = require "video_material"
  27. local no_filter_origin = require "no_filter_origin"
  28. local origin_video_titles = require "origin_video_titles"
  29. local promotion_audit_suggestions = require "promotion_audit_suggestions"
  30. local tg_butler = require "tg_butler"
  31. local tg_mini_program_platform = require "tg_mini_program_platform"
  32. local status_200 = 200
  33. local CMD = {
  34. }
  35. CMD["tg_temp_app"] = tg_temp_app;
  36. CMD["tg_platform"] = tg_platform;
  37. CMD["tg_zhanghu"] = tg_zhanghu;
  38. CMD["tg_max_zhuanhua"] = tg_max_zhuanhua;
  39. CMD["tg_app"] = tg_app;
  40. CMD["user"] = user;
  41. CMD["tg_main"] = tg_main;
  42. CMD["db_filter_config"] = db_filter_config;
  43. CMD["push_msg"] = push_msg;
  44. CMD["filter_task"] = filter_task;
  45. CMD["fq_book"] = fq_book;
  46. CMD["book_black_list"] = book_black_list;
  47. CMD["video_titles"] = video_titles;
  48. CMD["pull_data_config"] = pull_data_config;
  49. CMD["pull_data_status"] = pull_data_status;
  50. CMD["video_applet_product"] = video_applet_product;
  51. CMD["filter_data"] = filter_data;
  52. CMD["video_material"] = video_material;
  53. CMD["no_filter_origin"] = no_filter_origin;
  54. CMD["origin_video_titles"] = origin_video_titles;
  55. CMD["promotion_audit_suggestions"] = promotion_audit_suggestions;
  56. CMD["tg_butler"] = tg_butler;
  57. CMD["tg_mini_program_platform"] = tg_mini_program_platform;
  58. function run(target,fun,msg_body,fd)
  59. if target~=nil and fun~=nil and target[fun]~=nil then
  60. local isok,data,total = target[fun](msg_body)
  61. if isok then
  62. if data~=nil then
  63. if total~=nil then
  64. tools.response(fd,status_200,cjson.encode({code=10000,data=data,total=total}))
  65. else
  66. tools.response(fd,status_200,cjson.encode({code=10000,data=data}))
  67. end
  68. else
  69. tools.response(fd,status_200,cjson.encode({code=10000,msg="OK!"}))
  70. end
  71. else
  72. tools.response(fd,status_200,cjson.encode({code=10001,msg=data}))
  73. end
  74. else
  75. return tools.response(fd,status_200,{code=10002,msg="没找到方法!"})
  76. end
  77. end
  78. CMD.api = function(msg_body,fd)
  79. if msg_body~=nil and msg_body~="" then
  80. if CMD[msg_body['cmd']] then
  81. run(CMD[msg_body['cmd']],msg_body['fun'],msg_body['data'],fd)
  82. end
  83. end
  84. end
  85. CMD.ws_push_msg = function(msg_body)
  86. CMD['push_msg'].push(msg_body.cmd,msg_body.data)
  87. end
  88. --接口end
  89. s.resp.on_recv = function (source, fd, msg_id, msg_body)
  90. if CMD[msg_id]~=nil then
  91. tools.dump(msg_body)
  92. CMD[msg_id](cjson.decode(msg_body),fd)
  93. end
  94. end
  95. s.init = function()
  96. end
  97. s.start(...)