// 存放路径: src/services/home.ts

import { http } from "@/utils/http";

// 登陆
export const loginByAccount = (data: {
  userName: string;
  password: string;
}) => {
  return http({
    method: "POST",
    url: "/api/user/login",
    data,
  });
};
// 登陆
export const logOut = () => {
  return http({
    method: "POST",
    url: "/api/user/logOut",
  });
};

// 验证码登录
export const loginPhone = (data: { phone: string; code: string }) => {
  return http({
    method: "GET",
    url: "/api/user/loginPhone",
    data,
  });
};

// 发送验证码
export const sendMsg = (data: { phone: string }) => {
  return http({
    method: "GET",
    url: "/api/user/sendMsg",
    data,
  });
};

// 创建角色
export const addRole = (data: { roleCode: string; roleName: string }) => {
  return http({
    method: "POST",
    url: "/api/role/addRole",
    data,
  });
};
// 修改角色
export const updateRole = (data: {
  id: string;
  roleCode: string;
  roleName: string;
  isDeleted: string;
}) => {
  return http({
    method: "POST",
    url: "/api/role/updateRole",
    data,
  });
};

// 发送验证码
export const getRoleList = () => {
  return http({
    method: "GET",
    url: "/api/role/getRoleList",
  });
};
// 验证角色是否重复 1=code 2=名称 3=全部
export const verifyRole = (data: {
  roleCode: string;
  roleName: string;
  type: string;
}) => {
  return http({
    method: "GET",
    url: "/api/role/verifyRole",
    data,
  });
};
// 添加角色菜单权限
export const addMenusRole = (data: {
  id: number;
  list: {
    menusId: number;
    state: number; // 状态1=开启0=关闭
  }[];
}) => {
  return http({
    method: "POST",
    url: "/api/role/addMenusRole",
    data,
  });
};
