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.

104 lines
2.7 KiB

8 years ago
7 years ago
8 years ago
7 years ago
8 years ago
7 years ago
8 years ago
7 years ago
8 years ago
7 years ago
8 years ago
7 years ago
8 years ago
7 years ago
8 years ago
7 years ago
8 years ago
7 years ago
8 years ago
7 years ago
8 years ago
7 years ago
8 years ago
7 years ago
8 years ago
7 years ago
8 years ago
7 years ago
8 years ago
7 years ago
8 years ago
  1. <?php
  2. namespace App\Http\Controllers\Api;
  3. use Log;
  4. use 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\UserGoodsHistory;
  10. use App\Http\Logic\UserGoodsHistoryLogic;
  11. //我的足迹
  12. class UserGoodsHistoryController extends BaseController
  13. {
  14. public function __construct()
  15. {
  16. parent::__construct();
  17. }
  18. public function getLogic()
  19. {
  20. return logic('UserGoodsHistory');
  21. }
  22. public function userGoodsHistoryList(Request $request)
  23. {
  24. //参数
  25. $limit = $request->input('limit', 10);
  26. $offset = $request->input('offset', 0);
  27. $where['user_id'] = Token::$uid;
  28. $res = $this->getLogic()->getList($where, array('id', 'desc'), '*', $offset, $limit);
  29. return ReturnData::create(ReturnData::SUCCESS,$res);
  30. }
  31. public function userGoodsHistoryDetail(Request $request)
  32. {
  33. //参数
  34. if(!checkIsNumber($request->input('id',null))){return ReturnData::create(ReturnData::PARAMS_ERROR);}
  35. $id = $request->input('id');
  36. $where['id'] = $id;
  37. $res = $this->getLogic()->getOne($where);
  38. if(!$res)
  39. {
  40. return ReturnData::create(ReturnData::RECORD_NOT_EXIST);
  41. }
  42. return ReturnData::create(ReturnData::SUCCESS,$res);
  43. }
  44. //添加
  45. public function userGoodsHistoryAdd(Request $request)
  46. {
  47. if(Helper::isPostRequest())
  48. {
  49. $_POST['user_id'] = Token::$uid;
  50. return $this->getLogic()->add($_POST);
  51. }
  52. }
  53. //修改
  54. public function userGoodsHistoryUpdate(Request $request)
  55. {
  56. if(!checkIsNumber($request->input('id',null))){return ReturnData::create(ReturnData::PARAMS_ERROR);}
  57. $id = $request->input('id');
  58. if(Helper::isPostRequest())
  59. {
  60. unset($_POST['id']);
  61. $where['id'] = $id;
  62. $where['user_id'] = Token::$uid;
  63. return $this->getLogic()->edit($_POST,$where);
  64. }
  65. }
  66. //删除
  67. public function userGoodsHistoryDelete(Request $request)
  68. {
  69. if(!checkIsNumber($request->input('id',null))){return ReturnData::create(ReturnData::PARAMS_ERROR);}
  70. $id = $request->input('id');
  71. if(Helper::isPostRequest())
  72. {
  73. $where['id'] = $id;
  74. $where['user_id'] = Token::$uid;
  75. return $this->getLogic()->del($where);
  76. }
  77. }
  78. //清空我的足迹
  79. public function userGoodsHistoryClear(Request $request)
  80. {
  81. if(Helper::isPostRequest())
  82. {
  83. $where['user_id'] = Token::$uid;
  84. return $this->getLogic()->del($where);
  85. }
  86. }
  87. }