index.js 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. 'use strict';
  2. const repository = require('./repository.js');
  3. exports.main = async function main(event, context) {
  4. const { page, action, data } = event;
  5. switch (page) {
  6. // 团购页面
  7. case 'tuangou':
  8. if (action === 'findGroupBuyPage') {
  9. // 分页查询团购数据
  10. return await repository.groupbuy.findGroupBuyPage(data)
  11. } else if (action === 'addGroupBuy') {
  12. // 新增团购
  13. return await repository.groupbuy.addGroupBuy(data)
  14. } else if (action === 'updateGroupBuy') {
  15. // 编辑团购(根据Id)
  16. return await repository.groupbuy.updateGroupBuy(data)
  17. } else if (action === 'deleteGroupBuy') {
  18. // 删除团购(根据Id)
  19. return await repository.groupbuy.deleteGroupBuy(data)
  20. } else if (action === 'findguigeBytuangouId') {
  21. // 根据团购Id查询规格
  22. return await repository.groupbuy.findguigeBytuangouId(data)
  23. } else if (action === 'addguige') {
  24. // 新增商品规格
  25. return await repository.groupbuy.addguige(data)
  26. } else if (action === 'updateguigeById') {
  27. // 编辑商品规格
  28. return await repository.groupbuy.updateguigeById(data)
  29. } else if (action === 'deleteguigeById') {
  30. // 根据Id删除商品规格
  31. return await repository.groupbuy.deleteguigeById(data)
  32. } else {
  33. throw new Error('接口未实现!')
  34. }
  35. // 异常行为预警页面
  36. case 'yichangxingweiyujing':
  37. if (action === 'addBehaviorAlarm') {
  38. // 新增异常行为告警
  39. return await repository.abnormal.addBehaviorAlarm(data)
  40. } else if (action === 'deleteBehaviorAlarm') {
  41. // 删除异常行为告警
  42. return await repository.abnormal.deleteBehaviorAlarm(data)
  43. } else if (action === 'updateBehaviorAlarm') {
  44. // 编辑异常行为告警
  45. return await repository.abnormal.updateBehaviorAlarm(data)
  46. } else if (action === 'findBehaviorAlarmPage') {
  47. // 条件分页查询
  48. return await repository.abnormal.findBehaviorAlarmPage(data)
  49. } else if (action === 'findBehaviorAlarmById') {
  50. // 根据Id查询
  51. return await repository.abnormal.findBehaviorAlarmById(data)
  52. } else {
  53. throw new Error('接口未实现!')
  54. }
  55. // 售后管理页面
  56. case 'shouhouguanli':
  57. if (action === 'findSchoolAll') {
  58. // 查询所有学校
  59. return await repository.aftersales.findSchoolAll(data)
  60. } else if (action === 'addAfterService') {
  61. // 新增售后
  62. return await repository.aftersales.addAfterService(data)
  63. } else if (action === 'deleteAfterService') {
  64. // 删除售后
  65. return await repository.aftersales.deleteAfterService(data)
  66. } else if (action === 'updateAfterService') {
  67. // 编辑异常行为告警
  68. return await repository.aftersales.updateAfterService(data)
  69. } else if (action === 'findAfterServicePage') {
  70. // 条件分页查询
  71. return await repository.aftersales.findAfterServicePage(data)
  72. } else if (action === 'findAfterServiceById') {
  73. // 根据Id查询
  74. return await repository.aftersales.findAfterServiceById(data)
  75. } else {
  76. throw new Error('接口未实现!')
  77. }
  78. // 下载量统计页面
  79. case 'xiazailiangtongji':
  80. if (action === 'findSchoolAll') {
  81. // 查询所有学校
  82. return await repository.aftersales.findSchoolAll(data)
  83. } else if (action === 'addMicrocode') {
  84. // 新增
  85. return await repository.download.addMicrocode(data)
  86. } else if (action === 'deleteMicrocode') {
  87. // 删除
  88. return await repository.download.deleteMicrocode(data)
  89. } else if (action === 'updateMicrocode') {
  90. // 编辑
  91. return await repository.download.updateMicrocode(data)
  92. } else if (action === 'findMicrocodePage') {
  93. // 条件分页查询
  94. return await repository.download.findMicrocodePage(data)
  95. } else if (action === 'findMicrocodeById') {
  96. // 根据Id查询
  97. return await repository.download.findMicrocodeById(data)
  98. } else {
  99. throw new Error('接口未实现!')
  100. }
  101. // 订单管理页面
  102. case 'dingdanguanli':
  103. if (action === 'addOrder') {
  104. // 新增
  105. return await repository.order.addOrder(data)
  106. } else if (action === 'deleteOrder') {
  107. // 删除
  108. return await repository.order.deleteOrder(data)
  109. } else if (action === 'updateOrder') {
  110. // 编辑
  111. return await repository.order.updateOrder(data)
  112. } else if (action === 'findOrderPage') {
  113. // 条件
  114. return await repository.order.findOrderPage(data)
  115. } else if (action === 'findOrderById') {
  116. // 根据Id查询
  117. return await repository.order.findOrderById(data)
  118. } else {
  119. throw new Error('接口未实现!')
  120. }
  121. // 用户行为统计页面
  122. case 'userstats':
  123. if (action === 'addMmonitorBehavior') {
  124. // 新增
  125. return await repository.userstats.addMmonitorBehavior(data)
  126. } else if (action === 'deleteMmonitorBehavior') {
  127. // 删除
  128. return await repository.userstats.deleteMmonitorBehavior(data)
  129. } else if (action === 'updateMmonitorBehavior') {
  130. // 编辑
  131. return await repository.userstats.updateMmonitorBehavior(data)
  132. } else if (action === 'findMmonitorBehaviorPage') {
  133. // 条件
  134. return await repository.userstats.findMmonitorBehaviorPage(data)
  135. } else if (action === 'findMmonitorBehaviorById') {
  136. // 根据Id查询
  137. return await repository.userstats.findMmonitorBehaviorById(data)
  138. } else {
  139. throw new Error('接口未实现!')
  140. }
  141. // 付款统计页面接口
  142. case 'payment':
  143. if (action === 'findPaymentPage') {
  144. // 按照班级分组
  145. return await repository.payment.findPaymentPage(data)
  146. } else if (action === 'findPaymentPageBySchool') {
  147. // 按照学校分组
  148. return await repository.payment.findPaymentPageBySchool(data)
  149. } else {
  150. throw new Error('接口未实现!')
  151. }
  152. // 首页接口
  153. case 'home':
  154. if (action === 'findCountAndTotal') {
  155. // 今日,今年下单付款统计
  156. return await repository.home.findCountAndTotal()
  157. } else if (action === 'findBehaviorAlarm') {
  158. // 查询异常行为预警
  159. return await repository.home.findBehaviorAlarm()
  160. } else if (action === 'findOrderCountByMonth') {
  161. // 按月份统计下单量
  162. return await repository.home.findOrderCountByMonth(data)
  163. } else if (action === 'findOrderCountByDay') {
  164. // 按天统计下单量
  165. return await repository.home.findOrderCountByDay(data)
  166. } else if (action === 'findFileCount') {
  167. // 按月份分组查询课件上传统计
  168. return await repository.home.findFileCount(data)
  169. } else {
  170. throw new Error('接口未实现!')
  171. }
  172. //推荐
  173. case 'recommende':
  174. if (action === 'findFileRangee') {
  175. return await repository.recommend.findFileRangee(data)
  176. } else {
  177. throw new Error('接口未实现!')
  178. }
  179. default:
  180. throw new Error('未知的操作类型')
  181. }
  182. }