u
This commit is contained in:
1 parent
e893ef2e48
commit
b6415c0d65
25 files changed
+1495
-112
No files matched your search
@@ -1,10 +1,12 @@
|
||||
package db
|
||||
|
||||
import (
|
||||
"allapp-go/internal/middleware"
|
||||
"context"
|
||||
"fmt"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
// 构建 INSERT SQL(单条)
|
||||
@@ -43,6 +45,25 @@ func (c *Client) Insert(
|
||||
return err
|
||||
}
|
||||
|
||||
if !auditExcludeTables[table] {
|
||||
now := time.Now()
|
||||
|
||||
delete(data, "create_time")
|
||||
delete(data, "update_time")
|
||||
delete(data, "create_by")
|
||||
delete(data, "update_by")
|
||||
|
||||
data["create_time"] = now
|
||||
data["update_time"] = now
|
||||
|
||||
userID, flag := middleware.GetUserID(ctx)
|
||||
|
||||
if flag {
|
||||
data["create_by"] = userID
|
||||
data["update_by"] = userID
|
||||
}
|
||||
}
|
||||
|
||||
sql, args := buildInsertSQL(table, data)
|
||||
|
||||
_, err := c.exec().Exec(ctx, sql, args...)
|
||||
|
||||
Reference in new issue
Block a user