PlatformSelect.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use think\Db;
  5. class PlatformSelect extends Api
  6. {
  7. protected $noNeedLogin = '*';
  8. protected $noNeedRight = '*';
  9. protected $model = null;
  10. public function _initialize()
  11. {
  12. parent::_initialize();
  13. $this->model = Db::name('platform_select');
  14. }
  15. /**
  16. * 平台甄选列表
  17. * @return void
  18. */
  19. public function getList()
  20. {
  21. try {
  22. $field = 'id,title,image,createtime';
  23. $where['status'] = 1;
  24. $result = $this->model->field($field)->where($where)->order('createtime desc')->autopage()->select();
  25. if (!empty($result)) {
  26. foreach ($result as $key => &$value) {
  27. $value['createtime'] = !empty($value['createtime']) ? date('Y-m-d H:i:s',$value['createtime']) : '';
  28. }
  29. $result = list_domain_image($result,['image']);
  30. }
  31. $this->success('获取成功',$result);
  32. } catch (Exception $e) {
  33. $this->error($e->getMessage());
  34. }
  35. }
  36. /**
  37. * 平台甄选详情
  38. * @return void
  39. */
  40. public function getInfo()
  41. {
  42. try {
  43. $id = $this->request->param('id',0);
  44. $field = 'id,title,image,content,createtime';
  45. $where['status'] = 1;
  46. $where['id'] = $id;
  47. $result = $this->model->field($field)->where($where)->find();
  48. if (!empty($result)) {
  49. $result['createtime'] = !empty($result['createtime']) ? date('Y.m.d H:i:s',$result['createtime']) : '';
  50. $result = info_domain_image($result,['image']);
  51. }
  52. $this->success('获取成功',$result);
  53. } catch (Exception $e) {
  54. $this->error($e->getMessage());
  55. }
  56. }
  57. }