import microRequest from '../../utils/micro_request';
import type { LoginParams } from '../../types/user';

// 微服务
const basePath = import.meta.env.VITE_ADMIN

/**
 * API 层: 声明请求，使用 micro_request，不处理业务状态存储
 */

// 登录接口 

export function useLoginApi() {

  return {

    signIn: (query: LoginParams) => {
      return microRequest.postRequest(basePath, 'System', 'Login', query);
    },

    signOut: () => {
      return microRequest.postRequest(basePath, 'System', 'Logout');
    },

    getCaptchaImg: () => {
      return microRequest.postRequest(basePath, 'System', 'GetCaptchaImg');
    },

    // 钉钉免登接口
    dingTalkLogin: (data: { code: string }) => {
      return microRequest.postRequest(basePath, 'DingDingApi', 'GetUserInfoByCode', data);
    },

    register: (query?: object) => {
      return microRequest.postRequest(basePath, 'Personnel', 'RegisterPersonnel', query);
    },
    checkUserNamePhoneExists: (query?: object) => {
      return microRequest.postRequest(basePath, 'Personnel', 'CheckUserNamePhoneExists', query);
    },
    validatePassword: (query?: object) => {
      return microRequest.postRequest(basePath, 'Personnel', 'ValidatePassword', query);
    },
    generatePassword: () => {
      return microRequest.postRequest(basePath, 'Personnel', 'GeneratePassword');
    },





  }

}