package db

import (
	"context"
	"github.com/sirupsen/logrus"
	"youngee_b_api/model/gorm_model"
)

// FindProjectMaterialByProjectId 根据projectId查找素材
func FindProjectMaterialByProjectId(ctx context.Context, projectId string) ([]*gorm_model.ProjectMaterial, error) {
	db := GetReadDB(ctx)
	var sProjectInfo []*gorm_model.ProjectMaterial
	// 1. 根据服务商种草任务id过滤
	err := db.Model(gorm_model.ProjectMaterial{}).Where("project_id = ?", projectId).Find(&sProjectInfo).Error
	if err != nil {
		logrus.WithContext(ctx).Errorf("[GetSProjectDetail] error query mysql, err:%+v", err)
		return nil, err
	}
	return sProjectInfo, nil
}
