Commit a63f1e23 by 杨树贤

新增地址返回地址id

parent e1bd8e6e
......@@ -17,7 +17,7 @@ class UserAddressApiController extends Controller
{
$userId = $request->user->id;
$data = UserAddressService::getUserAddressList($userId);
return $this->setSuccessData($data,count($data));
return $this->setSuccessData($data, count($data));
}
public function detail(Request $request)
......@@ -44,12 +44,12 @@ class UserAddressApiController extends Controller
'is_default'
]);
$user = $request->user;
$result = UserAddressService::addUserAddress($address, $user);
if (!$result) {
$addressId = UserAddressService::addUserAddress($address, $user);
if (!$addressId) {
return $this->setError('Add user address failed');
}
return $this->setSuccess('Add user address success');
return $this->setSuccessData($addressId, 0, 0, 'Add user address success');
}
public function update(UserAddressSave $request)
......@@ -81,7 +81,7 @@ class UserAddressApiController extends Controller
public function delete(Request $request)
{
$addressId = $request->input('address_id');
$result = UserAddressModel::where('address_id',$addressId)->delete();
$result = UserAddressModel::where('address_id', $addressId)->delete();
if (!$result) {
return $this->setError('Delete user address failed');
}
......
......@@ -23,7 +23,7 @@ class UserAddressService
if (!$hasDefaultAddress) {
$address['is_default'] = 1;
}
return UserAddressModel::insert($address);
return UserAddressModel::insertGetId($address);
});
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment