|
@@ -1,13 +1,13 @@
|
|
|
package com.qmth.teachcloud.report.api;
|
|
|
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
import com.qmth.boot.api.annotation.Aac;
|
|
|
import com.qmth.boot.api.annotation.BOOL;
|
|
|
import com.qmth.boot.api.constant.ApiConstant;
|
|
|
-import com.qmth.boot.tools.signature.SignatureEntity;
|
|
|
-import com.qmth.boot.tools.signature.SignatureType;
|
|
|
+import com.qmth.teachcloud.common.bean.params.BasicSemesterParams;
|
|
|
import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
|
-import com.qmth.teachcloud.common.util.HttpUtil;
|
|
|
+import com.qmth.teachcloud.common.entity.BasicSchool;
|
|
|
+import com.qmth.teachcloud.common.service.BasicSemesterService;
|
|
|
+import com.qmth.teachcloud.common.util.AuthThirdUtil;
|
|
|
import com.qmth.teachcloud.common.util.JacksonUtil;
|
|
|
import com.qmth.teachcloud.common.util.Result;
|
|
|
import com.qmth.teachcloud.common.util.ResultUtil;
|
|
@@ -20,59 +20,90 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
import java.io.IOException;
|
|
|
import java.net.URLDecoder;
|
|
|
-import java.util.Objects;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
|
- * 开放接口前端控制器
|
|
|
+ * 教研分析开放接口前端控制器
|
|
|
* </p>
|
|
|
*
|
|
|
* @author wangliang
|
|
|
* @since 2022-04-26
|
|
|
*/
|
|
|
-@Api(tags = "开放接口Controller")
|
|
|
+@Api(tags = "教研分析开放接口Controller")
|
|
|
@RestController
|
|
|
@RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + "/${prefix.url.open}")
|
|
|
@Validated
|
|
|
-@Aac(auth = BOOL.FALSE)
|
|
|
public class OpenApiController {
|
|
|
private final static Logger log = LoggerFactory.getLogger(OpenApiController.class);
|
|
|
|
|
|
- @ApiOperation(value = "接收基础考务数据")
|
|
|
- @ApiResponses({@ApiResponse(code = 200, message = "推送基础考务数据", response = Object.class)})
|
|
|
- @RequestMapping(value = "/basic/examination/data", method = RequestMethod.POST)
|
|
|
- public Result basicExaminationData(@ApiParam(value = "接收基础考务数据信息", required = true) @RequestBody String result) throws IOException, InterruptedException {
|
|
|
- log.info("basicExaminationData进来了,result:{}", result);
|
|
|
+ @Resource
|
|
|
+ BasicSemesterService basicSemesterService;
|
|
|
+
|
|
|
+ @ApiOperation(value = "学期创建/更新接口")
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "学期创建/更新接口", response = Object.class)})
|
|
|
+ @RequestMapping(value = "/semester_edit", method = RequestMethod.POST)
|
|
|
+ @Aac(auth = BOOL.FALSE)
|
|
|
+ public Result semesterEdit(@ApiParam(value = "接收学期数据信息", required = true) @RequestBody String result) throws IOException, InterruptedException, IllegalAccessException {
|
|
|
+ log.info("semesterEdit进来了,result:{}", JacksonUtil.parseJson(result));
|
|
|
String decodeJson = URLDecoder.decode(result, SystemConstant.CHARSET_NAME);
|
|
|
log.info("decodeJson:{}", decodeJson);
|
|
|
- if (Objects.nonNull(decodeJson)) {
|
|
|
- JSONObject jsonObject = JSONObject.parseObject(decodeJson);
|
|
|
- String callbackUrl = jsonObject.getString("callbackUrl");
|
|
|
- String accessKey = jsonObject.getString("accessKey");
|
|
|
- String accessSecret = jsonObject.getString("accessSecret");
|
|
|
- if (Objects.nonNull(callbackUrl)) {
|
|
|
- Double progress = 0D;
|
|
|
- for (int i = 0; i < 11; i++) {
|
|
|
- progress += 10D;
|
|
|
- JSONObject dataObjectJson = new JSONObject();
|
|
|
- dataObjectJson.put("progress", progress);
|
|
|
- if (progress == 100D) {
|
|
|
- dataObjectJson.put("status", "FINISHED");
|
|
|
- } else {
|
|
|
- dataObjectJson.put("status", "RUNNING");
|
|
|
- }
|
|
|
- Long timestamp = System.currentTimeMillis();
|
|
|
- String accessToken = SignatureEntity.build(SignatureType.SECRET, SystemConstant.METHOD, callbackUrl, timestamp, accessKey, accessSecret);
|
|
|
- String callbackResult = HttpUtil.postJson("http://127.0.0.1:7001" + callbackUrl, dataObjectJson.toJSONString(), accessToken, timestamp);
|
|
|
- if (Objects.nonNull(callbackResult)) {
|
|
|
- log.info("callbackResult:{}", JacksonUtil.parseJson(callbackResult));
|
|
|
- }
|
|
|
- Thread.sleep(5000);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ BasicSemesterParams basicSemesterParams = JacksonUtil.readJson(decodeJson, BasicSemesterParams.class);
|
|
|
+ BasicSchool basicSchool = AuthThirdUtil.hasPermission();
|
|
|
+ return ResultUtil.ok(basicSemesterService.saveBasicSemesterCommon(basicSemesterParams, basicSchool.getId(), null));
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "考试创建/更新接口")
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "考试创建/更新接口", response = Object.class)})
|
|
|
+ @RequestMapping(value = "/exam_edit", method = RequestMethod.POST)
|
|
|
+ public Result examEdit(@ApiParam(value = "接收考试数据信息", required = true) @RequestBody String result) throws IOException, InterruptedException {
|
|
|
+ log.info("examEdit进来了,result:{}", result);
|
|
|
return ResultUtil.ok(true);
|
|
|
}
|
|
|
+
|
|
|
+ @ApiOperation(value = "分析课程(试卷)创建/更新接口")
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "分析课程(试卷)创建/更新接口", response = Object.class)})
|
|
|
+ @RequestMapping(value = "/course_edit", method = RequestMethod.POST)
|
|
|
+ public Result courseEdit(@ApiParam(value = "接收分析课程(试卷)数据信息", required = true) @RequestBody String result) throws IOException, InterruptedException {
|
|
|
+ log.info("courseEdit进来了,result:{}", result);
|
|
|
+ return ResultUtil.ok(true);
|
|
|
+ }
|
|
|
+
|
|
|
+// @ApiOperation(value = "接收基础考务数据")
|
|
|
+// @ApiResponses({@ApiResponse(code = 200, message = "推送基础考务数据", response = Object.class)})
|
|
|
+// @RequestMapping(value = "/basic/examination/data", method = RequestMethod.POST)
|
|
|
+// public Result basicExaminationData(@ApiParam(value = "接收基础考务数据信息", required = true) @RequestBody String result) throws IOException, InterruptedException {
|
|
|
+// log.info("basicExaminationData进来了,result:{}", result);
|
|
|
+// String decodeJson = URLDecoder.decode(result, SystemConstant.CHARSET_NAME);
|
|
|
+// log.info("decodeJson:{}", decodeJson);
|
|
|
+// if (Objects.nonNull(decodeJson)) {
|
|
|
+// JSONObject jsonObject = JSONObject.parseObject(decodeJson);
|
|
|
+// String callbackUrl = jsonObject.getString("callbackUrl");
|
|
|
+// String accessKey = jsonObject.getString("accessKey");
|
|
|
+// String accessSecret = jsonObject.getString("accessSecret");
|
|
|
+// if (Objects.nonNull(callbackUrl)) {
|
|
|
+// Double progress = 0D;
|
|
|
+// for (int i = 0; i < 11; i++) {
|
|
|
+// progress += 10D;
|
|
|
+// JSONObject dataObjectJson = new JSONObject();
|
|
|
+// dataObjectJson.put("progress", progress);
|
|
|
+// if (progress == 100D) {
|
|
|
+// dataObjectJson.put("status", "FINISHED");
|
|
|
+// } else {
|
|
|
+// dataObjectJson.put("status", "RUNNING");
|
|
|
+// }
|
|
|
+// Long timestamp = System.currentTimeMillis();
|
|
|
+// String accessToken = SignatureEntity.build(SignatureType.SECRET, SystemConstant.METHOD, callbackUrl, timestamp, accessKey, accessSecret);
|
|
|
+// String callbackResult = HttpUtil.postJson("http://127.0.0.1:7001" + callbackUrl, dataObjectJson.toJSONString(), accessToken, timestamp);
|
|
|
+// if (Objects.nonNull(callbackResult)) {
|
|
|
+// log.info("callbackResult:{}", JacksonUtil.parseJson(callbackResult));
|
|
|
+// }
|
|
|
+// Thread.sleep(5000);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// return ResultUtil.ok(true);
|
|
|
+// }
|
|
|
}
|