entity_view.js 5.7 KB

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