Ver código fonte

增加权限配置项

ting.yin 8 anos atrás
pai
commit
76e2517cde

+ 1 - 1
exam-work-api/src/main/java/cn/com/qmth/examcloud/service/examwork/api/ExamApi.java

@@ -55,7 +55,7 @@ public class ExamApi {
     @GetMapping("/exam")
     public ResponseEntity getAllExam(HttpServletRequest request){
     	AccessUser accessUser = (AccessUser) request.getAttribute("accessUser");
-        return new ResponseEntity(examRepo.findByOrgId(accessUser.getOrgId()), HttpStatus.OK);
+        return new ResponseEntity(examRepo.findByOrgId(accessUser.getRootOrgId()), HttpStatus.OK);
     }
 
     @ApiOperation(value="按ID查询考试批次",notes = "ID查询")

+ 28 - 0
exam-work-main/src/main/java/cn/com/qmth/examcloud/service/examwork/AccessControlConfig.java

@@ -0,0 +1,28 @@
+package cn.com.qmth.examcloud.service.examwork;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Profile;
+import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
+
+import cn.com.qmth.examcloud.common.uac.AccessCtrlInterceptor;
+
+/**
+ * prod环境开启权限验证
+ * @author ting.yin
+ */
+@Configuration
+//@Profile("prod")
+public class AccessControlConfig extends WebMvcConfigurerAdapter {
+
+	@Bean
+	public AccessCtrlInterceptor getInterceptor() {
+		return new AccessCtrlInterceptor();
+	}
+
+    @Override
+	public void addInterceptors(InterceptorRegistry registry) {
+		registry.addInterceptor(getInterceptor()).addPathPatterns("/**").excludePathPatterns("/**/swagger-ui.html#/**");
+	}
+}

+ 2 - 2
pom.xml

@@ -19,7 +19,7 @@
     <parent>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-parent</artifactId>
-        <version>1.4.3.RELEASE</version>
+        <version>1.5.2.RELEASE</version>
     </parent>
 
 
@@ -38,7 +38,7 @@
         <!-- maven plugins -->
         <maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
         <maven-compiler-plugin.version>3.3</maven-compiler-plugin.version>
-        <spring.boot.version>1.4.3.RELEASE</spring.boot.version>
+        <spring.boot.version>1.5.2.RELEASE</spring.boot.version>
         <exam.cloud.version>0.1.0</exam.cloud.version>
     </properties>