Ads.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace addons\unishop\controller;
  3. use app\common\controller\Api;
  4. /**
  5. * 广告
  6. */
  7. class Ads extends Api
  8. {
  9. protected $noNeedLogin = ['index'];
  10. protected $noNeedRight = ['*'];
  11. public function _initialize()
  12. {
  13. parent::_initialize();
  14. }
  15. /**
  16. * @ApiTitle (广告列表)
  17. * @ApiSummary (首页上方)
  18. * @ApiMethod (GET)
  19. * @ApiReturn ({"code":1,"msg":"","data":[]})
  20. * @ApiReturnParams (name="id", type="integer", description="广告id")
  21. * @ApiReturnParams (name="image", type="string", description="图片地址")
  22. * @ApiReturnParams (name="background", type="string", description="颜色值")
  23. * @ApiReturnParams (name="product_id", type="integer", description="跳转商品id")
  24. * @ApiReturnParams (name="status", type="integer", description="是否显示")
  25. */
  26. public function index()
  27. {
  28. $ads = \addons\unishop\model\Ads::where('status', 1)->cache('ads-index', 20)->select();
  29. $this->success('广告列表', $ads);
  30. }
  31. }