Adv.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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\diy;
  12. use app\dict\diy\AdvPositionDict;
  13. use app\service\admin\diy\AdvService;
  14. use core\base\BaseAdminController;
  15. use think\Response;
  16. /**
  17. * 广告管理
  18. * Class Nav
  19. * @package app\adminapi\controller\web
  20. */
  21. class Adv extends BaseAdminController
  22. {
  23. /**
  24. * 广告位
  25. * @return \think\Response
  26. */
  27. public function advPosition(){
  28. return success(AdvPositionDict::getAdvPosition());
  29. }
  30. /**
  31. * 获取广告分页列表
  32. * @return \think\Response
  33. */
  34. public function pages(){
  35. $data = $this->request->params([
  36. ['ap_key', '']
  37. ]);
  38. return success((new AdvService())->getPage($data));
  39. }
  40. /**
  41. * 获取广告列表
  42. * @return \think\Response
  43. */
  44. public function lists(){
  45. $data = $this->request->params([
  46. ['ap_key', '']
  47. ]);
  48. return success((new AdvService())->getList($data));
  49. }
  50. /**
  51. * 广告详情
  52. * @param int $id
  53. * @return \think\Response
  54. */
  55. public function info(int $id){
  56. return success((new AdvService())->getInfo($id));
  57. }
  58. /**
  59. * 添加广告
  60. * @return \think\Response
  61. */
  62. public function add(){
  63. $data = $this->request->params([
  64. ['ap_key', ''],
  65. ['adv_title', ''],
  66. ['adv_url', ''],
  67. ['adv_image', ''],
  68. ['slide_sort', 0],
  69. ['background', '#FFFFFF'],
  70. ]);
  71. $id = (new AdvService())->add($data);
  72. return success('ADD_SUCCESS', ['id' => $id]);
  73. }
  74. /**
  75. * 广告编辑
  76. * @param $id 广告id
  77. * @return \think\Response
  78. */
  79. public function edit($id){
  80. $data = $this->request->params([
  81. ['ap_key', ''],
  82. ['adv_title', ''],
  83. ['adv_url', ''],
  84. ['adv_image', ''],
  85. ['slide_sort', 0],
  86. ['background', '#FFFFFF'],
  87. ]);
  88. (new AdvService())->edit($id, $data);
  89. return success('EDIT_SUCCESS');
  90. }
  91. /**
  92. * 广告删除
  93. * @param int $id
  94. * @return Response
  95. */
  96. public function del(int $id){
  97. (new AdvService())->del($id);
  98. return success('DELETE_SUCCESS');
  99. }
  100. }