forked from ebhomengo/niki
21 lines
646 B
Go
21 lines
646 B
Go
|
package mysqladdress
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
|
||
|
errmsg "git.gocasts.ir/ebhomengo/niki/pkg/err_msg"
|
||
|
richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
|
||
|
)
|
||
|
|
||
|
func (d *DB) DeleteBenefactorAddress(ctx context.Context, addressID uint, benefactorID uint) error {
|
||
|
const op = "mysqladdress.DeleteBenefactorAddress"
|
||
|
|
||
|
_, err := d.conn.Conn().ExecContext(ctx, `UPDATE addresses SET deleted_at = CURRENT_TIMESTAMP WHERE id = ? AND benefactor_id = ? AND deleted_at IS NULL`, addressID, benefactorID)
|
||
|
if err != nil {
|
||
|
|
||
|
return richerror.New(op).WithErr(err).WithKind(richerror.KindUnexpected).WithMessage(errmsg.ErrorMsgCantDeleteAddress)
|
||
|
}
|
||
|
|
||
|
return nil
|
||
|
}
|