一个 service 里面依赖了很多 repository,大家是怎么处理的?并且这些都是业务逻辑需要且围绕当前主体进行使用的。比如
@Service
@RequiredArgsConstructor
public class PlanMaterialServiceImpl extends BaseServiceImpl<PlanMaterialRepository,
PlanMaterial, Long>
implements PlanMaterialService {
private final @NonNull MaterialRepository materialRepository;
private final @NonNull MaterialTypeRepository materialTypeRepository;
private final @NonNull PlanMaterialRepository planMaterialRepository;
private final @NonNull ProcurementPlanRepository procurementPlanRepository;
private final @NonNull MaterialDemandPlanRepository materialPlanRepository;
private final @NonNull SysDepartmentRepository sysDepartmentRepository;
private final @NonNull ApprovalRepository approvalRepository;
private final @NonNull SysUserRepository sysUserRepository;
private final @NonNull NotificationRepository notificationRepository;
private final @NonNull NotifyUtil notifyUtil;
// ......
}
这样他就有 10 个 Repository 需要注入了,但是主体确实是 PlanMaterial
。。。大家如何处理这种情况的呢?