xiatian 8 月之前
父節點
當前提交
ac9f8fc04f
共有 2 個文件被更改,包括 20 次插入64 次删除
  1. 16 0
      install/mysql/init/scan_central_db.sql
  2. 4 64
      src/main/java/cn/com/qmth/scancentral/config/InitData.java

+ 16 - 0
install/mysql/init/scan_central_db.sql

@@ -561,6 +561,22 @@ CREATE TABLE IF NOT EXISTS `sc_mark_site`
     UNIQUE KEY `exam_subject_paper` (`exam_id`, `subject_code`, `paper_type`)
 ) ENGINE = InnoDB
   DEFAULT CHARSET = utf8mb4;
+  
+INSERT INTO `sc_system_config` (`id`, `scanner_enable_login`, `scanner_password`) 
+VALUES (1,1, '');
+
+ 
+INSERT INTO `sc_user` (`login_name`, `name`, `password`, `role`, `enable`, `create_time`, `update_time`) 
+VALUES ('admin1', '学校管理员1', '123456', 'SCHOOL_ADMIN', 1, now(), now());
+INSERT INTO `sc_user` (`login_name`, `name`, `password`, `role`, `enable`, `create_time`, `update_time`) 
+VALUES ('admin2', '学校管理员2', '123456', 'SCHOOL_ADMIN', 1, now(), now());
+INSERT INTO `sc_user` (`login_name`, `name`, `password`, `role`, `enable`, `create_time`, `update_time`) 
+VALUES ('admin3', '学校管理员3', '123456', 'SCHOOL_ADMIN', 1, now(), now());
+INSERT INTO `sc_user` (`login_name`, `name`, `password`, `role`, `enable`, `create_time`, `update_time`) 
+VALUES ('admin4', '学校管理员4', '123456', 'SCHOOL_ADMIN', 1, now(), now());
+INSERT INTO `sc_user` (`login_name`, `name`, `password`, `role`, `enable`, `create_time`, `update_time`) 
+VALUES ('admin5', '学校管理员5', '123456', 'SCHOOL_ADMIN', 1, now(), now()); 
+  
 
 INSERT INTO `sc_question` (`subject_code`,`objective`,`main_number`, `sub_number`, `main_title`) VALUES ('1',0,1,'1','作文');
 INSERT INTO `sc_question` (`subject_code`,`objective`,`main_number`, `sub_number`, `main_title`) VALUES ('1',1,2,'1','听力');

+ 4 - 64
src/main/java/cn/com/qmth/scancentral/config/InitData.java

@@ -1,11 +1,7 @@
 package cn.com.qmth.scancentral.config;
 
-import cn.com.qmth.scancentral.entity.SystemConfigEntity;
-import cn.com.qmth.scancentral.entity.UserEntity;
-import cn.com.qmth.scancentral.enums.Role;
-import cn.com.qmth.scancentral.service.SystemConfigService;
-import cn.com.qmth.scancentral.service.UserService;
-import cn.com.qmth.scancentral.util.FileUtil;
+import java.io.File;
+import java.io.IOException;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -13,8 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.CommandLineRunner;
 import org.springframework.stereotype.Component;
 
-import java.io.File;
-import java.io.IOException;
+import cn.com.qmth.scancentral.util.FileUtil;
 
 @Component
 public class InitData implements CommandLineRunner {
@@ -24,15 +19,9 @@ public class InitData implements CommandLineRunner {
     @Autowired
     private SysProperty sysProperty;
 
-    @Autowired
-    private UserService userService;
-
-    @Autowired
-    private SystemConfigService systemConfigService;
-
     @Override
     public void run(String... args) throws IOException {
-        log.info("开始系统初始化...");
+        // log.info("开始系统初始化...");
         // 自动创建图片转存目录
         String dir = sysProperty.getTransferDir();
         File dfile = new File(dir);
@@ -41,59 +30,10 @@ public class InitData implements CommandLineRunner {
             log.info("创建图片转存目录:{}", dir);
         }
 
-        // 初始化系统配置
-        SystemConfigEntity config = systemConfigService.find();
-        if (config == null) {
-            config = new SystemConfigEntity();
-            config.setId(1L);
-            config.setScannerEnableLogin(true);
-            config.setScannerPassword("");
-            systemConfigService.save(config);
-            log.info("初始化sc_system_config记录");
-        }
-        initByStandalone();
         File temp = new File("temp");
         if (temp.exists()) {
             FileUtil.deleteDirectory(temp);
         }
-        log.info("系统初始化完成!");
-    }
-
-    private void initByStandalone() throws IOException {
-        // 创建含考生编号+科目代码唯一索引的考生表
-        // executeSql("script/init_standalone.sql");
-        // 按照学校ID=1创建管理员账号
-        if (userService.count() == 0) {
-            UserEntity user = new UserEntity();
-            user.setLoginName("admin");
-            user.setName("学校管理员");
-            user.setPassword("123456");
-            user.setRole(Role.SCHOOL_ADMIN);
-            user.setEnable(true);
-            user.setCreateTime(System.currentTimeMillis());
-            user.setUpdateTime(user.getCreateTime());
-            userService.save(user);
-            log.info("创建初始用户账号:{}", user.getLoginName());
-        }
     }
 
-    // private void initByMarkingcloud() throws IOException {
-    // // 创建含考生编号+科目代码普通索引的考生表
-    // executeSql("script/init_markingcloud.sql");
-    // }
-
-    // private void executeSql(String path) throws IOException {
-    // String[] array = StringUtils.split(
-    // ByteArray.fromInputStream(this.getClass().getClassLoader().getResourceAsStream(path)).toString(),
-    // ";");
-    // int count = 0;
-    // for (String sql : array) {
-    // if (StringUtils.isNotBlank(sql)) {
-    // jdbcTemplate.execute(sql);
-    // count++;
-    // }
-    // }
-    // log.info("表结构初始化:{},完成{}条", path, count);
-    // }
-
 }