Archived
写入Agent IP时,不提示id重复错误
This commit is contained in:
@@ -13,6 +13,7 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -94,9 +95,13 @@ func (this *DB) InsertAgentIP(ipId int64, ip string, agentCode string) error {
|
|||||||
return errors.New("db should not be nil")
|
return errors.New("db should not be nil")
|
||||||
}
|
}
|
||||||
|
|
||||||
this.log("InsertAgentIP", "id:", ipId, "ip:", ip, "agent:", agentCode)
|
|
||||||
_, err := this.insertAgentIPStmt.Exec(ipId, ip, agentCode)
|
_, err := this.insertAgentIPStmt.Exec(ipId, ip, agentCode)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
// 不提示ID重复错误
|
||||||
|
if strings.Contains(err.Error(), "UNIQUE constraint") {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user