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.

102 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
  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\FeedBack;
  10. use App\Http\Logic\FeedBackLogic;
  11. class FeedBackController extends BaseController
  12. {
  13. public function __construct()
  14. {
  15. parent::__construct();
  16. }
  17. public function getLogic()
  18. {
  19. return logic('FeedBack');
  20. }
  21. public function feedbackList(Request $request)
  22. {
  23. //参数
  24. $limit = $request->input('limit', 10);
  25. $offset = $request->input('offset', 0);
  26. $where['user_id'] = Token::$uid;
  27. $res = $this->getLogic()->getList($where, array('id', 'desc'), '*', $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 feedbackDetail(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 feedbackAdd(Request $request)
  51. {
  52. if(Helper::isPostRequest())
  53. {
  54. $_POST['user_id'] = Token::$uid;
  55. $_POST['add_time'] = time();
  56. return $this->getLogic()->add($_POST);
  57. }
  58. }
  59. //修改
  60. public function feedbackUpdate(Request $request)
  61. {
  62. if(!checkIsNumber($request->input('id',null))){return ReturnData::create(ReturnData::PARAMS_ERROR);}
  63. $id = $request->input('id');
  64. if(Helper::isPostRequest())
  65. {
  66. unset($_POST['id']);
  67. $where['id'] = $id;
  68. //$where['user_id'] = Token::$uid;
  69. return $this->getLogic()->edit($_POST,$where);
  70. }
  71. }
  72. //删除
  73. public function feedbackDelete(Request $request)
  74. {
  75. if(!checkIsNumber($request->input('id',null))){return ReturnData::create(ReturnData::PARAMS_ERROR);}
  76. $id = $request->input('id');
  77. if(Helper::isPostRequest())
  78. {
  79. $where['id'] = $id;
  80. //$where['user_id'] = Token::$uid;
  81. return $this->getLogic()->del($where);
  82. }
  83. }
  84. }