merge
This commit is contained in:
@ -3,22 +3,24 @@ import { AxiosPromise } from 'axios';
|
||||
import { LoginData, LoginResult, VerifyCodeResult, TenantInfo } from './types';
|
||||
import { UserInfo } from '@/api/system/user/types';
|
||||
|
||||
// pc端固定客户端授权id
|
||||
const clientId = 'e5cd7e4891bf95d1d19206ce24a7b32e';
|
||||
|
||||
/**
|
||||
* @param data {LoginData}
|
||||
* @returns
|
||||
*/
|
||||
export function login(data: LoginData): AxiosPromise<LoginResult> {
|
||||
const params = {
|
||||
tenantId: data.tenantId,
|
||||
username: data.username.trim(),
|
||||
password: data.password,
|
||||
code: data.code,
|
||||
uuid: data.uuid
|
||||
...data,
|
||||
clientId: data.clientId || clientId,
|
||||
grantType: data.grantType || 'password'
|
||||
};
|
||||
return request({
|
||||
url: '/auth/login',
|
||||
headers: {
|
||||
isToken: false
|
||||
isToken: false,
|
||||
isEncrypt: true
|
||||
},
|
||||
method: 'post',
|
||||
data: params
|
||||
@ -60,19 +62,20 @@ export function getCodeImg(): AxiosPromise<VerifyCodeResult> {
|
||||
timeout: 20000
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 第三方登录
|
||||
* @param source 第三方登录类型
|
||||
* */
|
||||
export function socialLogin(source: string, code: any, state: any): AxiosPromise<any> {
|
||||
const data = {
|
||||
code,
|
||||
state
|
||||
*/
|
||||
export function callback(data: LoginData): AxiosPromise<any> {
|
||||
const LoginData = {
|
||||
...data,
|
||||
clientId: clientId,
|
||||
grantType: 'social'
|
||||
};
|
||||
return request({
|
||||
url: '/auth/social-login/' + source,
|
||||
method: 'get',
|
||||
params: data
|
||||
url: '/auth/social/callback',
|
||||
method: 'post',
|
||||
data: LoginData
|
||||
});
|
||||
}
|
||||
|
||||
|
80
src/api/system/client/index.ts
Normal file
80
src/api/system/client/index.ts
Normal file
@ -0,0 +1,80 @@
|
||||
import request from '@/utils/request';
|
||||
import { AxiosPromise } from 'axios';
|
||||
import { ClientVO, ClientForm, ClientQuery } from '@/api/system/client/types';
|
||||
|
||||
/**
|
||||
* 查询客户端管理列表
|
||||
* @param query
|
||||
* @returns {*}
|
||||
*/
|
||||
|
||||
export const listClient = (query?: ClientQuery): AxiosPromise<ClientVO[]> => {
|
||||
return request({
|
||||
url: '/system/client/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 查询客户端管理详细
|
||||
* @param id
|
||||
*/
|
||||
export const getClient = (id: string | number): AxiosPromise<ClientVO> => {
|
||||
return request({
|
||||
url: '/system/client/' + id,
|
||||
method: 'get'
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 新增客户端管理
|
||||
* @param data
|
||||
*/
|
||||
export const addClient = (data: ClientForm) => {
|
||||
return request({
|
||||
url: '/system/client',
|
||||
method: 'post',
|
||||
data: data
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 修改客户端管理
|
||||
* @param data
|
||||
*/
|
||||
export const updateClient = (data: ClientForm) => {
|
||||
return request({
|
||||
url: '/system/client',
|
||||
method: 'put',
|
||||
data: data
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 删除客户端管理
|
||||
* @param id
|
||||
*/
|
||||
export const delClient = (id: string | number | Array<string | number>) => {
|
||||
return request({
|
||||
url: '/system/client/' + id,
|
||||
method: 'delete'
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 状态修改
|
||||
* @param id ID
|
||||
* @param status 状态
|
||||
*/
|
||||
export function changeStatus(id: number | string, status: string) {
|
||||
const data = {
|
||||
id,
|
||||
status
|
||||
};
|
||||
return request({
|
||||
url: '/system/client/changeStatus',
|
||||
method: 'put',
|
||||
data: data
|
||||
});
|
||||
}
|
138
src/api/system/client/types.ts
Normal file
138
src/api/system/client/types.ts
Normal file
@ -0,0 +1,138 @@
|
||||
export interface ClientVO {
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
id: string | number;
|
||||
|
||||
/**
|
||||
* 客户端id
|
||||
*/
|
||||
clientId: string | number;
|
||||
|
||||
/**
|
||||
* 客户端key
|
||||
*/
|
||||
clientKey: string;
|
||||
|
||||
/**
|
||||
* 客户端秘钥
|
||||
*/
|
||||
clientSecret: string;
|
||||
|
||||
/**
|
||||
* 授权类型
|
||||
*/
|
||||
grantTypeList: string[];
|
||||
|
||||
/**
|
||||
* 设备类型
|
||||
*/
|
||||
deviceType: string;
|
||||
|
||||
/**
|
||||
* token活跃超时时间
|
||||
*/
|
||||
activeTimeout: number;
|
||||
|
||||
/**
|
||||
* token固定超时
|
||||
*/
|
||||
timeout: number;
|
||||
|
||||
/**
|
||||
* 状态(0正常 1停用)
|
||||
*/
|
||||
status: string;
|
||||
|
||||
}
|
||||
|
||||
export interface ClientForm extends BaseEntity {
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
id?: string | number;
|
||||
|
||||
/**
|
||||
* 客户端id
|
||||
*/
|
||||
clientId?: string | number;
|
||||
|
||||
/**
|
||||
* 客户端key
|
||||
*/
|
||||
clientKey?: string;
|
||||
|
||||
/**
|
||||
* 客户端秘钥
|
||||
*/
|
||||
clientSecret?: string;
|
||||
|
||||
/**
|
||||
* 授权类型
|
||||
*/
|
||||
grantTypeList?: string[];
|
||||
|
||||
/**
|
||||
* 设备类型
|
||||
*/
|
||||
deviceType?: string;
|
||||
|
||||
/**
|
||||
* token活跃超时时间
|
||||
*/
|
||||
activeTimeout?: number;
|
||||
|
||||
/**
|
||||
* token固定超时
|
||||
*/
|
||||
timeout?: number;
|
||||
|
||||
/**
|
||||
* 状态(0正常 1停用)
|
||||
*/
|
||||
status?: string;
|
||||
|
||||
}
|
||||
|
||||
export interface ClientQuery extends PageQuery {
|
||||
/**
|
||||
* 客户端id
|
||||
*/
|
||||
clientId?: string | number;
|
||||
|
||||
/**
|
||||
* 客户端key
|
||||
*/
|
||||
clientKey?: string;
|
||||
|
||||
/**
|
||||
* 客户端秘钥
|
||||
*/
|
||||
clientSecret?: string;
|
||||
|
||||
/**
|
||||
* 授权类型
|
||||
*/
|
||||
grantType?: string;
|
||||
|
||||
/**
|
||||
* 设备类型
|
||||
*/
|
||||
deviceType?: string;
|
||||
|
||||
/**
|
||||
* token活跃超时时间
|
||||
*/
|
||||
activeTimeout?: number;
|
||||
|
||||
/**
|
||||
* token固定超时
|
||||
*/
|
||||
timeout?: number;
|
||||
|
||||
/**
|
||||
* 状态(0正常 1停用)
|
||||
*/
|
||||
status?: string;
|
||||
|
||||
}
|
@ -15,19 +15,24 @@ export type RegisterForm = {
|
||||
* 登录请求
|
||||
*/
|
||||
export interface LoginData {
|
||||
tenantId: string;
|
||||
username: string;
|
||||
password: string;
|
||||
tenantId?: string;
|
||||
username?: string;
|
||||
password?: string;
|
||||
rememberMe?: boolean;
|
||||
socialCode?: string,
|
||||
socialState?: string,
|
||||
source?: string,
|
||||
code?: string;
|
||||
uuid?: string;
|
||||
clientId: string;
|
||||
grantType: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 登录响应
|
||||
*/
|
||||
export interface LoginResult {
|
||||
token: string;
|
||||
access_token: string;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user