Address.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Niucloud-admin 企业快速开发的多应用管理平台
  4. // +----------------------------------------------------------------------
  5. // | 官方网址:https://www.niucloud.com
  6. // +----------------------------------------------------------------------
  7. // | niucloud团队 版权所有 开源版本可自由商用
  8. // +----------------------------------------------------------------------
  9. // | Author: Niucloud Team
  10. // +----------------------------------------------------------------------
  11. namespace app\api\controller\member;
  12. use core\base\BaseApiController;
  13. use app\service\api\member\AddressService;
  14. /**
  15. * 会员收货地址控制器
  16. * Class Address
  17. * @package app\api\controller\address
  18. */
  19. class Address extends BaseApiController
  20. {
  21. /**
  22. * 获取会员收货地址列表
  23. * @return \think\Response
  24. */
  25. public function lists(){
  26. $data = $this->request->params([
  27. ["type",""]
  28. ]);
  29. return success((new AddressService())->getList($data));
  30. }
  31. /**
  32. * 会员收货地址详情
  33. * @param int $id
  34. * @return \think\Response
  35. */
  36. public function info(int $id){
  37. return success((new AddressService())->getInfo($id));
  38. }
  39. /**
  40. * 添加会员收货地址
  41. * @return \think\Response
  42. */
  43. public function add(){
  44. $data = $this->request->params([
  45. ["name",""],
  46. ["mobile",""],
  47. ["province_id",0],
  48. ["city_id",0],
  49. ["district_id",0],
  50. ["address",""],
  51. ["address_name", ""],
  52. ["full_address",""],
  53. ["lng",""],
  54. ["lat",""],
  55. ["is_default",0],
  56. ["type",'']
  57. ]);
  58. $this->validate($data, 'app\validate\member\Address.add');
  59. $id = (new AddressService())->add($data);
  60. return success('ADD_SUCCESS', ['id' => $id]);
  61. }
  62. /**
  63. * 会员收货地址编辑
  64. * @param $id 会员收货地址id
  65. * @return \think\Response
  66. */
  67. public function edit($id){
  68. $data = $this->request->params([
  69. ["name",""],
  70. ["mobile",""],
  71. ["province_id",0],
  72. ["city_id",0],
  73. ["district_id",0],
  74. ["address",""],
  75. ["address_name", ""],
  76. ["full_address",""],
  77. ["lng",""],
  78. ["lat",""],
  79. ["is_default",0],
  80. ["type",'']
  81. ]);
  82. $this->validate($data, 'app\validate\member\Address.edit');
  83. (new AddressService())->edit($id, $data);
  84. return success('EDIT_SUCCESS');
  85. }
  86. /**
  87. * 会员收货地址删除
  88. * @param $id 会员收货地址id
  89. * @return \think\Response
  90. */
  91. public function del(int $id){
  92. (new AddressService())->del($id);
  93. return success('DELETE_SUCCESS');
  94. }
  95. }