Compare commits
2 Commits
feature/us
...
master
| Author | SHA1 | Date |
|---|---|---|
|
|
8e3a573916 | 3 years ago |
|
|
97788886fa | 3 years ago |
7 changed files with 18 additions and 128 deletions
@ -1,30 +0,0 @@ |
|||||||
pipeline{ |
|
||||||
agent any |
|
||||||
|
|
||||||
tools{ |
|
||||||
maven '3.8.6' |
|
||||||
jdk 'JDK 18' |
|
||||||
} |
|
||||||
|
|
||||||
stages { |
|
||||||
stage ('Initialize') { |
|
||||||
steps { |
|
||||||
sh ''' |
|
||||||
echo "PATH = ${PATH}" |
|
||||||
echo "M2_HOME = ${M2_HOME}" |
|
||||||
''' |
|
||||||
} |
|
||||||
} |
|
||||||
stage('Build'){ |
|
||||||
steps{ |
|
||||||
sh 'mvn -Dmaven.test.failure.ignore=true install test' |
|
||||||
} |
|
||||||
post{ |
|
||||||
success{ |
|
||||||
junit 'target/surefire-reports/**/*.xml' |
|
||||||
archiveArtifacts artifacts: 'target/*.jar, *.pom', fingerprint: true, followSymlinks: false, onlyIfSuccessful: true |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,46 +0,0 @@ |
|||||||
package org.leolo.nrapi.util; |
|
||||||
|
|
||||||
|
|
||||||
import org.leolo.nrapi.manager.DatabaseManager; |
|
||||||
import org.slf4j.Logger; |
|
||||||
import org.slf4j.LoggerFactory; |
|
||||||
|
|
||||||
import java.sql.Connection; |
|
||||||
import java.sql.PreparedStatement; |
|
||||||
import java.sql.ResultSet; |
|
||||||
import java.sql.SQLException; |
|
||||||
|
|
||||||
public class RoleUtil { |
|
||||||
|
|
||||||
private static Logger log = LoggerFactory.getLogger(RoleUtil.class); |
|
||||||
|
|
||||||
public static boolean hasPermission(long userId, String prem){ |
|
||||||
try( |
|
||||||
Connection conn = DatabaseManager.getInstance().getConnection(); |
|
||||||
PreparedStatement pstmt = conn.prepareStatement( |
|
||||||
"SELECT 1 FROM user_perm WHERE user_id = ? AND perm_name = ? " + |
|
||||||
"UNION ALL SELECT 1 FROM user_groups ug JOIN group_perm gp on ug.group_id = gp.group_id " + |
|
||||||
"WHERE ug.user_id = ? and gp.perm_name = ?" |
|
||||||
) |
|
||||||
){ |
|
||||||
pstmt.setLong(1, userId); |
|
||||||
pstmt.setString(2, prem); |
|
||||||
pstmt.setLong(3, userId); |
|
||||||
pstmt.setString(4, prem); |
|
||||||
try(ResultSet rs = pstmt.executeQuery()){ |
|
||||||
return rs.next(); |
|
||||||
} |
|
||||||
}catch (SQLException e){ |
|
||||||
log.error(e.getMessage(),e); |
|
||||||
} |
|
||||||
return false; |
|
||||||
} |
|
||||||
|
|
||||||
public static boolean hasPermission(String permission){ |
|
||||||
long userId = HttpReqRespUtils.getUserId(); |
|
||||||
if(userId!=-1){ |
|
||||||
return hasPermission(userId, permission); |
|
||||||
} |
|
||||||
return false; |
|
||||||
} |
|
||||||
} |
|
||||||
Loading…
Reference in new issue