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.

94 lines
2.5 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
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\UserPoint;
  10. use App\Http\Logic\UserPointLogic;
  11. class UserPointController extends BaseController
  12. {
  13. public function __construct()
  14. {
  15. parent::__construct();
  16. }
  17. public function getLogic()
  18. {
  19. return logic('UserPoint');
  20. }
  21. public function userPointList(Request $request)
  22. {
  23. //参数
  24. $limit = $request->input('limit', 10);
  25. $offset = $request->input('offset', 0);
  26. if($request->input('type', null) != null){$data['type'] = $request->input('type');}
  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 userPointDetail(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 userPointAdd(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 userPointUpdate(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 userPointDelete(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. }