Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
D
dataWareHose
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
黄夏豪
dataWareHose
Commits
034da93b
提交
034da93b
authored
7月 06, 2021
作者:
ww1xhqc
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[数据模型] 稳定版修改integer和double的错误
上级
c7b4b059
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
35 行增加
和
15 行删除
+35
-15
FourComsumer.java
...va/com/tykj/datawarehouse/base/consumer/FourComsumer.java
+6
-0
ModelImpl.java
.../com/tykj/datawarehouse/model/service/impl/ModelImpl.java
+1
-1
CheckUtils.java
...n/java/com/tykj/datawarehouse/model/utils/CheckUtils.java
+17
-3
SqlUtil.java
...main/java/com/tykj/datawarehouse/model/utils/SqlUtil.java
+11
-11
没有找到文件。
src/main/java/com/tykj/datawarehouse/base/consumer/FourComsumer.java
浏览文件 @
034da93b
...
...
@@ -13,6 +13,7 @@ import java.util.Objects;
public
interface
FourComsumer
<
T
,
Y
,
U
,
I
>
{
/**
* accept
* @param t
* @param y
* @param u
...
...
@@ -20,6 +21,11 @@ public interface FourComsumer<T, Y, U, I> {
*/
void
accept
(
T
t
,
Y
y
,
U
u
,
I
i
);
/**
* andThen
* @param after
* @return
*/
default
FourComsumer
<
T
,
Y
,
U
,
I
>
andThen
(
FourComsumer
<?
super
T
,
?
super
Y
,
?
super
U
,
?
super
I
>
after
)
{
Objects
.
requireNonNull
(
after
);
...
...
src/main/java/com/tykj/datawarehouse/model/service/impl/ModelImpl.java
浏览文件 @
034da93b
...
...
@@ -669,7 +669,7 @@ public class ModelImpl implements ModelService {
//引用校验
if
(!
isNull
(
quoteDao
.
findAllByColumnId
(
columnInfo
.
getId
())))
{
List
<
String
>
quotes
=
quoteDao
.
findAllByColumnId
(
columnInfo
.
getId
()).
stream
().
map
(
Quote:
:
getValue
).
collect
(
Collectors
.
toList
());
if
(!
validationQuote
(
quotes
,
(
String
)
value
))
{
if
(!
validationQuote
(
quotes
,
value
))
{
throw
new
ApiException
(
"引用校验不通过!"
);
}
}
...
...
src/main/java/com/tykj/datawarehouse/model/utils/CheckUtils.java
浏览文件 @
034da93b
package
com
.
tykj
.
datawarehouse
.
model
.
utils
;
import
com.tykj.datawarehouse.base.result.ApiException
;
import
lombok.val
;
import
org.apache.commons.lang3.StringUtils
;
import
java.util.List
;
...
...
@@ -36,15 +37,28 @@ public class CheckUtils {
throw
new
ApiException
(
"校验不通过!"
);
}
public
static
Boolean
validationQuote
(
List
<
String
>
quotes
,
String
val
)
{
public
static
Boolean
validationQuote
(
List
<
String
>
quotes
,
Object
val
)
{
//如果没有引用就通过
if
(
quotes
.
size
()
==
0
)
{
return
true
;
}
//如果引用存在则通过
if
(
quotes
.
contains
(
val
))
{
return
true
;
if
(
val
instanceof
String
){
if
(
quotes
.
contains
(
val
))
{
return
true
;
}
}
if
(
val
instanceof
Integer
){
if
(
quotes
.
contains
(
val
))
{
return
true
;
}
}
if
(
val
instanceof
Double
){
if
(
quotes
.
contains
(
val
))
{
return
true
;
}
}
throw
new
ApiException
(
"引用不通过!"
);
}
...
...
src/main/java/com/tykj/datawarehouse/model/utils/SqlUtil.java
浏览文件 @
034da93b
...
...
@@ -50,7 +50,7 @@ public class SqlUtil {
//基本部分
result
.
append
(
String
.
format
(
"ALTER TABLE %s ADD COLUMN %s %s"
,
table
,
name
,
type
));
//字段长度
if
(
nonNull
(
length
))
{
if
(
nonNull
(
length
)
&&
type
.
equals
(
"java.lang.String"
)
)
{
result
.
append
(
String
.
format
(
"(%s)"
,
length
));
}
result
.
append
(
";"
);
...
...
@@ -77,12 +77,12 @@ public class SqlUtil {
&&
nonNull
(
newType
);
StringBuilder
result
=
new
StringBuilder
();
if
(
hasValue
)
{
if
(
needLengthColumn
(
newType
)){
result
.
append
(
String
.
format
(
"ALTER TABLE %s MODIFY %s %s (%s) ;"
,
table
,
name
,
newType
,
newLength
));
}
else
{
if
(
needLengthColumn
(
newType
))
{
result
.
append
(
String
.
format
(
"ALTER TABLE %s MODIFY %s %s (%s) ;"
,
table
,
name
,
newType
,
newLength
));
}
else
{
result
.
append
(
String
.
format
(
"ALTER TABLE %s MODIFY %s %s ;"
,
table
,
name
,
newType
));
}
if
(
isNull
(
newName
)){
if
(
isNull
(
newName
))
{
result
.
append
(
String
.
format
(
"ALTER TABLE %s RENAME COLUMN %s TO %s ;"
,
table
,
name
,
newName
));
}
}
else
{
...
...
@@ -94,16 +94,16 @@ public class SqlUtil {
/**
* 修改表的单个字段的SQL语句
*
* @param table
表名
* @param name
旧字段名
* @param newName
新字段名
* @param table 表名
* @param name 旧字段名
* @param newName 新字段名
* @return SQL语句
*/
public
static
String
updateColumnName
(
String
table
,
String
name
,
String
newName
)
{
boolean
hasValue
=
!
Strings
.
isNullOrEmpty
(
table
);
StringBuilder
result
=
new
StringBuilder
();
if
(
hasValue
)
{
if
(!
isNull
(
newName
)){
if
(!
isNull
(
newName
))
{
result
.
append
(
String
.
format
(
"ALTER TABLE %s RENAME COLUMN %s TO %s ;"
,
table
,
name
,
newName
));
}
}
else
{
...
...
@@ -123,8 +123,8 @@ public class SqlUtil {
return
String
.
format
(
"ALTER TABLE %s DROP %s;"
,
table
,
name
);
}
private
static
boolean
needLengthColumn
(
String
type
){
switch
(
type
){
private
static
boolean
needLengthColumn
(
String
type
)
{
switch
(
type
)
{
case
"varchar"
:
return
true
;
default
:
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论