mirror of
https://github.com/documize/community.git
synced 2025-07-22 22:59:43 +02:00
implemented delete reusable content block
This commit is contained in:
parent
2493a09ba9
commit
fc9127e165
12 changed files with 130 additions and 16 deletions
|
@ -12,6 +12,7 @@
|
|||
package request
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
|
@ -113,6 +114,30 @@ func (p *Persister) DecrementBlockUsage(id string) (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
// RemoveBlockReference clears page.blockid for given blockID.
|
||||
func (p *Persister) RemoveBlockReference(id string) (err error) {
|
||||
stmt, err := p.Context.Transaction.Preparex("UPDATE page SET blockid='', revised=? WHERE orgid=? AND blockid=?")
|
||||
defer utility.Close(stmt)
|
||||
if err != nil {
|
||||
log.Error(fmt.Sprintf("Unable to prepare update RemoveBlockReference id %s", id), err)
|
||||
return
|
||||
}
|
||||
|
||||
_, err = stmt.Exec(time.Now().UTC(), p.Context.OrgID, id)
|
||||
|
||||
// skip no rows affected
|
||||
if err == sql.ErrNoRows {
|
||||
return
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
log.Error(fmt.Sprintf("Unable to execute RemoveBlockReference id %s", id), err)
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// UpdateBlock updates existing reusable content block item.
|
||||
func (p *Persister) UpdateBlock(b entity.Block) (err error) {
|
||||
b.Revised = time.Now().UTC()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue