git clone https://github.com/purang-fintech/seppf.git
cd seppf
npm install
npm run dev
npm run build
MIT
@0x88 你要的东西来了
顶!有东西可以来分享啦~
果断 start 支持。 我也在做,很多东西可以参考学习。
dev.dev.js 文件缺失
直接 test.js 好像可以用
虽然没看代码,但是技术栈就很不错,赞。
未提交代码的组件权限控制设计:
目前权限系统的权限控制粒度能控制到按钮级别,按钮和接口权限同步,同时保证前端实现权限控制的同时,保证后端服务的安全(接口权限)
权限配置->资源配置
a.组件名:该值是按钮所属页面组件的名称()
b.组件id:该值是开发自己赋予的值(该值要确保在当前页面是唯一的)
c.接口:该按钮功能下对应的接口权限(按钮可能存在一对多的情况,目前支持单一接口的权限)
d.接口类型:略
e.角色:按钮和接口对应的角色
f.是否生效:略
目前前端提供了两个权限组件用于权限控制(auth.js、has.js)
使用该指令后,就可以通过页面配置权限的方式动态的给使用该指令的按钮分配权限
例如资源配置里的删除按钮
<el-button v-auth="{id:'deleteResource',component:'ResourceConfig'}" icon="el-icon-delete" @user1="deleteResourceConfig(scope.row)" type="text"
class="oper-button"
style="color:#EE6F6F"></el-button>
v-auth指令中两个必须参数;id该页面中该按钮的唯一标识;component为当前组件的name;
注意:在确认使用 v-has 的时候必须在该组件测 created 方法中加入 this.$auth();
如图:
v-has指令属于前端控制指令、仅对前端的按钮做权限控制,适合资源配置页面,虽然资源配置页面也使用v-auth指令,但是对于资源配置页面的按钮权限来说,使用v-has更加合适
<el-button v-has="['admin']" style="float: right; padding: 3px 0" type="text" @user2="addResource">添加</el-button>
v-has 指令的参数为数组形式,可以加入多个角色,在这里个人不推荐使用 id 作为参数,而是采用 code
1.auth.js
function install(Vue, options = {}) {
Vue.directive(options.name || "auth", {
inserted(el, binding) {
if (!check(binding.value)) {
el.parentNode && el.parentNode.removeChild(el);
}
}
});
}
function getCurrentAuthority() {
return JSON.parse(localStorage.getItem("roleIds"));
}
function check(authInfo) {
const currentAuthority = getCurrentAuthority();
alert(this.$options.name);
let auth = localStorage.getItem(authInfo.component);
let authJson = JSON.parse(auth);
for (let authData of authJson) {
if (authData.authId == authInfo.id) {
return currentAuthority.some(item => authData.roleIds.includes(item));
}
}
return false;
}
export default {install};
2.has.js
function install(Vue, options = {}) {
Vue.directive(options.name || "has", {
inserted(el, binding) {
if (!check(binding.value)) {
el.parentNode && el.parentNode.removeChild(el);
}
}
});
}
function getCurrentAuthority() {
return JSON.parse(localStorage.getItem("roleCodes"));
}
function check(roles) {
return getCurrentAuthority().some(item => roles.includes(item));;
}
export default {install};
对于在资源配置页面配置过的接口需要在后端接口加上相应的权限标识,以让配置生效
例如在上面配置的删除资源配置的权限接口可以加上@ApiPermission注解以让该接口的权限生效
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface ApiPermission {
Role[] roles() default ALL;
boolean dynamic() default true;
RoleGroup[] groups() default RoleGroup.ALL;
enum RoleGroup {
ALL
}
}
目前该注解有三个参数:roles、dynamic、groups
groups 可以忽略
roles和dynamic是成对出现的,如果我们不想动态配置接口的权限,可以将dynamic设置为false,然后设置roles,否则单独设置roles并不会生效,因为默认情况dynamic为true会从数据库读取相关角色信息
@ 米阳 MeYoung 看声明
部署后端的时候 最后一步报错了 java -Dpath=/opt/seppb/conf/spring.properties -jar /opt/seppb/sepp.jar &
提示:Unable to access jarfile /opt/seppb/sepp.jar
添加了几张基本的逻辑控制说明思维导图
1、你是 IDE 报错还是命令行 mvn package 报错?
2、你确定你的代码版本是最新的吗?
3、你确定你按照 readme 一步一步操作了没有?
4、我这 pom.xml 写的清清楚楚,您还需要什么信息,我一个个给您找?
环境如下:
1.java:1.8.0_181
2.maven 版本:apache-maven-3.6.0
构建命令:使用官方
1.mvn clean package -Dmaven.test.skip=true
2.官方图
3.git 代码分支:master,日志版本信息如下:
备注:我们这边仅先尝试部署起来进行功能查看,所以要是能直接提供 jar 包,我就不必本地构建啦。
报错信息:
[INFO] /geelyapp/seppb/src/main/java/com/pr/sepp/utils/fasfdfs/conn/FdfsConnectionPool.java: Recompile with -Xlint:unchecked for details.
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /geelyapp/seppb/src/main/java/com/pr/sepp/utils/jenkins/JenkinsClientManager.java:[34,89] cannot find symbol
symbol: method getBuildJenkinsClientProviderMap()
location: variable jenkinsClientProvider of type com.pr.sepp.utils.jenkins.JenkinsClientProvider
[ERROR] /geelyapp/seppb/src/main/java/com/pr/sepp/utils/jenkins/JenkinsClientManager.java:[37,84] cannot find symbol
symbol: method getJenkinsClientProviderMap()
location: variable jenkinsClientProvider of type com.pr.sepp.utils.jenkins.JenkinsClientProvider
[INFO] 2 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 23.076 s
[INFO] Finished at: 2020-01-08T09:12:05+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project sepp: Compilation failure: Compilation failure:
[ERROR] /geelyapp/seppb/src/main/java/com/pr/sepp/utils/jenkins/JenkinsClientManager.java:[34,89] cannot find symbol
[ERROR] symbol: method getBuildJenkinsClientProviderMap()
[ERROR] location: variable jenkinsClientProvider of type com.pr.sepp.utils.jenkins.JenkinsClientProvider
[ERROR] /geelyapp/seppb/src/main/java/com/pr/sepp/utils/jenkins/JenkinsClientManager.java:[37,84] cannot find symbol
[ERROR] symbol: method getJenkinsClientProviderMap()
[ERROR] location: variable jenkinsClientProvider of type com.pr.sepp.utils.jenkins.JenkinsClientProvider
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project sepp: Compilation failure
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
Caused by: org.apache.maven.plugin.compiler.CompilationFailureException: Compilation failure
at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute (AbstractCompilerMojo.java:1161)
at org.apache.maven.plugin.compiler.CompilerMojo.execute (CompilerMojo.java:168)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
谢谢大佬,构建可以了,不过还有一个问题配置文件里面的 AES 加密(密钥采用里面默认自定义)提示解密失败
配置如下:
dbc.username=这个地方换成自己加密后的user
jdbc.password=换成加密后的pwd
signing.secret=1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ
看代码,加解密的 key 要一致,源码里默认是写死的,没有给你配置的机会
private static final String ERROR_EN_MSG = "用户名密码解密失败";
private static final String ERROR_DE_MSG = "用户名密码解密失败";
private static final String CIPHER_INSTANCE = "AES/CBC/PKCS5Padding";
private static final String SERIAL_KEY = "0102030405060708";
private static final String ENCRYPT_STYLE = "AES";