wangliang 4 ani în urmă
părinte
comite
52a1a7852e

+ 10 - 0
teachcloud-common/src/main/java/com/qmth/teachcloud/common/domain/SysDomain.java

@@ -45,6 +45,16 @@ public class SysDomain implements Serializable {
 
     Duration sessionActive;
 
+    String loginAuthenUrl;
+
+    public String getLoginAuthenUrl() {
+        return loginAuthenUrl;
+    }
+
+    public void setLoginAuthenUrl(String loginAuthenUrl) {
+        this.loginAuthenUrl = loginAuthenUrl;
+    }
+
     public Duration getSessionActive() {
         return sessionActive;
     }

+ 14 - 7
teachcloud-report/src/main/java/com/qmth/teachcloud/report/api/WudaOpenApiController.java

@@ -31,6 +31,9 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.validation.Valid;
 import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.net.URLEncoder;
 import java.security.NoSuchAlgorithmException;
 import java.text.MessageFormat;
 import java.util.List;
@@ -79,9 +82,13 @@ public class WudaOpenApiController {
         if (Objects.isNull(uid)) {
             throw ExceptionResultEnum.NOT_LOGIN.exception();
         }
-        BasicSchool basicSchool = cacheService.schoolCache(SystemConstant.SCHOOL_CODE);
+        UserAuthenticationDto userAuthenticationDto = new UserAuthenticationDto(uid, SystemConstant.getUuid());
+        WhuUserAuthCacheUtil.setAuthCode(userAuthenticationDto);
+        String pattern = "{0}{1}{2}";
+        String code = URLEncoder.encode(MessageFormat.format(pattern, userAuthenticationDto.getUid(), SignatureEntityTest.FIELD_JOINER, SignatureEntityTest.encrypt(userAuthenticationDto.getCode())), SystemConstant.CHARSET_NAME);
+        log.info("code:{}", code);
         response.setHeader("Access-Control-Allow-Origin", "*");
-        response.sendRedirect(dictionaryConfig.sysDomain().getReportUrl() + basicSchool.getId() + "/" + uid);
+        response.sendRedirect(dictionaryConfig.sysDomain().getLoginAuthenUrl() + "/" + code);
     }
 
     @ApiOperation(value = "cas用户鉴权测试接口")
@@ -92,19 +99,19 @@ public class WudaOpenApiController {
         String uid = "yz1";
         UserAuthenticationDto userAuthenticationDto = new UserAuthenticationDto(uid, SystemConstant.getUuid());
         WhuUserAuthCacheUtil.setAuthCode(userAuthenticationDto);
-        String PATTERN = "{0}{1}{2}";
-        String code = MessageFormat.format(PATTERN, userAuthenticationDto.getUid(), SignatureEntityTest.FIELD_JOINER, SignatureEntityTest.encrypt(userAuthenticationDto.getCode()));
+        String pattern = "{0}{1}{2}";
+        String code = URLEncoder.encode(MessageFormat.format(pattern, userAuthenticationDto.getUid(), SignatureEntityTest.FIELD_JOINER, SignatureEntityTest.encrypt(userAuthenticationDto.getCode())), SystemConstant.CHARSET_NAME);
         log.info("code:{}", code);
         response.setHeader("Access-Control-Allow-Origin", "*");
-        response.sendRedirect(dictionaryConfig.sysDomain().getReportUrl() + code);
+        response.sendRedirect(dictionaryConfig.sysDomain().getLoginAuthenUrl() + code);
     }
 
     @ApiOperation(value = "cas用户临时授权登录接口")
     @RequestMapping(value = "/user/authentication/login", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "返回消息", response = LoginResult.class)})
     @Aac(auth = BOOL.FALSE)
-    public Result login(@ApiParam(value = "授权码信息", required = true) @RequestParam String code) throws NoSuchAlgorithmException {
-        String[] values = StringUtils.split(code, SignatureEntityTest.FIELD_JOINER);
+    public Result login(@ApiParam(value = "授权码信息", required = true) @RequestParam String code) throws NoSuchAlgorithmException, UnsupportedEncodingException {
+        String[] values = StringUtils.split(URLDecoder.decode(code, SystemConstant.CHARSET_NAME), SignatureEntityTest.FIELD_JOINER);
         if (Objects.isNull(values) || values.length != 2) {
             throw ExceptionResultEnum.ERROR.exception("临时授权码出错,请重新获取");
         }

+ 2 - 1
teachcloud-report/src/main/resources/application-dev.properties

@@ -13,7 +13,7 @@ spring.application.name=teachcloud-report
 db.host=192.168.10.136
 #db.host=localhost
 db.port=3306
-db.name=teachcloud-report-617
+db.name=teachcloud-report
 db.username=root
 db.password=Qmth87863577!
 #db.password=123456789
@@ -60,6 +60,7 @@ sys.config.threadPoolCoreSize=1
 sys.config.customThreadPoolCoreSize=false
 sys.config.sessionActive=1h
 sys.config.reportUrl=http://localhost:9099/#/student-report/
+sys.config.loginAuthenUrl=http://localhost:9099/#/login-authen/
 spring.resources.static-locations=file:${sys.config.serverUpload},classpath:/META-INF/resources/,classpath:/resources/
 
 org.center.url=https://solar.qmth.com.cn

+ 1 - 0
teachcloud-report/src/main/resources/application-release.properties

@@ -58,6 +58,7 @@ sys.config.threadPoolCoreSize=1
 sys.config.customThreadPoolCoreSize=false
 sys.config.sessionActive=1h
 sys.config.reportUrl=https://wdfx.qmth.com.cn/#/student-report/
+sys.config.loginAuthenUrl=https://wdfx.qmth.com.cn/#/login-authen/
 spring.resources.static-locations=file:${sys.config.serverUpload},classpath:/META-INF/resources/,classpath:/resources/
 
 org.center.url=https://solar.qmth.com.cn

+ 1 - 0
teachcloud-report/src/main/resources/application-test.properties

@@ -58,6 +58,7 @@ sys.config.threadPoolCoreSize=1
 sys.config.customThreadPoolCoreSize=false
 sys.config.sessionActive=1h
 sys.config.reportUrl=http://192.168.10.136:7005/#/student-report/
+sys.config.loginAuthenUrl=http://192.168.10.136:7005/#/login-authen/
 spring.resources.static-locations=file:${sys.config.serverUpload},classpath:/META-INF/resources/,classpath:/resources/
 
 org.center.url=https://solar.qmth.com.cn