Просмотр исходного кода

refactor(user): 移除用户地址创建中的锁机制

- 删除了 new_create 方法中的 lock() 调用
- 删除了各个返回路径中的 unlock() 调用
- 简化了地址创建和更新流程的并发控制逻辑
shichen месяцев назад: 4
Родитель
Сommit
53a4f01f95
1 измененных файлов с 0 добавлено и 5 удалено
  1. 0 5
      app/controller/api/user/UserAddress.php

+ 0 - 5
app/controller/api/user/UserAddress.php

@@ -70,7 +70,6 @@ class UserAddress extends BaseController
70
     //新用户地址添加修改
70
     //新用户地址添加修改
71
     public function new_create(validate $validate)
71
     public function new_create(validate $validate)
72
     {
72
     {
73
-        makeLock()->lock();
74
         $data = $this->checkParams($validate);
73
         $data = $this->checkParams($validate);
75
         if ($data['is_default']) {
74
         if ($data['is_default']) {
76
             $this->repository->changeDefault($this->request->uid());
75
             $this->repository->changeDefault($this->request->uid());
@@ -78,22 +77,18 @@ class UserAddress extends BaseController
78
             if (!$this->repository->defaultExists($this->request->uid())) $data['is_default'] = 1;
77
             if (!$this->repository->defaultExists($this->request->uid())) $data['is_default'] = 1;
79
         }
78
         }
80
         if (!$data['code_list']) {
79
         if (!$data['code_list']) {
81
-            makeLock()->unlock();
82
             return app('json')->fail('请选择完整地址');
80
             return app('json')->fail('请选择完整地址');
83
         }
81
         }
84
         if ($data['address_id']) {
82
         if ($data['address_id']) {
85
             if (!$this->repository->fieldExists($data['address_id'], $this->request->uid())) {
83
             if (!$this->repository->fieldExists($data['address_id'], $this->request->uid())) {
86
-                makeLock()->unlock();
87
                 return app('json')->fail('信息不存在');
84
                 return app('json')->fail('信息不存在');
88
             }
85
             }
89
 
86
 
90
             $this->repository->update($data['address_id'], $data);
87
             $this->repository->update($data['address_id'], $data);
91
-            makeLock()->unlock();
92
             return app('json')->success('编辑成功', ['address_id' => $data['address_id']]);
88
             return app('json')->success('编辑成功', ['address_id' => $data['address_id']]);
93
         };
89
         };
94
         $data['uid'] = $this->request->uid();
90
         $data['uid'] = $this->request->uid();
95
         $address = $this->repository->create($data);
91
         $address = $this->repository->create($data);
96
-        makeLock()->unlock();
97
         return app('json')->success('添加成功', $address->toArray());
92
         return app('json')->success('添加成功', $address->toArray());
98
     }
93
     }
99
 
94