package xunji_service

import (
	"context"
	"github.com/suyuan32/simple-admin-common/msg/errormsg"
	"wechat-api/ent/xunjiservice"
	"wechat-api/internal/utils/dberrorhandler"

	"wechat-api/internal/svc"
	"wechat-api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

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

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

func (l *DeleteXunjiServiceLogic) DeleteXunjiService(req *types.IDsReq) (*types.BaseMsgResp, error) {
	_, err := l.svcCtx.DB.XunjiService.Delete().Where(xunjiservice.IDIn(req.Ids...)).Exec(l.ctx)

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

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