package logic

import (
	"context"
	"fmt"
	"github.com/zeromicro/go-zero/core/logx"
	sysModel "sundynix-micro-go/app/system/model"
	"sundynix-micro-go/app/system/rpc/internal/svc"
	"sundynix-micro-go/app/system/rpc/system"
)

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

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

func (l *DeleteDictLogic) DeleteDict(in *system.IdsReq) (*system.CommonResp, error) {
	if err := l.svcCtx.DB.Where("id IN ?", in.Ids).Delete(&sysModel.SundynixDict{}).Error; err != nil {
		return nil, fmt.Errorf("删除字典失败")
	}
	return &system.CommonResp{Code: 200, Msg: "success"}, nil
}
