deason 2 ani în urmă
părinte
comite
ef4a387b5b

+ 6 - 6
src/main/java/cn/com/qmth/examcloud/tool/config/SysProperty.java

@@ -18,8 +18,8 @@ public class SysProperty {
     @Value("${examcloud.server.url}")
     public String serverUrl;
 
-    @Value("${examcloud.server.domain}")
-    public String serverDomain;
+    @Value("${examcloud.server.rootOrgId}")
+    public Long serverRootOrgId;
 
     @Value("${examcloud.server.loginName}")
     public String serverLoginName;
@@ -43,12 +43,12 @@ public class SysProperty {
         this.serverUrl = serverUrl;
     }
 
-    public String getServerDomain() {
-        return serverDomain;
+    public Long getServerRootOrgId() {
+        return serverRootOrgId;
     }
 
-    public void setServerDomain(String serverDomain) {
-        this.serverDomain = serverDomain;
+    public void setServerRootOrgId(Long serverRootOrgId) {
+        this.serverRootOrgId = serverRootOrgId;
     }
 
     public String getServerLoginName() {

+ 14 - 2
src/main/java/cn/com/qmth/examcloud/tool/service/CommonService.java

@@ -25,13 +25,25 @@ public class CommonService {
     @Autowired
     private SysProperty sysProperty;
 
+    public User login(Long rootOrgId, String loginName, String password) {
+        Map<String, Object> params = new HashMap<>();
+        params.put("rootOrgId", rootOrgId);
+        params.put("accountValue", loginName);
+        params.put("password", password);
+        return this.doLogin(params);
+    }
+
     public User login(String domain, String loginName, String password) {
         Map<String, Object> params = new HashMap<>();
-        // params.put("rootOrgId", 0L);
         params.put("domain", domain);
-        params.put("accountType", "COMMON_LOGIN_NAME");
         params.put("accountValue", loginName);
         params.put("password", password);
+        return this.doLogin(params);
+    }
+
+    private User doLogin(Map<String, Object> params) {
+        params.put("accountType", "COMMON_LOGIN_NAME");
+        params.put("smsCode", "5220");
 
         String url = sysProperty.getServerUrl() + "/api/ecs_core/auth/login";
         String result = HttpHelper.post(url, null, params);

+ 1 - 1
src/main/java/cn/com/qmth/examcloud/tool/service/export_student_answer_and_score_detail/ExportStudentAnswerAndScoreDetailTask.java

@@ -43,7 +43,7 @@ public class ExportStudentAnswerAndScoreDetailTask {
         final String tempDir = "export_" + DateHelper.currentTimeMillis() + "_" + task.getId();
         FileHelper.makeDirs(sysProperty.getDataDir() + "/" + tempDir);
 
-        User user = commonService.login(sysProperty.getServerDomain(), sysProperty.getServerLoginName(), sysProperty.getServerPassword());
+        User user = commonService.login(sysProperty.getServerRootOrgId(), sysProperty.getServerLoginName(), sysProperty.getServerPassword());
         this.execute(jsonParams, user, tempDir);
 
         // 压缩文件

+ 1 - 1
src/main/java/cn/com/qmth/examcloud/tool/service/update_correct_answer_and_re_fix_score/UpdateCorrectAnswerAndReFixScoreTask.java

@@ -41,7 +41,7 @@ public class UpdateCorrectAnswerAndReFixScoreTask {
             throw new StatusException("任务参数解析错误!");
         }
 
-        User user = commonService.login(sysProperty.getServerDomain(), sysProperty.getServerLoginName(), sysProperty.getServerPassword());
+        User user = commonService.login(sysProperty.getServerRootOrgId(), sysProperty.getServerLoginName(), sysProperty.getServerPassword());
         this.execute(jsonParams, user);
     }
 

+ 6 - 5
src/main/resources/application.properties

@@ -16,9 +16,10 @@ spring.h2.console.enabled=true
 spring.h2.console.path=/h2
 # examcloud config
 examcloud.tool.dataDir=files
-examcloud.server.url=https://192.168.10.39
-#examcloud.server.url=https://www.ea100.com.cn
+examcloud.server.rootOrgId=0
+examcloud.server.loginName=devops
+examcloud.server.password=Qmth$5220
 #examcloud.server.url=https://www.exam-cloud.cn
-examcloud.server.domain=fds.ecs.qmth.com.cn
-examcloud.server.loginName=feng
-examcloud.server.password=123456
+#examcloud.server.url=https://www.ea100.com.cn
+#examcloud.server.url=https://192.168.10.41
+examcloud.server.url=https://192.168.10.39

+ 3 - 3
src/main/resources/templates/login.ftlh

@@ -41,9 +41,9 @@
     new Vue({
         el: '#myVue',
         data: {
-            domain: "fds",
-            loginName: "feng",
-            password: "123456"
+            domain: "",
+            loginName: "",
+            password: ""
         },
         methods: {
             doLogin() {

+ 1 - 1
src/test/java/cn/com/qmth/examcloud/tool/ToolTest.java

@@ -25,7 +25,7 @@ public class ToolTest {
     }
 
     private void testLogin() {
-        User user = commonService.login(sysProperty.getServerDomain(), sysProperty.getServerLoginName(), sysProperty.getServerPassword());
+        User user = commonService.login(sysProperty.getServerRootOrgId(), sysProperty.getServerLoginName(), sysProperty.getServerPassword());
         System.out.println(user.getKey() + " " + user.getToken());
     }