package user_social

import (
	"context"
	"git.noahlan.cn/n-admin/n-admin-server/rpc/core/ent/usersocial"
	"git.noahlan.cn/n-admin/n-admin-server/rpc/core/internal/utils/hander"
	"git.noahlan.cn/noahlan/ntool-biz/core/nstatus/code"
	"git.noahlan.cn/noahlan/ntool-biz/core/nstatus/msg"

	"git.noahlan.cn/n-admin/n-admin-server/rpc/core/internal/svc"
	"git.noahlan.cn/n-admin/n-admin-server/rpc/core/types/core"
)

type DeleteUserSocialLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewDeleteUserSocialLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteUserSocialLogic {
	return &DeleteUserSocialLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *DeleteUserSocialLogic) DeleteUserSocial(in *core.IDsReq) (*core.BaseResp, error) {
	_, err := l.svcCtx.DB.UserSocial.Delete().Where(usersocial.IDIn(in.Ids...)).Exec(l.ctx)
	if err != nil {
		return nil, hander.HandleEntErr(err, in)
	}
	return &core.BaseResp{
		Code: code.StatusOK,
		Msg:  msg.DeleteSuccess,
	}, nil
}
