pg_project_module_version.go 1.0 KB
package dao

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

type ProjectModuleDao struct {
	transactionContext *transaction.TransactionContext
}

func (dao *ProjectModuleDao) DuplicateVersion(srcProjectId, srcVersionId int64, curVersionId int64) error {
	tx := dao.transactionContext.PgTx
	_, err := tx.Exec(`insert into project_module_files(project_module_id,project_module_version_id,file_type,file_name,file_key,code_block,parent_id,sort,remark,create_time,update_time,path)
select ?,?,file_type,file_name,file_key,code_block,parent_id,sort,remark,now(),now(),path from project_module_files where project_module_id=? and project_module_version_id=?`,
		srcProjectId, curVersionId, srcProjectId, srcVersionId)
	return err
}

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