|
@@ -0,0 +1,53 @@
|
|
|
+package com.xzl.web.service.impl;
|
|
|
+
|
|
|
+
|
|
|
+import com.xzl.web.mapper.DataGovernanceMapper;
|
|
|
+import com.xzl.web.model.dataGovernance.entity.DatabaseInfo;
|
|
|
+import com.xzl.web.service.DataGovernanceService;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+@Service
|
|
|
+public class DataGovernanceServiceImpl implements DataGovernanceService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private DataGovernanceMapper dataGovernanceMapper;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<DatabaseInfo> getDatabaseList() {
|
|
|
+ return dataGovernanceMapper.getDatabaseList();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, String> createDatabase(String databaseName) {
|
|
|
+ Map<String,String> result = new HashMap<>();
|
|
|
+ if(databaseName.isEmpty()){
|
|
|
+ result.put("message","数据库名称不符合规则");
|
|
|
+ result.put("type","error");
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ if(!databaseName.matches("^[a-zA-Z_][a-zA-Z0-9_]{0,63}$")){
|
|
|
+ result.put("message","数据库名称不符合规则");
|
|
|
+ result.put("type","error");
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ dataGovernanceMapper.createDatabase(databaseName);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ result.put("message","创建失败!");
|
|
|
+ result.put("type","error");
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ result.put("message","创建成功!");
|
|
|
+ result.put("type","success");
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+}
|