mirror of
https://github.com/vbenjs/vue-vben-admin.git
synced 2025-08-26 08:36:19 +08:00
initial commit
This commit is contained in:
18
src/api/sys/menu.ts
Normal file
18
src/api/sys/menu.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { defHttp } from '/@/utils/http/axios';
|
||||
|
||||
import { getMenuListByIdParams, getMenuListByIdParamsResultModel } from './model/menuModel';
|
||||
|
||||
enum Api {
|
||||
GetMenuListById = '/getMenuListById',
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 根据id获取用户菜单
|
||||
*/
|
||||
export function getMenuListById(params: getMenuListByIdParams) {
|
||||
return defHttp.request<getMenuListByIdParamsResultModel>({
|
||||
url: Api.GetMenuListById,
|
||||
method: 'GET',
|
||||
params,
|
||||
});
|
||||
}
|
23
src/api/sys/model/menuModel.ts
Normal file
23
src/api/sys/model/menuModel.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { RouteMeta } from '/@/router/types';
|
||||
export interface RouteItem {
|
||||
path: string;
|
||||
component: any;
|
||||
meta: RouteMeta;
|
||||
name?: string;
|
||||
alias?: string | string[];
|
||||
redirect?: string;
|
||||
caseSensitive?: boolean;
|
||||
children?: RouteItem[];
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 获取菜单接口
|
||||
*/
|
||||
export interface getMenuListByIdParams {
|
||||
id: number | string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 获取菜单返回值
|
||||
*/
|
||||
export type getMenuListByIdParamsResultModel = RouteItem[];
|
43
src/api/sys/model/userModel.ts
Normal file
43
src/api/sys/model/userModel.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
* @description: Login interface parameters
|
||||
*/
|
||||
export interface LoginParams {
|
||||
username: string;
|
||||
password: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: Get user information
|
||||
*/
|
||||
export interface GetUserInfoByUserIdParams {
|
||||
userId: string | number;
|
||||
}
|
||||
|
||||
export interface RoleInfo {
|
||||
roleName: string;
|
||||
value: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: Login interface return value
|
||||
*/
|
||||
export interface LoginResultModel {
|
||||
userId: string | number;
|
||||
token: string;
|
||||
role: RoleInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: Get user information return value
|
||||
*/
|
||||
export interface GetUserInfoByUserIdModel {
|
||||
role: RoleInfo;
|
||||
// 用户id
|
||||
userId: string | number;
|
||||
// 用户名
|
||||
username: string;
|
||||
// 真实名字
|
||||
realName: string;
|
||||
// 介绍
|
||||
desc?: string;
|
||||
}
|
48
src/api/sys/user.ts
Normal file
48
src/api/sys/user.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
import { defHttp } from '/@/utils/http/axios';
|
||||
import {
|
||||
LoginParams,
|
||||
LoginResultModel,
|
||||
GetUserInfoByUserIdParams,
|
||||
GetUserInfoByUserIdModel,
|
||||
} from './model/userModel';
|
||||
|
||||
enum Api {
|
||||
Login = '/login',
|
||||
GetUserInfoById = '/getUserInfoById',
|
||||
GetPermCodeByUserId = '/getPermCodeByUserId',
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: user login api
|
||||
*/
|
||||
export function loginApi(params: LoginParams) {
|
||||
return defHttp.request<LoginResultModel>(
|
||||
{
|
||||
url: Api.Login,
|
||||
method: 'POST',
|
||||
params,
|
||||
},
|
||||
{
|
||||
errorMessageMode: 'modal',
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: getUserInfoById
|
||||
*/
|
||||
export function getUserInfoById(params: GetUserInfoByUserIdParams) {
|
||||
return defHttp.request<GetUserInfoByUserIdModel>({
|
||||
url: Api.GetUserInfoById,
|
||||
method: 'GET',
|
||||
params,
|
||||
});
|
||||
}
|
||||
|
||||
export function getPermCodeByUserId(params: GetUserInfoByUserIdParams) {
|
||||
return defHttp.request<string[]>({
|
||||
url: Api.GetPermCodeByUserId,
|
||||
method: 'GET',
|
||||
params,
|
||||
});
|
||||
}
|
Reference in New Issue
Block a user