Эх сурвалжийг харах

url参数修改,通过controller跳过去的参数名不能相同

wangliang 2 жил өмнө
parent
commit
9010fee386

+ 17 - 15
teachcloud-exchange-common-api/src/main/java/com/qmth/teachcloud/exchange/common/api/CommonOpenApiController.java

@@ -58,17 +58,19 @@ public class CommonOpenApiController {
     @ApiResponses({@ApiResponse(code = 200, message = "返回消息", response = Result.class)})
     @RequestMapping(value = "/authentication/teachcloud", method = RequestMethod.GET)
     @Aac(auth = BOOL.FALSE)
-    public void authenticationTeachcloud(@ApiParam(value = "工号", required = true) @RequestParam String account,
-                                         @ApiParam(value = "学校code", required = true) @RequestParam String schoolCode,
-                                         @ApiParam(value = "返回url") @RequestParam(required = false) String returnUrl,
-                                         @ApiParam(value = "其它参数") @RequestParam(required = false) String params) throws IOException {
-        log.info("公用跳转接口进来了,account:{},schoolCode:{}", account, schoolCode);
+    public void authenticationTeachcloud(@ApiParam(value = "工号", required = true) @RequestParam String accountCommon,
+                                         @ApiParam(value = "学校code", required = true) @RequestParam String schoolCodeCommon,
+                                         @ApiParam(value = "返回url") @RequestParam(required = false) String returnUrlCommon,
+                                         @ApiParam(value = "其它参数") @RequestParam(required = false) String paramsCommon) throws IOException {
+        log.info("公用跳转接口进来了,account:{},schoolCode:{}", accountCommon, schoolCodeCommon);
         Optional.ofNullable(teachcloudLoginUrl).orElseThrow(() -> ExceptionResultEnum.PARAMS_ERROR.exception("知学登录跳转地址不存在"));
-        Optional.ofNullable(account).orElseThrow(() -> ExceptionResultEnum.PARAMS_ERROR.exception("工号不存在"));
-        Optional.ofNullable(schoolCode).orElseThrow(() -> ExceptionResultEnum.PARAMS_ERROR.exception("学校code不存在"));
+        Optional.ofNullable(accountCommon).orElseThrow(() -> ExceptionResultEnum.PARAMS_ERROR.exception("工号不存在"));
+        Optional.ofNullable(schoolCodeCommon).orElseThrow(() -> ExceptionResultEnum.PARAMS_ERROR.exception("学校code不存在"));
+
+//        accountUser = URLDecoder.decode(accountUser, SystemConstant.CHARSET_NAME);
 
         QueryWrapper<BasicSchool> basicSchoolQueryWrapper = new QueryWrapper<>();
-        basicSchoolQueryWrapper.lambda().eq(BasicSchool::getCode, schoolCode);
+        basicSchoolQueryWrapper.lambda().eq(BasicSchool::getCode, schoolCodeCommon);
         BasicSchool basicSchool = basicSchoolService.getOne(basicSchoolQueryWrapper);
         Optional.ofNullable(basicSchool).orElseThrow(() -> ExceptionResultEnum.PARAMS_ERROR.exception("学校信息不存在"));
 
@@ -84,21 +86,21 @@ public class CommonOpenApiController {
                 .add(teachcloudLoginUrl)
                 .add(SystemConstant.GET_UNKNOWN).add(SystemConstant.HEADER_TIME).add(SystemConstant.GET_EQUAL).add(String.valueOf(timestamp))
                 .add(SystemConstant.GET_SYMBOL).add(SystemConstant.SIGNATURE).add(SystemConstant.GET_EQUAL).add(signature)
-                .add(SystemConstant.GET_SYMBOL).add(SystemConstant.USER).add(SystemConstant.GET_EQUAL).add(account);
+                .add(SystemConstant.GET_SYMBOL).add(SystemConstant.USER).add(SystemConstant.GET_EQUAL).add(accountCommon);
 
-        if (Objects.nonNull(returnUrl) && !Objects.equals(returnUrl, "")) {
-            stringJoiner = stringJoiner.add(SystemConstant.GET_SYMBOL).add(SystemConstant.RETURN_URL).add(SystemConstant.GET_EQUAL).add(returnUrl);
+        if (Objects.nonNull(returnUrlCommon) && !Objects.equals(returnUrlCommon, "")) {
+            stringJoiner = stringJoiner.add(SystemConstant.GET_SYMBOL).add(SystemConstant.RETURN_URL).add(SystemConstant.GET_EQUAL).add(returnUrlCommon);
         }
-        if (Objects.nonNull(params) && !Objects.equals(params, "")) {
-            String decodeJson = URLDecoder.decode(params, SystemConstant.CHARSET_NAME);
+        if (Objects.nonNull(paramsCommon) && !Objects.equals(paramsCommon, "")) {
+            String decodeJson = URLDecoder.decode(paramsCommon, SystemConstant.CHARSET_NAME);
             OpenParams openParams = JacksonUtil.readJson(decodeJson, OpenParams.class);
             stringJoiner = stringJoiner.add(SystemConstant.GET_SYMBOL).add(SystemConstant.PARAMS).add(SystemConstant.GET_EQUAL).add(JacksonUtil.parseJson(openParams));
         }
         String redirectUrl = URLEncoder.encode(stringJoiner.toString(), SystemConstant.CHARSET);
-        log.info("path:{},timestamp:{},account:{},signature:{},redirectUrl:{},redirectUrl_urlencode:{}", path, timestamp, account, signature, stringJoiner.toString(), redirectUrl);
+        log.info("path:{},timestamp:{},account:{},signature:{},redirectUrl:{},redirectUrl_urlencode:{}", path, timestamp, accountCommon, signature, stringJoiner.toString(), redirectUrl);
 
         HttpServletResponse response = ServletUtil.getResponse();
-        response.setHeader("Access-Control-Allow-Origin", "*");
+        response.setHeader("Access-Control-Allow-Origin", SystemConstant.PATH_MATCH);
         response.sendRedirect(redirectUrl);
     }
 }

+ 4 - 0
teachcloud-exchange-common/src/main/java/com/qmth/teachcloud/exchange/common/contant/SystemConstant.java

@@ -32,11 +32,15 @@ public class SystemConstant {
     public static final String UPDATE_TIME = "updateTime";
     public static final String SESSION = "session:";
     public static final String USER = "account";
+    public static final String USER_COMMON = "accountCommon";
     public static final String SCHOOL_ID = "schoolId";
     public static final String SCHOOL = "school";
     public static final String SCHOOL_CODE = "schoolCode";
+    public static final String SCHOOL_CODE_COMMON = "schoolCodeCommon";
     public static final String RETURN_URL = "returnUrl";
+    public static final String RETURN_URL_COMMON = "returnUrlCommon";
     public static final String PARAMS = "params";
+    public static final String PARAMS_COMMON = "paramsCommon";
     public static final String ORG = "org";
     public static final String MD5 = "MD5";
     public static final String ID = "id";

+ 7 - 5
xjtu-exchange/src/main/java/com/qmth/xjtu/api/OpenApiController.java

@@ -23,6 +23,7 @@ import org.springframework.web.bind.annotation.RequestParam;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
+import java.net.URLEncoder;
 import java.util.Objects;
 import java.util.StringJoiner;
 
@@ -54,19 +55,20 @@ public class OpenApiController {
 
         StringJoiner stringJoiner = new StringJoiner("")
                 .add(SystemConstant.JUMP_API_URL)
-                .add(SystemConstant.GET_UNKNOWN).add(SystemConstant.USER).add(SystemConstant.GET_EQUAL).add(account)
-                .add(SystemConstant.GET_SYMBOL).add(SystemConstant.SCHOOL_CODE).add(SystemConstant.GET_EQUAL).add(schoolCode);
+//                .add(SystemConstant.GET_UNKNOWN).add(SystemConstant.USER_COMMON).add(SystemConstant.GET_EQUAL).add(URLEncoder.encode(account, SystemConstant.CHARSET))
+                .add(SystemConstant.GET_UNKNOWN).add(SystemConstant.USER_COMMON).add(SystemConstant.GET_EQUAL).add(account)
+                .add(SystemConstant.GET_SYMBOL).add(SystemConstant.SCHOOL_CODE_COMMON).add(SystemConstant.GET_EQUAL).add(schoolCode);
 
         if (Objects.nonNull(returnUrl) && !Objects.equals(returnUrl, "")) {
-            stringJoiner = stringJoiner.add(SystemConstant.GET_SYMBOL).add(SystemConstant.RETURN_URL).add(SystemConstant.GET_EQUAL).add(returnUrl);
+            stringJoiner = stringJoiner.add(SystemConstant.GET_SYMBOL).add(SystemConstant.RETURN_URL_COMMON).add(SystemConstant.GET_EQUAL).add(returnUrl);
         }
         OpenParams openParams = new OpenParams();
         openParams.setName("test1");
 
         if (Objects.nonNull(openParams)) {
-            stringJoiner = stringJoiner.add(SystemConstant.GET_SYMBOL).add(SystemConstant.PARAMS).add(SystemConstant.GET_EQUAL).add(JacksonUtil.parseJson(openParams));
+            stringJoiner = stringJoiner.add(SystemConstant.GET_SYMBOL).add(SystemConstant.PARAMS_COMMON).add(SystemConstant.GET_EQUAL).add(JacksonUtil.parseJson(openParams));
         }
-        log.info("redirectUrl:{},schoolCode:{}", stringJoiner.toString(), schoolCode);
+        log.info("redirectUrl:{},account:{},schoolCode:{}", stringJoiner.toString(), account, schoolCode);
         return stringJoiner.toString();
     }
 }