|
@@ -16,7 +16,7 @@ class AddressService extends CrudService {
|
|
|
async afterCreate(body, data) {
|
|
|
const { is_default } = data;
|
|
|
if (is_default !== this.defaultValue) await this.toDefault({ id: data._id });
|
|
|
- await this.checkDefault();
|
|
|
+ await this.checkDefault({ customer: data.customer });
|
|
|
return data;
|
|
|
}
|
|
|
/**
|
|
@@ -29,6 +29,11 @@ class AddressService extends CrudService {
|
|
|
if (num <= 0) data.is_default = '1';
|
|
|
return data;
|
|
|
}
|
|
|
+ async afterUpdate(filter, body, data) {
|
|
|
+ if (data.is_default !== this.defaultValue) await this.toDefault({ id: data._id });
|
|
|
+ await this.checkDefault({ customer: data.customer });
|
|
|
+ return data;
|
|
|
+ }
|
|
|
|
|
|
async toDefault({ id }) {
|
|
|
const data = await this.model.findById(id);
|