All Downloads are FREE. Search and download functionalities are using the official Maven repository.

templates.golang.database.executor.service_executor.insert.template Maven / Gradle / Ivy

func (se *Executor) Execute@title@(ctx context.Context, request *fs.@service_request@) (*fs.@service_response@, error) {

	model := mappers.Make@service_request@VO(request)
	args := @title@Args(model)

	var rows sql.Result
	currQuery := database.QUERY_@title_query@
    @sql_replace@
	err := Driver.GetDriver().Exec(ctx, currQuery, args, &rows)
	if err != nil {
		logger.Error("Error could not Execute@service_request@", zap.Error(err))
		return nil, err
	}

	insertedId, err := rows.LastInsertId()
    if err != nil {
        logger.Error("Error could not get lastInsertedId for @service_request@", zap.Error(err))
        return nil, err
    }

	response :=  &fs.@service_response@{
        Status: @response_status_success@
        Count: 1,
        RecordId: cast.ToString(insertedId),
    }

    return response, nil
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy