UserAddressController.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. namespace app\api\controller;
  3. use app\api\logic\UserAddressLogic;
  4. use app\api\validate\UserAddressValidate;
  5. /**
  6. * 用户地址控制器
  7. * Class UserAddressController
  8. * @package app\api\controller
  9. */
  10. class UserAddressController extends BaseApiController
  11. {
  12. public function addressList()
  13. {
  14. $result = UserAddressLogic::getAddressList($this->userId);
  15. return $this->data($result);
  16. }
  17. /**
  18. * @notes 添加
  19. * @return \think\response\Json
  20. */
  21. public function add()
  22. {
  23. $params = (new UserAddressValidate())->post()->goCheck('add',[
  24. 'user_id'=>$this->userId
  25. ]);
  26. $result = UserAddressLogic::add($params);
  27. if (true === $result) {
  28. return $this->success('添加成功', [], 1, 1);
  29. }
  30. return $this->fail(UserAddressLogic::getError());
  31. }
  32. /**
  33. * @notes 编辑
  34. * @return \think\response\Json
  35. */
  36. public function edit()
  37. {
  38. $params = (new UserAddressValidate())->post()->goCheck('edit',[
  39. 'user_id'=>$this->userId
  40. ]);
  41. $result = UserAddressLogic::edit($params);
  42. if (true === $result) {
  43. return $this->success('编辑成功', [], 1, 1);
  44. }
  45. return $this->fail(UserAddressLogic::getError());
  46. }
  47. /**
  48. * @notes 删除
  49. * @return \think\response\Json
  50. */
  51. public function delete()
  52. {
  53. $params = (new UserAddressValidate())->post()->goCheck('delete',[
  54. 'user_id'=>$this->userId
  55. ]);
  56. UserAddressLogic::delete($params);
  57. return $this->success('删除成功', [], 1, 1);
  58. }
  59. /**
  60. * @notes 获取详情
  61. * @return \think\response\Json
  62. * @author likeadmin
  63. * @date 2024/07/18 13:51
  64. */
  65. public function detail()
  66. {
  67. $params = (new UserAddressValidate())->goCheck('detail',[
  68. 'user_id'=>$this->userId
  69. ]);
  70. $result = UserAddressLogic::detail($params);
  71. return $this->data($result);
  72. }
  73. }