feat: 包装api接口文档

This commit is contained in:
fit2cloud-chenyw 2021-08-11 14:58:29 +08:00
parent 92c2cbd7a8
commit 99aac19d46
10 changed files with 136 additions and 1 deletions

View File

@ -51,6 +51,7 @@ public class ShiroConfig {
filterMap.put("jwt", new JWTFilter());
filterMap.put("logout", new F2CLogoutFilter());
filterMap.put("link", new F2CLinkFilter());
filterMap.put("doc", new F2CDocFilter());
factoryBean.setSecurityManager(securityManager);
factoryBean.setLoginUrl("/login");
factoryBean.setUnauthorizedUrl("/login");

View File

@ -0,0 +1,26 @@
package io.dataease.auth.filter;
import org.apache.shiro.web.filter.authc.AnonymousFilter;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
public class F2CDocFilter extends AnonymousFilter {
@Override
protected boolean onPreHandle(ServletRequest request, ServletResponse response, Object mappedValue) {
HttpServletRequest req = (HttpServletRequest) request;
String path = "/deApi";
try {
req.getRequestDispatcher(path).forward(req, response);
} catch (ServletException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return true;
}
}

View File

@ -20,7 +20,8 @@ public class ShiroServiceImpl implements ShiroService {
// 配置过滤:不会被拦截的链接 -> 放行 start ----------------------------------------------------------
// 放行Swagger2页面需要放行这些
filterChainDefinitionMap.put("/doc.html",ANON);
filterChainDefinitionMap.put("/doc.html**","doc");
filterChainDefinitionMap.put("/deApi**",ANON);
filterChainDefinitionMap.put("/swagger-ui.html",ANON);
filterChainDefinitionMap.put("/swagger-ui/**",ANON);
filterChainDefinitionMap.put("/swagger/**",ANON);

View File

@ -1,13 +1,21 @@
package io.dataease.controller;
import io.dataease.commons.license.DefaultLicenseService;
import io.dataease.commons.license.F2CLicenseResponse;
import io.dataease.exception.DataEaseException;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.annotation.Resource;
@Controller
@RequestMapping
public class IndexController {
@Resource
private DefaultLicenseService defaultLicenseService;
@GetMapping(value = "/")
public String index() {
return "index.html";
@ -28,5 +36,18 @@ public class IndexController {
return "test.html";
}
@GetMapping("/deApi")
public String deApi() {
F2CLicenseResponse f2CLicenseResponse = defaultLicenseService.validateLicense();
switch (f2CLicenseResponse.getStatus()) {
case valid:
return "doc.html";
default:
// DataEaseException.throwException("Invalid License.");
return "nolic.html";
}
// return "index.html";
}
}

View File

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="shortcut icon" href="<%= BASE_URL %>favicon.ico">
<title>DataEase</title>
</head>
<body style="height: 100%;">
<div id="nolic"></div>
</body>
</html>

View File

@ -0,0 +1,16 @@
<template>
<div id="nolic" style="height:100%;">
<router-view />
</div>
</template>
<script>
export default {
data() {
return {
}
}
}
</script>
<style scoped>
</style>

View File

@ -0,0 +1,17 @@
import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)
export default new Router({
routes: [
{
path: '/',
name: 'home',
component: () => import('../views/nolic/index.vue'),
meta: {
title: '首页'
}
}
]
})

View File

@ -0,0 +1,26 @@
import Vue from 'vue'
import Nolic from './Nolic.vue'
import router from './nolic-router'
import store from '../store'
import '@/styles/index.scss' // global css
import i18n from '../lang' // internationalization
import ElementUI from 'element-ui'
import '@/components/canvas/custom-component' // 注册自定义组件
import widgets from '@/components/widget'
import * as echarts from 'echarts'
import UmyUi from 'umy-ui'
Vue.use(UmyUi)
Vue.prototype.$echarts = echarts
Vue.config.productionTip = false
Vue.use(widgets)
Vue.use(ElementUI, {
i18n: (key, value) => i18n.t(key, value)
})
new Vue({
router,
store,
i18n,
render: h => h(Nolic)
}).$mount('#nolic')

View File

@ -0,0 +1,9 @@
<template>
<div>缺少许可</div>
</template>
<script>
export default {
}
</script>

View File

@ -40,6 +40,11 @@ module.exports = {
entry: 'src/link/link.js',
template: 'public/link.html',
filename: 'link.html'
},
nolic: {
entry: 'src/nolic/nolic.js',
template: 'public/nolic.html',
filename: 'nolic.html'
}
},
configureWebpack: {