table_sentence.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <?php
  2. //header('Content-type: application/json; charset=utf8');
  3. require_once "../path.php";
  4. require_once "../sync/function.php";
  5. require_once "../redis/function.php";
  6. require_once "../usent/function.php";
  7. $input = (object) [
  8. "database" => _FILE_DB_SENTENCE_,
  9. "table" => "sentence",
  10. "uuid" => "id",
  11. "sync_id" => ["book","paragraph","begin","end","channal"],
  12. "modify_time" => "modify_time",
  13. "receive_time" => "receive_time",
  14. "where"=>"and (not (channal is null))",
  15. "insert" => [
  16. 'id',
  17. 'block_id',
  18. 'book',
  19. 'paragraph',
  20. 'begin',
  21. 'end',
  22. 'tag',
  23. 'author',
  24. 'editor',
  25. 'text',
  26. 'language',
  27. 'ver',
  28. 'status',
  29. 'channal',
  30. 'parent',
  31. 'strlen',
  32. 'create_time',
  33. 'modify_time',
  34. 'receive_time'
  35. ],
  36. "update" => [
  37. 'block_id',
  38. 'tag',
  39. 'author',
  40. 'editor',
  41. 'text',
  42. 'language',
  43. 'ver',
  44. 'status',
  45. 'channal',
  46. 'parent',
  47. 'strlen',
  48. 'modify_time',
  49. 'receive_time'
  50. ]
  51. ];
  52. $output=array();
  53. $output["error"]=0;
  54. $output["message"]="";
  55. if (isset($_GET["op"])) {
  56. $op = $_GET["op"];
  57. } else if (isset($_POST["op"])) {
  58. $op = $_POST["op"];
  59. } else {
  60. $output["error"]=1;
  61. $output["message"]="无操作码";
  62. echo json_encode($output, JSON_UNESCAPED_UNICODE);
  63. exit;
  64. }
  65. switch ($op) {
  66. case "sync":
  67. $result = do_sync($input);
  68. echo json_encode($result, JSON_UNESCAPED_UNICODE);
  69. break;
  70. case "get":
  71. $result = do_sync($input);
  72. echo json_encode($result, JSON_UNESCAPED_UNICODE);
  73. break;
  74. case "insert":
  75. if (isset($_POST["data"])) {
  76. $data = $_POST["data"];
  77. $arrData = json_decode($data, true);
  78. $Sent=new Sent_DB(redis_connect());
  79. $result = $Sent->insert($arrData);
  80. if($result){
  81. $output["message"]="添加成功";
  82. }
  83. else{
  84. $output["error"]=1;
  85. $output["message"]="添加失败";
  86. }
  87. } else {
  88. $output["error"]=1;
  89. $output["message"]=$Sent->getError();
  90. }
  91. echo json_encode($output, JSON_UNESCAPED_UNICODE);
  92. break;
  93. case "update":
  94. if (isset($_POST["data"])) {
  95. $data = $_POST["data"];
  96. $arrData = json_decode($data, true);
  97. $Sent=new Sent_DB(redis_connect());
  98. $result = $Sent->update($arrData);
  99. if($result==false){
  100. $output["error"]=1;
  101. $output["message"]="修改失败";
  102. }
  103. else{
  104. $output["error"]=0;
  105. $output["message"]="修改成功";
  106. }
  107. } else {
  108. $output["error"]=1;
  109. $output["message"]=$Sent->getError();
  110. }
  111. echo json_encode($output, JSON_UNESCAPED_UNICODE);
  112. break;
  113. }
  114. ?>