You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

105 lines
2.9 KiB

7 years ago
4 years ago
7 years ago
7 years ago
6 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
6 years ago
7 years ago
6 years ago
7 years ago
6 years ago
7 years ago
6 years ago
7 years ago
6 years ago
7 years ago
7 years ago
7 years ago
6 years ago
7 years ago
6 years ago
7 years ago
7 years ago
  1. <?php
  2. namespace App\Http\Controllers\Api;
  3. use Illuminate\Support\Facades\Log;
  4. use Illuminate\Support\Facades\DB;
  5. use Illuminate\Http\Request;
  6. use App\Common\ReturnData;
  7. use App\Common\Helper;
  8. use App\Common\Token;
  9. use App\Http\Model\Slide;
  10. use App\Http\Logic\SlideLogic;
  11. class SlideController extends BaseController
  12. {
  13. public function __construct()
  14. {
  15. parent::__construct();
  16. }
  17. public function getLogic()
  18. {
  19. return new SlideLogic();
  20. }
  21. public function slideList(Request $request)
  22. {
  23. //参数
  24. $where = array();
  25. $limit = $request->input('limit', 10);
  26. $offset = $request->input('offset', 0);
  27. if($request->input('group_id', null) != null){$where['group_id'] = $request->input('group_id');}
  28. if($request->input('type', null) != null){$where['type'] = $request->input('type');}
  29. $where['is_show'] = Slide::IS_SHOW;
  30. $res = $this->getLogic()->getList($where, array('listorder', 'asc'), '*', $offset, $limit);
  31. if($res['count']>0)
  32. {
  33. foreach($res['list'] as $k=>$v)
  34. {
  35. if(!empty($res['list'][$k]->pic)){$res['list'][$k]->pic = http_host().$v->pic;}
  36. }
  37. }
  38. return ReturnData::create(ReturnData::SUCCESS,$res);
  39. }
  40. //详情
  41. public function slideDetail(Request $request)
  42. {
  43. //参数
  44. if(!checkIsNumber($request->input('id',null))){return ReturnData::create(ReturnData::PARAMS_ERROR);}
  45. $id = $request->input('id');
  46. $where['id'] = $id;
  47. $res = $this->getLogic()->getOne($where);
  48. if(!$res){return ReturnData::create(ReturnData::RECORD_NOT_EXIST);}
  49. if(!empty($res->pic)){$res->pic = http_host().$res->pic;}
  50. return ReturnData::create(ReturnData::SUCCESS,$res);
  51. }
  52. //添加
  53. public function slideAdd(Request $request)
  54. {
  55. if(Helper::isPostRequest())
  56. {
  57. $res = $this->getLogic()->add($_POST);
  58. return $res;
  59. }
  60. }
  61. //修改
  62. public function slideUpdate(Request $request)
  63. {
  64. if(!checkIsNumber($request->input('id',null))){return ReturnData::create(ReturnData::PARAMS_ERROR);}
  65. $id = $request->input('id');
  66. if(Helper::isPostRequest())
  67. {
  68. unset($_POST['id']);
  69. $where['id'] = $id;
  70. $res = $this->getLogic()->edit($_POST,$where);
  71. return $res;
  72. }
  73. }
  74. //删除
  75. public function slideDelete(Request $request)
  76. {
  77. if(!checkIsNumber($request->input('id',null))){return ReturnData::create(ReturnData::PARAMS_ERROR);}
  78. $id = $request->input('id');
  79. if(Helper::isPostRequest())
  80. {
  81. $where['id'] = $id;
  82. $res = $this->getLogic()->del($where);
  83. return $res;
  84. }
  85. }
  86. }