package credit_usage

import (
	"context"

    "wechat-api/ent/creditusage"
    "wechat-api/internal/svc"
    "wechat-api/internal/types"
    "wechat-api/internal/utils/dberrorhandler"

    "github.com/suyuan32/simple-admin-common/msg/errormsg"
    "github.com/zeromicro/go-zero/core/logx"
)

type DeleteCreditUsageLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewDeleteCreditUsageLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteCreditUsageLogic {
	return &DeleteCreditUsageLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *DeleteCreditUsageLogic) DeleteCreditUsage(req *types.IDsReq) (*types.BaseMsgResp, error) {
	_, err := l.svcCtx.DB.CreditUsage.Delete().Where(creditusage.IDIn(req.Ids...)).Exec(l.ctx)

    if err != nil {
		return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
	}

    return &types.BaseMsgResp{Msg: errormsg.DeleteSuccess}, nil
}
