|
@@ -26,6 +26,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
import javax.crypto.Cipher;
|
|
|
import javax.crypto.spec.SecretKeySpec;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
|
|
@@ -56,11 +57,18 @@ public class SwjtuController extends ControllerSupport {
|
|
|
@Naked
|
|
|
@PostMapping("getScore")
|
|
|
public ResponseEntity<?> getScore(
|
|
|
- @RequestParam String studentCode, @RequestParam String subjectCode,
|
|
|
+ @RequestParam(required = false) String studentCode,
|
|
|
+ @RequestParam(required = false) String subjectCode,
|
|
|
@RequestParam(required = false) Long examId,
|
|
|
@RequestParam(required = false, defaultValue = "true") boolean encrypt,
|
|
|
@RequestParam(required = false, defaultValue = "false") boolean detail,
|
|
|
HttpServletRequest request) {
|
|
|
+ if (StringUtils.isBlank(studentCode)) {
|
|
|
+ throw new StatusException("001005", "studentCode参数值不能为空!");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(subjectCode)) {
|
|
|
+ throw new StatusException("001005", "subjectCode参数值不能为空!");
|
|
|
+ }
|
|
|
|
|
|
log.warn("[swjtu-getScore] studentCode:{} subjectCode:{} examId:{} encrypt:{} detail:{}", studentCode, subjectCode, examId, encrypt, detail);
|
|
|
|
|
@@ -77,12 +85,14 @@ public class SwjtuController extends ControllerSupport {
|
|
|
OrgPropertyCacheBean orgPropertyCacheBean = CacheHelper.getOrgProperty(rootOrgId, "THIRD_PARTY_API_DEFAULT_EXAM_ID");
|
|
|
String value = orgPropertyCacheBean.getValue();
|
|
|
if (StringUtils.isBlank(value)) {
|
|
|
- throw new StatusException("001005", "examId is not configured");
|
|
|
+ throw new StatusException("001005", "examId系统未配置!");
|
|
|
}
|
|
|
examId = StringUtil.toLong(value);
|
|
|
+ log.warn("[swjtu-getScore] default config examId:{}", examId);
|
|
|
}
|
|
|
|
|
|
if (!loginnameConf.equals(loginname) || !passwordConf.equals(password)) {
|
|
|
+ log.warn("[swjtu-getScore] auth-info is invalid. loginname:{} password:{}", loginname, password);
|
|
|
return ResponseEntity.status(HttpStatus.UNAUTHORIZED).build();
|
|
|
}
|
|
|
|
|
@@ -106,6 +116,7 @@ public class SwjtuController extends ControllerSupport {
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
map.put("exception", "500");
|
|
|
+ log.error("[swjtu-getScore] err:{}", e.getMessage());
|
|
|
}
|
|
|
|
|
|
String result = JsonUtil.toJson(map);
|
|
@@ -139,8 +150,9 @@ public class SwjtuController extends ControllerSupport {
|
|
|
|
|
|
public final static String encrypt(String data) {
|
|
|
try {
|
|
|
- return byte2base64(encrypt(data.getBytes("ISO-8859-1"), CRYPT_KEY));
|
|
|
+ return byte2base64(encrypt(data.getBytes(StandardCharsets.ISO_8859_1), CRYPT_KEY));
|
|
|
} catch (Exception e) {
|
|
|
+ log.error(e.getMessage());
|
|
|
}
|
|
|
return null;
|
|
|
}
|