前端和后端源码,合并到一个git仓库中,方便用户下载,避免前后端不匹配的问题

This commit is contained in:
JEECG
2024-06-23 10:39:52 +08:00
parent bb918b742e
commit 0325e34dcb
1439 changed files with 171106 additions and 0 deletions

View File

@ -0,0 +1,150 @@
import { defHttp } from '/@/utils/http/axios';
import { message } from 'ant-design-vue';
import { useGlobSetting } from '/@/hooks/setting';
const globSetting = useGlobSetting();
const baseUploadUrl = globSetting.uploadUrl;
enum Api {
positionList = '/sys/position/list',
userList = '/sys/user/list',
roleList = '/sys/role/list',
queryDepartTreeSync = '/sys/sysDepart/queryDepartTreeSync',
queryTreeList = '/sys/sysDepart/queryTreeList',
loadTreeData = '/sys/category/loadTreeData',
loadDictItem = '/sys/category/loadDictItem/',
getDictItems = '/sys/dict/getDictItems/',
getTableList = '/sys/user/queryUserComponentData',
getCategoryData = '/sys/category/loadAllData',
}
/**
* 上传父路径
*/
export const uploadUrl = `${baseUploadUrl}/sys/common/upload`;
/**
* 职务列表
* @param params
*/
export const getPositionList = (params) => {
return defHttp.get({ url: Api.positionList, params });
};
/**
* 用户列表
* @param params
*/
export const getUserList = (params) => {
return defHttp.get({ url: Api.userList, params });
};
/**
* 角色列表
* @param params
*/
export const getRoleList = (params) => {
return defHttp.get({ url: Api.roleList, params });
};
/**
* 异步获取部门树列表
*/
export const queryDepartTreeSync = (params?) => {
return defHttp.get({ url: Api.queryDepartTreeSync, params });
};
/**
* 获取部门树列表
*/
export const queryTreeList = (params?) => {
return defHttp.get({ url: Api.queryTreeList, params });
};
/**
* 分类字典树控件 加载节点
*/
export const loadTreeData = (params?) => {
return defHttp.get({ url: Api.loadTreeData, params });
};
/**
* 根据字典code加载字典text
*/
export const loadDictItem = (params?) => {
return defHttp.get({ url: Api.loadDictItem, params });
};
/**
* 根据字典code加载字典text
*/
export const getDictItems = (dictCode) => {
return defHttp.get({ url: Api.getDictItems + dictCode }, { joinTime: false });
};
/**
* 部门用户modal选择列表加载list
*/
export const getTableList = (params) => {
return defHttp.get({ url: Api.getTableList, params });
};
/**
* 加载全部分类字典数据
*/
export const loadCategoryData = (params) => {
return defHttp.get({ url: Api.getCategoryData, params });
};
/**
* 文件上传
*/
export const uploadFile = (params, success) => {
return defHttp.uploadFile({ url: uploadUrl }, params, { success });
};
/**
* 下载文件
* @param url 文件路径
* @param fileName 文件名
* @param parameter
* @returns {*}
*/
export const downloadFile = (url, fileName?, parameter?) => {
return getFileblob(url, parameter).then((data) => {
if (!data || data.size === 0) {
message.warning('文件下载失败');
return;
}
if (typeof window.navigator.msSaveBlob !== 'undefined') {
window.navigator.msSaveBlob(new Blob([data]), fileName);
} else {
let url = window.URL.createObjectURL(new Blob([data]));
let link = document.createElement('a');
link.style.display = 'none';
link.href = url;
link.setAttribute('download', fileName);
document.body.appendChild(link);
link.click();
document.body.removeChild(link); //下载完成移除元素
window.URL.revokeObjectURL(url); //释放掉blob对象
}
});
};
/**
* 下载文件 用于excel导出
* @param url
* @param parameter
* @returns {*}
*/
export const getFileblob = (url, parameter) => {
return defHttp.get(
{
url: url,
params: parameter,
responseType: 'blob',
},
{ isTransformResponse: false }
);
};
/**
* 【用于评论功能】自定义文件上传-方法
*/
export const uploadMyFile = (url, data) => {
return defHttp.uploadMyFile(url, data);
};

View File

@ -0,0 +1,16 @@
import { defHttp } from '/@/utils/http/axios';
import { GetAccountInfoModel } from './model/accountModel';
enum Api {
ACCOUNT_INFO = '/mock/account/getAccountInfo',
SESSION_TIMEOUT = '/mock/user/sessionTimeout',
TOKEN_EXPIRED = '/mock/user/tokenExpired',
}
// Get personal center-basic settings
export const accountInfoApi = () => defHttp.get<GetAccountInfoModel>({ url: Api.ACCOUNT_INFO });
export const sessionTimeoutApi = () => defHttp.post<void>({ url: Api.SESSION_TIMEOUT });
export const tokenExpiredApi = () => defHttp.post<void>({ url: Api.TOKEN_EXPIRED });

View File

@ -0,0 +1,12 @@
import { defHttp } from '/@/utils/http/axios';
enum Api {
// The address does not exist
Error = '/error',
}
/**
* @description: Trigger ajax error
*/
export const fireErrorApi = () => defHttp.get({ url: Api.Error });

View File

@ -0,0 +1,7 @@
export interface GetAccountInfoModel {
email: string;
name: string;
introduction: string;
phone: string;
address: string;
}

View File

@ -0,0 +1,15 @@
import { BasicFetchResult } from '/@/api/model/baseModel';
export interface DemoOptionsItem {
label: string;
value: string;
}
export interface selectParams {
id: number | string;
}
/**
* @description: Request list return value
*/
export type DemoOptionsGetResultModel = BasicFetchResult<DemoOptionsItem>;

View File

@ -0,0 +1,103 @@
import { BasicPageParams, BasicFetchResult } from '/@/api/model/baseModel';
export type AccountParams = BasicPageParams & {
account?: string;
nickname?: string;
};
export type RoleParams = {
roleName?: string;
status?: string;
};
export type TestParams = {
testName?: string;
};
export type RolePageParams = BasicPageParams & RoleParams;
export type TestPageParams = BasicPageParams & TestParams;
export type UserPageParams = BasicPageParams & UserParams;
export type DeptParams = {
deptName?: string;
status?: string;
};
export type UserParams = {
username?: string;
};
export type MenuParams = {
menuName?: string;
status?: string;
};
export interface AccountListItem {
id: string;
account: string;
email: string;
nickname: string;
role: number;
createTime: string;
remark: string;
status: number;
}
export interface DeptListItem {
id: string;
orderNo: string;
createTime: string;
remark: string;
status: number;
}
export interface MenuListItem {
id: string;
orderNo: string;
createTime: string;
status: number;
icon: string;
component: string;
permission: string;
}
export interface RoleListItem {
id: string;
roleName: string;
roleValue: string;
status: number;
orderNo: string;
createTime: string;
}
export interface TestListItem {
id: string;
testName: string;
testValue: string;
createTime: string;
}
export interface UserListItem {
id: string;
username: string;
password: string;
realname: string;
}
/**
* @description: Request list return value
*/
export type AccountListGetResultModel = BasicFetchResult<AccountListItem>;
export type DeptListGetResultModel = BasicFetchResult<DeptListItem>;
export type MenuListGetResultModel = BasicFetchResult<MenuListItem>;
export type RolePageListGetResultModel = BasicFetchResult<RoleListItem>;
export type RoleListGetResultModel = RoleListItem[];
export type TestListGetResultModel = TestListItem[];
export type UserListGetResultModel = UserListItem[];

View File

@ -0,0 +1,20 @@
import { BasicPageParams, BasicFetchResult } from '/@/api/model/baseModel';
/**
* @description: Request list interface parameters
*/
export type DemoParams = BasicPageParams;
export interface DemoListItem {
id: string;
beginTime: string;
endTime: string;
address: string;
name: string;
no: number;
status: number;
}
/**
* @description: Request list return value
*/
export type DemoListGetResultModel = BasicFetchResult<DemoListItem>;

View File

@ -0,0 +1,10 @@
import { defHttp } from '/@/utils/http/axios';
import { DemoOptionsItem, selectParams } from './model/optionsModel';
enum Api {
OPTIONS_LIST = '/mock/select/getDemoOptions',
}
/**
* @description: Get sample options value
*/
export const optionsListApi = (params?: selectParams) => defHttp.get<DemoOptionsItem[]>({ url: Api.OPTIONS_LIST, params });

View File

@ -0,0 +1,45 @@
import {
AccountParams,
DeptListItem,
MenuParams,
RoleParams,
TestPageParams,
RolePageParams,
MenuListGetResultModel,
DeptListGetResultModel,
AccountListGetResultModel,
RolePageListGetResultModel,
RoleListGetResultModel,
TestListGetResultModel,
} from './model/systemModel';
import { defHttp } from '/@/utils/http/axios';
enum Api {
AccountList = '/mock/system/getAccountList',
IsAccountExist = '/mock/system/accountExist',
DeptList = '/mock/system/getDeptList',
setRoleStatus = '/mock/system/setRoleStatus',
MenuList = '/mock/system/getMenuList',
RolePageList = '/mock/system/getRoleListByPage',
DemoTableList = '/mock/system/getDemoTableListByPage',
TestPageList = '/mock/system/getTestListByPage',
GetAllRoleList = '/mock/system/getAllRoleList',
}
export const getAccountList = (params: AccountParams) => defHttp.get<AccountListGetResultModel>({ url: Api.AccountList, params });
export const getDeptList = (params?: DeptListItem) => defHttp.get<DeptListGetResultModel>({ url: Api.DeptList, params });
export const getMenuList = (params?: MenuParams) => defHttp.get<MenuListGetResultModel>({ url: Api.MenuList, params });
export const getRoleListByPage = (params?: RolePageParams) => defHttp.get<RolePageListGetResultModel>({ url: Api.RolePageList, params });
export const getAllRoleList = (params?: RoleParams) => defHttp.get<RoleListGetResultModel>({ url: Api.GetAllRoleList, params });
export const setRoleStatus = (id: number, status: string) => defHttp.post({ url: Api.setRoleStatus, params: { id, status } });
export const getTestListByPage = (params?: TestPageParams) => defHttp.get<TestListGetResultModel>({ url: Api.TestPageList, params });
export const getDemoTableListByPage = (params) => defHttp.get({ url: Api.DemoTableList, params });
export const isAccountExist = (account: string) => defHttp.post({ url: Api.IsAccountExist, params: { account } }, { errorMessageMode: 'none' });

View File

@ -0,0 +1,19 @@
import { defHttp } from '/@/utils/http/axios';
import { DemoParams, DemoListGetResultModel } from './model/tableModel';
enum Api {
DEMO_LIST = '/mock/table/getDemoList',
}
/**
* @description: Get sample list value
*/
export const demoListApi = (params: DemoParams) =>
defHttp.get<DemoListGetResultModel>({
url: Api.DEMO_LIST,
params,
headers: {
ignoreCancelToken: true,
},
});

View File

@ -0,0 +1,10 @@
import { defHttp } from '/@/utils/http/axios';
enum Api {
TREE_OPTIONS_LIST = '/mock/tree/getDemoOptions',
}
/**
* @description: Get sample options value
*/
export const treeOptionsListApi = (params?: Recordable) => defHttp.get<Recordable[]>({ url: Api.TREE_OPTIONS_LIST, params });

View File

@ -0,0 +1,14 @@
export interface BasicPageParams {
page: number;
pageSize: number;
}
export interface BasicFetchResult<T extends any> {
items: T[];
total: number;
}
export interface BasicResult<T extends any> {
records: T[];
total: number;
}

View File

@ -0,0 +1,43 @@
import { defHttp } from '/@/utils/http/axios';
import { getMenuListResultModel } from './model/menuModel';
enum Api {
GetMenuList = '/sys/permission/getUserPermissionByToken',
// 【QQYUN-8487】
// SwitchVue3Menu = '/sys/switchVue3Menu',
}
/**
* @description: Get user menu based on id
*/
export const getMenuList = () => {
return new Promise((resolve) => {
//为了兼容mock和接口数据
defHttp.get<getMenuListResultModel>({ url: Api.GetMenuList }).then((res) => {
if (Array.isArray(res)) {
resolve(res);
} else {
resolve(res['menu']);
}
});
});
};
/**
* @description: 获取后台菜单权限和按钮权限
*/
export function getBackMenuAndPerms() {
return defHttp.get({ url: Api.GetMenuList });
}
/**
* 切换成vue3菜单
*/
// update-begin--author:liaozhiyang---date:20240313---for【QQYUN-8487】注释掉判断菜单是否vue2版本逻辑代码
// export const switchVue3Menu = () => {
// return new Promise((resolve) => {
// defHttp.get({ url: Api.SwitchVue3Menu });
// });
// };
// update-end--author:liaozhiyang---date:20240313---for【QQYUN-8487】注释掉判断菜单是否vue2版本逻辑代码

View File

@ -0,0 +1,16 @@
import type { RouteMeta } from 'vue-router';
export interface RouteItem {
path: string;
component: any;
meta: RouteMeta;
name?: string;
alias?: string | string[];
redirect?: string;
caseSensitive?: boolean;
children?: RouteItem[];
}
/**
* @description: Get menu return value
*/
export type getMenuListResultModel = RouteItem[];

View File

@ -0,0 +1,5 @@
export interface UploadApiResult {
message: string;
code: number;
url: string;
}

View File

@ -0,0 +1,58 @@
/**
* @description: Login interface parameters
*/
export interface LoginParams {
username: string;
password: string;
}
export interface ThirdLoginParams {
token: string;
thirdType: string;
}
export interface RoleInfo {
roleName: string;
value: string;
}
/**
* @description: Login interface return value
*/
export interface LoginResultModel {
userId: string | number;
token: string;
role: RoleInfo;
userInfo?: any
}
/**
* @description: Get user information return value
*/
export interface GetUserInfoModel {
roles: RoleInfo[];
// 用户id
userId: string | number;
// 用户名
username: string;
// 真实名字
realname: string;
// 头像
avatar: string;
// 介绍
desc?: string;
// 用户信息
userInfo?: any;
// 缓存字典项
sysAllDictItems?: any;
}
/**
* @description: Get user information return value
*/
export interface GetResultModel {
code: number;
message: string;
result: object;
success: Boolean;
}

View File

@ -0,0 +1,32 @@
import { UploadApiResult } from './model/uploadModel';
import { defHttp } from '/@/utils/http/axios';
import { UploadFileParams } from '/#/axios';
import { useGlobSetting } from '/@/hooks/setting';
const { uploadUrl = '' } = useGlobSetting();
/**
* @description: Upload interface
*/
export function uploadApi(params: UploadFileParams, onUploadProgress: (progressEvent: ProgressEvent) => void) {
return defHttp.uploadFile<UploadApiResult>(
{
url: uploadUrl,
onUploadProgress,
},
params
);
}
/**
* @description: Upload interface
*/
export function uploadImg(params: UploadFileParams, onUploadProgress: (progressEvent: ProgressEvent) => void) {
return defHttp.uploadFile<UploadApiResult>(
{
url: `${uploadUrl}/sys/common/upload`,
onUploadProgress,
},
params,
{ isReturnResponse: true }
);
}

View File

@ -0,0 +1,222 @@
import { defHttp } from '/@/utils/http/axios';
import { LoginParams, LoginResultModel, GetUserInfoModel } from './model/userModel';
import { ErrorMessageMode } from '/#/axios';
import { useMessage } from '/@/hooks/web/useMessage';
import { useUserStoreWithOut } from '/@/store/modules/user';
import { setAuthCache } from '/@/utils/auth';
import { TOKEN_KEY } from '/@/enums/cacheEnum';
import { router } from '/@/router';
import { PageEnum } from '/@/enums/pageEnum';
import { ExceptionEnum } from "@/enums/exceptionEnum";
const { createErrorModal } = useMessage();
enum Api {
Login = '/sys/login',
phoneLogin = '/sys/phoneLogin',
Logout = '/sys/logout',
GetUserInfo = '/sys/user/getUserInfo',
// 获取系统权限
// 1、查询用户拥有的按钮/表单访问权限
// 2、所有权限
// 3、系统安全模式
GetPermCode = '/sys/permission/getPermCode',
//新加的获取图形验证码的接口
getInputCode = '/sys/randomImage',
//获取短信验证码的接口
getCaptcha = '/sys/sms',
//注册接口
registerApi = '/sys/user/register',
//校验用户接口
checkOnlyUser = '/sys/user/checkOnlyUser',
//SSO登录校验
validateCasLogin = '/sys/cas/client/validateLogin',
//校验手机号
phoneVerify = '/sys/user/phoneVerification',
//修改密码
passwordChange = '/sys/user/passwordChange',
//第三方登录
thirdLogin = '/sys/thirdLogin/getLoginUser',
//第三方登录
getThirdCaptcha = '/sys/thirdSms',
//获取二维码信息
getLoginQrcode = '/sys/getLoginQrcode',
//监控二维码扫描状态
getQrcodeToken = '/sys/getQrcodeToken',
}
/**
* @description: user login api
*/
export function loginApi(params: LoginParams, mode: ErrorMessageMode = 'modal') {
return defHttp.post<LoginResultModel>(
{
url: Api.Login,
params,
},
{
errorMessageMode: mode,
}
);
}
/**
* @description: user phoneLogin api
*/
export function phoneLoginApi(params: LoginParams, mode: ErrorMessageMode = 'modal') {
return defHttp.post<LoginResultModel>(
{
url: Api.phoneLogin,
params,
},
{
errorMessageMode: mode,
}
);
}
/**
* @description: getUserInfo
*/
export function getUserInfo() {
return defHttp.get<GetUserInfoModel>({ url: Api.GetUserInfo }, {}).catch((e) => {
// update-begin--author:zyf---date:20220425---for:【VUEN-76】捕获接口超时异常,跳转到登录界面
if (e && (e.message.includes('timeout') || e.message.includes('401'))) {
//接口不通时跳转到登录界面
const userStore = useUserStoreWithOut();
userStore.setToken('');
setAuthCache(TOKEN_KEY, null);
// update-begin-author:sunjianlei date:20230306 for: 修复登录成功后,没有正确重定向的问题
router.push({
path: PageEnum.BASE_LOGIN,
query: {
// 传入当前的路由,登录成功后跳转到当前路由
redirect: router.currentRoute.value.fullPath,
}
});
// update-end-author:sunjianlei date:20230306 for: 修复登录成功后,没有正确重定向的问题
}
// update-end--author:zyf---date:20220425---for:【VUEN-76】捕获接口超时异常,跳转到登录界面
});
}
export function getPermCode() {
return defHttp.get({ url: Api.GetPermCode });
}
export function doLogout() {
return defHttp.get({ url: Api.Logout });
}
export function getCodeInfo(currdatetime) {
let url = Api.getInputCode + `/${currdatetime}`;
return defHttp.get({ url: url });
}
/**
* @description: 获取短信验证码
*/
export function getCaptcha(params) {
return new Promise((resolve, reject) => {
defHttp.post({ url: Api.getCaptcha, params }, { isTransformResponse: false }).then((res) => {
console.log(res);
if (res.success) {
resolve(true);
} else {
//update-begin---author:wangshuai---date:2024-04-18---for:【QQYUN-9005】同一个IP1分钟超过5次短信则提示需要验证码---
if(res.code != ExceptionEnum.PHONE_SMS_FAIL_CODE){
createErrorModal({ title: '错误提示', content: res.message || '未知问题' });
reject();
}
reject(res);
//update-end---author:wangshuai---date:2024-04-18---for:【QQYUN-9005】同一个IP1分钟超过5次短信则提示需要验证码---
}
}).catch((res)=>{
createErrorModal({ title: '错误提示', content: res.message || '未知问题' });
reject();
});
});
}
/**
* @description: 注册接口
*/
export function register(params) {
return defHttp.post({ url: Api.registerApi, params }, { isReturnNativeResponse: true });
}
/**
*校验用户是否存在
* @param params
*/
export const checkOnlyUser = (params) => defHttp.get({ url: Api.checkOnlyUser, params }, { isTransformResponse: false });
/**
*校验手机号码
* @param params
*/
export const phoneVerify = (params) => defHttp.post({ url: Api.phoneVerify, params }, { isTransformResponse: false });
/**
*密码修改
* @param params
*/
export const passwordChange = (params) => defHttp.get({ url: Api.passwordChange, params }, { isTransformResponse: false });
/**
* @description: 第三方登录
*/
export function thirdLogin(params, mode: ErrorMessageMode = 'modal') {
//==========begin 第三方登录/auth2登录需要传递租户id===========
let tenantId = "0";
if(!params.tenantId){
tenantId = params.tenantId;
}
//==========end 第三方登录/auth2登录需要传递租户id===========
return defHttp.get<LoginResultModel>(
{
url: `${Api.thirdLogin}/${params.token}/${params.thirdType}/${tenantId}`,
},
{
errorMessageMode: mode,
}
);
}
/**
* @description: 获取第三方短信验证码
*/
export function setThirdCaptcha(params) {
return new Promise((resolve, reject) => {
defHttp.post({ url: Api.getThirdCaptcha, params }, { isTransformResponse: false }).then((res) => {
console.log(res);
if (res.success) {
resolve(true);
} else {
createErrorModal({ title: '错误提示', content: res.message || '未知问题' });
reject();
}
});
});
}
/**
* 获取登录二维码信息
*/
export function getLoginQrcode() {
let url = Api.getLoginQrcode;
return defHttp.get({ url: url });
}
/**
* 监控扫码状态
*/
export function getQrcodeToken(params) {
let url = Api.getQrcodeToken;
return defHttp.get({ url: url, params });
}
/**
* SSO登录校验
*/
export async function validateCasLogin(params) {
let url = Api.validateCasLogin;
return defHttp.get({ url: url, params });
}