entity_document.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. var service_base_path = '../jaxrs/document';
  2. function data_get_document( ) {
  3. var service_url = $("#get_service_url").val();
  4. var query_url = service_base_path + "/" + service_url;
  5. //获取用户所填写的参数
  6. var id = $("#id").val();
  7. var appId = $("#appId").val();
  8. var catagoryId = $("#catagoryId").val();
  9. var last_id = $("#last_id").val();
  10. var count = $("#count").val();
  11. //根据参数组织URL
  12. if( "{id}" == service_url ){
  13. query_url = query_url.replace( "{id}",id );
  14. if( id == null || id == "" || id == undefined){
  15. alert("请填写ID");return false;
  16. }
  17. }else if( "list/catagory/{catagoryId}" == service_url ){
  18. query_url = query_url.replace( "{catagoryId}",catagoryId );
  19. if( appId == null || appId == "" || appId == undefined){
  20. alert("请填写appId");return false;
  21. }
  22. }
  23. alert("GET:"+query_url);
  24. $.ajax({
  25. type : 'get',
  26. dataType : 'json',
  27. contentType : 'application/json; charset=utf-8',
  28. url : query_url,
  29. xhrFields : {
  30. 'withCredentials' : true
  31. },
  32. crossDomain : true
  33. }).done(function(json) {
  34. $('#result').html( JSON.stringify( json, null, 4) );
  35. }).fail(function(json) {
  36. failure(json);
  37. });
  38. }
  39. function data_put_document( id ) {
  40. var service_url = $("#put_service_url").val();
  41. var query_url = service_base_path + "/" + service_url;
  42. //获取用户所填写的参数
  43. var id = $("#id").val();
  44. var appId = $("#appId").val();
  45. var catagoryId = $("#catagoryId").val();
  46. var last_id = $("#last_id").val();
  47. var count = $("#count").val();
  48. var status = $("#status").val();
  49. //根据参数组织URL
  50. if( "{id}" == service_url ){
  51. query_url = query_url.replace( "{id}",id );
  52. if( id == null || id == "" || id == undefined){
  53. alert("请填写ID");return false;
  54. }
  55. }else if( "publish/{id}" == service_url ){
  56. query_url = query_url.replace( "{id}",id );
  57. if( id == null || id == "" || id == undefined){
  58. alert("请填写ID");return false;
  59. }
  60. }else if( "publish/{id}/cancel" == service_url ){
  61. query_url = query_url.replace( "{id}",id );
  62. if( id == null || id == "" || id == undefined){
  63. alert("请填写ID");return false;
  64. }
  65. }else if( "achive/{id}" == service_url ){
  66. query_url = query_url.replace( "{id}",id );
  67. if( id == null || id == "" || id == undefined){
  68. alert("请填写ID");return false;
  69. }
  70. }else if( "draft/{id}" == service_url ){
  71. query_url = query_url.replace( "{id}",id );
  72. if( id == null || id == "" || id == undefined){
  73. alert("请填写ID");return false;
  74. }
  75. }else if( "draft/list/{id}/next/{count}" == service_url ){
  76. query_url = query_url.replace( "{id}",last_id );
  77. query_url = query_url.replace( "{count}",count );
  78. if( last_id == null || last_id == "" || last_id == undefined){
  79. alert("请填写last_id");return false;
  80. }
  81. if( count == null || count == "" || count == undefined){
  82. alert("请填写count");return false;
  83. }
  84. }else if( "draft/list/{id}/prev/{count}" == service_url ){
  85. query_url = query_url.replace( "{id}",last_id );
  86. query_url = query_url.replace( "{count}",count );
  87. if( last_id == null || last_id == "" || last_id == undefined){
  88. alert("请填写last_id");return false;
  89. }
  90. if( count == null || count == "" || count == undefined){
  91. alert("请填写count");return false;
  92. }
  93. }else if( "filter/list/{id}/next/{count}" == service_url ){
  94. query_url = query_url.replace( "{id}",last_id );
  95. query_url = query_url.replace( "{count}",count );
  96. query_url = query_url.replace( "{status}",status );
  97. if( last_id == null || last_id == "" || last_id == undefined){
  98. alert("请填写last_id");return false;
  99. }
  100. if( count == null || count == "" || count == undefined){
  101. alert("请填写count");return false;
  102. }
  103. }else if( "filter/list/{id}/prev/{count}" == service_url ){
  104. query_url = query_url.replace( "{id}",last_id );
  105. query_url = query_url.replace( "{count}",count );
  106. query_url = query_url.replace( "{status}",status );
  107. if( last_id == null || last_id == "" || last_id == undefined){
  108. alert("请填写last_id");return false;
  109. }
  110. if( count == null || count == "" || count == undefined){
  111. alert("请填写count");return false;
  112. }
  113. }
  114. alert("PUT:"+query_url);
  115. $.ajax({
  116. type : 'put',
  117. dataType : 'json',
  118. contentType : 'application/json; charset=utf-8',
  119. url : query_url,
  120. xhrFields : {
  121. 'withCredentials' : true
  122. },
  123. data : JSON.stringify($.parseJSON($('#content').val())),
  124. crossDomain : true
  125. }).done(function(json) {
  126. $('#result').html(JSON.stringify(json.data, null, 4));
  127. });
  128. }
  129. function data_post_document( id ) {
  130. $.ajax({
  131. type : 'post',
  132. dataType : 'json',
  133. contentType : 'application/json; charset=utf-8',
  134. url : service_base_path ,
  135. xhrFields : {
  136. 'withCredentials' : true
  137. },
  138. data : JSON.stringify($.parseJSON($('#content').val())),
  139. crossDomain : true
  140. }).done(function(json) {
  141. $('#result').html(JSON.stringify(json.data, null, 4));
  142. });
  143. }
  144. function data_delete_document( id ) {
  145. if( id == null || id == undefined || id == "" ){
  146. alert("请输入ID");
  147. return false;
  148. }
  149. $.ajax({
  150. type : 'delete',
  151. dataType : 'json',
  152. contentType : 'application/json; charset=utf-8',
  153. url : service_base_path + "/" + id ,
  154. xhrFields : {
  155. 'withCredentials' : true
  156. },
  157. crossDomain : true
  158. }).done(function(json) {
  159. $('#result').html(JSON.stringify(json.data, null, 4));
  160. });
  161. }