pg_project_module_files_dao.go 959 字节
package dao

import (
	"fmt"
	"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/infrastructure/pg/transaction"
	"strings"
)

type ProjectModuleFilesDao struct {
	transactionContext *transaction.TransactionContext
}

func (dao *ProjectModuleFilesDao) UpdateFilesPath(srcProjectId, srcVersionId int64, oldPath, newPath string) error {
	tx := dao.transactionContext.PgTx
	_, err := tx.Exec(fmt.Sprintf(`update  project_module_files set "path"= replace("path",?,?) where project_module_id=? and project_module_version_id=? and "path" like '%%%v%%'`, strings.Replace(oldPath, "\\", "\\\\", -1)),
		oldPath, newPath, srcProjectId, srcVersionId)
	return err
}

func NewProjectModuleFilesDao(transactionContext *transaction.TransactionContext) (*ProjectModuleFilesDao, error) {
	if transactionContext == nil {
		return nil, fmt.Errorf("transactionContext参数不能为nil")
	} else {
		return &ProjectModuleFilesDao{
			transactionContext: transactionContext,
		}, nil
	}
}