Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
D
dataWareHose
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
黄夏豪
dataWareHose
Commits
bb0382c1
提交
bb0382c1
authored
6月 30, 2021
作者:
ww1xhqc
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[数据模型] 修改校验bug
上级
3d71175a
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
42 行增加
和
49 行删除
+42
-49
QuoteController.java
.../tykj/datawarehouse/model/controller/QuoteController.java
+0
-18
QuoteDao.java
src/main/java/com/tykj/datawarehouse/model/dao/QuoteDao.java
+0
-1
RuleDao.java
src/main/java/com/tykj/datawarehouse/model/dao/RuleDao.java
+6
-3
ModelImpl.java
.../com/tykj/datawarehouse/model/service/impl/ModelImpl.java
+9
-13
QuoteServiceImpl.java
...kj/datawarehouse/model/service/impl/QuoteServiceImpl.java
+2
-2
CheckUtils.java
...n/java/com/tykj/datawarehouse/model/utils/CheckUtils.java
+2
-5
CreateTableUtil.java
...a/com/tykj/datawarehouse/model/utils/CreateTableUtil.java
+18
-6
DataTestApplicationTests.java
...java/com/tykj/datawarehouse/DataTestApplicationTests.java
+5
-1
没有找到文件。
src/main/java/com/tykj/datawarehouse/model/controller/QuoteController.java
浏览文件 @
bb0382c1
...
@@ -60,23 +60,5 @@ public class QuoteController {
...
@@ -60,23 +60,5 @@ public class QuoteController {
public
ResponseEntity
saveQuote
(
@RequestBody
Quote
quote
)
{
public
ResponseEntity
saveQuote
(
@RequestBody
Quote
quote
)
{
return
ResultUtil
.
success
(
quoteService
.
saveQuote
(
quote
)
,
"保存成功!"
);
return
ResultUtil
.
success
(
quoteService
.
saveQuote
(
quote
)
,
"保存成功!"
);
}
}
// @ApiModelProperty("查找所有引用如果没有引用的话就全部的值")
// @PostMapping("/getAllQuoteIf")
// public ResponseEntity getAllQuoteOr(@RequestBody SearchQuoteVO searchQuoteVO) {
// List<Quote> allQuote = quoteService.getAllQuote(searchQuoteVO);
// if (searchQuoteVO.getColumnIds().length!=1){
// throw new ApiException("查询字段补正确");
// }
// if (allQuote.size()<=0){
// Optional<ColumnInfo> byId = columnInfoDao.findById(searchQuoteVO.getColumnIds()[0]);
// ColumnInfo columnInfo = byId.get();
// List diaoyan = model.complexQuery("diaoyan", Arrays.asList(columnInfo.getFieldName()), Arrays.asList(new QueryCondition(columnInfo.getFieldName(),"!=","null", ConnectionType.AND)), columnInfo.getFieldName());
// for (Object str : diaoyan) {
// allQuote.add(new Quote(searchQuoteVO.getColumnIds()[0],str+""));
// }
// }
// return ResultUtil.success(allQuote, "查询成功!");
// }
}
}
src/main/java/com/tykj/datawarehouse/model/dao/QuoteDao.java
浏览文件 @
bb0382c1
...
@@ -21,5 +21,4 @@ public interface QuoteDao extends JpaRepository<Quote, Integer>, JpaSpecificatio
...
@@ -21,5 +21,4 @@ public interface QuoteDao extends JpaRepository<Quote, Integer>, JpaSpecificatio
*/
*/
List
<
Quote
>
findAllByColumnId
(
Integer
id
);
List
<
Quote
>
findAllByColumnId
(
Integer
id
);
List
<
Quote
>
findByColumnIdIn
(
List
<
Integer
>
ids
);
}
}
src/main/java/com/tykj/datawarehouse/model/dao/RuleDao.java
浏览文件 @
bb0382c1
...
@@ -11,9 +11,12 @@ import java.util.List;
...
@@ -11,9 +11,12 @@ import java.util.List;
* @Author WWW
* @Author WWW
* @Date 2021/6/29 11:01
* @Date 2021/6/29 11:01
*/
*/
public
interface
RuleDao
extends
JpaRepository
<
Rule
,
Integer
>,
JpaSpecificationExecutor
<
Rule
>
{
public
interface
RuleDao
extends
JpaRepository
<
Rule
,
Integer
>,
JpaSpecificationExecutor
<
Rule
>
{
/**
* 根据columnId查询
* @param id
* @return
*/
Rule
findByColumnId
(
Integer
id
);
Rule
findByColumnId
(
Integer
id
);
}
}
src/main/java/com/tykj/datawarehouse/model/service/impl/ModelImpl.java
浏览文件 @
bb0382c1
...
@@ -257,14 +257,6 @@ public class ModelImpl implements ModelService {
...
@@ -257,14 +257,6 @@ public class ModelImpl implements ModelService {
**/
**/
public
void
insertValue
(
String
tableName
,
Map
map
,
SessionImpl
session
)
{
public
void
insertValue
(
String
tableName
,
Map
map
,
SessionImpl
session
)
{
TableInfo
tableInfo
=
tableInfoDao
.
findByModelName
(
tableName
);
TableInfo
tableInfo
=
tableInfoDao
.
findByModelName
(
tableName
);
// List<ColumnInfo> columnInfos = columnInfoDao.findAllByDbId(tableInfo.getId());
// //所有columnID
// List<Integer> columnIds = columnInfos.stream().map(ColumnInfo::getId).collect(Collectors.toList());
// //所有引用值
// List<String> quoteValues = quoteDao.findByColumnIdIn(columnIds).stream().map(Quote::getValue).collect(Collectors.toList());
//
// validationQuote(quoteValues,"");
EntityPersister
entityPersister
=
session
.
getEntityPersister
(
tableName
,
map
);
EntityPersister
entityPersister
=
session
.
getEntityPersister
(
tableName
,
map
);
//主键类型推断
//主键类型推断
...
@@ -648,13 +640,17 @@ public class ModelImpl implements ModelService {
...
@@ -648,13 +640,17 @@ public class ModelImpl implements ModelService {
//引用校验
//引用校验
if
(!
isNull
(
quoteDao
.
findAllByColumnId
(
columnInfo
.
getId
()))){
if
(!
isNull
(
quoteDao
.
findAllByColumnId
(
columnInfo
.
getId
()))){
List
<
String
>
quotes
=
quoteDao
.
findAllByColumnId
(
columnInfo
.
getId
()).
stream
().
map
(
Quote:
:
getValue
).
collect
(
Collectors
.
toList
());
List
<
String
>
quotes
=
quoteDao
.
findAllByColumnId
(
columnInfo
.
getId
()).
stream
().
map
(
Quote:
:
getValue
).
collect
(
Collectors
.
toList
());
validationQuote
(
quotes
,
(
String
)
value
);
if
(!
validationQuote
(
quotes
,
(
String
)
value
)){
throw
new
ApiException
(
"引用校验不通过!"
);
}
}
}
//规则校验
//规则校验
if
(!
isNull
(
ruleDao
.
findByColumnId
(
columnInfo
.
getId
()))){
// if (!isNull( ruleDao.findByColumnId(columnInfo.getId()))){
String
regular
=
ruleDao
.
findByColumnId
(
columnInfo
.
getId
()).
getRegular
();
// String regular = ruleDao.findByColumnId(columnInfo.getId()).getRegular();
validationRule
(
regular
,
(
String
)
value
);
// if (!validationRule(regular, (String) value)){
}
// throw new ApiException("正则校验不通过!");
// }
// }
}
}
}
}
...
...
src/main/java/com/tykj/datawarehouse/model/service/impl/QuoteServiceImpl.java
浏览文件 @
bb0382c1
...
@@ -76,9 +76,9 @@ public class QuoteServiceImpl implements QuoteService {
...
@@ -76,9 +76,9 @@ public class QuoteServiceImpl implements QuoteService {
.
map
(
Quote:
:
getValue
)
.
map
(
Quote:
:
getValue
)
.
collect
(
Collectors
.
toList
());
.
collect
(
Collectors
.
toList
());
if
(
collect
.
contains
(
value
))
{
if
(
collect
.
contains
(
value
))
{
return
tru
e
;
return
fals
e
;
}
}
return
fals
e
;
return
tru
e
;
}
}
...
...
src/main/java/com/tykj/datawarehouse/model/utils/CheckUtils.java
浏览文件 @
bb0382c1
...
@@ -23,13 +23,10 @@ public class CheckUtils {
...
@@ -23,13 +23,10 @@ public class CheckUtils {
* @return
* @return
*/
*/
public
static
Boolean
validationRule
(
String
regx
,
String
val
)
{
public
static
Boolean
validationRule
(
String
regx
,
String
val
)
{
//加入没有规则就默认不需要校验
if
(
StringUtils
.
isNotEmpty
(
regx
)
||
isNull
(
regx
))
{
return
true
;
}
//假如规则不为空,值为空默认通过校验
//假如规则不为空,值为空默认通过校验
if
(!
StringUtils
.
isEmpty
(
regx
))
{
if
(!
StringUtils
.
isEmpty
(
regx
))
{
if
(
StringUtils
.
is
Not
Empty
(
val
)
||
isNull
(
val
))
{
if
(
StringUtils
.
isEmpty
(
val
)
||
isNull
(
val
))
{
return
true
;
return
true
;
}
else
{
}
else
{
Pattern
pattern
=
Pattern
.
compile
(
regx
);
Pattern
pattern
=
Pattern
.
compile
(
regx
);
...
...
src/main/java/com/tykj/datawarehouse/model/utils/CreateTableUtil.java
浏览文件 @
bb0382c1
...
@@ -55,13 +55,13 @@ public class CreateTableUtil {
...
@@ -55,13 +55,13 @@ public class CreateTableUtil {
" \"-//Hibernate/Hibernate Mapping DTD 3.0//EN\"\n"
+
" \"-//Hibernate/Hibernate Mapping DTD 3.0//EN\"\n"
+
" \"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd\">\n"
+
" \"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd\">\n"
+
"<hibernate-mapping>\n"
+
"<hibernate-mapping>\n"
+
" <class entity-name=\""
+
tableVO
.
getModelName
().
to
UpperCase
()
+
"\" table=\""
+
tableVO
.
getModelNam
e
().
toUpperCase
()
+
"\">\n"
;
" <class entity-name=\""
+
tableVO
.
getModelName
().
to
LowerCase
().
toUpperCase
()
+
"\" table=\""
+
tableVO
.
getModelName
().
toLowerCas
e
().
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\" >"
+
" <generator class=\"com.tykj.datawarehouse.base.entity.XMQGenerator\" >
\n
"
+
"<param name=\"sequence\">SEQUENCE_"
+
tableVO
.
getModelName
().
toUpperCase
()+
"</param>"
+
"<param name=\"sequence\">SEQUENCE_"
+
tableVO
.
getModelName
().
toLowerCase
().
toUpperCase
()
+
"</param>"
+
"</generator>"
+
"</generator>"
+
" </id>"
;
" </id>
\n
"
;
for
(
ColumnVO
columnVO
:
dataList
)
{
for
(
ColumnVO
columnVO
:
dataList
)
{
...
@@ -70,8 +70,8 @@ public class CreateTableUtil {
...
@@ -70,8 +70,8 @@ public class CreateTableUtil {
"\n <property type=\""
+
columnVO
.
getFieldType
()
+
"\" name=\""
+
columnVO
.
getFieldName
().
toUpperCase
()
+
"\" length=\""
+
columnVO
.
getFieldLength
()
+
"\n <property type=\""
+
columnVO
.
getFieldType
()
+
"\" name=\""
+
columnVO
.
getFieldName
().
toUpperCase
()
+
"\" length=\""
+
columnVO
.
getFieldLength
()
+
"\" column=\""
+
columnVO
.
getFieldName
().
toUpperCase
()
+
"\"/>\n"
;
"\" column=\""
+
columnVO
.
getFieldName
().
toUpperCase
()
+
"\"/>\n"
;
}
catch
(
Exception
e
){
}
catch
(
Exception
e
)
{
throw
new
ApiException
(
"
列名转为大写错误
"
);
throw
new
ApiException
(
"
名称不合法!
"
);
}
}
}
}
...
@@ -140,4 +140,16 @@ public class CreateTableUtil {
...
@@ -140,4 +140,16 @@ public class CreateTableUtil {
String
class_
=
aClass
.
replace
(
"class "
,
""
);
String
class_
=
aClass
.
replace
(
"class "
,
""
);
return
TYPE_MAP
.
get
(
class_
);
return
TYPE_MAP
.
get
(
class_
);
}
}
/**
*小写
*/
String
lowerCaseReg
=
"^[a-z]+$"
;
/**
*大写
*/
String
upperCaseReg
=
"^[A-Z]+$"
;
}
}
src/test/java/com/tykj/datawarehouse/DataTestApplicationTests.java
浏览文件 @
bb0382c1
package
com
.
tykj
.
datawarehouse
;
package
com
.
tykj
.
datawarehouse
;
import
com.tykj.datawarehouse.model.dao.RuleDao
;
import
org.junit.jupiter.api.Test
;
import
org.junit.jupiter.api.Test
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
javax.xml.soap.SAAJResult
;
import
javax.xml.soap.SAAJResult
;
...
@@ -11,6 +13,8 @@ import java.util.regex.Pattern;
...
@@ -11,6 +13,8 @@ import java.util.regex.Pattern;
@SpringBootTest
@SpringBootTest
class
DataTestApplicationTests
{
class
DataTestApplicationTests
{
@Autowired
RuleDao
ruleDao
;
@Test
@Test
void
contextLoads
()
{
void
contextLoads
()
{
...
@@ -23,7 +27,7 @@ class DataTestApplicationTests {
...
@@ -23,7 +27,7 @@ class DataTestApplicationTests {
// boolean matches = pattern.matcher(str).matches();
// boolean matches = pattern.matcher(str).matches();
//
//
// System.out.println(matches);
// System.out.println(matches);
System
.
out
.
println
(
ruleDao
.
findByColumnId
(
2
));
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论