12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- import qs from 'qs';
- import { request } from '@/utils';
- /**
- * 获取认证授权服务 url
- */
- const apiUaa = (path: string, params?: unknown) => {
- const apiUrl = params ? `${path}?${qs.stringify(params)}` : path;
- return `/api-uaa${apiUrl}`;
- };
- /**
- * 获取业务服务 url
- */
- const apiBiz = (path: string, params?: unknown) => {
- const apiUrl = params ? `${path}?${qs.stringify(params)}` : path;
- return `/api-biz${apiUrl}`;
- };
- // 登录和注销
- export const loginUser = async () => {
- const params = {
- grant_type: 'password',
- username: 'admin1',
- password: 'admin',
- };
- await request(apiUaa('/oauth/token', params), {
- method: 'POST',
- headers: {
- Authorization: 'Basic ' + btoa('unimat:unimat'),
- },
- });
- };
- export const logoutUser = async () => {
- await request(apiUaa('/oauth/remove/token'));
- };
- export const refreshUser = async () => {
- await request(apiUaa('/oauth/token'));
- };
- // 设备列表
- export const addDevice = async () => {
- await request(apiBiz('/device/add'));
- };
- // 网关基本信息
- export const addGateway = async () => {
- await request(apiBiz('/gateway/add'));
- };
- // 协议基本信息
- export const addProtocolBaseInfo = async () => {
- await request(apiBiz('/protocolBaseInfo/add'), {
- method: 'POST',
- });
- };
|