Browse Source

feat(customer-resources): 添加资源分享关联并优化查询

- 在 CustomerResources 模型中添加 resourceSharingHasMany 方法,实现一对多关联资源共享表
- 在 CustomerResourcesService 中使用 with 方法预加载资源分享关联数据
master
liutong 10 months ago
parent
commit
3258d6071d
  1. 9
      niucloud/app/model/customer_resources/CustomerResources.php
  2. 3
      niucloud/app/service/api/apiService/CustomerResourcesService.php

9
niucloud/app/model/customer_resources/CustomerResources.php

@ -153,6 +153,15 @@ class CustomerResources extends BaseModel
return $this->hasOne(SixSpeed::class, 'resource_id', 'id');
}
//一对多关联"资源共享表"
public function resourceSharingHasMany()
{
return $this->hasMany(ResourceSharing::class, 'resource_id', 'id');
}
/**
* 获取客户初步意向度类型名称
* @param $value

3
niucloud/app/service/api/apiService/CustomerResourcesService.php

@ -52,6 +52,9 @@ class CustomerResourcesService extends BaseApiService
$model = $model->where('name', 'like', "%{$where['name']}%");
}
$data = $model->field($field)
->with([
'resourceSharingHasMany'
])
->append([
'initial_intent_name'
])

Loading…
Cancel
Save