ShopAddress.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. namespace app\api\controller\v1;
  3. use app\api\controller\Base;
  4. use app\hander\HelpHander;
  5. use think\App;
  6. use think\Db;
  7. class ShopAddress extends Base
  8. {
  9. public function __construct(App $app = null) {
  10. parent::__construct($app);
  11. $this->model = new \app\common\model\ShopAddress();
  12. }
  13. public function add(){
  14. $model = $this->model;
  15. $ret=$model->add($this->userId);
  16. if(!$ret){
  17. HelpHander::error($model->getError());
  18. }
  19. HelpHander::success([],'添加成功');
  20. }
  21. public function update(){
  22. $id=input('id/d',0);
  23. $model = $this->model;
  24. $ret=$model->updates($id,$this->userId);
  25. if(!$ret){
  26. HelpHander::error($model->getError());
  27. }
  28. HelpHander::success([],'修改成功');
  29. }
  30. public function lists(){
  31. $model = $this->model;
  32. $ret=$model->lists($this->userId);
  33. HelpHander::success($ret);
  34. }
  35. public function detail(){
  36. $id=input('id/d',0);
  37. $model = $this->model;
  38. $ret=$model->detail($id);
  39. if(!$ret){
  40. HelpHander::error('数据不存在');
  41. }
  42. HelpHander::success($ret);
  43. }
  44. public function del(){
  45. $id=input('id/d',0);
  46. $model = $this->model;
  47. $ret=$model->del($id);
  48. if($ret == 0){
  49. HelpHander::error('删除失败');
  50. }
  51. HelpHander::success([],'删除成功');
  52. }
  53. //获取默认地址
  54. public function addressOne(){
  55. $model = $this->model;
  56. $ret = $model->finds($this->userId);
  57. HelpHander::success($ret);
  58. }
  59. }