Просмотр исходного кода

数据源对接前端的修改

soft5566 2 лет назад
Родитель
Сommit
29349b2995

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

@@ -1,6 +1,7 @@
 package com.template.controller;
 
 
+import com.github.pagehelper.PageInfo;
 import com.template.api.SmartDataSourceControllerAPI;
 import com.template.common.utils.CommonUtil;
 import com.template.common.utils.paramUtils;
@@ -114,7 +115,7 @@ public class SmartDataSourceController implements SmartDataSourceControllerAPI {
      */
     @Override
     public CommonResult queryPageSmartDataSources(int currentPage, int pageCount, SmartDataSource smartDataSource) {
-        PageUtils<SmartDataSource> result = smartDataSourceService.queryPageSmartDataSources(currentPage, pageCount, smartDataSource);
+        PageInfo<SmartDataSource> result = smartDataSourceService.queryPageSmartDataSources(currentPage, pageCount, smartDataSource);
 
         return CommonResult.ok(result);
     }

+ 18 - 0
src/main/java/com/template/mapper/SmartDataSourceMapper.java

@@ -47,4 +47,22 @@ public interface SmartDataSourceMapper extends BaseMapper<SmartDataSource> {
             "    smart_department ")
     List<SmartDepartment> getDepart();
 
+    @Select({
+            "<script>",
+            "   SELECT ",
+            "      ds_id, s.ds_cls_id, ds_cls_name, ds_name, ds_url, ds_user, ds_password, ds_status, ds_descrition, ds_source ",
+            "      , ds_target, ds_create_time, ds_update_time ",
+            "   FROM smart_data_source s ",
+            "      LEFT JOIN smart_data_class c ON s.ds_cls_id = c.ds_cls_id ",
+            "   <where>",
+            "      <if test='dsClsId != null'>AND s.ds_cls_id = #{dsClsId}</if>",
+            "      <if test='dsStatus != null'>AND ds_status = #{dsStatus}</if>",
+            "      <if test='dsName != null'>AND ds_name like CONCAT('%', #{dsName}, '%')</if>",
+            "      <if test='dsUrl != null'>AND ds_url like CONCAT('%', #{dsUrl}, '%')</if>",
+            "      <if test='dsDescrition != null'>AND ds_descrition like CONCAT('%', #{dsDescrition}, '%')</if>",
+            "   </where>",
+            "   ORDER BY ds_update_time ",
+            "</script>"
+    })
+    List<SmartDataSource> selectPageDsSource(SmartDataSource smartDataSource);
 }

+ 5 - 1
src/main/java/com/template/model/pojo/SmartDataSource.java

@@ -2,6 +2,8 @@ package com.template.model.pojo;
 
 import com.baomidou.mybatisplus.annotation.IdType;
 import java.util.Date;
+
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.Version;
 import com.baomidou.mybatisplus.annotation.TableId;
 import java.io.Serializable;
@@ -68,5 +70,7 @@ public class SmartDataSource implements Serializable {
     @ApiModelProperty(value = "更新时间")
     private Date dsUpdateTime;
 
-
+    @ApiModelProperty(value = "数据源名称")
+    @TableField(exist = false)
+    private String dsClsName;
 }

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

@@ -1,5 +1,6 @@
 package com.template.services;
 
+import com.github.pagehelper.PageInfo;
 import com.template.model.pojo.SmartDataSource;
 import com.template.model.pojo.SmartDataSource;
 import com.baomidou.mybatisplus.extension.service.IService;
@@ -20,7 +21,7 @@ public interface SmartDataSourceService extends IService<SmartDataSource> {
 
     Map<String, Object> updateSmartDataSource(SmartDataSource rns);
 
-    PageUtils<SmartDataSource> queryPageSmartDataSources(int currentPage, int pageCount, SmartDataSource smartDataSource);
+    PageInfo<SmartDataSource> queryPageSmartDataSources(int currentPage, int pageCount, SmartDataSource smartDataSource);
 
     int deleteSmartDataSourceById(int id);
 

+ 15 - 12
src/main/java/com/template/services/impl/SmartDataSourceServiceImpl.java

@@ -4,11 +4,14 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
 import com.template.common.utils.CommonUtil;
 import com.template.mapper.SmartDataClassMapper;
 import com.template.mapper.SmartDataSourceMapper;
 import com.template.model.pojo.SmartDataClass;
 import com.template.model.pojo.SmartDataSource;
+import com.template.model.pojo.SmartDataTaskErr;
 import com.template.model.result.PageUtils;
 import com.template.services.SmartDataSourceService;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -146,6 +149,13 @@ public class SmartDataSourceServiceImpl extends ServiceImpl<SmartDataSourceMappe
             return CommonUtil.getReturnMap("1", "数据未修改,请修改后再提交!");
         }
 
+        Map<String, Object> stringObjectMap = vcoSmartDataSource(smartDataSource);
+        if ("1".equals(stringObjectMap.get("code"))) {
+            smartDataSource.setDsStatus(0);
+        } else {
+            smartDataSource.setDsStatus(1);
+        }
+
         int result = smartDataSourceMapper.updateById(smartDataSource);
         if (result > 0) {
             return CommonUtil.getReturnMap("0", "数据源修改成功!");
@@ -155,16 +165,10 @@ public class SmartDataSourceServiceImpl extends ServiceImpl<SmartDataSourceMappe
     }
 
     @Override
-    public PageUtils<SmartDataSource> queryPageSmartDataSources(int currentPage, int pageCount, SmartDataSource smartDataSource) {
-        Page<SmartDataSource> page = new Page<>(currentPage, pageCount);
-        QueryWrapper<SmartDataSource> queryWrapper = new QueryWrapper<>();
-        queryWrapper.like(StringUtils.hasText(smartDataSource.getDsName()), "ds_name", smartDataSource.getDsName());
-        queryWrapper.like(StringUtils.hasText(smartDataSource.getDsUrl()), "ds_url", smartDataSource.getDsUrl());
-        queryWrapper.like(smartDataSource.getDsStatus() != null, "ds_status", smartDataSource.getDsStatus());
-        queryWrapper.eq(StringUtils.hasText(smartDataSource.getDsDescrition()), "ds_descrition", smartDataSource.getDsDescrition());
-        queryWrapper.orderByDesc("ds_update_time");
-        IPage<SmartDataSource> result = smartDataSourceMapper.selectPage(page, queryWrapper);
-        return new PageUtils<>(result);
+    public PageInfo<SmartDataSource> queryPageSmartDataSources(int currentPage, int pageCount, SmartDataSource smartDataSource) {
+        PageHelper.startPage(currentPage, pageCount);
+        List<SmartDataSource> result = smartDataSourceMapper.selectPageDsSource(smartDataSource);
+        return new PageInfo<>(result);
     }
 
     @Override
@@ -190,8 +194,7 @@ public class SmartDataSourceServiceImpl extends ServiceImpl<SmartDataSourceMappe
             return CommonUtil.getReturnMap("1", "选择的【数据源类型】不存在!");
         }
 
-        String dsClsDriver = smartDataClass.getDsClsDriver();
-        dataSource.setDriverClassName(dsClsDriver);
+        dataSource.setDriverClassName(smartDataClass.getDsClsDriver());
         dataSource.setUrl(smartDataSource.getDsUrl());
         dataSource.setUsername(smartDataSource.getDsUser());
         dataSource.setPassword(smartDataSource.getDsPassword());

+ 1 - 2
src/main/java/com/template/services/impl/SmartDataTaskServiceImpl.java

@@ -679,8 +679,7 @@ public class SmartDataTaskServiceImpl extends ServiceImpl<SmartDataTaskMapper, S
     public PageInfo<SmartDataTaskErr> queryPageSmartDataTaskErr(int currentPage, int pageCount, Integer eTaskId, String startTime, String endTime) {
         PageHelper.startPage(currentPage, pageCount);
         List<SmartDataTaskErr> result = smartDataTaskMapper.selectPageOrderByDatetimeDesc(eTaskId, startTime, endTime);
-        PageInfo<SmartDataTaskErr> logPageInfo = new PageInfo<>(result);
-        return logPageInfo;
+        return new PageInfo<>(result);
     }
 
     @Override