You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
644 B
23 lines
644 B
package dao |
|
|
|
import ( |
|
"context" |
|
"go-common/app/service/bbq/video/model" |
|
"regexp" |
|
) |
|
|
|
const ( |
|
_insertRecord = "insert bvc_flow_record (`bvcid`,`svid`,`type`) values (?,?,?)" |
|
_updateRecord = "update bvc_flow_record set `svid` = ?,`type` = ? where `bvcid` = ?" |
|
) |
|
|
|
// AddOrUpdateFlowRecord 添加bvc flow记录 |
|
func (d *Dao) AddOrUpdateFlowRecord(c context.Context, r *model.BVCRecord) error { |
|
_, err := d.db.Exec(c, _insertRecord, r.FLowID, r.SVID, r.Type) |
|
if err != nil { |
|
if matched, _ := regexp.MatchString("Duplicate entry", err.Error()); matched { |
|
_, err = d.db.Exec(c, _updateRecord, r.SVID, r.Type, r.FLowID) |
|
} |
|
} |
|
return err |
|
}
|
|
|