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.

103 lines
2.8 KiB

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