table_sentence.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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 ( channal IS NOT 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_count":
  67. $result = do_sync($input);
  68. echo json_encode($result, JSON_UNESCAPED_UNICODE);
  69. break;
  70. case "sync":
  71. $result = do_sync($input);
  72. echo json_encode($result, JSON_UNESCAPED_UNICODE);
  73. break;
  74. case "get":
  75. $result = do_sync($input);
  76. echo json_encode($result, JSON_UNESCAPED_UNICODE);
  77. break;
  78. case "insert":
  79. if (isset($_POST["data"])) {
  80. $data = $_POST["data"];
  81. $arrData = json_decode($data, true);
  82. $Sent=new Sent_DB(redis_connect());
  83. $result = $Sent->insert($arrData);
  84. if($result){
  85. $output["message"]="添加成功";
  86. }
  87. else{
  88. $output["error"]=1;
  89. $output["message"]="添加失败";
  90. }
  91. } else {
  92. $output["error"]=1;
  93. $output["message"]=$Sent->getError();
  94. }
  95. echo json_encode($output, JSON_UNESCAPED_UNICODE);
  96. break;
  97. case "update":
  98. if (isset($_POST["data"])) {
  99. $data = $_POST["data"];
  100. $arrData = json_decode($data, true);
  101. $Sent=new Sent_DB(redis_connect());
  102. $result = $Sent->update($arrData);
  103. if($result==false){
  104. $output["error"]=1;
  105. $output["message"]="修改失败";
  106. }
  107. else{
  108. $output["error"]=0;
  109. $output["message"]="修改成功";
  110. }
  111. } else {
  112. $output["error"]=1;
  113. $output["message"]=$Sent->getError();
  114. }
  115. echo json_encode($output, JSON_UNESCAPED_UNICODE);
  116. break;
  117. }
  118. ?>