From 08b1e36548fc708c552e8ba60a8d9cb2f54dd98a Mon Sep 17 00:00:00 2001 From: wxy <14293288+zysysys@user.noreply.gitee.com> Date: Fri, 24 May 2024 14:53:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/run-auth.bat | 14 + jing-common/jing-common-core/pom.xml | 118 +++ .../com/jing/file/config/ResourcesConfig.java | 50 + .../com/jing/system/domain/vo/RouterVo.java | 148 +++ jing-ui/public/robots.txt | 2 + jing-ui/src/api/system/role.js | 119 +++ jing-ui/src/assets/icons/svg/peoples.svg | 1 + jing-ui/src/assets/icons/svg/phone.svg | 1 + jing-ui/src/assets/icons/svg/row.svg | 1 + jing-ui/src/components/Crontab/result.vue | 559 +++++++++++ jing-ui/src/permission.js | 58 ++ jing-ui/src/store/modules/permission.js | 137 +++ jing-ui/src/utils/permission.js | 47 + jing-ui/src/views/dashboard/PieChart.vue | 79 ++ jing-ui/src/views/tool/build/RightPanel.vue | 946 ++++++++++++++++++ 15 files changed, 2280 insertions(+) create mode 100644 bin/run-auth.bat create mode 100644 jing-common/jing-common-core/pom.xml create mode 100644 jing-modules/jing-file/src/main/java/com/jing/file/config/ResourcesConfig.java create mode 100644 jing-modules/jing-system/src/main/java/com/jing/system/domain/vo/RouterVo.java create mode 100644 jing-ui/public/robots.txt create mode 100644 jing-ui/src/api/system/role.js create mode 100644 jing-ui/src/assets/icons/svg/peoples.svg create mode 100644 jing-ui/src/assets/icons/svg/phone.svg create mode 100644 jing-ui/src/assets/icons/svg/row.svg create mode 100644 jing-ui/src/components/Crontab/result.vue create mode 100644 jing-ui/src/permission.js create mode 100644 jing-ui/src/store/modules/permission.js create mode 100644 jing-ui/src/utils/permission.js create mode 100644 jing-ui/src/views/dashboard/PieChart.vue create mode 100644 jing-ui/src/views/tool/build/RightPanel.vue diff --git a/bin/run-auth.bat b/bin/run-auth.bat new file mode 100644 index 0000000..d1d1bef --- /dev/null +++ b/bin/run-auth.bat @@ -0,0 +1,14 @@ +@echo off +echo. +echo [信息] 使用Jar命令运行Auth工程。 +echo. + +cd %~dp0 +cd ../jing-auth/target + +set JAVA_OPTS=-Xms512m -Xmx1024m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m + +java -Dfile.encoding=utf-8 %JAVA_OPTS% -jar jing-auth.jar + +cd bin +pause \ No newline at end of file diff --git a/jing-common/jing-common-core/pom.xml b/jing-common/jing-common-core/pom.xml new file mode 100644 index 0000000..aa0609e --- /dev/null +++ b/jing-common/jing-common-core/pom.xml @@ -0,0 +1,118 @@ + + + + com.jing + jing-common + 3.6.4 + + 4.0.0 + + jing-common-core + + + jing-common-core鏍稿績妯″潡 + + + + + + + org.springframework.cloud + spring-cloud-starter-openfeign + + + + + org.springframework.cloud + spring-cloud-starter-loadbalancer + + + + + org.springframework + spring-context-support + + + + + org.springframework + spring-web + + + + + com.alibaba + transmittable-thread-local + + + + + com.github.pagehelper + pagehelper-spring-boot-starter + + + + + org.springframework.boot + spring-boot-starter-validation + + + + + com.fasterxml.jackson.core + jackson-databind + + + + + com.alibaba.fastjson2 + fastjson2 + + + + + io.jsonwebtoken + jjwt + + + + + javax.xml.bind + jaxb-api + + + + + org.apache.commons + commons-lang3 + + + + + commons-io + commons-io + + + + + org.apache.poi + poi-ooxml + + + + + javax.servlet + javax.servlet-api + + + + + io.swagger + swagger-annotations + + + + + diff --git a/jing-modules/jing-file/src/main/java/com/jing/file/config/ResourcesConfig.java b/jing-modules/jing-file/src/main/java/com/jing/file/config/ResourcesConfig.java new file mode 100644 index 0000000..208e520 --- /dev/null +++ b/jing-modules/jing-file/src/main/java/com/jing/file/config/ResourcesConfig.java @@ -0,0 +1,50 @@ +package com.jing.file.config; + +import java.io.File; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.CorsRegistry; +import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +/** + * 閫氱敤鏄犲皠閰嶇疆 + * + * @author ruoyi + */ +@Configuration +public class ResourcesConfig implements WebMvcConfigurer +{ + /** + * 涓婁紶鏂囦欢瀛樺偍鍦ㄦ湰鍦扮殑鏍硅矾寰 + */ + @Value("${file.path}") + private String localFilePath; + + /** + * 璧勬簮鏄犲皠璺緞 鍓嶇紑 + */ + @Value("${file.prefix}") + public String localFilePrefix; + + @Override + public void addResourceHandlers(ResourceHandlerRegistry registry) + { + /** 鏈湴鏂囦欢涓婁紶璺緞 */ + registry.addResourceHandler(localFilePrefix + "/**") + .addResourceLocations("file:" + localFilePath + File.separator); + } + + /** + * 寮鍚法鍩 + */ + @Override + public void addCorsMappings(CorsRegistry registry) { + // 璁剧疆鍏佽璺ㄥ煙鐨勮矾鐢 + registry.addMapping(localFilePrefix + "/**") + // 璁剧疆鍏佽璺ㄥ煙璇锋眰鐨勫煙鍚 + .allowedOrigins("*") + // 璁剧疆鍏佽鐨勬柟娉 + .allowedMethods("GET"); + } +} \ No newline at end of file diff --git a/jing-modules/jing-system/src/main/java/com/jing/system/domain/vo/RouterVo.java b/jing-modules/jing-system/src/main/java/com/jing/system/domain/vo/RouterVo.java new file mode 100644 index 0000000..e35bbea --- /dev/null +++ b/jing-modules/jing-system/src/main/java/com/jing/system/domain/vo/RouterVo.java @@ -0,0 +1,148 @@ +package com.jing.system.domain.vo; + +import com.fasterxml.jackson.annotation.JsonInclude; +import java.util.List; + +/** + * 璺敱閰嶇疆淇℃伅 + * + * @author ruoyi + */ +@JsonInclude(JsonInclude.Include.NON_EMPTY) +public class RouterVo +{ + /** + * 璺敱鍚嶅瓧 + */ + private String name; + + /** + * 璺敱鍦板潃 + */ + private String path; + + /** + * 鏄惁闅愯棌璺敱锛屽綋璁剧疆 true 鐨勬椂鍊欒璺敱涓嶄細鍐嶄晶杈规爮鍑虹幇 + */ + private boolean hidden; + + /** + * 閲嶅畾鍚戝湴鍧锛屽綋璁剧疆 noRedirect 鐨勬椂鍊欒璺敱鍦ㄩ潰鍖呭睉瀵艰埅涓笉鍙鐐瑰嚮 + */ + private String redirect; + + /** + * 缁勪欢鍦板潃 + */ + private String component; + + /** + * 璺敱鍙傛暟锛氬 {"id": 1, "name": "ry"} + */ + private String query; + + /** + * 褰撲綘涓涓矾鐢变笅闈㈢殑 children 澹版槑鐨勮矾鐢卞ぇ浜1涓椂锛岃嚜鍔ㄤ細鍙樻垚宓屽鐨勬ā寮--濡傜粍浠堕〉闈 + */ + private Boolean alwaysShow; + + /** + * 鍏朵粬鍏冪礌 + */ + private MetaVo meta; + + /** + * 瀛愯矾鐢 + */ + private List children; + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public String getPath() + { + return path; + } + + public void setPath(String path) + { + this.path = path; + } + + public boolean getHidden() + { + return hidden; + } + + public void setHidden(boolean hidden) + { + this.hidden = hidden; + } + + public String getRedirect() + { + return redirect; + } + + public void setRedirect(String redirect) + { + this.redirect = redirect; + } + + public String getComponent() + { + return component; + } + + public void setComponent(String component) + { + this.component = component; + } + + public String getQuery() + { + return query; + } + + public void setQuery(String query) + { + this.query = query; + } + + public Boolean getAlwaysShow() + { + return alwaysShow; + } + + public void setAlwaysShow(Boolean alwaysShow) + { + this.alwaysShow = alwaysShow; + } + + public MetaVo getMeta() + { + return meta; + } + + public void setMeta(MetaVo meta) + { + this.meta = meta; + } + + public List getChildren() + { + return children; + } + + public void setChildren(List children) + { + this.children = children; + } +} diff --git a/jing-ui/public/robots.txt b/jing-ui/public/robots.txt new file mode 100644 index 0000000..77470cb --- /dev/null +++ b/jing-ui/public/robots.txt @@ -0,0 +1,2 @@ +User-agent: * +Disallow: / \ No newline at end of file diff --git a/jing-ui/src/api/system/role.js b/jing-ui/src/api/system/role.js new file mode 100644 index 0000000..f13e6f4 --- /dev/null +++ b/jing-ui/src/api/system/role.js @@ -0,0 +1,119 @@ +import request from '@/utils/request' + +// 鏌ヨ瑙掕壊鍒楄〃 +export function listRole(query) { + return request({ + url: '/system/role/list', + method: 'get', + params: query + }) +} + +// 鏌ヨ瑙掕壊璇︾粏 +export function getRole(roleId) { + return request({ + url: '/system/role/' + roleId, + method: 'get' + }) +} + +// 鏂板瑙掕壊 +export function addRole(data) { + return request({ + url: '/system/role', + method: 'post', + data: data + }) +} + +// 淇敼瑙掕壊 +export function updateRole(data) { + return request({ + url: '/system/role', + method: 'put', + data: data + }) +} + +// 瑙掕壊鏁版嵁鏉冮檺 +export function dataScope(data) { + return request({ + url: '/system/role/dataScope', + method: 'put', + data: data + }) +} + +// 瑙掕壊鐘舵佷慨鏀 +export function changeRoleStatus(roleId, status) { + const data = { + roleId, + status + } + return request({ + url: '/system/role/changeStatus', + method: 'put', + data: data + }) +} + +// 鍒犻櫎瑙掕壊 +export function delRole(roleId) { + return request({ + url: '/system/role/' + roleId, + method: 'delete' + }) +} + +// 鏌ヨ瑙掕壊宸叉巿鏉冪敤鎴峰垪琛 +export function allocatedUserList(query) { + return request({ + url: '/system/role/authUser/allocatedList', + method: 'get', + params: query + }) +} + +// 鏌ヨ瑙掕壊鏈巿鏉冪敤鎴峰垪琛 +export function unallocatedUserList(query) { + return request({ + url: '/system/role/authUser/unallocatedList', + method: 'get', + params: query + }) +} + +// 鍙栨秷鐢ㄦ埛鎺堟潈瑙掕壊 +export function authUserCancel(data) { + return request({ + url: '/system/role/authUser/cancel', + method: 'put', + data: data + }) +} + +// 鎵归噺鍙栨秷鐢ㄦ埛鎺堟潈瑙掕壊 +export function authUserCancelAll(data) { + return request({ + url: '/system/role/authUser/cancelAll', + method: 'put', + params: data + }) +} + +// 鎺堟潈鐢ㄦ埛閫夋嫨 +export function authUserSelectAll(data) { + return request({ + url: '/system/role/authUser/selectAll', + method: 'put', + params: data + }) +} + +// 鏍规嵁瑙掕壊ID鏌ヨ閮ㄩ棬鏍戠粨鏋 +export function deptTreeSelect(roleId) { + return request({ + url: '/system/role/deptTree/' + roleId, + method: 'get' + }) +} diff --git a/jing-ui/src/assets/icons/svg/peoples.svg b/jing-ui/src/assets/icons/svg/peoples.svg new file mode 100644 index 0000000..aab852e --- /dev/null +++ b/jing-ui/src/assets/icons/svg/peoples.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/jing-ui/src/assets/icons/svg/phone.svg b/jing-ui/src/assets/icons/svg/phone.svg new file mode 100644 index 0000000..ab8e8c4 --- /dev/null +++ b/jing-ui/src/assets/icons/svg/phone.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/jing-ui/src/assets/icons/svg/row.svg b/jing-ui/src/assets/icons/svg/row.svg new file mode 100644 index 0000000..0780992 --- /dev/null +++ b/jing-ui/src/assets/icons/svg/row.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/jing-ui/src/components/Crontab/result.vue b/jing-ui/src/components/Crontab/result.vue new file mode 100644 index 0000000..aea6e0e --- /dev/null +++ b/jing-ui/src/components/Crontab/result.vue @@ -0,0 +1,559 @@ + + + diff --git a/jing-ui/src/permission.js b/jing-ui/src/permission.js new file mode 100644 index 0000000..c568979 --- /dev/null +++ b/jing-ui/src/permission.js @@ -0,0 +1,58 @@ +import router from './router' +import store from './store' +import { Message } from 'element-ui' +import NProgress from 'nprogress' +import 'nprogress/nprogress.css' +import { getToken } from '@/utils/auth' +import { isRelogin } from '@/utils/request' + +NProgress.configure({ showSpinner: false }) + +const whiteList = ['/login', '/register'] + +router.beforeEach((to, from, next) => { + NProgress.start() + if (getToken()) { + to.meta.title && store.dispatch('settings/setTitle', to.meta.title) + /* has token*/ + if (to.path === '/login') { + next({ path: '/' }) + NProgress.done() + } else if (whiteList.indexOf(to.path) !== -1) { + next() + } else { + if (store.getters.roles.length === 0) { + isRelogin.show = true + // 鍒ゆ柇褰撳墠鐢ㄦ埛鏄惁宸叉媺鍙栧畬user_info淇℃伅 + store.dispatch('GetInfo').then(() => { + isRelogin.show = false + store.dispatch('GenerateRoutes').then(accessRoutes => { + // 鏍规嵁roles鏉冮檺鐢熸垚鍙闂殑璺敱琛 + router.addRoutes(accessRoutes) // 鍔ㄦ佹坊鍔犲彲璁块棶璺敱琛 + next({ ...to, replace: true }) // hack鏂规硶 纭繚addRoutes宸插畬鎴 + }) + }).catch(err => { + store.dispatch('LogOut').then(() => { + Message.error(err) + next({ path: '/' }) + }) + }) + } else { + next() + } + } + } else { + // 娌℃湁token + if (whiteList.indexOf(to.path) !== -1) { + // 鍦ㄥ厤鐧诲綍鐧藉悕鍗曪紝鐩存帴杩涘叆 + next() + } else { + next(`/login?redirect=${encodeURIComponent(to.fullPath)}`) // 鍚﹀垯鍏ㄩ儴閲嶅畾鍚戝埌鐧诲綍椤 + NProgress.done() + } + } +}) + +router.afterEach(() => { + NProgress.done() +}) diff --git a/jing-ui/src/store/modules/permission.js b/jing-ui/src/store/modules/permission.js new file mode 100644 index 0000000..b3c216a --- /dev/null +++ b/jing-ui/src/store/modules/permission.js @@ -0,0 +1,137 @@ +import auth from '@/plugins/auth' +import router, { constantRoutes, dynamicRoutes } from '@/router' +import { getRouters } from '@/api/menu' +import Layout from '@/layout/index' +import ParentView from '@/components/ParentView' +import InnerLink from '@/layout/components/InnerLink' + +const permission = { + state: { + routes: [], + addRoutes: [], + defaultRoutes: [], + topbarRouters: [], + sidebarRouters: [] + }, + mutations: { + SET_ROUTES: (state, routes) => { + state.addRoutes = routes + state.routes = constantRoutes.concat(routes) + }, + SET_DEFAULT_ROUTES: (state, routes) => { + state.defaultRoutes = constantRoutes.concat(routes) + }, + SET_TOPBAR_ROUTES: (state, routes) => { + state.topbarRouters = routes + }, + SET_SIDEBAR_ROUTERS: (state, routes) => { + state.sidebarRouters = routes + }, + }, + actions: { + // 鐢熸垚璺敱 + GenerateRoutes({ commit }) { + return new Promise(resolve => { + // 鍚戝悗绔姹傝矾鐢辨暟鎹 + getRouters().then(res => { + const sdata = JSON.parse(JSON.stringify(res.data)) + const rdata = JSON.parse(JSON.stringify(res.data)) + const sidebarRoutes = filterAsyncRouter(sdata) + const rewriteRoutes = filterAsyncRouter(rdata, false, true) + const asyncRoutes = filterDynamicRoutes(dynamicRoutes); + rewriteRoutes.push({ path: '*', redirect: '/404', hidden: true }) + router.addRoutes(asyncRoutes); + commit('SET_ROUTES', rewriteRoutes) + commit('SET_SIDEBAR_ROUTERS', constantRoutes.concat(sidebarRoutes)) + commit('SET_DEFAULT_ROUTES', sidebarRoutes) + commit('SET_TOPBAR_ROUTES', sidebarRoutes) + resolve(rewriteRoutes) + }) + }) + } + } +} + +// 閬嶅巻鍚庡彴浼犳潵鐨勮矾鐢卞瓧绗︿覆锛岃浆鎹负缁勪欢瀵硅薄 +function filterAsyncRouter(asyncRouterMap, lastRouter = false, type = false) { + return asyncRouterMap.filter(route => { + if (type && route.children) { + route.children = filterChildren(route.children) + } + if (route.component) { + // Layout ParentView 缁勪欢鐗规畩澶勭悊 + if (route.component === 'Layout') { + route.component = Layout + } else if (route.component === 'ParentView') { + route.component = ParentView + } else if (route.component === 'InnerLink') { + route.component = InnerLink + } else { + route.component = loadView(route.component) + } + } + if (route.children != null && route.children && route.children.length) { + route.children = filterAsyncRouter(route.children, route, type) + } else { + delete route['children'] + delete route['redirect'] + } + return true + }) +} + +function filterChildren(childrenMap, lastRouter = false) { + var children = [] + childrenMap.forEach((el, index) => { + if (el.children && el.children.length) { + if (el.component === 'ParentView' && !lastRouter) { + el.children.forEach(c => { + c.path = el.path + '/' + c.path + if (c.children && c.children.length) { + children = children.concat(filterChildren(c.children, c)) + return + } + children.push(c) + }) + return + } + } + if (lastRouter) { + el.path = lastRouter.path + '/' + el.path + if (el.children && el.children.length) { + children = children.concat(filterChildren(el.children, el)) + return + } + } + children = children.concat(el) + }) + return children +} + +// 鍔ㄦ佽矾鐢遍亶鍘嗭紝楠岃瘉鏄惁鍏峰鏉冮檺 +export function filterDynamicRoutes(routes) { + const res = [] + routes.forEach(route => { + if (route.permissions) { + if (auth.hasPermiOr(route.permissions)) { + res.push(route) + } + } else if (route.roles) { + if (auth.hasRoleOr(route.roles)) { + res.push(route) + } + } + }) + return res +} + +export const loadView = (view) => { + if (process.env.NODE_ENV === 'development') { + return (resolve) => require([`@/views/${view}`], resolve) + } else { + // 浣跨敤 import 瀹炵幇鐢熶骇鐜鐨勮矾鐢辨噿鍔犺浇 + return () => import(`@/views/${view}`) + } +} + +export default permission diff --git a/jing-ui/src/utils/permission.js b/jing-ui/src/utils/permission.js new file mode 100644 index 0000000..189a716 --- /dev/null +++ b/jing-ui/src/utils/permission.js @@ -0,0 +1,47 @@ +import store from '@/store' + +/** + * 瀛楃鏉冮檺鏍¢獙 + * @param {Array} value 鏍¢獙鍊 + * @returns {Boolean} + */ +export function checkPermi(value) { + if (value && value instanceof Array && value.length > 0) { + const permissions = store.getters && store.getters.permissions + const permissionDatas = value + const all_permission = "*:*:*"; + + const hasPermission = permissions.some(permission => { + return all_permission === permission || permissionDatas.includes(permission) + }) + + return hasPermission; + + } else { + console.error(`need roles! Like checkPermi="['system:user:add','system:user:edit']"`) + return false + } +} + +/** + * 瑙掕壊鏉冮檺鏍¢獙 + * @param {Array} value 鏍¢獙鍊 + * @returns {Boolean} + */ +export function checkRole(value) { + if (value && value instanceof Array && value.length > 0) { + const roles = store.getters && store.getters.roles + const permissionRoles = value + const super_admin = "admin"; + + const hasRole = roles.some(role => { + return super_admin === role || permissionRoles.includes(role) + }) + + return hasRole; + + } else { + console.error(`need roles! Like checkRole="['admin','editor']"`) + return false + } +} \ No newline at end of file diff --git a/jing-ui/src/views/dashboard/PieChart.vue b/jing-ui/src/views/dashboard/PieChart.vue new file mode 100644 index 0000000..63f0d84 --- /dev/null +++ b/jing-ui/src/views/dashboard/PieChart.vue @@ -0,0 +1,79 @@ + + + diff --git a/jing-ui/src/views/tool/build/RightPanel.vue b/jing-ui/src/views/tool/build/RightPanel.vue new file mode 100644 index 0000000..c2760eb --- /dev/null +++ b/jing-ui/src/views/tool/build/RightPanel.vue @@ -0,0 +1,946 @@ + + + + +