package user

import (
	"context"
	"github.com/gogf/gf/v2/frame/g"
	"server/internal/model"
	"server/internal/service"

	"server/api/user/v1"
)

func (c *ControllerV1) Delete(ctx context.Context, req *v1.DeleteReq) (res *v1.DeleteRes, err error) {
	userId := g.RequestFromCtx(ctx).GetCtxVar("id").Int64()
	out, err := service.User().Delete(ctx, &model.UserDeleteIn{UserId: userId, Password: req.Password})
	if err != nil {
		return nil, err
	}
	return &v1.DeleteRes{Success: out.Success}, nil
}
