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.

95 lines
2.6 KiB

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