|
@@ -19,6 +19,13 @@ class AddressService extends CrudService {
|
|
|
return data;
|
|
|
}
|
|
|
|
|
|
+ async beforeCreate(data) {
|
|
|
+ const { customer } = data;
|
|
|
+ const num = await this.model.count({ customer });
|
|
|
+ if (num <= 0) data.is_default = '1';
|
|
|
+ return data;
|
|
|
+ }
|
|
|
+
|
|
|
async toDefault({ id }) {
|
|
|
const data = await this.model.findById(id);
|
|
|
if (!data) throw new BusinessError(ErrorCode.DATA_NOT_EXIST);
|