|
@@ -1,5 +1,6 @@
|
|
|
package cn.com.qmth.examcloud.task.service.impl;
|
|
|
|
|
|
+import java.lang.reflect.Method;
|
|
|
import java.util.List;
|
|
|
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
@@ -8,18 +9,13 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import cn.com.qmth.examcloud.commons.api.HandleSyncCloudService;
|
|
|
+import cn.com.qmth.examcloud.commons.api.request.SyncBaseRequest;
|
|
|
import cn.com.qmth.examcloud.commons.api.request.SyncCourseReq;
|
|
|
import cn.com.qmth.examcloud.commons.api.request.SyncExamReq;
|
|
|
import cn.com.qmth.examcloud.commons.api.request.SyncExamStudentReq;
|
|
|
import cn.com.qmth.examcloud.commons.api.request.SyncOrgReq;
|
|
|
import cn.com.qmth.examcloud.commons.api.request.SyncSpecialtyReq;
|
|
|
import cn.com.qmth.examcloud.commons.api.request.SyncStudentReq;
|
|
|
-import cn.com.qmth.examcloud.commons.api.response.SyncCourseResp;
|
|
|
-import cn.com.qmth.examcloud.commons.api.response.SyncExamResp;
|
|
|
-import cn.com.qmth.examcloud.commons.api.response.SyncExamStudentResp;
|
|
|
-import cn.com.qmth.examcloud.commons.api.response.SyncOrgResp;
|
|
|
-import cn.com.qmth.examcloud.commons.api.response.SyncSpecialtyResp;
|
|
|
-import cn.com.qmth.examcloud.commons.api.response.SyncStudentResp;
|
|
|
import cn.com.qmth.examcloud.commons.base.exception.StatusException;
|
|
|
import cn.com.qmth.examcloud.commons.base.util.JsonUtil;
|
|
|
import cn.com.qmth.examcloud.commons.base.util.PropertiesUtil;
|
|
@@ -44,21 +40,15 @@ public class DataSyncServiceImpl implements DataSyncService {
|
|
|
@Autowired
|
|
|
HandleSyncCloudService handleSyncCloudService;
|
|
|
|
|
|
- @Override
|
|
|
- public SyncCourseResp syncCourse(SyncCourseReq req) {
|
|
|
- // TODO Auto-generated method stub
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public SyncOrgResp syncOrg(SyncOrgReq req) {
|
|
|
- // TODO Auto-generated method stub
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public SyncStudentResp syncStudent(SyncStudentReq req) {
|
|
|
- String group = PropertiesUtil.getString("$sync.syncStudent.group");
|
|
|
+ /**
|
|
|
+ * 方法注释
|
|
|
+ *
|
|
|
+ * @author WANGWEI
|
|
|
+ * @param methodName
|
|
|
+ * @param req
|
|
|
+ */
|
|
|
+ private void sync(String methodName, SyncBaseRequest req) {
|
|
|
+ String group = PropertiesUtil.getString("$sync." + methodName + ".group");
|
|
|
if (StringUtils.isBlank(group)) {
|
|
|
throw new StatusException("T-001001", "group is not configured");
|
|
|
}
|
|
@@ -70,13 +60,17 @@ public class DataSyncServiceImpl implements DataSyncService {
|
|
|
}
|
|
|
|
|
|
for (String component : componentList) {
|
|
|
- String url = PropertiesUtil.getString("$sync.syncStudent.component." + component);
|
|
|
+ String url = PropertiesUtil
|
|
|
+ .getString("$sync." + methodName + ".component." + component);
|
|
|
req.setUrl(url);
|
|
|
try {
|
|
|
- handleSyncCloudService.syncStudent(req);
|
|
|
+ Method method = handleSyncCloudService.getClass().getMethod(methodName,
|
|
|
+ req.getClass());
|
|
|
+ method.invoke(handleSyncCloudService, req);
|
|
|
} catch (Exception e) {
|
|
|
DataSyncEntity entity = new DataSyncEntity();
|
|
|
- entity.setMethodName("syncStudent");
|
|
|
+ entity.setComponent(component);
|
|
|
+ entity.setMethodName(methodName);
|
|
|
entity.setParamType(
|
|
|
cn.com.qmth.examcloud.commons.api.request.SyncStudentReq.class.getName());
|
|
|
entity.setSyncNum(0);
|
|
@@ -84,27 +78,36 @@ public class DataSyncServiceImpl implements DataSyncService {
|
|
|
dataSyncRepo.saveAndFlush(entity);
|
|
|
}
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- SyncStudentResp resp = new SyncStudentResp();
|
|
|
- return resp;
|
|
|
+ @Override
|
|
|
+ public void syncCourse(SyncCourseReq req) {
|
|
|
+ sync("syncCourse", req);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void syncOrg(SyncOrgReq req) {
|
|
|
+ sync("syncOrg", req);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void syncStudent(SyncStudentReq req) {
|
|
|
+ sync("syncStudent", req);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public SyncExamStudentResp syncExamStudent(SyncExamStudentReq req) {
|
|
|
- // TODO Auto-generated method stub
|
|
|
- return null;
|
|
|
+ public void syncExamStudent(SyncExamStudentReq req) {
|
|
|
+ sync("syncExamStudent", req);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public SyncSpecialtyResp syncSpecialty(SyncSpecialtyReq req) {
|
|
|
- // TODO Auto-generated method stub
|
|
|
- return null;
|
|
|
+ public void syncSpecialty(SyncSpecialtyReq req) {
|
|
|
+ sync("syncSpecialty", req);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public SyncExamResp syncExam(SyncExamReq req) {
|
|
|
- // TODO Auto-generated method stub
|
|
|
- return null;
|
|
|
+ public void syncExam(SyncExamReq req) {
|
|
|
+ sync("syncExam", req);
|
|
|
}
|
|
|
|
|
|
}
|