zouxuan 5 年之前
父节点
当前提交
8364a27fc0

+ 1 - 1
edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/AuthServerApplication.java

@@ -16,7 +16,7 @@ import com.spring4all.swagger.EnableSwagger2Doc;
 
 @SpringBootApplication
 @EnableDiscoveryClient
-@EnableFeignClients({"com.keao.edu"})
+@EnableFeignClients({"com.keao.edu.auth.api.client"})
 @MapperScan("com.keao.edu.auth.dal.dao")
 @ComponentScan(basePackages="com.keao.edu")
 @Configuration

+ 16 - 11
edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/core/filter/PhoneLoginAuthenticationFilter.java

@@ -1,12 +1,9 @@
 package com.keao.edu.auth.core.filter;
 
-import java.io.IOException;
-
-import javax.servlet.FilterChain;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
+import com.keao.edu.auth.api.entity.LoginEntity;
+import com.keao.edu.auth.api.util.SecurityConstants;
+import com.keao.edu.auth.config.token.PhoneAuthenticationToken;
+import com.keao.edu.datasource.DataSourceContextHolder;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.security.authentication.AbstractAuthenticationToken;
 import org.springframework.security.authentication.AuthenticationServiceException;
@@ -15,10 +12,11 @@ import org.springframework.security.core.AuthenticationException;
 import org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter;
 import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
 
-import com.keao.edu.auth.api.entity.LoginEntity;
-import com.keao.edu.auth.api.util.SecurityConstants;
-import com.keao.edu.auth.config.token.PhoneAuthenticationToken;
-import com.keao.edu.datasource.DataSourceContextHolder;
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
 
 public class PhoneLoginAuthenticationFilter extends AbstractAuthenticationProcessingFilter {
 
@@ -26,6 +24,8 @@ public class PhoneLoginAuthenticationFilter extends AbstractAuthenticationProces
 	private static final String SPRING_SECURITY_RESTFUL_VERIFY_CODE_KEY = "smsCode";
 	private static final String clientIdParameter = "clientId";
 	private static final String tenantIdParameter = "tenantId";
+	private static final String registerFlagParameter = "registerFlag";
+	private static final String organIdParameter = "organId";
 
 	private static final String SPRING_SECURITY_RESTFUL_LOGIN_URL = "/smsLogin";
 	private boolean postOnly = true;
@@ -63,6 +63,11 @@ public class PhoneLoginAuthenticationFilter extends AbstractAuthenticationProces
 		loginEntity.setClientId(clientId);
 		loginEntity.setPhone(principal);
 		loginEntity.setSmsCode(credentials);
+		String organId = obtainParameter(request, organIdParameter);
+		if(StringUtils.isNotEmpty(organId)){
+			loginEntity.setOrganId(Integer.parseInt(organId));
+		}
+		loginEntity.setRegisterFlag(obtainParameter(request, registerFlagParameter));
 
 		authRequest = new PhoneAuthenticationToken(SecurityConstants.PHONE_PRINCIPAL_PREFIX + principal, loginEntity);
 

+ 2 - 1
edu-auth/edu-auth-server/src/main/java/com/keao/edu/auth/service/impl/SysUserServiceImpl.java

@@ -145,7 +145,8 @@ public class SysUserServiceImpl extends BaseServiceImpl<Integer, SysUser> implem
 	@Transactional(rollbackFor = Exception.class)
 	public SysUserInfo initUser(LoginEntity loginEntity) {
 		if(StringUtils.equalsIgnoreCase(loginEntity.getClientId(),"STUDENT")){
-			eduUserFeignService.studentApply(new Student(loginEntity.getOrganId(),loginEntity.getPhone()));
+//			eduUserFeignService.studentApply(new Student(loginEntity.getOrganId(),loginEntity.getPhone()));
+			eduUserFeignService.getExamRoom(1);
 			return queryUserInfoByPhone(loginEntity.getPhone());
 		}
 		throw new UsernameNotFoundException("404.9");

+ 6 - 6
edu-user/edu-user-client-api/src/main/java/com/keao/edu/user/api/client/EduUserFeignService.java

@@ -7,16 +7,16 @@ import com.keao.edu.user.api.entity.ExamRoom;
 import com.keao.edu.user.api.entity.Student;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.http.MediaType;
-import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
 
-@FeignClient(contextId = "eduUserFeignService", name = "user-server", configuration = { FeignConfiguration.class }, fallback = EduUserFeignServiceFallback.class)
+@FeignClient(name = "user-server", configuration = { FeignConfiguration.class }, fallback = EduUserFeignServiceFallback.class)
 public interface EduUserFeignService {
 
-	@GetMapping(value = "examRoom/get")
-	ExamRoom getExamRoom(@RequestParam("id") Integer id);
+	@RequestMapping(value = "examRoom/get", method = RequestMethod.GET)
+	ExamRoom getExamRoom(Integer id);
 
 	@PostMapping(value = "student/apply", consumes = MediaType.APPLICATION_JSON_VALUE)
-	Boolean studentApply(Student student);
+	Object studentApply(Student student);
 }

+ 0 - 22
edu-user/edu-user-client-api/src/main/java/com/keao/edu/user/api/client/fallback/EduUserFeignServiceFallback.java

@@ -1,22 +0,0 @@
-package com.keao.edu.user.api.client.fallback;
-
-import com.keao.edu.user.api.client.EduUserFeignService;
-import com.keao.edu.user.api.entity.ExamRoom;
-import com.keao.edu.user.api.entity.Student;
-import org.springframework.stereotype.Component;
-import org.springframework.web.bind.annotation.RequestParam;
-
-@Component
-public class EduUserFeignServiceFallback implements EduUserFeignService {
-
-	@Override
-	public ExamRoom getExamRoom(@RequestParam("id") Integer id){
-		return null;
-	}
-
-	@Override
-	public Boolean studentApply(Student student) {
-		return null;
-	}
-
-}

+ 1 - 1
edu-user/edu-user-server/src/main/java/com/keao/edu/user/UserServerApplication.java

@@ -15,7 +15,7 @@ import org.springframework.web.client.RestTemplate;
 
 @SpringBootApplication
 @EnableDiscoveryClient
-@EnableFeignClients({"com.keao.edu"})
+@EnableFeignClients({"com.keao.edu.user.api.client"})
 @MapperScan({"com.keao.edu.user.dao"})
 @ComponentScan(basePackages="com.keao.edu")
 @Configuration

+ 0 - 3
edu-user/edu-user-server/src/main/java/com/keao/edu/user/config/ResourceServerConfig.java

@@ -27,9 +27,6 @@ public class ResourceServerConfig extends ResourceServerConfigurerAdapter {
 		http.authorizeRequests()
 				.antMatchers("/v2/api-docs", "/su/**")
 				.permitAll()
-				// 任何人不登录都可以获取的资源
-				// .antMatchers("/ipController/**").hasIpAddress("127.0.0.1") //特定ip可以不登录获取资源
-				// .antMatchers("/ipControll/**").access("isAuthenticated() and hasIpAddress('127.0.0.1')")// 特定ip必须登录才能获取
 				.anyRequest().authenticated().and().csrf().disable().exceptionHandling().accessDeniedHandler(baseAccessDeniedHandler)
 				.authenticationEntryPoint(baseAuthenticationEntryPoint).and();
 	}

+ 3 - 6
edu-user/edu-user-server/src/main/java/com/keao/edu/user/controller/StudentController.java

@@ -11,9 +11,7 @@ import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 /**
  * 系统配置控制层
@@ -41,9 +39,8 @@ public class StudentController extends BaseController {
 	}
 
 	@ApiOperation(value = "学员报名")
-	@GetMapping(value = "studentApply")
-    @PreAuthorize("@pcs.hasPermissions('student/apply')")
-	public HttpResponseResult apply(Student student) {
+	@PostMapping(value = "apply")
+	public HttpResponseResult apply(@RequestBody Student student) {
 		studentService.addStudent(student);
 		return succeed();
 	}