|
|
@@ -3,6 +3,7 @@ package postgres
|
|
|
import (
|
|
|
"encoding/json"
|
|
|
"fmt"
|
|
|
+ "gframe/errors"
|
|
|
"github.com/jackc/pgx/v4"
|
|
|
)
|
|
|
|
|
|
@@ -10,17 +11,37 @@ type Test struct {
|
|
|
base
|
|
|
}
|
|
|
|
|
|
-func (t Test) UserAdd(name string) {
|
|
|
+func (t Test) UserAdd2(name string) (err error) {
|
|
|
stCode := -999
|
|
|
sql := `select fn_user_add2($1,$2);`
|
|
|
- _, err := t.writeDB().QueryFunc(t.ctx(), sql, []interface{}{name, stCode}, []interface{}{&stCode}, func(pgx.QueryFuncRow) error {
|
|
|
- fmt.Printf("%v", stCode)
|
|
|
+ _, err = t.writeDB().QueryFunc(t.ctx(), sql, []interface{}{name, stCode}, []interface{}{&stCode}, func(pgx.QueryFuncRow) error {
|
|
|
+ //fmt.Printf("%v", stCode)
|
|
|
return nil
|
|
|
})
|
|
|
+
|
|
|
+ if stCode < 0 {
|
|
|
+ err = errors.NewServiceErr(errors.CodeUserErr, "用户添加错误:")
|
|
|
+ }
|
|
|
if err != nil {
|
|
|
fmt.Printf("QueryFunc error: %v", err)
|
|
|
}
|
|
|
+ return
|
|
|
+}
|
|
|
+func (t Test) UserAdd1(paramStr string) (err error) {
|
|
|
+ stCode := -999
|
|
|
+ sql := `select fn_user_add($1,$2);`
|
|
|
+ _, err = t.writeDB().QueryFunc(t.ctx(), sql, []interface{}{paramStr, stCode}, []interface{}{&stCode}, func(pgx.QueryFuncRow) error {
|
|
|
+ //fmt.Printf("%v", stCode)
|
|
|
+ return nil
|
|
|
+ })
|
|
|
|
|
|
+ if stCode < 0 {
|
|
|
+ err = errors.NewServiceErr(errors.CodeUserErr, "用户添加错误:")
|
|
|
+ }
|
|
|
+ if err != nil {
|
|
|
+ fmt.Printf("QueryFunc error: %v", err)
|
|
|
+ }
|
|
|
+ return
|
|
|
}
|
|
|
|
|
|
type UserListInfo struct {
|