forked from ebhomengo/niki
1
0
Fork 0
niki/repository/mysql/kind_box/enumerate.go

23 lines
668 B
Go

package mysqlkindbox
import (
"context"
"git.gocasts.ir/ebhomengo/niki/entity"
errmsg "git.gocasts.ir/ebhomengo/niki/pkg/err_msg"
richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
)
func (d DB) EnumerateKindBox(ctx context.Context, kindBoxID uint, amount uint) error {
const op = "mysqlkindbox.EnumerateKindBox"
query := `UPDATE kind_boxes SET amount = ?, status = ? WHERE id = ?`
_, err := d.conn.Conn().ExecContext(ctx, query, amount, entity.KindBoxEnumeratedStatus.String(), kindBoxID)
if err != nil {
return richerror.New(op).WithErr(err).
WithMessage(errmsg.ErrorMsgSomethingWentWrong).WithKind(richerror.KindUnexpected)
}
return nil
}