|
|
@@ -3,15 +3,24 @@ package com.template.services.impl;
|
|
|
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.template.common.utils.CommonUtil;
|
|
|
import com.template.mapper.SmartDataSourceMapper;
|
|
|
import com.template.model.pojo.SmartDataSource;
|
|
|
import com.template.model.pojo.SmartDataSource;
|
|
|
import com.template.mapper.SmartDataSourceMapper;
|
|
|
+import com.template.model.result.CommonResult;
|
|
|
import com.template.model.result.PageUtils;
|
|
|
import com.template.services.SmartDataSourceService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import org.apache.poi.ss.formula.functions.T;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.util.StringUtils;
|
|
|
+
|
|
|
+import java.lang.reflect.Field;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
|
@@ -27,9 +36,30 @@ public class SmartDataSourceServiceImpl extends ServiceImpl<SmartDataSourceMappe
|
|
|
private SmartDataSourceMapper smartDataSourceMapper;
|
|
|
|
|
|
@Override
|
|
|
- public int insertSmartDataSource(SmartDataSource sa) {
|
|
|
- int result = smartDataSourceMapper.insert(sa);
|
|
|
- return result;
|
|
|
+ public Map<String, String> insertSmartDataSource(SmartDataSource smartDataSource) {
|
|
|
+ // 检测必要参数是否为null
|
|
|
+ if (smartDataSource.getDsClsId() == null) {
|
|
|
+ return CommonUtil.getReturnMap("0", "【数据源类型id】不能为空!");
|
|
|
+ }
|
|
|
+ if (smartDataSource.getDsName() == null) {
|
|
|
+ return CommonUtil.getReturnMap("0", "【数据源名称】不能为空!");
|
|
|
+ }
|
|
|
+ if (smartDataSource.getDsUrl() == null) {
|
|
|
+ return CommonUtil.getReturnMap("0", "【数据源连接地址】不能为空!");
|
|
|
+ }
|
|
|
+ if (smartDataSource.getDsSql() == null) {
|
|
|
+ return CommonUtil.getReturnMap("0", "【数据源SQL语言】不能为空!");
|
|
|
+ }
|
|
|
+ if (smartDataSource.getDsDescrition() == null) {
|
|
|
+ return CommonUtil.getReturnMap("0", "【数据源描述】不能为空!");
|
|
|
+ }
|
|
|
+ // 必填的参数不为null,则进行新增操作
|
|
|
+ int result = smartDataSourceMapper.insert(smartDataSource);
|
|
|
+ if (result > 0) {
|
|
|
+ return CommonUtil.getReturnMap(String.valueOf(result), "数据源添加成功!");
|
|
|
+ } else {
|
|
|
+ return CommonUtil.getReturnMap(String.valueOf(result), "数据源添加失败!");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -39,11 +69,14 @@ public class SmartDataSourceServiceImpl extends ServiceImpl<SmartDataSourceMappe
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public PageUtils<SmartDataSource> queryPageSmartDataSources(int currentPage, int pageCount, String name) {
|
|
|
+ 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(name), "name", name);
|
|
|
- IPage<SmartDataSource> result = smartDataSourceMapper.selectPage(page,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.like(StringUtils.hasText(smartDataSource.getDsDescrition()), "ds_descrition", smartDataSource.getDsDescrition());
|
|
|
+ IPage<SmartDataSource> result = smartDataSourceMapper.selectPage(page, queryWrapper);
|
|
|
return new PageUtils<>(result);
|
|
|
}
|
|
|
|