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.

96 lines
2.5 KiB

6 years ago
4 years ago
6 years ago
6 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\GoodsSearchword;
  10. use App\Http\Logic\GoodsSearchwordLogic;
  11. class GoodsSearchwordController extends BaseController
  12. {
  13. public function __construct()
  14. {
  15. parent::__construct();
  16. }
  17. public function getLogic()
  18. {
  19. return new GoodsSearchwordLogic();
  20. }
  21. public function goodsSearchwordList(Request $request)
  22. {
  23. //参数
  24. $limit = $request->input('limit', 10);
  25. $offset = $request->input('offset', 0);
  26. $where['status'] = 0;
  27. $res = $this->getLogic()->getList($where, [['click', 'desc'],['listorder', 'asc']], '*', $offset, $limit);
  28. /* if($res['count'] > 0)
  29. {
  30. foreach($res['list'] as $k=>$v)
  31. {
  32. }
  33. } */
  34. return ReturnData::create(ReturnData::SUCCESS, $res);
  35. }
  36. public function goodsSearchwordDetail(Request $request)
  37. {
  38. //参数
  39. if(!checkIsNumber($request->input('id',null))){return ReturnData::create(ReturnData::PARAMS_ERROR);}
  40. $id = $request->input('id');
  41. $where['id'] = $id;
  42. $res = $this->getLogic()->getOne($where);
  43. if(!$res)
  44. {
  45. return ReturnData::create(ReturnData::RECORD_NOT_EXIST);
  46. }
  47. return ReturnData::create(ReturnData::SUCCESS,$res);
  48. }
  49. //添加
  50. public function goodsSearchwordAdd(Request $request)
  51. {
  52. if(Helper::isPostRequest())
  53. {
  54. return $this->getLogic()->add($_POST);
  55. }
  56. }
  57. //修改
  58. public function goodsSearchwordUpdate(Request $request)
  59. {
  60. if(!checkIsNumber($request->input('id',null))){return ReturnData::create(ReturnData::PARAMS_ERROR);}
  61. $id = $request->input('id');
  62. if(Helper::isPostRequest())
  63. {
  64. unset($_POST['id']);
  65. $where['id'] = $id;
  66. return $this->getLogic()->edit($_POST,$where);
  67. }
  68. }
  69. //删除
  70. public function goodsSearchwordDelete(Request $request)
  71. {
  72. if(!checkIsNumber($request->input('id',null))){return ReturnData::create(ReturnData::PARAMS_ERROR);}
  73. $id = $request->input('id');
  74. if(Helper::isPostRequest())
  75. {
  76. $where['id'] = $id;
  77. return $this->getLogic()->del($where);
  78. }
  79. }
  80. }