Version.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Niucloud-admin 企业快速开发的saas管理平台
  4. // +----------------------------------------------------------------------
  5. // | 官方网址:https://www.niucloud.com
  6. // +----------------------------------------------------------------------
  7. // | niucloud团队 版权所有 开源版本可自由商用
  8. // +----------------------------------------------------------------------
  9. // | Author: Niucloud Team
  10. // +----------------------------------------------------------------------
  11. namespace app\adminapi\controller\applet;
  12. use app\service\admin\applet\AppletVersionService;
  13. use core\base\BaseAdminController;
  14. use Exception;
  15. use think\Response;
  16. /**
  17. * 小程序版本管理控制器
  18. */
  19. class Version extends BaseAdminController
  20. {
  21. /**
  22. * 列表
  23. * @return Response
  24. */
  25. public function lists()
  26. {
  27. $data = $this->request->params([
  28. ]);
  29. return success((new AppletVersionService())->getPage($data));
  30. }
  31. /**
  32. * 详情
  33. * @param int $id
  34. * @return Response
  35. */
  36. public function info(int $id)
  37. {
  38. return success((new AppletVersionService())->getInfo($id));
  39. }
  40. /**
  41. * 添加
  42. * @return Response
  43. */
  44. public function add()
  45. {
  46. $data = $this->request->params([
  47. ['type', ''],
  48. ['desc', ''],
  49. ['status', ''],
  50. ['path', ''],
  51. ['version', ''],
  52. ]);
  53. $id = (new AppletVersionService())->add($data);
  54. return success('ADD_SUCCESS');
  55. }
  56. /**
  57. * 编辑
  58. * @param int $id
  59. * @return Response
  60. */
  61. public function edit(int $id)
  62. {
  63. $data = $this->request->params([
  64. ['desc', ''],
  65. ['status', ''],
  66. ['path', ''],
  67. ['version', ''],
  68. ]);
  69. (new AppletVersionService())->edit($id, $data);
  70. return success('EDIT_SUCCESS');
  71. }
  72. /**
  73. * 删除
  74. * @param int $id
  75. * @return Response
  76. */
  77. public function del(int $id)
  78. {
  79. (new AppletVersionService())->del($id);
  80. return success('DELETE_SUCCESS');
  81. }
  82. /**
  83. * 设置状态
  84. * @param int $id
  85. * @param $status
  86. * @return Response
  87. */
  88. public function setStatus(int $id, $status)
  89. {
  90. (new AppletVersionService())->setStatus($id, $status);
  91. return success('EDIT_SUCCESS');
  92. }
  93. /**
  94. * 小程序包上传
  95. * @return Response
  96. * @throws Exception
  97. */
  98. public function upload()
  99. {
  100. $data = $this->request->params([
  101. ['file', 'file'],
  102. ]);
  103. return success(data: (new AppletVersionService())->upload($data['file']));
  104. }
  105. }