ShopAddress.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. namespace app\api\controller\h5;
  3. use app\hander\HelpHander;
  4. use think\App;
  5. use think\Controller;
  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 list(){
  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. $ret = Db::name('shop_address')->where('id',$id)->delete();
  47. if(!$ret){
  48. HelpHander::error('删除失败');
  49. }
  50. HelpHander::success([],'删除成功');
  51. }
  52. //获取默认地址
  53. public function addressOne(){
  54. $model = $this->model;
  55. $ret = $model->finds($this->userId);
  56. HelpHander::success($ret);
  57. }
  58. }