import request from "@/config/axios";

// 钉钉扫码登录
export async function socialLogin(type: string, code: string, state: string) {
  return await request.post({
    url: "/admin-api/system/auth/social-login",
    data: {
      type,
      code,
      state,
    },
  });
}

// 登出
export const loginOut = () => {
  return request.post({ url: "/admin-api/system/auth/logout" });
};

// 获取用户权限信息
export const getUserInfo = () => {
  return request.get({ url: "/admin-api/system/auth/get-permission-info" });
};

// 密码登陆

type UserLoginVO = {
  username: string;
  password: string;
  captchaVerification: string;
  socialType?: string;
  socialCode?: string;
  socialState?: string;
};
export const login = (data: UserLoginVO) => {
  return request.post({
    url: "/admin-api/system/auth/login",
    data,
  });
};

// SSO登录
export const ssoLogin = (data: any) => {
  return request.post({
    url: "/admin-api/system/auth/oaSsoToken",
    headers: { "Content-Type": "application/json" },
    data,
  });
};
