Attachment.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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\sys;
  12. use app\dict\sys\FileDict;
  13. use app\service\admin\sys\AttachmentService;
  14. use core\base\BaseAdminController;
  15. use think\Response;
  16. class Attachment extends BaseAdminController
  17. {
  18. /**
  19. * 附件列表
  20. */
  21. public function lists()
  22. {
  23. $data = $this->request->params([
  24. ['att_type', ''],
  25. ['cate_id', 0],
  26. ['real_name', ''],
  27. ['page', 0],
  28. ['limit', 0],
  29. ]);
  30. return success((new AttachmentService())->getPage($data));
  31. }
  32. /**
  33. * 删除附件
  34. * @param $att_id
  35. * @return Response
  36. */
  37. // public function del($att_id)
  38. // {
  39. // return success((new AttachmentService())->del($att_id));
  40. // }
  41. /**
  42. * 批量删除
  43. * @return Response
  44. */
  45. public function batchDel()
  46. {
  47. $data = $this->request->params([
  48. ['att_ids', []],
  49. ]);
  50. (new AttachmentService())->delAll($data['att_ids']);
  51. return success('DELETE_SUCCESS');
  52. }
  53. /**
  54. * 新增附件分组
  55. * @return Response
  56. */
  57. public function addCategory()
  58. {
  59. $data = $this->request->params([
  60. ['type', FileDict::IMAGE],
  61. ['name', '']
  62. ]);
  63. $this->validate($data, 'app\validate\sys\AttachmentCategory.add');
  64. (new AttachmentService())->addCategory($data);
  65. return success('ADD_SUCCESS');
  66. }
  67. /**
  68. * 附件分组列表
  69. */
  70. public function categoryLists()
  71. {
  72. $data = $this->request->params([
  73. ['type', ''],
  74. ['name', ''],
  75. ]);
  76. return success((new AttachmentService())->getCategoryList($data));
  77. }
  78. /**
  79. * 更新附件分组
  80. * @return Response
  81. */
  82. public function editCategory($id)
  83. {
  84. $data = $this->request->params([
  85. ['name', '']
  86. ]);
  87. $this->validate($data, 'app\validate\sys\AttachmentCategory.edit');
  88. (new AttachmentService())->editCategory($id, $data);
  89. return success('EDIT_SUCCESS');
  90. }
  91. /**
  92. * 删除附件组
  93. * @param $id
  94. * @return Response
  95. */
  96. public function deleteCategory($id)
  97. {
  98. (new AttachmentService())->delCategory($id);
  99. return success('DELETE_SUCCESS');
  100. }
  101. /**
  102. * 移动图片分组
  103. * @return Response
  104. */
  105. public function moveCategory($att_id)
  106. {
  107. $data = $this->request->params([
  108. ['cate_id', '']
  109. ]);
  110. (new AttachmentService())->modifyCategory($att_id, $data['cate_id']);
  111. return success();
  112. }
  113. /**
  114. * 批量移动图片分组
  115. * @return Response
  116. */
  117. public function batchMoveCategory()
  118. {
  119. $data = $this->request->params([
  120. ['cate_id', ''],
  121. ['att_ids', []]
  122. ]);
  123. (new AttachmentService())->batchModifyCategory($data['att_ids'], $data['cate_id']);
  124. return success();
  125. }
  126. /**
  127. * 获取图标库分类列表
  128. */
  129. public function getIconCategoryList()
  130. {
  131. $data = $this->request->params([
  132. ['name', ''],
  133. ]);
  134. return success((new AttachmentService())->getIconCategoryList($data));
  135. }
  136. /**
  137. * 获取图标库列表
  138. */
  139. public function getIconList()
  140. {
  141. $data = $this->request->params([
  142. ['page', 0],
  143. ['limit', 0],
  144. ['cate_id', 0],
  145. ['real_name', ''],
  146. ]);
  147. return success((new AttachmentService())->getIconList($data));
  148. }
  149. }