forked from ebhomengo/niki
31 lines
972 B
Go
31 lines
972 B
Go
package mysqlkindboxreq
|
|
|
|
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"
|
|
"git.gocasts.ir/ebhomengo/niki/repository/mysql"
|
|
)
|
|
|
|
func (d *DB) RejectKindBoxReq(ctx context.Context, kindBoxReqID uint, description string) error {
|
|
const op = "mysqlkindboxreq.RejectKindBoxReq"
|
|
|
|
query := `update kind_box_reqs set description = ? , status = ? where id = ?`
|
|
//nolint
|
|
stmt, err := d.conn.PrepareStatement(ctx, mysql.StatementKeyKindBoxReqReject, query)
|
|
if err != nil {
|
|
return richerror.New(op).WithErr(err).
|
|
WithMessage(errmsg.ErrorMsgCantPrepareStatement).WithKind(richerror.KindUnexpected)
|
|
}
|
|
|
|
_, err = stmt.ExecContext(ctx, description, entity.KindBoxReqRejectedStatus, kindBoxReqID)
|
|
if err != nil {
|
|
return richerror.New(op).WithErr(err).
|
|
WithMessage(errmsg.ErrorMsgSomethingWentWrong).WithKind(richerror.KindUnexpected)
|
|
}
|
|
|
|
return nil
|
|
}
|