Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
D
dataWareHose
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
黄夏豪
dataWareHose
Commits
c7b4b059
提交
c7b4b059
authored
7月 06, 2021
作者:
ww1xhqc
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[数据模型] 稳定版
上级
9e3ded72
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
130 行增加
和
64 行删除
+130
-64
FourComsumer.java
...va/com/tykj/datawarehouse/base/consumer/FourComsumer.java
+32
-0
ModelController.java
.../tykj/datawarehouse/model/controller/ModelController.java
+14
-6
QuoteController.java
.../tykj/datawarehouse/model/controller/QuoteController.java
+12
-3
ModelService.java
...va/com/tykj/datawarehouse/model/service/ModelService.java
+28
-11
QuoteService.java
...va/com/tykj/datawarehouse/model/service/QuoteService.java
+1
-1
ModelImpl.java
.../com/tykj/datawarehouse/model/service/impl/ModelImpl.java
+29
-37
QuoteServiceImpl.java
...kj/datawarehouse/model/service/impl/QuoteServiceImpl.java
+13
-5
CreateTableUtil.java
...a/com/tykj/datawarehouse/model/utils/CreateTableUtil.java
+1
-1
没有找到文件。
src/main/java/com/tykj/datawarehouse/base/consumer/FourComsumer.java
0 → 100644
浏览文件 @
c7b4b059
package
com
.
tykj
.
datawarehouse
.
base
.
consumer
;
import
java.util.Objects
;
/**
* @Description TODO
* @Author WWW
* @Date 2021/7/5 17:28
*/
@FunctionalInterface
public
interface
FourComsumer
<
T
,
Y
,
U
,
I
>
{
/**
* @param t
* @param y
* @param u
* @param i
*/
void
accept
(
T
t
,
Y
y
,
U
u
,
I
i
);
default
FourComsumer
<
T
,
Y
,
U
,
I
>
andThen
(
FourComsumer
<?
super
T
,
?
super
Y
,
?
super
U
,
?
super
I
>
after
)
{
Objects
.
requireNonNull
(
after
);
return
(
l
,
y
,
u
,
i
)
->
{
accept
(
l
,
y
,
u
,
i
);
after
.
accept
(
l
,
y
,
u
,
i
);
};
}
}
src/main/java/com/tykj/datawarehouse/model/controller/ModelController.java
浏览文件 @
c7b4b059
...
@@ -12,9 +12,12 @@ import com.tykj.datawarehouse.model.entity.TableInfo;
...
@@ -12,9 +12,12 @@ import com.tykj.datawarehouse.model.entity.TableInfo;
import
com.tykj.datawarehouse.model.entity.vo.*
;
import
com.tykj.datawarehouse.model.entity.vo.*
;
import
com.tykj.datawarehouse.model.service.ModelService
;
import
com.tykj.datawarehouse.model.service.ModelService
;
import
com.tykj.datawarehouse.model.service.impl.ModelHelper
;
import
com.tykj.datawarehouse.model.service.impl.ModelHelper
;
import
com.tykj.datawarehouse.model.utils.SessionUtil
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.hibernate.Session
;
import
org.hibernate.internal.SessionImpl
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Page
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.HttpStatus
;
...
@@ -49,6 +52,8 @@ public class ModelController {
...
@@ -49,6 +52,8 @@ public class ModelController {
private
QuoteDao
quoteDao
;
private
QuoteDao
quoteDao
;
@Autowired
@Autowired
private
RuleDao
ruleDao
;
private
RuleDao
ruleDao
;
@Autowired
SessionUtil
sessionUtil
;
/**
/**
* @param
* @param
...
@@ -132,7 +137,8 @@ public class ModelController {
...
@@ -132,7 +137,8 @@ public class ModelController {
@ApiOperation
(
value
=
"根据表名表插入数据"
)
@ApiOperation
(
value
=
"根据表名表插入数据"
)
@PostMapping
(
"/insertValues"
)
@PostMapping
(
"/insertValues"
)
public
ResponseEntity
insertValues
(
@RequestBody
Map
<
String
,
Object
>
map
)
{
public
ResponseEntity
insertValues
(
@RequestBody
Map
<
String
,
Object
>
map
)
{
int
i
=
modelService
.
putValueByEntityName
(
map
,
false
);
SessionImpl
session
=(
SessionImpl
)
sessionUtil
.
getSession
();
int
i
=
modelService
.
operationValueByEntityName
(
map
,
session
,
session:
:
saveOrUpdate
,
modelService:
:
validationAllRuleAndQuote
);
if
(
i
==
0
)
{
if
(
i
==
0
)
{
return
ResultUtil
.
success
(
""
,
"数据插入成功!"
);
return
ResultUtil
.
success
(
""
,
"数据插入成功!"
);
}
}
...
@@ -150,9 +156,10 @@ public class ModelController {
...
@@ -150,9 +156,10 @@ public class ModelController {
@ApiOperation
(
value
=
"根据表名表插入数据"
)
@ApiOperation
(
value
=
"根据表名表插入数据"
)
@PostMapping
(
"/insertValueList"
)
@PostMapping
(
"/insertValueList"
)
public
ResponseEntity
insertValueList
(
@RequestBody
List
<
Map
<
String
,
Object
>>
mapList
)
{
public
ResponseEntity
insertValueList
(
@RequestBody
List
<
Map
<
String
,
Object
>>
mapList
)
{
int
i
=
modelService
.
putValueByEntityNameList
(
mapList
,
false
);
SessionImpl
session
=(
SessionImpl
)
sessionUtil
.
getSession
();
int
i
=
modelService
.
operationValueByEntityNameList
(
mapList
,
session
,
session:
:
saveOrUpdate
,
modelService:
:
validationAllRuleAndQuote
);
if
(
i
==
0
)
{
if
(
i
==
0
)
{
return
ResultUtil
.
success
(
""
,
"数据
插入
成功!"
);
return
ResultUtil
.
success
(
""
,
"数据
删除
成功!"
);
}
}
return
ResultUtil
.
failed
(
"模型类型不支持插入数据!"
);
return
ResultUtil
.
failed
(
"模型类型不支持插入数据!"
);
}
}
...
@@ -229,11 +236,12 @@ public class ModelController {
...
@@ -229,11 +236,12 @@ public class ModelController {
@ApiOperation
(
"删除接口"
)
@ApiOperation
(
"删除接口"
)
@PostMapping
(
"/deleteValue"
)
@PostMapping
(
"/deleteValue"
)
public
ResponseEntity
deleteValue
(
@RequestBody
Map
<
String
,
Object
>
map
)
{
public
ResponseEntity
deleteValue
(
@RequestBody
Map
<
String
,
Object
>
map
)
{
int
i
=
modelService
.
putValueByEntityName
(
map
,
true
);
SessionImpl
session
=(
SessionImpl
)
sessionUtil
.
getSession
();
int
i
=
modelService
.
operationValueByEntityName
(
map
,
session
,
session:
:
delete
,
null
);
if
(
i
==
0
)
{
if
(
i
==
0
)
{
return
ResultUtil
.
success
(
""
,
"数据
删除
成功!"
);
return
ResultUtil
.
success
(
""
,
"数据
插入
成功!"
);
}
}
return
ResultUtil
.
failed
(
"模型类型不支持
删除
数据!"
);
return
ResultUtil
.
failed
(
"模型类型不支持
插入
数据!"
);
}
}
@ApiOperation
(
"字段类型"
)
@ApiOperation
(
"字段类型"
)
...
...
src/main/java/com/tykj/datawarehouse/model/controller/QuoteController.java
浏览文件 @
c7b4b059
...
@@ -30,13 +30,21 @@ public class QuoteController {
...
@@ -30,13 +30,21 @@ public class QuoteController {
@ApiOperation
(
"引用删除"
)
@ApiOperation
(
"引用删除"
)
@GetMapping
(
"/delete"
)
@GetMapping
(
"/delete"
)
public
ResponseEntity
deleteQuote
(
Integer
id
)
{
public
ResponseEntity
deleteQuote
(
Integer
id
)
{
return
ResultUtil
.
success
(
quoteService
.
delQuote
(
id
),
"删除成功!"
);
Integer
integer
=
quoteService
.
delQuote
(
id
);
if
(
integer
==
1
){
return
ResultUtil
.
success
(
"删除成功!"
);
}
return
ResultUtil
.
failed
(
"此id不存在,删除失败"
);
}
}
@ApiOperation
(
"引用更新"
)
@ApiOperation
(
"引用更新"
)
@PostMapping
(
"/update"
)
@PostMapping
(
"/update"
)
public
ResponseEntity
UpdateQuote
(
@RequestBody
UpdateQuoteVO
updateQuoteVO
)
{
public
ResponseEntity
UpdateQuote
(
@RequestBody
UpdateQuoteVO
updateQuoteVO
)
{
return
ResultUtil
.
success
(
quoteService
.
updateQuote
(
updateQuoteVO
),
"更新成功!"
);
int
i
=
quoteService
.
updateQuote
(
updateQuoteVO
);
if
(
i
==
0
){
return
ResultUtil
.
success
(
"更新/保存成功!"
);
}
return
ResultUtil
.
failed
(
"引用数据重复,导致更新/保存失败!"
);
}
}
@ApiOperation
(
"查找所有引用"
)
@ApiOperation
(
"查找所有引用"
)
...
@@ -44,10 +52,11 @@ public class QuoteController {
...
@@ -44,10 +52,11 @@ public class QuoteController {
public
ResponseEntity
getAllQuote
(
@RequestBody
SearchQuoteVO
searchQuoteVO
)
{
public
ResponseEntity
getAllQuote
(
@RequestBody
SearchQuoteVO
searchQuoteVO
)
{
return
ResultUtil
.
success
(
quoteService
.
getAllQuote
(
searchQuoteVO
),
"查询成功!"
);
return
ResultUtil
.
success
(
quoteService
.
getAllQuote
(
searchQuoteVO
),
"查询成功!"
);
}
}
@ApiOperation
(
"保存引用"
)
@ApiOperation
(
"保存引用"
)
@PostMapping
(
"/saveQuote"
)
@PostMapping
(
"/saveQuote"
)
public
ResponseEntity
saveQuote
(
@RequestBody
Quote
quote
)
{
public
ResponseEntity
saveQuote
(
@RequestBody
Quote
quote
)
{
return
ResultUtil
.
success
(
quoteService
.
saveQuote
(
quote
)
,
"保存成功!"
);
return
ResultUtil
.
success
(
quoteService
.
saveQuote
(
quote
)
,
"保存成功!"
);
}
}
}
}
src/main/java/com/tykj/datawarehouse/model/service/ModelService.java
浏览文件 @
c7b4b059
package
com
.
tykj
.
datawarehouse
.
model
.
service
;
package
com
.
tykj
.
datawarehouse
.
model
.
service
;
import
com.tykj.datawarehouse.base.consumer.FourComsumer
;
import
com.tykj.datawarehouse.model.entity.ColumnInfo
;
import
com.tykj.datawarehouse.model.entity.ColumnInfo
;
import
com.tykj.datawarehouse.model.entity.TableInfo
;
import
com.tykj.datawarehouse.model.entity.TableInfo
;
import
com.tykj.datawarehouse.model.entity.vo.*
;
import
com.tykj.datawarehouse.model.entity.vo.*
;
import
org.hibernate.internal.SessionImpl
;
import
org.hibernate.type.Type
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Page
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
...
@@ -11,6 +14,7 @@ import org.springframework.transaction.annotation.Transactional;
...
@@ -11,6 +14,7 @@ import org.springframework.transaction.annotation.Transactional;
import
java.sql.SQLException
;
import
java.sql.SQLException
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.function.BiConsumer
;
/**
/**
* @ClassName ModelService
* @ClassName ModelService
...
@@ -62,15 +66,15 @@ public interface ModelService {
...
@@ -62,15 +66,15 @@ public interface ModelService {
* @param map
* @param map
* @return
* @return
*/
*/
int
putValueByEntityName
(
Map
<
String
,
Object
>
map
,
Boolean
isDelete
);
int
operationValueByEntityName
(
Map
<
String
,
Object
>
map
,
SessionImpl
session
,
/**
BiConsumer
<
String
,
Object
>
biConsumer
,
* 插入一组数据
FourComsumer
<
TableInfo
,
Object
,
Type
,
String
>
valitor
);
* @param mapList
* @return
int
operationValueByEntityNameList
(
List
<
Map
<
String
,
Object
>>
mapList
,
*/
SessionImpl
session
,
int
putValueByEntityNameList
(
List
<
Map
<
String
,
Object
>>
mapList
,
Boolean
isDelete
);
BiConsumer
<
String
,
Object
>
biConsumer
,
FourComsumer
<
TableInfo
,
Object
,
Type
,
String
>
valitor
);
/**
/**
* 根据表名查询所有
* 根据表名查询所有
*
*
...
@@ -88,7 +92,10 @@ public interface ModelService {
...
@@ -88,7 +92,10 @@ public interface ModelService {
* @param queryConditions
* @param queryConditions
* @return
* @return
*/
*/
List
<
Map
<
String
,
Object
>>
complexQuery
(
String
tableName
,
List
<
String
>
columnNames
,
List
<
QueryCondition
>
queryConditions
,
String
groupName
);
List
<
Map
<
String
,
Object
>>
complexQuery
(
String
tableName
,
List
<
String
>
columnNames
,
List
<
QueryCondition
>
queryConditions
,
String
groupName
);
/**
/**
* 复杂查询(带分类)
* 复杂查询(带分类)
...
@@ -97,7 +104,13 @@ public interface ModelService {
...
@@ -97,7 +104,13 @@ public interface ModelService {
* @param queryConditions
* @param queryConditions
* @return
* @return
*/
*/
CustomPage
complexQueryWithGroup
(
String
tableName
,
GroupCondition
groupCondition
,
List
<
String
>
columnNames
,
List
<
QueryCondition
>
queryConditions
,
String
groupByColumn
,
Integer
page
,
Integer
size
);
CustomPage
complexQueryWithGroup
(
String
tableName
,
GroupCondition
groupCondition
,
List
<
String
>
columnNames
,
List
<
QueryCondition
>
queryConditions
,
String
groupByColumn
,
Integer
page
,
Integer
size
);
/**
/**
...
@@ -135,4 +148,8 @@ public interface ModelService {
...
@@ -135,4 +148,8 @@ public interface ModelService {
*/
*/
List
<
Map
<
String
,
Object
>>
executeQuery
(
String
sql
)
throws
SQLException
;
List
<
Map
<
String
,
Object
>>
executeQuery
(
String
sql
)
throws
SQLException
;
void
validationAllRuleAndQuote
(
TableInfo
tableInfo
,
Object
value
,
Type
propertyType
,
String
propertyNames
);
}
}
src/main/java/com/tykj/datawarehouse/model/service/QuoteService.java
浏览文件 @
c7b4b059
...
@@ -19,7 +19,7 @@ public interface QuoteService {
...
@@ -19,7 +19,7 @@ public interface QuoteService {
* 更新quote
* 更新quote
* @param updateQuoteVO
* @param updateQuoteVO
*/
*/
List
<
Quote
>
updateQuote
(
UpdateQuoteVO
updateQuoteVO
);
int
updateQuote
(
UpdateQuoteVO
updateQuoteVO
);
/**
/**
* 条件查询引用
* 条件查询引用
...
...
src/main/java/com/tykj/datawarehouse/model/service/impl/ModelImpl.java
浏览文件 @
c7b4b059
...
@@ -2,7 +2,7 @@ package com.tykj.datawarehouse.model.service.impl;
...
@@ -2,7 +2,7 @@ package com.tykj.datawarehouse.model.service.impl;
import
com.github.wenhao.jpa.PredicateBuilder
;
import
com.github.wenhao.jpa.PredicateBuilder
;
import
com.github.wenhao.jpa.Specifications
;
import
com.github.wenhao.jpa.Specifications
;
import
com.
oscar.util.OSQLException
;
import
com.
tykj.datawarehouse.base.consumer.FourComsumer
;
import
com.tykj.datawarehouse.base.result.ApiException
;
import
com.tykj.datawarehouse.base.result.ApiException
;
import
com.tykj.datawarehouse.base.result.ResultUtil
;
import
com.tykj.datawarehouse.base.result.ResultUtil
;
import
com.tykj.datawarehouse.model.dao.ColumnInfoDao
;
import
com.tykj.datawarehouse.model.dao.ColumnInfoDao
;
...
@@ -35,13 +35,11 @@ import org.springframework.jdbc.core.JdbcTemplate;
...
@@ -35,13 +35,11 @@ import org.springframework.jdbc.core.JdbcTemplate;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.sql.SQLException
;
import
java.sql.SQLNonTransientException
;
import
java.sql.SQLSyntaxErrorException
;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
import
java.time.ZoneId
;
import
java.time.ZoneId
;
import
java.util.*
;
import
java.util.*
;
import
java.util.function.BiConsumer
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
import
static
com
.
tykj
.
datawarehouse
.
model
.
utils
.
CheckUtils
.
validationQuote
;
import
static
com
.
tykj
.
datawarehouse
.
model
.
utils
.
CheckUtils
.
validationQuote
;
...
@@ -107,7 +105,7 @@ public class ModelImpl implements ModelService {
...
@@ -107,7 +105,7 @@ public class ModelImpl implements ModelService {
private
PredicateBuilder
<
TableInfo
>
createPredicateBySearchTableInfoVo
(
SearchTableInfoVo
stv
)
{
private
PredicateBuilder
<
TableInfo
>
createPredicateBySearchTableInfoVo
(
SearchTableInfoVo
stv
)
{
PredicateBuilder
<
TableInfo
>
and
=
Specifications
.
and
();
PredicateBuilder
<
TableInfo
>
and
=
Specifications
.
and
();
if
(
!
isNull
(
stv
))
{
if
(!
isNull
(
stv
))
{
and
.
like
(!
isNull
(
stv
.
getModelName
())
&&
isNotEmpty
(
stv
.
getModelName
()),
"modelName"
,
"%"
+
stv
.
getModelName
()
+
"%"
);
and
.
like
(!
isNull
(
stv
.
getModelName
())
&&
isNotEmpty
(
stv
.
getModelName
()),
"modelName"
,
"%"
+
stv
.
getModelName
()
+
"%"
);
and
.
like
(!
isNull
(
stv
.
getModelTitle
())
&&
isNotEmpty
(
stv
.
getModelTitle
()),
"modelTitle"
,
"%"
+
stv
.
getModelTitle
()
+
"%"
);
and
.
like
(!
isNull
(
stv
.
getModelTitle
())
&&
isNotEmpty
(
stv
.
getModelTitle
()),
"modelTitle"
,
"%"
+
stv
.
getModelTitle
()
+
"%"
);
and
.
in
(!
isNull
(
stv
.
getModelType
())
&&
stv
.
getModelType
().
length
>
0
,
"modelType"
,
stv
.
getModelType
());
and
.
in
(!
isNull
(
stv
.
getModelType
())
&&
stv
.
getModelType
().
length
>
0
,
"modelType"
,
stv
.
getModelType
());
...
@@ -195,40 +193,31 @@ public class ModelImpl implements ModelService {
...
@@ -195,40 +193,31 @@ public class ModelImpl implements ModelService {
* @Date 16:17 2021/3/5
* @Date 16:17 2021/3/5
**/
**/
@Override
@Override
public
int
putValueByEntityName
(
Map
<
String
,
Object
>
map
,
Boolean
isDelete
)
{
public
int
operationValueByEntityName
(
Map
<
String
,
Object
>
map
,
SessionImpl
session
,
BiConsumer
<
String
,
Object
>
saveOrDelete
,
FourComsumer
<
TableInfo
,
Object
,
Type
,
String
>
valitor
)
{
session
.
getTransaction
().
begin
();
for
(
String
tableName
:
for
(
String
tableName
:
map
.
keySet
())
{
map
.
keySet
())
{
SessionImpl
session
=
(
SessionImpl
)
sessionUtil
.
getSession
();
session
.
getTransaction
().
begin
();
Object
values
=
map
.
get
(
tableName
);
Object
values
=
map
.
get
(
tableName
);
if
(
values
instanceof
Map
)
{
if
(
values
instanceof
Map
)
{
//插入数据
//插入数据
insertValue
(
tableName
,
(
Map
)
values
,
session
);
operationValue
(
tableName
,
(
Map
)
values
,
session
,
saveOrDelete
,
valitor
);
}
}
try
{
}
session
.
getTransaction
().
commit
();
try
{
}
catch
(
Exception
e
)
{
session
.
getTransaction
().
commit
();
//todo 等会捕捉一下
}
catch
(
Exception
e
)
{
if
(
e
.
getMessage
().
contains
(
"Batch update returned unexpected row count from"
))
{
//todo 等会捕捉一下
throw
new
ApiException
(
"要操作对象的主键不存在"
);
if
(
e
.
getMessage
().
contains
(
"Batch update returned unexpected row count from"
))
{
}
throw
new
ApiException
(
"要操作对象的主键不存在"
);
}
finally
{
session
.
close
();
}
}
}
finally
{
session
.
close
();
}
}
return
0
;
return
0
;
}
}
/**
* @param mapList 数据集合[{"tableName":{"ID":1}},{"tableName":{"ID":2}}]
* @return int
* @Author WWW
* @Description 根据表名新增数据
* @Date 16:17 2021/3/5
**/
@Override
@Override
public
int
putValueByEntityNameList
(
List
<
Map
<
String
,
Object
>>
mapList
,
Boolean
isDelete
)
{
public
int
operationValueByEntityNameList
(
List
<
Map
<
String
,
Object
>>
mapList
,
SessionImpl
session
,
BiConsumer
<
String
,
Object
>
biConsumer
,
FourComsumer
<
TableInfo
,
Object
,
Type
,
String
>
valitor
)
{
SessionImpl
session
=
(
SessionImpl
)
sessionUtil
.
getSession
();
session
.
getTransaction
().
begin
();
session
.
getTransaction
().
begin
();
for
(
Map
<
String
,
Object
>
map
:
mapList
)
{
for
(
Map
<
String
,
Object
>
map
:
mapList
)
{
for
(
String
tableName
:
for
(
String
tableName
:
...
@@ -236,7 +225,7 @@ public class ModelImpl implements ModelService {
...
@@ -236,7 +225,7 @@ public class ModelImpl implements ModelService {
Object
values
=
map
.
get
(
tableName
);
Object
values
=
map
.
get
(
tableName
);
if
(
values
instanceof
Map
)
{
if
(
values
instanceof
Map
)
{
//插入数据
//插入数据
insertValue
(
tableName
,
(
Map
)
values
,
session
);
operationValue
(
tableName
,
(
Map
)
values
,
session
,
biConsumer
,
valitor
);
}
}
}
}
}
}
...
@@ -261,9 +250,8 @@ public class ModelImpl implements ModelService {
...
@@ -261,9 +250,8 @@ public class ModelImpl implements ModelService {
* @Description 新增参数的方法
* @Description 新增参数的方法
* @Date 16:17 2021/3/5
* @Date 16:17 2021/3/5
**/
**/
public
void
insertValue
(
String
tableName
,
Map
map
,
SessionImpl
session
)
{
public
void
operationValue
(
String
tableName
,
Map
map
,
SessionImpl
session
,
BiConsumer
<
String
,
Object
>
saveOrDelete
,
FourComsumer
<
TableInfo
,
Object
,
Type
,
String
>
valitor
)
{
TableInfo
tableInfo
=
tableInfoDao
.
findByModelName
(
tableName
);
TableInfo
tableInfo
=
tableInfoDao
.
findByModelName
(
tableName
);
EntityPersister
entityPersister
=
session
.
getEntityPersister
(
tableName
,
map
);
EntityPersister
entityPersister
=
session
.
getEntityPersister
(
tableName
,
map
);
//主键类型推断
//主键类型推断
String
identifierPropertyName
=
entityPersister
.
getIdentifierPropertyName
();
String
identifierPropertyName
=
entityPersister
.
getIdentifierPropertyName
();
...
@@ -282,10 +270,11 @@ public class ModelImpl implements ModelService {
...
@@ -282,10 +270,11 @@ public class ModelImpl implements ModelService {
//根据目标Type转换
//根据目标Type转换
changeValueToTargetType
(
map
,
value
,
propertyType
,
propertyNames
[
i
]);
changeValueToTargetType
(
map
,
value
,
propertyType
,
propertyNames
[
i
]);
//验证
//验证
validationAllRuleAndQuote
(
tableInfo
,
value
,
propertyType
,
propertyNames
[
i
]);
if
(
valitor
!=
null
){
valitor
.
accept
(
tableInfo
,
value
,
propertyType
,
propertyNames
[
i
]);
}
}
}
saveOrDelete
.
accept
(
tableName
,
map
);
session
.
saveOrUpdate
(
tableName
,
map
);
}
}
...
@@ -321,6 +310,7 @@ public class ModelImpl implements ModelService {
...
@@ -321,6 +310,7 @@ public class ModelImpl implements ModelService {
}
}
return
new
ArrayList
<>();
return
new
ArrayList
<>();
}
}
@Override
@Override
public
List
<
Map
<
String
,
Object
>>
findAllByName
(
String
name
,
List
<
OrderCondition
>
orderConditions
)
{
public
List
<
Map
<
String
,
Object
>>
findAllByName
(
String
name
,
List
<
OrderCondition
>
orderConditions
)
{
StringBuilder
sb
=
new
StringBuilder
();
StringBuilder
sb
=
new
StringBuilder
();
...
@@ -333,7 +323,7 @@ public class ModelImpl implements ModelService {
...
@@ -333,7 +323,7 @@ public class ModelImpl implements ModelService {
String
sql
=
sb
.
substring
(
0
,
sb
.
toString
().
lastIndexOf
(
","
));
String
sql
=
sb
.
substring
(
0
,
sb
.
toString
().
lastIndexOf
(
","
));
try
{
try
{
return
jdbcTemplate
.
queryForList
(
"select * from "
+
name
+
" order by "
+
sql
);
return
jdbcTemplate
.
queryForList
(
"select * from "
+
name
+
" order by "
+
sql
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
new
ApiException
(
"操作数据库失败,请联系管理员"
);
throw
new
ApiException
(
"操作数据库失败,请联系管理员"
);
}
}
}
}
...
@@ -410,8 +400,7 @@ public class ModelImpl implements ModelService {
...
@@ -410,8 +400,7 @@ public class ModelImpl implements ModelService {
for
(
String
sql
:
sqls
)
{
for
(
String
sql
:
sqls
)
{
try
{
try
{
jdbcTemplate
.
execute
(
sql
);
jdbcTemplate
.
execute
(
sql
);
}
}
catch
(
Exception
exception
)
{
catch
(
Exception
exception
)
{
//todo
//todo
throw
new
ApiException
(
"出错"
);
throw
new
ApiException
(
"出错"
);
...
@@ -590,6 +579,7 @@ public class ModelImpl implements ModelService {
...
@@ -590,6 +579,7 @@ public class ModelImpl implements ModelService {
}
}
@Override
@Override
public
TableAndColumnInfoVO
getTableInfoAndColumnInfoByBatch
(
Integer
[]
ids
)
{
public
TableAndColumnInfoVO
getTableInfoAndColumnInfoByBatch
(
Integer
[]
ids
)
{
TableAndColumnInfoVO
tableAndColumnInfoVO
=
new
TableAndColumnInfoVO
();
TableAndColumnInfoVO
tableAndColumnInfoVO
=
new
TableAndColumnInfoVO
();
...
@@ -617,6 +607,7 @@ public class ModelImpl implements ModelService {
...
@@ -617,6 +607,7 @@ public class ModelImpl implements ModelService {
}
}
void
changeValueToTargetType
(
Map
map
,
Object
value
,
Type
propertyType
,
String
propertyName
)
{
void
changeValueToTargetType
(
Map
map
,
Object
value
,
Type
propertyType
,
String
propertyName
)
{
// TimestampType
// TimestampType
if
(
"UPDATE_TIME"
.
equals
(
propertyName
))
{
if
(
"UPDATE_TIME"
.
equals
(
propertyName
))
{
...
@@ -670,7 +661,8 @@ public class ModelImpl implements ModelService {
...
@@ -670,7 +661,8 @@ public class ModelImpl implements ModelService {
}
}
}
}
void
validationAllRuleAndQuote
(
TableInfo
tableInfo
,
Object
value
,
Type
propertyType
,
String
propertyNames
)
{
@Override
public
void
validationAllRuleAndQuote
(
TableInfo
tableInfo
,
Object
value
,
Type
propertyType
,
String
propertyNames
)
{
if
(
propertyType
instanceof
StringType
)
{
if
(
propertyType
instanceof
StringType
)
{
// 通过 tableInfo 的 Id + columnName 为查询条件 查出 columnInfo
// 通过 tableInfo 的 Id + columnName 为查询条件 查出 columnInfo
ColumnInfo
columnInfo
=
columnInfoDao
.
findByDbIdAndFieldName
(
tableInfo
.
getId
(),
propertyNames
);
ColumnInfo
columnInfo
=
columnInfoDao
.
findByDbIdAndFieldName
(
tableInfo
.
getId
(),
propertyNames
);
...
...
src/main/java/com/tykj/datawarehouse/model/service/impl/QuoteServiceImpl.java
浏览文件 @
c7b4b059
...
@@ -32,13 +32,21 @@ public class QuoteServiceImpl implements QuoteService {
...
@@ -32,13 +32,21 @@ public class QuoteServiceImpl implements QuoteService {
@Override
@Override
public
List
<
Quote
>
updateQuote
(
UpdateQuoteVO
updateQuoteVO
)
{
public
int
updateQuote
(
UpdateQuoteVO
updateQuoteVO
)
{
List
<
Quote
>
quoteList
=
updateQuoteVO
.
getQuoteList
();
List
<
Quote
>
quoteList
=
updateQuoteVO
.
getQuoteList
();
for
(
Quote
quote
:
quoteList
)
{
quote
.
setColumnId
(
updateQuoteVO
.
getId
());
try
{
quoteDao
.
save
(
quote
);
for
(
Quote
quote
:
quoteList
)
{
quote
.
setColumnId
(
updateQuoteVO
.
getId
());
if
(
existValue
(
quote
.
getColumnId
(),
quote
.
getValue
()))
{
quoteDao
.
save
(
quote
);
}
}
return
0
;
}
catch
(
Exception
e
){
return
1
;
}
}
return
new
ArrayList
<>();
}
}
@Override
@Override
...
...
src/main/java/com/tykj/datawarehouse/model/utils/CreateTableUtil.java
浏览文件 @
c7b4b059
...
@@ -57,7 +57,7 @@ public class CreateTableUtil {
...
@@ -57,7 +57,7 @@ public class CreateTableUtil {
"<hibernate-mapping>\n"
+
"<hibernate-mapping>\n"
+
" <class entity-name=\""
+
tableVO
.
getModelName
().
toLowerCase
().
toUpperCase
()
+
"\" table=\""
+
tableVO
.
getModelName
().
toLowerCase
().
toUpperCase
()
+
"\">\n"
;
" <class entity-name=\""
+
tableVO
.
getModelName
().
toLowerCase
().
toUpperCase
()
+
"\" table=\""
+
tableVO
.
getModelName
().
toLowerCase
().
toUpperCase
()
+
"\">\n"
;
xmlMapping
+=
" <id name=\"
id
\" type=\"java.lang.Integer\" length=\"11\" unsaved-value=\"null\" >\n"
+
xmlMapping
+=
" <id name=\"
ID
\" type=\"java.lang.Integer\" length=\"11\" unsaved-value=\"null\" >\n"
+
" <generator class=\"com.tykj.datawarehouse.base.entity.XMQGenerator\" >\n"
+
" <generator class=\"com.tykj.datawarehouse.base.entity.XMQGenerator\" >\n"
+
"<param name=\"sequence\">SEQUENCE_"
+
tableVO
.
getModelName
().
toLowerCase
().
toUpperCase
()
+
"</param>"
+
"<param name=\"sequence\">SEQUENCE_"
+
tableVO
.
getModelName
().
toLowerCase
().
toUpperCase
()
+
"</param>"
+
"</generator>"
+
"</generator>"
+
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论