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.

97 lines
2.4 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
  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\Region;
  10. use App\Http\Logic\RegionLogic;
  11. class RegionController extends BaseController
  12. {
  13. public function __construct()
  14. {
  15. parent::__construct();
  16. }
  17. public function getLogic()
  18. {
  19. return logic('Region');
  20. }
  21. public function regionList(Request $request)
  22. {
  23. //参数
  24. $where['parent_id'] = $request->input('id', 86);
  25. $res = $this->getLogic()->getAll($where);
  26. /* if($res['count']>0)
  27. {
  28. foreach($res['list'] as $k=>$v)
  29. {
  30. }
  31. } */
  32. return ReturnData::create(ReturnData::SUCCESS,$res);
  33. }
  34. public function regionDetail(Request $request)
  35. {
  36. //参数
  37. if(!checkIsNumber($request->input('id',null))){return ReturnData::create(ReturnData::PARAMS_ERROR);}
  38. $id = $request->input('id');
  39. $where['id'] = $id;
  40. $res = $this->getLogic()->getOne($where);
  41. if(!$res)
  42. {
  43. return ReturnData::create(ReturnData::RECORD_NOT_EXIST);
  44. }
  45. return ReturnData::create(ReturnData::SUCCESS,$res);
  46. }
  47. //添加
  48. public function regionAdd(Request $request)
  49. {
  50. if(Helper::isPostRequest())
  51. {
  52. return $this->getLogic()->add($_POST);
  53. }
  54. }
  55. //修改
  56. public function regionUpdate(Request $request)
  57. {
  58. if(!checkIsNumber($request->input('id',null))){return ReturnData::create(ReturnData::PARAMS_ERROR);}
  59. $id = $request->input('id');
  60. if(Helper::isPostRequest())
  61. {
  62. unset($_POST['id']);
  63. $where['id'] = $id;
  64. //$where['user_id'] = Token::$uid;
  65. return $this->getLogic()->edit($_POST,$where);
  66. }
  67. }
  68. //删除
  69. public function regionDelete(Request $request)
  70. {
  71. if(!checkIsNumber($request->input('id',null))){return ReturnData::create(ReturnData::PARAMS_ERROR);}
  72. $id = $request->input('id');
  73. if(Helper::isPostRequest())
  74. {
  75. $where['id'] = $id;
  76. //$where['user_id'] = Token::$uid;
  77. return $this->getLogic()->del($where);
  78. }
  79. }
  80. }