提交 0c2fda2e authored 作者: 黄夏豪's avatar 黄夏豪

Merge remote-tracking branch 'origin/master'

...@@ -2,15 +2,15 @@ package com.tykj.workflowcore.model_layer.controller; ...@@ -2,15 +2,15 @@ package com.tykj.workflowcore.model_layer.controller;
import com.tykj.workflowcore.base.result.ResultUtil; import com.tykj.workflowcore.base.result.ResultUtil;
import com.tykj.workflowcore.model_layer.model.ColumnInfo;
import com.tykj.workflowcore.model_layer.model.QueryCondition;
import com.tykj.workflowcore.model_layer.model.TableInfo; import com.tykj.workflowcore.model_layer.model.TableInfo;
import com.tykj.workflowcore.model_layer.model.TableVO; import com.tykj.workflowcore.model_layer.model.TableVO;
import com.tykj.workflowcore.model_layer.service.ModelService; import com.tykj.workflowcore.model_layer.service.ModelService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -128,4 +128,23 @@ public class ModelController { ...@@ -128,4 +128,23 @@ public class ModelController {
} }
return ResultUtil.success( null,"获取失败"); return ResultUtil.success( null,"获取失败");
} }
/**
* @Author WWW
* @Description 复杂查询
* @Date 11:03 2021/3/11
* @param tableName
* @param queryConditions
* @return org.springframework.http.ResponseEntity
**/
@ApiOperation("复杂查询")
@GetMapping("/complexQuery")
public ResponseEntity complexQuery(String tableName, List<QueryCondition> queryConditions) {
List list = modelService.complexquery(tableName, queryConditions);
if (list!=null){
return ResultUtil.success(list,"查询成功");
}
return ResultUtil.success(null,"没有数据");
}
} }
...@@ -4,6 +4,7 @@ package com.tykj.workflowcore.model_layer.service; ...@@ -4,6 +4,7 @@ package com.tykj.workflowcore.model_layer.service;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import com.tykj.workflowcore.model_layer.model.ColumnInfo; import com.tykj.workflowcore.model_layer.model.ColumnInfo;
import com.tykj.workflowcore.model_layer.model.QueryCondition;
import com.tykj.workflowcore.model_layer.model.TableInfo; import com.tykj.workflowcore.model_layer.model.TableInfo;
import com.tykj.workflowcore.model_layer.model.TableVO; import com.tykj.workflowcore.model_layer.model.TableVO;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -39,4 +40,6 @@ public interface ModelService { ...@@ -39,4 +40,6 @@ public interface ModelService {
void swaggerScan(List<Class<?>> classList); void swaggerScan(List<Class<?>> classList);
List findAllByName(String name) throws SQLException; List findAllByName(String name) throws SQLException;
List complexquery(String tableName, List<QueryCondition> queryConditions);
} }
...@@ -8,10 +8,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; ...@@ -8,10 +8,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.tykj.workflowcore.model_layer.annotatiion.WorkFlowCoreNoScan; import com.tykj.workflowcore.model_layer.annotatiion.WorkFlowCoreNoScan;
import com.tykj.workflowcore.model_layer.dao.ColumnInfoDao; import com.tykj.workflowcore.model_layer.dao.ColumnInfoDao;
import com.tykj.workflowcore.model_layer.dao.TableInfoDao; import com.tykj.workflowcore.model_layer.dao.TableInfoDao;
import com.tykj.workflowcore.model_layer.model.ColumnInfo; import com.tykj.workflowcore.model_layer.model.*;
import com.tykj.workflowcore.model_layer.model.ColumnVO;
import com.tykj.workflowcore.model_layer.model.TableInfo;
import com.tykj.workflowcore.model_layer.model.TableVO;
import com.tykj.workflowcore.model_layer.service.ModelService; import com.tykj.workflowcore.model_layer.service.ModelService;
import com.tykj.workflowcore.model_layer.utils.CreatTableUtil; import com.tykj.workflowcore.model_layer.utils.CreatTableUtil;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
...@@ -44,6 +41,7 @@ import java.text.SimpleDateFormat; ...@@ -44,6 +41,7 @@ import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import static com.tykj.workflowcore.model_layer.utils.CreatTableUtil.*; import static com.tykj.workflowcore.model_layer.utils.CreatTableUtil.*;
import static com.tykj.workflowcore.model_layer.utils.HqlUtil.createQuery;
/** /**
...@@ -347,7 +345,13 @@ public class ModelImpl implements ModelService { ...@@ -347,7 +345,13 @@ public class ModelImpl implements ModelService {
} }
} }
} }
/**
* @Author WWW
* @Description 判重
* @Date 10:50 2021/3/11
* @param tableName
* @return boolean
**/
public boolean checkRepeat(String tableName) { public boolean checkRepeat(String tableName) {
Specification spec = (Specification) (root, criteriaQuery, criteriaBuilder) -> { Specification spec = (Specification) (root, criteriaQuery, criteriaBuilder) -> {
Path name = root.get("name"); Path name = root.get("name");
...@@ -365,12 +369,40 @@ public class ModelImpl implements ModelService { ...@@ -365,12 +369,40 @@ public class ModelImpl implements ModelService {
return true; return true;
} }
/**
* @Author WWW
* @Description 通过表名查询所有信息
* @Date 10:51 2021/3/11
* @param name
* @return java.util.List
**/
@Override @Override
public List findAllByName(String name) throws SQLException { public List findAllByName(String name) {
if (name!=null&&name != ""){ if (name!=null&&name != ""){
return Db.use().findAll(name); try {
return Db.use().findAll(name);
} catch (SQLException throwables) {
throwables.printStackTrace();
}
} }
return null; return null;
} }
@Override
public List complexQuery(String tableName, List<QueryCondition> queryConditions) {
List<cn.hutool.db.Entity> list=null;
if (!tableName.equals("")){
String query = createQuery(tableName, queryConditions);
try {
list = Db.use().query(query);
} catch (SQLException throwables) {
throwables.printStackTrace();
}
}
else {
return null;
}
return list ;
}
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论