bvc.go 644 B

1234567891011121314151617181920212223
  1. package dao
  2. import (
  3. "context"
  4. "go-common/app/service/bbq/video/model"
  5. "regexp"
  6. )
  7. const (
  8. _insertRecord = "insert bvc_flow_record (`bvcid`,`svid`,`type`) values (?,?,?)"
  9. _updateRecord = "update bvc_flow_record set `svid` = ?,`type` = ? where `bvcid` = ?"
  10. )
  11. // AddOrUpdateFlowRecord 添加bvc flow记录
  12. func (d *Dao) AddOrUpdateFlowRecord(c context.Context, r *model.BVCRecord) error {
  13. _, err := d.db.Exec(c, _insertRecord, r.FLowID, r.SVID, r.Type)
  14. if err != nil {
  15. if matched, _ := regexp.MatchString("Duplicate entry", err.Error()); matched {
  16. _, err = d.db.Exec(c, _updateRecord, r.SVID, r.Type, r.FLowID)
  17. }
  18. }
  19. return err
  20. }