init.lua 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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 task_material_queue_queue = require "task_material_queue_queue"
  33. local video_product = require "video_product"
  34. local origin_data = require "origin_data"
  35. local video_product_material = require "video_product_material"
  36. local aweme_auth_list = require "aweme_auth_list"
  37. local checks = require "checks"
  38. local fq_mf_book = require "fq_mf_book"
  39. local tg_main_price_template = require "tg_main_price_template"
  40. local ad_convert_type = require "ad_convert_type"
  41. local other_book = require "other_book"
  42. local platform_shared = require "platform_shared"
  43. local status_200 = 200
  44. local CMD = {
  45. }
  46. CMD["tg_temp_app"] = tg_temp_app;
  47. CMD["tg_platform"] = tg_platform;
  48. CMD["tg_zhanghu"] = tg_zhanghu;
  49. CMD["tg_max_zhuanhua"] = tg_max_zhuanhua;
  50. CMD["tg_app"] = tg_app;
  51. CMD["user"] = user;
  52. CMD["tg_main"] = tg_main;
  53. CMD["db_filter_config"] = db_filter_config;
  54. CMD["push_msg"] = push_msg;
  55. CMD["filter_task"] = filter_task;
  56. CMD["fq_book"] = fq_book;
  57. CMD["book_black_list"] = book_black_list;
  58. CMD["video_titles"] = video_titles;
  59. CMD["pull_data_config"] = pull_data_config;
  60. CMD["pull_data_status"] = pull_data_status;
  61. CMD["video_applet_product"] = video_applet_product;
  62. CMD["filter_data"] = filter_data;
  63. CMD["video_material"] = video_material;
  64. CMD["no_filter_origin"] = no_filter_origin;
  65. CMD["origin_video_titles"] = origin_video_titles;
  66. CMD["promotion_audit_suggestions"] = promotion_audit_suggestions;
  67. CMD["tg_butler"] = tg_butler;
  68. CMD["tg_mini_program_platform"] = tg_mini_program_platform;
  69. CMD["task_material_queue_queue"] = task_material_queue_queue;
  70. CMD["video_product"] = video_product;
  71. CMD["origin_data"] = origin_data;
  72. CMD["video_product_material"] = video_product_material;
  73. CMD["aweme_auth_list"] = aweme_auth_list;
  74. CMD["checks"] = checks;
  75. CMD["fq_mf_book"] = fq_mf_book;
  76. CMD["tg_main_price_template"] = tg_main_price_template;
  77. CMD["ad_convert_type"] = ad_convert_type;
  78. CMD["other_book"] = other_book;
  79. CMD["platform_shared"] = platform_shared;
  80. function run(target,fun,msg_body,fd)
  81. if target~=nil and fun~=nil and target[fun]~=nil then
  82. local isok,data,total = target[fun](msg_body)
  83. if isok then
  84. if data~=nil then
  85. if total~=nil then
  86. tools.response(fd,status_200,cjson.encode({code=10000,data=data,total=total}))
  87. else
  88. tools.response(fd,status_200,cjson.encode({code=10000,data=data}))
  89. end
  90. else
  91. tools.response(fd,status_200,cjson.encode({code=10000,msg="OK!"}))
  92. end
  93. else
  94. tools.response(fd,status_200,cjson.encode({code=10001,msg=data}))
  95. end
  96. else
  97. return tools.response(fd,status_200,{code=10002,msg="没找到方法!"})
  98. end
  99. end
  100. CMD.api = function(msg_body,fd)
  101. if msg_body~=nil and msg_body~="" then
  102. if CMD[msg_body['cmd']] then
  103. run(CMD[msg_body['cmd']],msg_body['fun'],msg_body['data'],fd)
  104. end
  105. end
  106. end
  107. CMD.ws_push_msg = function(msg_body)
  108. CMD['push_msg'].push(msg_body.cmd,msg_body.data)
  109. end
  110. --接口end
  111. s.resp.on_recv = function (source, fd, msg_id, msg_body)
  112. if CMD[msg_id]~=nil then
  113. tools.dump(msg_body)
  114. CMD[msg_id](cjson.decode(msg_body),fd)
  115. end
  116. end
  117. s.init = function()
  118. end
  119. s.start(...)