Quellcode durchsuchen

日志接口基本完成

soft5566 vor 2 Jahren
Ursprung
Commit
16d98d2563

+ 35 - 11
.idea/workspace.xml

@@ -4,16 +4,18 @@
     <option name="autoReloadType" value="SELECTIVE" />
   </component>
   <component name="ChangeListManager">
-    <list default="true" id="33456f28-da03-4d10-99dd-fd9bd193cf84" name="Default Changelist" comment="任务通过接口操作">
-      <change beforePath="$PROJECT_DIR$/.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
+    <list default="true" id="33456f28-da03-4d10-99dd-fd9bd193cf84" name="Default Changelist" comment="日志接口基本完成">
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/src/main/java/com/template/api/SmartDataSourceLogControllerAPI.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/template/api/SmartDataSourceLogControllerAPI.java" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/src/main/java/com/template/common/utils/QuartzJobUtils.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/template/common/utils/QuartzJobUtils.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/template/api/SmartDataSourceControllerAPI.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/template/api/SmartDataSourceControllerAPI.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/template/controller/SmartDataClassController.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/template/controller/SmartDataClassController.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/template/controller/SmartDataSourceController.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/template/controller/SmartDataSourceController.java" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/src/main/java/com/template/controller/SmartDataSourceLogController.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/template/controller/SmartDataSourceLogController.java" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/src/main/java/com/template/model/pojo/SmartDataSourceLog.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/template/model/pojo/SmartDataSourceLog.java" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/src/main/java/com/template/services/SmartDataSourceLogService.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/template/services/SmartDataSourceLogService.java" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/src/main/java/com/template/services/impl/SmartDataSourceLogServiceImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/template/services/impl/SmartDataSourceLogServiceImpl.java" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/src/main/java/com/template/services/impl/SmartDataTaskServiceImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/template/services/impl/SmartDataTaskServiceImpl.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/template/model/pojo/SmartDataClass.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/template/model/pojo/SmartDataClass.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/template/services/SmartDataSourceService.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/template/services/SmartDataSourceService.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/java/com/template/services/impl/SmartDataSourceServiceImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/template/services/impl/SmartDataSourceServiceImpl.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/resources/application-dev.yml" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/application-dev.yml" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/resources/application-prod.yml" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/application-prod.yml" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/main/resources/application.yml" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/application.yml" afterDir="false" />
     </list>
     <option name="SHOW_DIALOG" value="false" />
     <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -555,7 +557,10 @@
       <workItem from="1702041902347" duration="730000" />
       <workItem from="1702101136568" duration="17031000" />
       <workItem from="1702198575272" duration="25051000" />
-      <workItem from="1702254015850" duration="11585000" />
+      <workItem from="1702254015850" duration="11814000" />
+      <workItem from="1702279037484" duration="433000" />
+      <workItem from="1702302748830" duration="227000" />
+      <workItem from="1702457243216" duration="4411000" />
     </task>
     <task id="LOCAL-00001" summary="Default Changelist">
       <option name="closed" value="true" />
@@ -581,7 +586,15 @@
       <option name="project" value="LOCAL" />
       <updated>1702224101946</updated>
     </task>
-    <option name="localTasksCounter" value="4" />
+    <task id="LOCAL-00004" summary="日志接口基本完成">
+      <option name="closed" value="true" />
+      <created>1702266412248</created>
+      <option name="number" value="00004" />
+      <option name="presentableId" value="LOCAL-00004" />
+      <option name="project" value="LOCAL" />
+      <updated>1702266412248</updated>
+    </task>
+    <option name="localTasksCounter" value="5" />
     <servers />
   </component>
   <component name="TimeTrackingManager">
@@ -695,7 +708,8 @@
   <component name="VcsManagerConfiguration">
     <MESSAGE value="Default Changelist" />
     <MESSAGE value="任务通过接口操作" />
-    <option name="LAST_COMMIT_MESSAGE" value="任务通过接口操作" />
+    <MESSAGE value="日志接口基本完成" />
+    <option name="LAST_COMMIT_MESSAGE" value="日志接口基本完成" />
   </component>
   <component name="XDebuggerManager">
     <breakpoint-manager>
@@ -710,6 +724,16 @@
           <line>10</line>
           <option name="timeStamp" value="21" />
         </line-breakpoint>
+        <line-breakpoint enabled="true" type="java-line">
+          <url>file://$PROJECT_DIR$/src/main/java/com/template/controller/SmartDataClassController.java</url>
+          <line>64</line>
+          <option name="timeStamp" value="22" />
+        </line-breakpoint>
+        <line-breakpoint enabled="true" type="java-line">
+          <url>file://$PROJECT_DIR$/src/main/java/com/template/services/impl/SmartDataSourceServiceImpl.java</url>
+          <line>201</line>
+          <option name="timeStamp" value="24" />
+        </line-breakpoint>
       </breakpoints>
     </breakpoint-manager>
     <pin-to-top-manager>

+ 4 - 0
src/main/java/com/template/api/SmartDataSourceControllerAPI.java

@@ -22,6 +22,10 @@ public interface SmartDataSourceControllerAPI {
     @ApiOperation(value = "添加数据源", notes = "添加数据源数据", httpMethod = "POST")
     CommonResult insertSmartDataSource(@Validated @RequestBody SmartDataSource smartDataSource, BindingResult bindingResult);
 
+    @PostMapping(value = "/vcoSmartDataSource")
+    @ApiOperation(value = "测试数据源连接有效性", notes = "测试数据源连接有效性", httpMethod = "POST")
+    CommonResult vcoSmartDataSource(@Validated @RequestBody SmartDataSource smartDataSource, BindingResult bindingResult);
+
     @PostMapping(value = "/updateSmartDataSourceById")
     @ApiOperation(value = "编辑数据源数据", notes = "编辑数据源数据", httpMethod = "POST")
     CommonResult updateSmartDataSourceById(@Validated @RequestBody SmartDataSource smartDataSource, BindingResult bindingResult);

+ 20 - 8
src/main/java/com/template/controller/SmartDataClassController.java

@@ -31,8 +31,10 @@ public class SmartDataClassController implements SmartDataClassControllerAPI {
 
     @Autowired
     private SmartDataSourceService smartDataSourceService;
+
     /**
      * 新增 数据源分类
+     *
      * @param smartDataClass
      * @param bindingResult
      * @return
@@ -47,13 +49,17 @@ public class SmartDataClassController implements SmartDataClassControllerAPI {
         if (smartDataClass.getDsClsName() == null) {
             return CommonResult.fail("数据源分类名称为空!");
         }
+        if (smartDataClass.getDsClsDriver() == null) {
+            return CommonResult.fail("数据源驱动为空!");
+        }
 
         // 检测是否有重复名称
         QueryWrapper<SmartDataClass> smartDataClassQueryWrapper = new QueryWrapper<>();
         smartDataClassQueryWrapper.eq("ds_cls_name", smartDataClass.getDsClsName());
+        smartDataClassQueryWrapper.eq("ds_cls_driver", smartDataClass.getDsClsDriver());
         int count = smartDataClassService.count(smartDataClassQueryWrapper);
-        if(count > 0){
-            return CommonResult.fail("数据源分类名称有重名,新增失败!");
+        if (count > 0) {
+            return CommonResult.fail("数据源分类名称和驱动有重复,新增失败!");
         }
 
         int result = smartDataClassService.insertSmartDataClass(smartDataClass);
@@ -63,6 +69,7 @@ public class SmartDataClassController implements SmartDataClassControllerAPI {
 
     /**
      * 更新 数据源分类
+     *
      * @param smartDataClass
      * @param bindingResult
      * @return
@@ -77,13 +84,17 @@ public class SmartDataClassController implements SmartDataClassControllerAPI {
         if (smartDataClass.getDsClsName() == null) {
             return CommonResult.fail("数据源分类名称为空!");
         }
+        if (smartDataClass.getDsClsDriver() == null) {
+            return CommonResult.fail("数据源驱动为空!");
+        }
 
         // 检测是否有重复名称
         QueryWrapper<SmartDataClass> smartDataClassQueryWrapper = new QueryWrapper<>();
         smartDataClassQueryWrapper.eq("ds_cls_name", smartDataClass.getDsClsName());
+        smartDataClassQueryWrapper.eq("ds_cls_driver", smartDataClass.getDsClsDriver());
         int count = smartDataClassService.count(smartDataClassQueryWrapper);
-        if(count > 0){
-            return CommonResult.fail("数据源分类名称有重名,更新失败!");
+        if (count > 0) {
+            return CommonResult.fail("数据源分类名称和驱动有重复,更新失败!");
         }
 
         int result = smartDataClassService.updateSmartDataClass(smartDataClass);
@@ -92,9 +103,10 @@ public class SmartDataClassController implements SmartDataClassControllerAPI {
 
     /**
      * 数据源分类 分页数据查询
+     *
      * @param currentPage 当前页数
-     * @param pageCount 一页数据条数
-     * @param name 查询名称
+     * @param pageCount   一页数据条数
+     * @param name        查询名称
      * @return
      */
     @Override
@@ -110,7 +122,7 @@ public class SmartDataClassController implements SmartDataClassControllerAPI {
 
         SmartDataClass data = smartDataClassService.getSmartById(id);
 
-        if(data == null){
+        if (data == null) {
             return CommonResult.fail("当前数据不存在,删除失败!");
         }
 
@@ -118,7 +130,7 @@ public class SmartDataClassController implements SmartDataClassControllerAPI {
         QueryWrapper<SmartDataSource> smartDataSourceQueryWrapper = new QueryWrapper<>();
         smartDataSourceQueryWrapper.eq("ds_cls_id", id);
         int count = smartDataSourceService.count(smartDataSourceQueryWrapper);
-        if(count > 0){
+        if (count > 0) {
             return CommonResult.fail("当前类别下有数据,不能删除,删除失败!");
         }
 

+ 14 - 1
src/main/java/com/template/controller/SmartDataSourceController.java

@@ -25,6 +25,7 @@ import java.util.Map;
  */
 @RestController
 public class SmartDataSourceController implements SmartDataSourceControllerAPI {
+
     @Autowired
     private SmartDataSourceService smartDataSourceService;
 
@@ -43,7 +44,19 @@ public class SmartDataSourceController implements SmartDataSourceControllerAPI {
 
         Map<String, Object> result = smartDataSourceService.insertSmartDataSource(smartDataSource);
 
-        return Integer.parseInt((String) result.get("code")) > 0 ? CommonResult.ok(result.get("msg")) : CommonResult.fail((String) result.get("msg"));
+        return Integer.parseInt((String) result.get("code")) == 0 ? CommonResult.ok(result.get("msg")) : CommonResult.fail((String) result.get("msg"));
+    }
+
+    @Override
+    public CommonResult vcoSmartDataSource(SmartDataSource smartDataSource, BindingResult bindingResult) {
+        if (bindingResult.hasErrors()) {
+            String st = paramUtils.getParamError(bindingResult);
+            return CommonResult.fail(st);
+        }
+
+        Map<String, Object> result = smartDataSourceService.vcoSmartDataSource(smartDataSource);
+
+        return Integer.parseInt((String) result.get("code")) == 0 ? CommonResult.ok(result.get("msg")) : CommonResult.fail((String) result.get("msg"));
     }
 
     /**

+ 0 - 2
src/main/java/com/template/controller/SmartDataSourceLogController.java

@@ -9,8 +9,6 @@ import com.template.model.result.PageUtils;
 import com.template.services.SmartDataSourceLogService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.BindingResult;
-import org.springframework.web.bind.annotation.RequestMapping;
-
 import org.springframework.web.bind.annotation.RestController;
 
 /**

+ 3 - 0
src/main/java/com/template/model/pojo/SmartDataClass.java

@@ -36,6 +36,9 @@ public class SmartDataClass implements Serializable {
     @ApiModelProperty(value = "数据源类别名称")
     private String dsClsName;
 
+    @ApiModelProperty(value = "数据源驱动")
+    private String dsClsDriver;
+
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     @ApiModelProperty(value = "创建时间")
     private Date dsClsCreateTime;

+ 2 - 0
src/main/java/com/template/services/SmartDataSourceService.java

@@ -25,4 +25,6 @@ public interface SmartDataSourceService extends IService<SmartDataSource> {
     int deleteSmartDataSourceById(int id);
 
     SmartDataSource getSmartById(int id);
+
+    Map<String, Object> vcoSmartDataSource(SmartDataSource smartDataSource);
 }

+ 102 - 40
src/main/java/com/template/services/impl/SmartDataSourceServiceImpl.java

@@ -12,12 +12,17 @@ import com.template.model.pojo.SmartDataSource;
 import com.template.model.result.PageUtils;
 import com.template.services.SmartDataSourceService;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.jdbc.datasource.DriverManagerDataSource;
 import org.springframework.stereotype.Service;
 import org.springframework.util.StringUtils;
 
+import java.sql.Connection;
+import java.sql.SQLException;
 import java.util.List;
 import java.util.Map;
 
+import static org.hibernate.validator.internal.util.Contracts.assertNotNull;
+
 /**
  * <p>
  * 数据源配置 服务实现类
@@ -35,30 +40,36 @@ public class SmartDataSourceServiceImpl extends ServiceImpl<SmartDataSourceMappe
     @Autowired
     private SmartDataClassMapper smartDataClassMapper;
 
+    private final static DriverManagerDataSource dataSource = new DriverManagerDataSource();
+
     @Override
     public Map<String, Object> insertSmartDataSource(SmartDataSource smartDataSource) {
         // 检测参数,还有是否存在重复记录
-        Map<String, Object> stringStringMap = validateParams(smartDataSource, "insert");
-        if (stringStringMap != null) {
-            return stringStringMap;
+        if (smartDataSource.getDsClsId() == null) {
+            return CommonUtil.getReturnMap("1", "【数据源类型id】不能为空!");
+        }
+        SmartDataClass smartDataClass = smartDataClassMapper.selectById(smartDataSource.getDsClsId());
+        if (smartDataClass == null) {
+            return CommonUtil.getReturnMap("1", "选择的【数据源类型】不存在!");
         }
 
-        // 必填的参数不为null,则进行新增操作
-        int result = smartDataSourceMapper.insert(smartDataSource);
-        if (result > 0) {
-            return CommonUtil.getReturnMap(String.valueOf(result), "数据源添加成功!");
-        } else {
-            return CommonUtil.getReturnMap(String.valueOf(result), "数据源添加失败!");
+        if (smartDataSource.getDsName() == null) {
+            return CommonUtil.getReturnMap("1", "【数据源名称】不能为空!");
+        }
+        if (smartDataSource.getDsUrl() == null) {
+            return CommonUtil.getReturnMap("1", "【数据源连接地址】不能为空!");
+        }
+        if (smartDataSource.getDsUser() == null) {
+            return CommonUtil.getReturnMap("1", "【数据源用户】不能为空!");
+        }
+        if (smartDataSource.getDsPassword() == null) {
+            return CommonUtil.getReturnMap("1", "【数据源密码】不能为空!");
+        }
+        if (smartDataSource.getDsDescrition() == null) {
+            return CommonUtil.getReturnMap("1", "【数据源描述】不能为空!");
         }
-    }
 
-    // 检测验证参数,和数据库中是否存在重复记录
-    private Map<String, Object> validateParams(SmartDataSource smartDataSource, String action) {
-        // 看是否有相同的记录
         QueryWrapper<SmartDataSource> queryWrapper = new QueryWrapper<>();
-        if ("update".equals(action)) {
-            queryWrapper.eq(smartDataSource.getDsId() != null, "ds_id", smartDataSource.getDsId());
-        }
         queryWrapper.eq(smartDataSource.getDsClsId() != null, "ds_cls_id", smartDataSource.getDsClsId());
         queryWrapper.eq(StringUtils.hasText(smartDataSource.getDsName()), "ds_name", smartDataSource.getDsName());
         queryWrapper.like(StringUtils.hasText(smartDataSource.getDsUrl()), "ds_url", smartDataSource.getDsUrl());
@@ -68,27 +79,39 @@ public class SmartDataSourceServiceImpl extends ServiceImpl<SmartDataSourceMappe
         queryWrapper.eq(StringUtils.hasText(smartDataSource.getDsDescrition()), "ds_descrition", smartDataSource.getDsDescrition());
         List<SmartDataSource> smartDataSources = smartDataSourceMapper.selectList(queryWrapper);
         if (smartDataSources.size() > 0) {
-            if ("update".equals(action)) {
-                return CommonUtil.getReturnMap("0", "数据未修改,请修改后再提交!");
-            } else {
-                return CommonUtil.getReturnMap("0", "有重复记录!");
-            }
+            return CommonUtil.getReturnMap("1", "有重复记录!");
         }
-        // 检测必要参数是否为null
-        if ("update".equals(action)) {
-            if (smartDataSource.getDsId() == null) {
-                return CommonUtil.getReturnMap("0", "【数据源id】不能为空!");
-            }
-            SmartDataSource sdc = smartDataSourceMapper.selectById(smartDataSource.getDsId());
-            if (sdc == null) {
-                return CommonUtil.getReturnMap("0", "要修改的【数据源】不存在!");
-            }
+
+        Map<String, Object> stringObjectMap = vcoSmartDataSource(smartDataSource);
+        if ("1".equals(stringObjectMap.get("code"))) {
+            smartDataSource.setDsStatus(0);
+        } else {
+            smartDataSource.setDsStatus(1);
+        }
+
+        // 必填的参数不为null,则进行新增操作
+        int result = smartDataSourceMapper.insert(smartDataSource);
+        if (result > 0) {
+            return CommonUtil.getReturnMap(String.valueOf(result), "数据源添加成功!");
+        } else {
+            return CommonUtil.getReturnMap(String.valueOf(result), "数据源添加失败!");
+        }
+    }
+
+    @Override
+    public Map<String, Object> updateSmartDataSource(SmartDataSource smartDataSource) {
+        // 检测参数,还有是否存在重复记录
+        if (smartDataSource.getDsId() == null) {
+            return CommonUtil.getReturnMap("0", "【数据源id】不能为空!");
+        }
+        SmartDataSource sdc = smartDataSourceMapper.selectById(smartDataSource.getDsId());
+        if (sdc == null) {
+            return CommonUtil.getReturnMap("0", "要修改的【数据源】不存在!");
         }
         // 检测必要参数是否为null
         if (smartDataSource.getDsClsId() == null) {
             return CommonUtil.getReturnMap("0", "【数据源类型id】不能为空!");
         }
-
         SmartDataClass smartDataClass = smartDataClassMapper.selectById(smartDataSource.getDsClsId());
         if (smartDataClass == null) {
             return CommonUtil.getReturnMap("0", "选择的【数据源类型】不存在!");
@@ -109,15 +132,18 @@ public class SmartDataSourceServiceImpl extends ServiceImpl<SmartDataSourceMappe
         if (smartDataSource.getDsDescrition() == null) {
             return CommonUtil.getReturnMap("0", "【数据源描述】不能为空!");
         }
-        return null;
-    }
-
-    @Override
-    public Map<String, Object> updateSmartDataSource(SmartDataSource smartDataSource) {
-        // 检测参数,还有是否存在重复记录
-        Map<String, Object> stringStringMap = validateParams(smartDataSource, "insert");
-        if (stringStringMap != null) {
-            return stringStringMap;
+        QueryWrapper<SmartDataSource> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq(smartDataSource.getDsId() != null, "ds_id", smartDataSource.getDsId());
+        queryWrapper.eq(smartDataSource.getDsClsId() != null, "ds_cls_id", smartDataSource.getDsClsId());
+        queryWrapper.eq(StringUtils.hasText(smartDataSource.getDsName()), "ds_name", smartDataSource.getDsName());
+        queryWrapper.like(StringUtils.hasText(smartDataSource.getDsUrl()), "ds_url", smartDataSource.getDsUrl());
+        queryWrapper.eq(StringUtils.hasText(smartDataSource.getDsUser()), "ds_user", smartDataSource.getDsUser());
+        queryWrapper.eq(StringUtils.hasText(smartDataSource.getDsPassword()), "ds_password", smartDataSource.getDsPassword());
+        queryWrapper.eq(smartDataSource.getDsStatus() != null, "ds_status", smartDataSource.getDsStatus());
+        queryWrapper.eq(StringUtils.hasText(smartDataSource.getDsDescrition()), "ds_descrition", smartDataSource.getDsDescrition());
+        List<SmartDataSource> smartDataSources = smartDataSourceMapper.selectList(queryWrapper);
+        if (smartDataSources.size() > 0) {
+            return CommonUtil.getReturnMap("0", "数据未修改,请修改后再提交!");
         }
 
         int result = smartDataSourceMapper.updateById(smartDataSource);
@@ -152,4 +178,40 @@ public class SmartDataSourceServiceImpl extends ServiceImpl<SmartDataSourceMappe
         SmartDataSource result = smartDataSourceMapper.selectById(id);
         return result;
     }
+
+    @Override
+    public Map<String, Object> vcoSmartDataSource(SmartDataSource smartDataSource) {
+        // 设置数据源信息
+        if (smartDataSource.getDsClsId() == null) {
+            return CommonUtil.getReturnMap("1", "【数据源类型id】不能为空!");
+        }
+        SmartDataClass smartDataClass = smartDataClassMapper.selectById(smartDataSource.getDsClsId());
+        if (smartDataClass == null) {
+            return CommonUtil.getReturnMap("1", "选择的【数据源类型】不存在!");
+        }
+
+        String dsClsDriver = smartDataClass.getDsClsDriver();
+        dataSource.setDriverClassName(dsClsDriver);
+        dataSource.setUrl(smartDataSource.getDsUrl());
+        dataSource.setUsername(smartDataSource.getDsUser());
+        dataSource.setPassword(smartDataSource.getDsPassword());
+
+        // 尝试获取数据库连接
+        Connection connection = null;
+        try {
+            connection = dataSource.getConnection();
+            assertNotNull(connection);
+            return CommonUtil.getReturnMap(String.valueOf(0), "连接成功!");
+        } catch (SQLException e) {
+            return CommonUtil.getReturnMap(String.valueOf(1), "连接失败:" + e.getMessage());
+        } finally {
+            if (connection != null) {
+                try {
+                    connection.close();
+                } catch (SQLException e) {
+                    throw new RuntimeException(e);
+                }
+            }
+        }
+    }
 }

+ 2 - 2
src/main/resources/application-dev.yml

@@ -8,8 +8,8 @@ spring:
     allow-circular-references: true
   datasource:
     username: root
-    password: Ro0!ot_369!
-    url: jdbc:mysql://192.168.1.34:3306/smart_middle?useUnicode=tru&characterEncoding=UTF-8&useSSL=false&useAffectedRows=true&allowPublicKeyRetrieval=true&allowMultiQueries=true&rewriteBatchedStatements=true&serverTimezone=Asia/Shanghai
+    password: Chuanghai2023.
+    url: jdbc:mysql://111.231.169.217:3306/smart_middle?useUnicode=tru&characterEncoding=UTF-8&useSSL=false&useAffectedRows=true&allowPublicKeyRetrieval=true&allowMultiQueries=true&rewriteBatchedStatements=true&serverTimezone=Asia/Shanghai
     driver-class-name: com.mysql.cj.jdbc.Driver
     cache:
       type: redis

+ 2 - 2
src/main/resources/application-prod.yml

@@ -8,8 +8,8 @@ spring:
     allow-circular-references: true
   datasource:
     username: root
-    password: Ro0!ot_369!
-    url: jdbc:mysql://192.168.1.34:3306/smart_middle?useUnicode=tru&characterEncoding=UTF-8&useSSL=false&useAffectedRows=true&allowPublicKeyRetrieval=true&allowMultiQueries=true&rewriteBatchedStatements=true&serverTimezone=Asia/Shanghai
+    password: Chuanghai2023.
+    url: jdbc:mysql://111.231.169.217:3306/smart_middle?useUnicode=tru&characterEncoding=UTF-8&useSSL=false&useAffectedRows=true&allowPublicKeyRetrieval=true&allowMultiQueries=true&rewriteBatchedStatements=true&serverTimezone=Asia/Shanghai
     driver-class-name: com.mysql.cj.jdbc.Driver
     cache:
       type: redis

+ 2 - 2
src/main/resources/application.yml

@@ -10,8 +10,8 @@ spring:
     allow-circular-references: true
   datasource:
     username: root
-    password: Ro0!ot_369!
-    url: jdbc:mysql://192.168.1.34:3306/smart_middle?useUnicode=tru&characterEncoding=UTF-8&useSSL=false&useAffectedRows=true&allowPublicKeyRetrieval=true&allowMultiQueries=true&rewriteBatchedStatements=true&serverTimezone=Asia/Shanghai
+    password: Chuanghai2023.
+    url: jdbc:mysql://111.231.169.217:3306/smart_middle?useUnicode=tru&characterEncoding=UTF-8&useSSL=false&useAffectedRows=true&allowPublicKeyRetrieval=true&allowMultiQueries=true&rewriteBatchedStatements=true&serverTimezone=Asia/Shanghai
     driver-class-name: com.mysql.cj.jdbc.Driver
     cache:
       type: redis