Poster.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  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\service\admin\sys\PosterService;
  13. use core\base\BaseAdminController;
  14. /**
  15. * 自定义海报
  16. * Class Poster
  17. * @package app\adminapi\controller\sys
  18. */
  19. class Poster extends BaseAdminController
  20. {
  21. /**
  22. * 获取自定义海报分页列表
  23. * @return \think\Response
  24. */
  25. public function pages()
  26. {
  27. $data = $this->request->params([
  28. [ "name", "" ],
  29. [ 'type', '' ]
  30. ]);
  31. return success(( new PosterService() )->getPage($data));
  32. }
  33. /**
  34. * 获取自定义海报分页列表
  35. * @return \think\Response
  36. */
  37. public function lists()
  38. {
  39. $data = $this->request->params([
  40. [ "name", "" ],
  41. [ 'type', '' ]
  42. ]);
  43. return success(( new PosterService() )->getList($data));
  44. }
  45. /**
  46. * 自定义海报详情
  47. * @param int $id
  48. * @return \think\Response
  49. */
  50. public function info(int $id)
  51. {
  52. return success(( new PosterService() )->getInfo($id));
  53. }
  54. /**
  55. * 添加自定义海报
  56. * @return \think\Response
  57. */
  58. public function add()
  59. {
  60. $data = $this->request->params([
  61. [ "name", "" ],
  62. [ "type", "" ],
  63. [ "channel", '' ],
  64. [ "value", '' ],
  65. [ "status", '' ],
  66. [ "addon", '' ],
  67. [ 'is_default', 0 ]
  68. ]);
  69. $id = ( new PosterService() )->add($data);
  70. return success('ADD_SUCCESS', [ 'id' => $id ]);
  71. }
  72. /**
  73. * 自定义海报编辑
  74. * @param int $id 自定义海报id
  75. * @return \think\Response
  76. */
  77. public function edit(int $id)
  78. {
  79. $data = $this->request->params([
  80. [ "name", "" ],
  81. [ "type", "" ],
  82. [ "channel", '' ],
  83. [ "value", '' ],
  84. [ "status", '' ],
  85. [ "addon", '' ],
  86. [ 'is_default', 0 ]
  87. ]);
  88. ( new PosterService() )->edit($id, $data);
  89. return success('EDIT_SUCCESS');
  90. }
  91. /**
  92. * 自定义海报删除
  93. * @param int $id 自定义海报id
  94. * @return \think\Response
  95. */
  96. public function del(int $id)
  97. {
  98. ( new PosterService() )->del($id);
  99. return success('DELETE_SUCCESS');
  100. }
  101. /**
  102. * 修改自定义海报状态
  103. * @return \think\Response
  104. */
  105. public function modifyStatus()
  106. {
  107. $data = $this->request->params([
  108. [ 'id', '' ],
  109. [ 'status', '' ],
  110. ]);
  111. ( new PosterService() )->modifyStatus($data);
  112. return success('SUCCESS');
  113. }
  114. /**
  115. * 将自定义海报修改为默认海报
  116. * @return \think\Response
  117. */
  118. public function modifyDefault()
  119. {
  120. $data = $this->request->params([
  121. [ 'id', '' ]
  122. ]);
  123. ( new PosterService() )->modifyDefault($data);
  124. return success('SUCCESS');
  125. }
  126. /**
  127. * 获取自定义海报类型
  128. * @return \think\Response
  129. */
  130. public function type()
  131. {
  132. $data = $this->request->params([
  133. [ 'type', '' ]
  134. ]);
  135. return success(( new PosterService() )->getType($data[ 'type' ]));
  136. }
  137. /**
  138. * 获取自定义海报模版
  139. * @return \think\Response
  140. */
  141. public function template()
  142. {
  143. $data = $this->request->params([
  144. [ 'addon', '' ],
  145. [ 'type', '' ]
  146. ]);
  147. return success(( new PosterService() )->getTemplateList($data[ 'addon' ], $data[ 'type' ]));
  148. }
  149. /**
  150. * 获取自定义海报初始化数据
  151. * @return \think\Response
  152. * @throws \think\db\exception\DbException
  153. */
  154. public function init()
  155. {
  156. $params = $this->request->params([
  157. [ 'id', "" ],
  158. [ "type", "" ],
  159. [ "name", "" ],
  160. ]);
  161. return success(( new PosterService() )->getInit($params));
  162. }
  163. /**
  164. * 获取自定义海报预览
  165. * @return array|\think\Response
  166. */
  167. public function preview()
  168. {
  169. $data = $this->request->params([
  170. [ 'id', 0 ], // 海报id
  171. [ 'type', '' ], // 海报类型
  172. [ 'param', [
  173. 'mode' => 'preview',
  174. ] ], // 数据参数
  175. [ 'channel', 'h5' ]
  176. ]);
  177. return success(data: poster($this->request->siteId(), ...$data));
  178. }
  179. }