AppController.java 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. package com.ruoyi.demo.controller;
  2. import cn.dev33.satoken.annotation.SaCheckPermission;
  3. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  4. import com.github.pagehelper.PageInfo;
  5. import com.ruoyi.common.annotation.Log;
  6. import com.ruoyi.common.core.domain.R;
  7. import com.ruoyi.common.core.validate.AddGroup;
  8. import com.ruoyi.common.core.validate.EditGroup;
  9. import com.ruoyi.common.core.validate.QueryGroup;
  10. import com.ruoyi.common.enums.BusinessType;
  11. import com.ruoyi.common.utils.poi.ExcelUtil;
  12. import com.ruoyi.demo.entity.App;
  13. import com.ruoyi.demo.entity.Commercial;
  14. import com.ruoyi.demo.entity.vo.AppVo;
  15. import com.ruoyi.demo.entity.vo.CommercialVo;
  16. import com.ruoyi.demo.service.AppService;
  17. import org.springframework.beans.factory.annotation.Autowired;
  18. import org.springframework.validation.annotation.Validated;
  19. import org.springframework.web.bind.annotation.*;
  20. import javax.servlet.http.HttpServletResponse;
  21. import javax.validation.constraints.NotBlank;
  22. import java.util.HashMap;
  23. import java.util.List;
  24. /**
  25. * app管理
  26. */
  27. @RestController
  28. @RequestMapping("/app")
  29. public class AppController {
  30. @Autowired
  31. AppService appService;
  32. /**
  33. * 添加小程序
  34. * @param appVo app信息接收体
  35. * @return
  36. */
  37. @SaCheckPermission("szzs:app:add")
  38. @PostMapping("/addApp")
  39. public R addApp(@RequestBody @Validated(value={AddGroup.class}) AppVo appVo){
  40. R r = appService.addApp(appVo);
  41. return r;
  42. }
  43. /**
  44. * 删除小程序
  45. * @param appKeys appKey
  46. * @return
  47. */
  48. @SaCheckPermission("szzs:app:delete")
  49. @DeleteMapping("/deleteApp")
  50. public R deleteApp(String[] appKeys){
  51. appService.deleteApp(appKeys);
  52. return R.ok();
  53. }
  54. /**
  55. * 获取商户下的app列表
  56. * @param appVo app信息接收体
  57. * @return
  58. */
  59. @SaCheckPermission("szzs:app:other")
  60. @GetMapping("/getAppListByCommercialId")
  61. public R getAppListByCommercialId(AppVo appVo){
  62. Page<App> appListByCommercialId = appService.getAppListByCommercialId(appVo);
  63. return R.ok(appListByCommercialId);
  64. }
  65. /**
  66. * 获取小程序详细信息
  67. * @param appVo app信息接收体
  68. * @return
  69. */
  70. @SaCheckPermission("szzs:app:query")
  71. @GetMapping("/getApp")
  72. public R getApp(@Validated(value = {QueryGroup.class}) AppVo appVo){
  73. App app = appService.getApp(appVo);
  74. return R.ok(app);
  75. }
  76. /**
  77. * 修改小程序信息
  78. * @param appVo app信息接收体
  79. * @return
  80. */
  81. @SaCheckPermission("szzs:app:update")
  82. @PutMapping("/updateApp")
  83. @Log(title = "小程序", businessType = BusinessType.UPDATE)
  84. public R updateApp(@RequestBody @Validated(value={EditGroup.class})AppVo appVo){
  85. R r = appService.updateApp(appVo);
  86. return r;
  87. }
  88. /**
  89. * 测试回调地址
  90. * @param callBack 回调地址
  91. * @return
  92. */
  93. @GetMapping("/testCallBack")
  94. public R testCallBack(@NotBlank String callBack){
  95. appService.testCallBack(callBack);
  96. return R.ok();
  97. }
  98. /**
  99. * 获取小程序列表
  100. * @param appVo app信息接收体
  101. * @return
  102. */
  103. @SaCheckPermission("szzs:app:list")
  104. @GetMapping("/getAppList")
  105. public R getAppList(AppVo appVo){
  106. Page<App> appList = appService.getAppList(appVo);
  107. return R.ok(appList);
  108. }
  109. /**
  110. * 获取商户列表(下拉框)
  111. * @return
  112. */
  113. @SaCheckPermission("szzs:app:other")
  114. @GetMapping("/getCommercialList")
  115. public R getCommercialList(){
  116. List<Commercial> commercialList = appService.getCommercialList();
  117. return R.ok(commercialList);
  118. }
  119. /**
  120. * 禁用小程序
  121. * @param appKey
  122. * @return
  123. */
  124. @SaCheckPermission("szzs:app:update")
  125. @PutMapping("/stopApp/{appkey}")
  126. @Log(title = "小程序", businessType = BusinessType.STOP)
  127. public R stopApp(@PathVariable("appkey") String appKey){
  128. R r = appService.stopApp(appKey);
  129. return r;
  130. }
  131. /**
  132. * 恢复小程序
  133. * @param appKey
  134. * @return
  135. */
  136. @SaCheckPermission("szzs:app:update")
  137. @PutMapping("/recoverApp/{appkey}")
  138. @Log(title = "小程序", businessType = BusinessType.RECOVER)
  139. public R recoverApp(@PathVariable("appkey") String appKey){
  140. R r = appService.recoverApp(appKey);
  141. return r;
  142. }
  143. /**
  144. * 导出小程序列表
  145. *
  146. * @param appVo body参数
  147. * @return
  148. */
  149. @Log(title = "小程序列表", businessType = BusinessType.EXPORT)
  150. @SaCheckPermission("szzs:app:export")
  151. @PostMapping("/export")
  152. public void export(@RequestBody AppVo appVo, HttpServletResponse response) {
  153. Page<App> appList = appService.getAppList(appVo);
  154. ExcelUtil.exportExcel(appList.getRecords(),"小程序列表", App.class, response);
  155. }
  156. }