Compare commits
14 Commits
master
...
feature/ac
| Author | SHA1 | Date |
|---|---|---|
|
|
8520e56409 | 3 years ago |
|
|
dc69cc4a83 | 3 years ago |
|
|
912bb7b178 | 3 years ago |
|
|
868bdf269d | 3 years ago |
|
|
404a744f07 | 3 years ago |
|
|
cf79616e92 | 3 years ago |
|
|
eab60906db | 3 years ago |
|
|
6f6f7b6122 | 3 years ago |
|
|
5df941e02b | 3 years ago |
|
|
512666f655 | 3 years ago |
|
|
43b4e1e515 | 3 years ago |
|
|
49ca333a0f | 3 years ago |
|
|
2d71ecd71d | 3 years ago |
|
|
cce091734b | 3 years ago |
7 changed files with 150 additions and 17 deletions
@ -0,0 +1,30 @@
|
||||
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 |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,46 @@
|
||||
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; |
||||
} |
||||
} |
||||
@ -0,0 +1,23 @@
|
||||
package org.leolo.nrapi.v0.api; |
||||
|
||||
import org.leolo.nrapi.v0.model.ReturnSet; |
||||
import org.springframework.web.bind.annotation.PathVariable; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
@RestController |
||||
@RequestMapping(value = {"train","v0/train"}) |
||||
public class TrainAPI { |
||||
|
||||
@RequestMapping(value = "/get/{trainId}") |
||||
public ReturnSet getSchedule( |
||||
@PathVariable(name = "trainId") String trainId |
||||
){ |
||||
return new ReturnSet() { |
||||
@Override |
||||
public String get_type() { |
||||
return ReturnSet.super.get_type(); |
||||
} |
||||
}; |
||||
} |
||||
} |
||||
Loading…
Reference in new issue