HomeApi.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. const Api = require('../net/Api');
  2. class HomeApi {
  3. /**
  4. * 获取目标用户的建筑
  5. * @param targetUid [long] 目标用户,当前用户就传自己的uid 的值
  6. * @param cityId [long] 城市 id
  7. */
  8. static getUserBuildings(targetUid, cityId, success, fail) {
  9. let url = "/building/getUserBuildings.do";
  10. let data = {
  11. targetUid: targetUid,
  12. cityId: cityId,
  13. };
  14. Api.httpGet(this.setRequestBody(url, data, success, fail));
  15. }
  16. /**
  17. * 升级建筑
  18. * @param buildingId [int] 建筑Id
  19. * @param cityId [int] 城市id
  20. * @param grossIncome [int] 当前总金币数
  21. * @param grossRate [int] 自动收入金额
  22. * @param level [int] 建筑等级
  23. * @param stars [int] 星星数
  24. *
  25. * */
  26. static buildingUpGrade(formmInfoJson, success, fail) {
  27. let url = "/building/upGrade.do";
  28. let data = {
  29. formInfo: formmInfoJson,
  30. };
  31. Api.httpPost(this.setRequestBody(url, data, success, fail));
  32. }
  33. /**
  34. * 获取首页好友列表
  35. * */
  36. static getFriends(success, fail) {
  37. let url = "/friend/getIndexList.do";
  38. Api.httpGet(this.setRequestBody(url, {}, success, fail));
  39. }
  40. /**
  41. * 主界面艺人管理列表
  42. */
  43. static getFriendManageList(success, fail) {
  44. let url = "/friend/getManageList.do";
  45. Api.httpGet(this.setRequestBody(url, {}, success, fail));
  46. }
  47. /**
  48. * 上报接口
  49. * @param {*} reportFormInfo {"grossIncome":1000,"grossRate":10000,"stars":1}
  50. * @param {*} success
  51. * @param {*} fail
  52. */
  53. static userReportGross(reportFormInfo, success, fail) {
  54. let url = "/building/report.do";
  55. let data = {
  56. reportFormInfo: reportFormInfo,
  57. };
  58. Api.httpPost(this.setRequestBody(url, data, success, fail));
  59. }
  60. /**
  61. * 获取好友艺人列表
  62. * @param {int} fid 好友uid
  63. * @param {*} success
  64. * @param {*} fail
  65. */
  66. static friendGetArtists(fid, success, fail) {
  67. let url = "/friend/getArtists.do";
  68. let data = {
  69. fid: fid,
  70. };
  71. Api.httpGet(this.setRequestBody(url, data, success, fail));
  72. }
  73. /**
  74. * 获取好友艺人列表
  75. * @param {int} buildingId 建筑对应的 buildingId
  76. * @param {*} success
  77. * @param {*} fail
  78. */
  79. static friendGetArtistsByBuildingId(targetUid, buildingId, success, fail) {
  80. let url = "/friend/getArtists4Station.do";
  81. let data = {
  82. targetUid: targetUid,
  83. buildingId: buildingId,
  84. };
  85. Api.httpGet(this.setRequestBody(url, data, success, fail));
  86. }
  87. /**
  88. * 艺人入驻
  89. * @param {*} formmInfoJson
  90. * @param {*} success
  91. * @param {*} fail
  92. */
  93. static friendStation(formmInfoJson, success, fail) {
  94. let url = "/friend/station.do";
  95. let data = {
  96. form: formmInfoJson,
  97. };
  98. Api.httpPost(this.setRequestBody(url, data, success, fail));
  99. }
  100. /**
  101. * 艺人的驱赶召回
  102. * @param {*} formmInfoJson
  103. * @param {*} success
  104. * @param {*} fail
  105. */
  106. static friendExpelRecall(artistUid, success, fail) {
  107. let url = "/friend/expelRecall.do";
  108. let data = {
  109. artistUid: artistUid,
  110. };
  111. Api.httpPost(this.setRequestBody(url, data, success, fail));
  112. }
  113. /**
  114. * 获取用户对应建筑入驻的艺人列表
  115. * @param {*} targetUid 目标用户(是谁的家园,目标用户就是谁)
  116. * @param {*} buildingId 建筑id
  117. * @param {*} success
  118. * @param {*} fail
  119. */
  120. static friendGetArtistsInBuilding(targetUid, buildingId, success, fail) {
  121. let url = "/friend/getArtistsInBuilding.do";
  122. let data = {
  123. targetUid: targetUid,
  124. buildingId: buildingId
  125. };
  126. Api.httpGet(this.setRequestBody(url, data, success, fail));
  127. }
  128. /**
  129. * 入驻艺人收益
  130. * @param {*} formmInfoJson
  131. * @param {*} success
  132. * @param {*} fail
  133. */
  134. static friendGetBenefit(artistUid, success, fail) {
  135. let url = "/friend/getBenefit.do";
  136. let data = {
  137. artistUid: artistUid,
  138. };
  139. Api.httpPost(this.setRequestBody(url, data, success, fail));
  140. }
  141. /**
  142. * 举报艺人
  143. * @param {*} formmInfoJson
  144. * @param {*} success
  145. * @param {*} fail
  146. */
  147. static friendReportArtist(artistUid, success, fail) {
  148. let url = "/friend/reportArtist.do";
  149. let data = {
  150. artistUid: artistUid,
  151. };
  152. Api.httpPost(this.setRequestBody(url, data, success, fail));
  153. }
  154. // 生成一个 RequestBody, 总是要写重复代码, 太恶心了
  155. static setRequestBody(url, data, success, fail) {
  156. let requestBody = {
  157. url: url,
  158. data: data,
  159. success: success,
  160. fail: fail,
  161. complete: () => {
  162. }
  163. };
  164. return requestBody;
  165. }
  166. }
  167. module.exports = HomeApi;