import service from '../../utils/request.mjs';

function useSysApi() {
  return {
    getSysInfo: (id) => {
      return service({
        url: `/api/sysTenant/sysInfo/${id}`,
        method: "GET"
      });
    },
    getSmPublicKey: () => {
      return service({
        url: `/api/sysConfig/smPublicKey`,
        method: "GET"
      });
    },
    getMenuTree: () => {
      return service({
        url: `/api/sysMenu/loginMenuTree`,
        method: "GET"
      });
    },
    getMenuUserMenuList: () => {
      return service({
        url: `/api/sysUserMenu/userMenuList`,
        method: "GET"
      });
    },
    addUserMenu: (data) => {
      return service({
        url: `/api/sysUserMenu/add`,
        method: "POST",
        data
      });
    },
    setNoticeRead: (data) => {
      return service({
        url: `/api/sysNotice/setRead`,
        method: "POST",
        data
      });
    },
    getNoticeTitle: () => {
      return service({
        url: `/api/sysNotice/noticeTitle`,
        method: "GET"
      });
    },
    getNoticeUnReadList: () => {
      return service({
        url: `/api/sysNotice/unReadList`,
        method: "GET"
      });
    },
    NoticePageReceived: (data) => {
      return service({
        url: `/api/sysNotice/pageReceived`,
        method: "POST",
        data
      });
    },
    getUpgradeLastUnRead: () => {
      return service({
        url: `/api/sysUpgrade/lastUnRead`,
        method: "GET"
      });
    },
    // 获取用户信息
    getUserInfo: () => {
      return service({
        url: `/api/sysAuth/userInfo`,
        method: "GET"
      });
    },
    getUserRoleTableList: () => {
      return service({
        url: `/api/sysRole/userRoleTableList`,
        method: "GET"
      });
    },
    getConstList: () => {
      return service({
        url: `/api/sysConst/list`,
        method: "GET"
      });
    },
    getPosList: () => {
      return service({
        url: `/api/sysPos/list`,
        method: "GET"
      });
    },
    getOwnRoleListById: (userid) => {
      return service({
        url: `/api/sysUser/ownRoleList/${userid}`,
        method: "GET"
      });
    },
    getRoleList: () => {
      return service({
        url: `/api/sysRole/list`,
        method: "GET"
      });
    },
    getSysOrgChildTreePidLevel: (pid, level) => {
      return service({
        url: `/api/sysOrg/childTree/${pid}/${level}`,
        method: "GET"
      });
    },
    getOrgList: (params) => {
      return service({
        url: `/api/sysOrg/list`,
        method: "GET",
        params
      });
    },
    getUserBaseInfo: () => {
      return service({
        url: `/api/sysUser/baseInfo`,
        method: "GET"
      });
    },
    getOwnExtOrgListByid: (userid) => {
      return service({
        url: `/api/sysUser/ownExtOrgList/${userid}`,
        method: "GET"
      });
    },
    getAllDictList: () => {
      return service({
        url: `/api/sysDictType/allDictList`,
        method: "GET"
      });
    },
    verifyPwdExpirationTime: () => {
      return service({
        url: `/api/sysUser/verifyPwdExpirationTime`,
        method: "POST"
      });
    },
    changePwd: (data) => {
      return service({
        url: `/fmauth/sysauth/changePwd`,
        method: "POST",
        data
      });
    },
    resetPwd: (data) => {
      return service({
        url: `/fmauth/sysauth/resetPwd`,
        method: "POST",
        data
      });
    },
    unlockLogin: (data) => {
      return service({
        url: `/fmauth/sysauth/unlockLogin`,
        method: "POST",
        data
      });
    },
    changeToken: (data) => {
      return service({
        url: `/fmauth/sysauth/changeToken`,
        method: "POST",
        data
      });
    },
    Logout: () => {
      return service({
        url: `/fmauth/sysauth/logout`,
        method: "POST"
      });
    },
    unLockScreen: (password) => {
      return service({
        url: `/fmauth/sysauth/unlockScreen/?password=${password}`,
        method: "POST"
      });
    },
    getOnlineUserList: (data) => {
      return service({
        url: `/fmauth/sysOnlineUser/page`,
        method: "POST",
        data
      });
    }
  };
}
function feature(promise, errorExt) {
  return promise.then((data) => [null, data]).catch((err) => {
    if (errorExt) {
      const parsedError = Object.assign({}, err, errorExt);
      return [parsedError, void 0];
    }
    return [err, void 0];
  });
}

export { feature, useSysApi };
