update
parent
72a783bdd3
commit
b6f4beb210
|
@ -39,13 +39,16 @@ func (e *Event) BeforeSave(tx *gorm.DB) (err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// test for collide
|
// test for collide
|
||||||
cnt := 0
|
cnt := ""
|
||||||
db.Raw(`select count(*) from events e where
|
db.Raw(`select id from events e where
|
||||||
(? >= "start" and ? <= "end" )
|
(? >= "start" and ? <= "end" )
|
||||||
or
|
or
|
||||||
(? >= "start" and ? <= "end" )
|
(? >= "start" and ? <= "end" )
|
||||||
and calendar_id = ?`,
|
and calendar_id = ? limit 1`,
|
||||||
e.End, e.End, e.Start, e.Start, e.CalendarID).Scan(&cnt)
|
e.End, e.End, e.Start, e.Start, e.CalendarID).Scan(&cnt)
|
||||||
|
if cnt != "" {
|
||||||
|
return errors.New(500, "event collide with existing")
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue