func (p *TnCommandContextHandler) Execute(args []interface{}, tx *sql.Tx, behavior *Behavior) interface{} { p.sql = (*p.CommandContext).getSql() // fmt.Printf("getBindVariables %v\n",(*p.CommandContext).getBindVariables()) // p.logSql((*p.CommandContext).getBindVariables(), // (*p.CommandContext).getBindVariableTypes()) // log.Flush() // fmt.Printf("statementFactory %v \n",p.statementFactory) bindVariables := (*p.CommandContext).getBindVariables() bindVariableTypes := (*p.CommandContext).getBindVariableTypes() dbc := (*(*behavior).GetBaseBehavior().GetBehaviorCommandInvoker().InvokerAssistant).GetDBCurrent() ps := (*p.statementFactory).PrepareStatement(p.sql, tx, dbc) defer ps.Close() bindVar := (*p.statementFactory).ModifyBindVariables(bindVariables, bindVariableTypes) p.logSql(bindVariables, bindVariableTypes) log.Flush() res, err := tx.Stmt(ps).Exec(bindVar.data...) if err != nil { panic(err.Error()) } updateno, _ := res.RowsAffected() log.InternalDebug(fmt.Sprintln("result no:", updateno)) return updateno }
func ErrorRecover(c *gin.Context, tx *sql.Tx) { errx := recover() if errx != nil { df.TxRollback(tx) errs := fmt.Sprintf("%v", errx) if errs == "" { errs = "System Error" } rmap := SetErrorMessage(errs) c.JSON(200, rmap) } else { df.TxCommit(tx) } log.Flush() }