|
@@ -35,9 +35,11 @@ export class CompanyService extends BaseService<modelType> {
|
|
|
const data = { is_collection: false };
|
|
|
const arr = await this.model.findById(id).lean();
|
|
|
if (arr && get(arr, '_id')) {
|
|
|
- // 查询是否收藏该企业
|
|
|
- const collection = await this.cModel.findOne({ user: user._id, source: arr._id }).lean();
|
|
|
- if (collection) data.is_collection = true;
|
|
|
+ if (user && user._id) {
|
|
|
+ // 查询是否收藏该企业
|
|
|
+ const collection = await this.cModel.findOne({ user: user._id, source: arr._id }).lean();
|
|
|
+ if (collection) data.is_collection = true;
|
|
|
+ }
|
|
|
}
|
|
|
return { ...arr, ...data };
|
|
|
}
|