func buildTransactionSerializableCommand() *jsonpatch.CommandContainer { callback := func(transaction, prev interface{}) (interface{}, error) { _, err := transaction.(*sql.Tx).Exec("SET TRANSACTION ISOLATION LEVEL SERIALIZABLE") if err != nil { return nil, err } return nil, nil } command := new(jsonpatch.CommandContainer) command.MainCallback = callback return command }
//database checked func generateRemoveModuleTree(id, userId, jwt string, officers, assistants map[string]bool, op *jsonpatch.Operation, params map[string]string) (*jsonpatch.CommandContainer, error) { if err := checkAuthorityAndValidatePatch(jsonpatch.REMOVE, op.Type, userId, officers); err != nil { return nil, err } command := new(jsonpatch.CommandContainer) command.MainCallback = func(transaction, prev interface{}) (interface{}, error) { row := transaction.(*sql.Tx).QueryRow("SELECT string_agg(id::varchar,'&oid=') from remove_module_tree($1,$2) group by id", id, params["moduleId"]) var val string err := row.Scan(&val) if err != nil { return nil, err } return val, nil } command.AfterCallback = func(transaction, prev interface{}) (interface{}, error) { client := serviceclient.New("acl-service") return nil, checkStatus(client.Delete(fmt.Sprintf("/objects?oid=%s", prev.(string)), "Authorization", jwt)) } return command, nil }
func buildDefaultCommand(stmt string, params ...interface{}) *jsonpatch.CommandContainer { command := new(jsonpatch.CommandContainer) command.MainCallback = buildDefaultMainCallback(stmt, params...) return command }