|
@@ -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);
|
|
|
- // }
|
|
|
-
|
|
|
}
|