Airdrop.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use app\common\model\AnnouncementModel;
  5. //空投
  6. class Airdrop extends Api
  7. {
  8. protected array $noNeedLogin = ['list','show'];
  9. protected string $lan = '';
  10. public function _initialize()
  11. {
  12. parent::_initialize();
  13. $this->lan = $this->request->getLan();
  14. }
  15. //新人福利
  16. public function newbie()
  17. {
  18. $paginator = (new AnnouncementModel)
  19. ->where('type_id', 1)
  20. ->where('status', 1)
  21. ->order('id DESC,weigh desc')
  22. ->field('id,img_url,createtime,' . $this->lan.'_title as title')
  23. ->paginate($this->pageSize);
  24. $this->success('', $this->buildResp($paginator->total(), $paginator->currentPage(), $paginator->items()));
  25. }
  26. public function show(int $id)
  27. {
  28. $info = (new AnnouncementModel)
  29. ->where('id', $id)
  30. ->where('status', 1)
  31. ->field('id,img_url,body,createtime,' . $this->lan.'_title as title')
  32. ->find();
  33. if(empty($info)){
  34. $this->error('公告信息不存');
  35. }
  36. $this->success('', $info);
  37. }
  38. }