Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
D
dataDeclaration
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
黄夏豪
dataDeclaration
Commits
1be24adf
提交
1be24adf
authored
5月 23, 2021
作者:
黄夏豪
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[数据模型] 改了一些bug
上级
9d9ac7aa
显示空白字符变更
内嵌
并排
正在显示
20 个修改的文件
包含
334 行增加
和
78 行删除
+334
-78
ModelController.java
...java/com/tykj/model_layer/controller/ModelController.java
+19
-8
QuoteController.java
...java/com/tykj/model_layer/controller/QuoteController.java
+33
-2
ExcelConfigDao.java
src/main/java/com/tykj/model_layer/dao/ExcelConfigDao.java
+2
-0
Quote.java
src/main/java/com/tykj/model_layer/entity/Quote.java
+2
-0
CustomPage.java
src/main/java/com/tykj/model_layer/entity/vo/CustomPage.java
+26
-0
complexQueryVo.java
...n/java/com/tykj/model_layer/entity/vo/complexQueryVo.java
+5
-1
ExcelData.java
src/main/java/com/tykj/model_layer/excel/ExcelData.java
+2
-2
ModelService.java
src/main/java/com/tykj/model_layer/service/ModelService.java
+11
-4
ModelImpl.java
...ain/java/com/tykj/model_layer/service/impl/ModelImpl.java
+115
-51
VersionServiceImpl.java
...com/tykj/model_layer/service/impl/VersionServiceImpl.java
+3
-2
ConditionSetting.java
src/main/java/com/tykj/setting/entity/ConditionSetting.java
+8
-4
ColumnInfoVo.java
src/main/java/com/tykj/setting/entity/vo/ColumnInfoVo.java
+23
-0
DisplaySettingVo.java
...ain/java/com/tykj/setting/entity/vo/DisplaySettingVo.java
+3
-0
GroupSettingVo.java
src/main/java/com/tykj/setting/entity/vo/GroupSettingVo.java
+4
-0
ScreenSettingVo.java
...main/java/com/tykj/setting/entity/vo/ScreenSettingVo.java
+2
-0
StatisticsParam.java
...main/java/com/tykj/setting/entity/vo/StatisticsParam.java
+1
-1
ConditionSettingRepository.java
...m/tykj/setting/repository/ConditionSettingRepository.java
+4
-0
DisplaySettingService.java
.../java/com/tykj/setting/service/DisplaySettingService.java
+16
-1
GroupSettingService.java
...in/java/com/tykj/setting/service/GroupSettingService.java
+32
-2
ScreenSettingService.java
...n/java/com/tykj/setting/service/ScreenSettingService.java
+23
-0
没有找到文件。
src/main/java/com/tykj/model_layer/controller/ModelController.java
浏览文件 @
1be24adf
...
@@ -13,6 +13,7 @@ import io.swagger.annotations.ApiOperation;
...
@@ -13,6 +13,7 @@ import io.swagger.annotations.ApiOperation;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
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.ResponseEntity
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
...
@@ -117,7 +118,7 @@ public class ModelController {
...
@@ -117,7 +118,7 @@ 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
);
int
i
=
modelService
.
putValueByEntityName
(
map
,
false
);
if
(
i
==
0
)
{
if
(
i
==
0
)
{
return
ResultUtil
.
success
(
""
,
"数据插入成功!"
);
return
ResultUtil
.
success
(
""
,
"数据插入成功!"
);
}
}
...
@@ -135,7 +136,7 @@ public class ModelController {
...
@@ -135,7 +136,7 @@ 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
);
int
i
=
modelService
.
putValueByEntityNameList
(
mapList
,
false
);
if
(
i
==
0
)
{
if
(
i
==
0
)
{
return
ResultUtil
.
success
(
""
,
"数据插入成功!"
);
return
ResultUtil
.
success
(
""
,
"数据插入成功!"
);
}
}
...
@@ -167,7 +168,8 @@ public class ModelController {
...
@@ -167,7 +168,8 @@ public class ModelController {
@ApiOperation
(
"复杂查询"
)
@ApiOperation
(
"复杂查询"
)
@PostMapping
(
"/complexQuery"
)
@PostMapping
(
"/complexQuery"
)
public
ResponseEntity
complexQuery
(
@RequestBody
complexQueryVo
complexQueryVo
)
{
public
ResponseEntity
complexQuery
(
@RequestBody
complexQueryVo
complexQueryVo
)
{
List
list
=
modelService
.
complexQuery
(
complexQueryVo
.
getTableName
(),
complexQueryVo
.
getColumnNames
(),
complexQueryVo
.
getQueryConditions
());
List
list
=
modelService
.
complexQuery
(
complexQueryVo
.
getTableName
(),
complexQueryVo
.
getColumnNames
(),
complexQueryVo
.
getQueryConditions
(),
complexQueryVo
.
getGroupByColumn
()
);
if
(
list
!=
null
)
{
if
(
list
!=
null
)
{
return
ResultUtil
.
success
(
list
,
"查询成功!"
);
return
ResultUtil
.
success
(
list
,
"查询成功!"
);
}
}
...
@@ -181,17 +183,16 @@ public class ModelController {
...
@@ -181,17 +183,16 @@ public class ModelController {
@ApiOperation
(
"复杂查询(分类)"
)
@ApiOperation
(
"复杂查询(分类)"
)
@PostMapping
(
"/complexQuery/group"
)
@PostMapping
(
"/complexQuery/group"
)
public
ResponseEntity
complexQueryWithGroup
(
@RequestBody
complexQueryVo
complexQueryVo
)
{
public
ResponseEntity
complexQueryWithGroup
(
@RequestBody
complexQueryVo
complexQueryVo
)
{
Map
<
Object
,
List
<
Map
<
String
,
Object
>>>
list
=
modelService
.
complexQueryWithGroup
(
complexQueryVo
.
getTableName
(),
complexQueryVo
.
getGroupConditions
(),
complexQueryVo
.
getColumnNames
(),
complexQueryVo
.
getQueryConditions
(),
complexQueryVo
.
getGroupByColumn
());
CustomPage
customPage
=
modelService
.
complexQueryWithGroup
(
complexQueryVo
.
getTableName
(),
complexQueryVo
.
getGroupCondition
(),
complexQueryVo
.
getColumnNames
(),
complexQueryVo
.
getQueryConditions
(),
complexQueryVo
.
getGroupByColumn
(),
complexQueryVo
.
getPage
(),
complexQueryVo
.
getSize
());
if
(
list
!=
null
)
{
if
(
customPage
.
getContents
()
!=
null
)
{
return
ResultUtil
.
success
(
list
,
"查询成功!"
);
return
ResultUtil
.
success
(
customPage
,
"查询成功!"
);
}
}
return
ResultUtil
.
failed
(
null
,
"没有数据!"
);
return
ResultUtil
.
failed
(
HttpStatus
.
INTERNAL_SERVER_ERROR
,
"没有数据!"
);
}
}
@ApiOperation
(
"编辑操作"
)
@ApiOperation
(
"编辑操作"
)
@PutMapping
(
"/update"
)
@PutMapping
(
"/update"
)
public
ResponseEntity
updateTable
(
@RequestBody
UpdateTableInfoVO
updateTableInfoVO
)
{
public
ResponseEntity
updateTable
(
@RequestBody
UpdateTableInfoVO
updateTableInfoVO
)
{
int
i
=
modelService
.
updateTable
(
updateTableInfoVO
);
int
i
=
modelService
.
updateTable
(
updateTableInfoVO
);
if
(
i
==
1
)
{
if
(
i
==
1
)
{
return
ResultUtil
.
success
(
""
,
"修改成功!"
);
return
ResultUtil
.
success
(
""
,
"修改成功!"
);
...
@@ -228,5 +229,15 @@ public class ModelController {
...
@@ -228,5 +229,15 @@ public class ModelController {
return
ResultUtil
.
failed
(
"SQL错误,查询失败!"
);
return
ResultUtil
.
failed
(
"SQL错误,查询失败!"
);
}
}
@ApiOperation
(
"删除接口"
)
@PostMapping
(
"/deleteValue"
)
public
ResponseEntity
deleteValue
(
@RequestBody
Map
<
String
,
Object
>
map
)
{
int
i
=
modelService
.
putValueByEntityName
(
map
,
true
);
if
(
i
==
0
)
{
return
ResultUtil
.
success
(
""
,
"数据删除成功!"
);
}
return
ResultUtil
.
failed
(
"模型类型不支持删除数据!"
);
}
}
}
src/main/java/com/tykj/model_layer/controller/QuoteController.java
浏览文件 @
1be24adf
package
com
.
tykj
.
model_layer
.
controller
;
package
com
.
tykj
.
model_layer
.
controller
;
import
com.tykj.base.result.ApiException
;
import
com.tykj.base.result.ResultUtil
;
import
com.tykj.base.result.ResultUtil
;
import
com.tykj.model_layer.dao.ColumnInfoDao
;
import
com.tykj.model_layer.entity.ColumnInfo
;
import
com.tykj.model_layer.entity.Quote
;
import
com.tykj.model_layer.entity.customEnums.ConnectionType
;
import
com.tykj.model_layer.entity.vo.QueryCondition
;
import
com.tykj.model_layer.entity.vo.SearchQuoteVO
;
import
com.tykj.model_layer.entity.vo.SearchQuoteVO
;
import
com.tykj.model_layer.entity.vo.UpdateQuoteVO
;
import
com.tykj.model_layer.entity.vo.UpdateQuoteVO
;
import
com.tykj.model_layer.service.QuoteService
;
import
com.tykj.model_layer.service.QuoteService
;
import
com.tykj.model_layer.service.impl.ModelImpl
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiModelProperty
;
import
io.swagger.annotations.ApiModelProperty
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -11,7 +18,7 @@ import org.springframework.http.ResponseEntity;
...
@@ -11,7 +18,7 @@ import org.springframework.http.ResponseEntity;
import
org.springframework.stereotype.Controller
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.
List
;
import
java.util.
*
;
/**
/**
* @Description TODO
* @Description TODO
...
@@ -26,6 +33,12 @@ public class QuoteController {
...
@@ -26,6 +33,12 @@ public class QuoteController {
@Autowired
@Autowired
private
QuoteService
quoteService
;
private
QuoteService
quoteService
;
@Autowired
ModelImpl
model
;
@Autowired
ColumnInfoDao
columnInfoDao
;
@ApiModelProperty
(
"引用删除"
)
@ApiModelProperty
(
"引用删除"
)
@GetMapping
(
"/delete"
)
@GetMapping
(
"/delete"
)
public
ResponseEntity
deleteQuote
(
Integer
id
)
{
public
ResponseEntity
deleteQuote
(
Integer
id
)
{
...
@@ -38,11 +51,29 @@ public class QuoteController {
...
@@ -38,11 +51,29 @@ public class QuoteController {
return
ResultUtil
.
success
(
quoteService
.
updateQuote
(
updateQuoteVO
),
"查询成功!"
);
return
ResultUtil
.
success
(
quoteService
.
updateQuote
(
updateQuoteVO
),
"查询成功!"
);
}
}
@ApiModelProperty
(
"
引用更新
"
)
@ApiModelProperty
(
"
查找所有引用
"
)
@PostMapping
(
"/getAllQuote"
)
@PostMapping
(
"/getAllQuote"
)
public
ResponseEntity
getAllQuote
(
@RequestBody
SearchQuoteVO
searchQuoteVO
)
{
public
ResponseEntity
getAllQuote
(
@RequestBody
SearchQuoteVO
searchQuoteVO
)
{
return
ResultUtil
.
success
(
quoteService
.
getAllQuote
(
searchQuoteVO
),
"查询成功!"
);
return
ResultUtil
.
success
(
quoteService
.
getAllQuote
(
searchQuoteVO
),
"查询成功!"
);
}
}
@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/model_layer/dao/ExcelConfigDao.java
浏览文件 @
1be24adf
...
@@ -3,6 +3,8 @@ package com.tykj.model_layer.dao;
...
@@ -3,6 +3,8 @@ package com.tykj.model_layer.dao;
import
com.tykj.model_layer.entity.ExcelConfig
;
import
com.tykj.model_layer.entity.ExcelConfig
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.JpaSpecificationExecutor
;
import
org.springframework.data.jpa.repository.JpaSpecificationExecutor
;
import
org.springframework.data.jpa.repository.Query
;
public
interface
ExcelConfigDao
extends
JpaRepository
<
ExcelConfig
,
Integer
>,
JpaSpecificationExecutor
<
ExcelConfig
>
{
public
interface
ExcelConfigDao
extends
JpaRepository
<
ExcelConfig
,
Integer
>,
JpaSpecificationExecutor
<
ExcelConfig
>
{
}
}
src/main/java/com/tykj/model_layer/entity/Quote.java
浏览文件 @
1be24adf
...
@@ -3,6 +3,7 @@ package com.tykj.model_layer.entity;
...
@@ -3,6 +3,7 @@ package com.tykj.model_layer.entity;
import
com.tykj.base.entity.BaseEntity
;
import
com.tykj.base.entity.BaseEntity
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
lombok.NoArgsConstructor
;
...
@@ -16,6 +17,7 @@ import javax.persistence.Table;
...
@@ -16,6 +17,7 @@ import javax.persistence.Table;
* @Date 2021/5/17 15:17
* @Date 2021/5/17 15:17
*/
*/
@Data
@Data
@AllArgsConstructor
@NoArgsConstructor
@NoArgsConstructor
@Entity
@Entity
@Table
@Table
...
...
src/main/java/com/tykj/model_layer/entity/vo/CustomPage.java
0 → 100644
浏览文件 @
1be24adf
package
com
.
tykj
.
model_layer
.
entity
.
vo
;
import
io.swagger.annotations.ApiModel
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.util.List
;
import
java.util.Map
;
/**
* @author HuangXiahao
* @version V1.0
* @class CustomPage
* @packageName com.tykj.model_layer.entity.vo
**/
@ApiModel
(
"带分页的返回"
)
@Data
@AllArgsConstructor
@NoArgsConstructor
public
class
CustomPage
{
public
long
total
;
public
List
contents
;
}
src/main/java/com/tykj/model_layer/entity/vo/complexQueryVo.java
浏览文件 @
1be24adf
...
@@ -28,11 +28,15 @@ public class complexQueryVo {
...
@@ -28,11 +28,15 @@ public class complexQueryVo {
List
<
String
>
columnNames
;
List
<
String
>
columnNames
;
@ApiModelProperty
(
"分类条件信息"
)
@ApiModelProperty
(
"分类条件信息"
)
List
<
GroupCondition
>
groupConditions
;
GroupCondition
groupCondition
;
@ApiModelProperty
(
"查询条件"
)
@ApiModelProperty
(
"查询条件"
)
List
<
QueryCondition
>
queryConditions
;
List
<
QueryCondition
>
queryConditions
;
@ApiModelProperty
(
"分类字段"
)
@ApiModelProperty
(
"分类字段"
)
String
groupByColumn
;
String
groupByColumn
;
Integer
page
=
0
;
Integer
size
=
15
;
}
}
src/main/java/com/tykj/model_layer/excel/ExcelData.java
浏览文件 @
1be24adf
...
@@ -155,7 +155,7 @@ public class ExcelData {
...
@@ -155,7 +155,7 @@ public class ExcelData {
queryCondition
.
setType
(
"="
);
queryCondition
.
setType
(
"="
);
queryCondition
.
setValue
(
row
.
getCell
(
dataCell
).
getStringCellValue
());
queryCondition
.
setValue
(
row
.
getCell
(
dataCell
).
getStringCellValue
());
queryConditions
.
add
(
queryCondition
);
queryConditions
.
add
(
queryCondition
);
List
<
Map
<
String
,
Object
>>
list
=
modelService
.
complexQuery
(
className
,
null
,
queryConditions
);
List
<
Map
<
String
,
Object
>>
list
=
modelService
.
complexQuery
(
className
,
null
,
queryConditions
,
null
);
if
(
list
!=
null
&&
list
.
size
()
>
0
){
if
(
list
!=
null
&&
list
.
size
()
>
0
){
Object
object
=
list
.
get
(
0
).
get
(
"id"
);
Object
object
=
list
.
get
(
0
).
get
(
"id"
);
propertyNameAndData
.
put
(
"id"
,
object
);
propertyNameAndData
.
put
(
"id"
,
object
);
...
@@ -189,7 +189,7 @@ public class ExcelData {
...
@@ -189,7 +189,7 @@ public class ExcelData {
}
}
}
}
int
re
=
modelService
.
putValueByEntityNameList
(
saveMapList
);
int
re
=
modelService
.
putValueByEntityNameList
(
saveMapList
,
false
);
if
(
re
==
0
){
if
(
re
==
0
){
successFileNameList
=
successFileNameList
+
"["
+
fileName
+
"]"
;
successFileNameList
=
successFileNameList
+
"["
+
fileName
+
"]"
;
dataFile
.
renameTo
(
new
File
(
successPath
+
fileName
));
dataFile
.
renameTo
(
new
File
(
successPath
+
fileName
));
...
...
src/main/java/com/tykj/model_layer/service/ModelService.java
浏览文件 @
1be24adf
...
@@ -61,7 +61,7 @@ public interface ModelService {
...
@@ -61,7 +61,7 @@ public interface ModelService {
* @param map
* @param map
* @return
* @return
*/
*/
int
putValueByEntityName
(
Map
<
String
,
Object
>
map
);
int
putValueByEntityName
(
Map
<
String
,
Object
>
map
,
Boolean
isDelete
);
/**
/**
* 插入一组数据
* 插入一组数据
...
@@ -69,7 +69,7 @@ public interface ModelService {
...
@@ -69,7 +69,7 @@ public interface ModelService {
* @param mapList
* @param mapList
* @return
* @return
*/
*/
int
putValueByEntityNameList
(
List
<
Map
<
String
,
Object
>>
mapList
);
int
putValueByEntityNameList
(
List
<
Map
<
String
,
Object
>>
mapList
,
Boolean
isDelete
);
/**
/**
* 根据表名查询所有
* 根据表名查询所有
...
@@ -88,7 +88,7 @@ public interface ModelService {
...
@@ -88,7 +88,7 @@ public interface ModelService {
* @param queryConditions
* @param queryConditions
* @return
* @return
*/
*/
List
<
Map
<
String
,
Object
>>
complexQuery
(
String
tableName
,
List
<
String
>
columnNames
,
List
<
QueryCondition
>
queryConditions
);
List
<
Map
<
String
,
Object
>>
complexQuery
(
String
tableName
,
List
<
String
>
columnNames
,
List
<
QueryCondition
>
queryConditions
,
String
groupName
);
/**
/**
* 复杂查询(带分类)
* 复杂查询(带分类)
...
@@ -97,7 +97,7 @@ public interface ModelService {
...
@@ -97,7 +97,7 @@ public interface ModelService {
* @param queryConditions
* @param queryConditions
* @return
* @return
*/
*/
Map
<
Object
,
List
<
Map
<
String
,
Object
>>>
complexQueryWithGroup
(
String
tableName
,
List
<
GroupCondition
>
groupConditions
,
List
<
String
>
columnNames
,
List
<
QueryCondition
>
queryConditions
,
String
groupByColumn
);
CustomPage
complexQueryWithGroup
(
String
tableName
,
GroupCondition
groupCondition
,
List
<
String
>
columnNames
,
List
<
QueryCondition
>
queryConditions
,
String
groupByColumn
,
Integer
page
,
Integer
size
);
/**
/**
...
@@ -126,5 +126,12 @@ public interface ModelService {
...
@@ -126,5 +126,12 @@ public interface ModelService {
*/
*/
TableAndColumnInfoVO
getTableInfoAndColumnInfoByBatch
(
Integer
[]
ids
);
TableAndColumnInfoVO
getTableInfoAndColumnInfoByBatch
(
Integer
[]
ids
);
/**
* 执行自定义SQL
* @param sql
* @return
* @throws SQLException
*/
List
<
Map
<
String
,
Object
>>
executeQuery
(
String
sql
)
throws
SQLException
;
List
<
Map
<
String
,
Object
>>
executeQuery
(
String
sql
)
throws
SQLException
;
}
}
src/main/java/com/tykj/model_layer/service/impl/ModelImpl.java
浏览文件 @
1be24adf
...
@@ -24,7 +24,10 @@ import lombok.extern.slf4j.Slf4j;
...
@@ -24,7 +24,10 @@ import lombok.extern.slf4j.Slf4j;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.logging.log4j.util.Strings
;
import
org.apache.logging.log4j.util.Strings
;
import
org.hibernate.HibernateException
;
import
org.hibernate.Session
;
import
org.hibernate.Session
;
import
org.hibernate.StaleStateException
;
import
org.hibernate.dialect.lock.OptimisticEntityLockException
;
import
org.hibernate.internal.SessionImpl
;
import
org.hibernate.internal.SessionImpl
;
import
org.hibernate.persister.entity.EntityPersister
;
import
org.hibernate.persister.entity.EntityPersister
;
import
org.hibernate.query.Query
;
import
org.hibernate.query.Query
;
...
@@ -202,7 +205,7 @@ public class ModelImpl implements ModelService {
...
@@ -202,7 +205,7 @@ 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
)
{
public
int
putValueByEntityName
(
Map
<
String
,
Object
>
map
,
Boolean
isDelete
)
{
for
(
String
tableName
:
for
(
String
tableName
:
map
.
keySet
())
{
map
.
keySet
())
{
//查找对应的表
//查找对应的表
...
@@ -217,24 +220,30 @@ public class ModelImpl implements ModelService {
...
@@ -217,24 +220,30 @@ public class ModelImpl implements ModelService {
if
(
one
.
isPresent
())
{
if
(
one
.
isPresent
())
{
tableInfo
=
(
TableInfo
)
one
.
get
();
tableInfo
=
(
TableInfo
)
one
.
get
();
}
}
Integer
modelType
=
tableInfo
.
getModelType
();
SessionImpl
session
=
(
SessionImpl
)
sessionUtil
.
getSession
();
SessionImpl
session
=
(
SessionImpl
)
sessionUtil
.
getSession
();
session
.
getTransaction
().
begin
();
session
.
getTransaction
().
begin
();
Object
values
=
map
.
get
(
tableName
);
Object
values
=
map
.
get
(
tableName
);
if
(
values
instanceof
Map
)
{
if
(
values
instanceof
Map
)
{
//插入数据
//插入数据
insertValue
(
tableInfo
.
getModelName
(),
(
Map
)
values
,
session
,
true
,
false
);
insertValue
(
tableInfo
.
getModelName
(),
(
Map
)
values
,
session
,
true
,
false
,
isDelete
);
}
else
{
}
else
{
//循环插入数据
//循环插入数据
List
valuesList
=
(
List
)
values
;
List
valuesList
=
(
List
)
values
;
for
(
int
i
=
0
;
i
<
valuesList
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
valuesList
.
size
();
i
++)
{
insertValue
(
tableInfo
.
getModelName
(),
(
Map
)
valuesList
.
get
(
i
),
session
,
true
,
false
);
insertValue
(
tableInfo
.
getModelName
(),
(
Map
)
valuesList
.
get
(
i
),
session
,
true
,
false
,
isDelete
);
}
}
}
}
try
{
session
.
getTransaction
().
commit
();
session
.
getTransaction
().
commit
();
}
catch
(
Exception
e
){
//todo 等会捕捉一下
if
(
e
.
getMessage
().
contains
(
"Batch update returned unexpected row count from"
)){
throw
new
ApiException
(
"要操作对象的主键不存在"
);
}
}
finally
{
session
.
close
();
session
.
close
();
}
}
}
...
@@ -249,7 +258,7 @@ public class ModelImpl implements ModelService {
...
@@ -249,7 +258,7 @@ public class ModelImpl implements ModelService {
* @Date 16:17 2021/3/5
* @Date 16:17 2021/3/5
**/
**/
@Override
@Override
public
int
putValueByEntityNameList
(
List
<
Map
<
String
,
Object
>>
mapList
)
{
public
int
putValueByEntityNameList
(
List
<
Map
<
String
,
Object
>>
mapList
,
Boolean
isDelete
)
{
SessionImpl
session
=
(
SessionImpl
)
sessionUtil
.
getSession
();
SessionImpl
session
=
(
SessionImpl
)
sessionUtil
.
getSession
();
session
.
getTransaction
().
begin
();
session
.
getTransaction
().
begin
();
for
(
Map
<
String
,
Object
>
map
:
mapList
)
{
for
(
Map
<
String
,
Object
>
map
:
mapList
)
{
...
@@ -267,23 +276,29 @@ public class ModelImpl implements ModelService {
...
@@ -267,23 +276,29 @@ public class ModelImpl implements ModelService {
if
(
one
.
isPresent
())
{
if
(
one
.
isPresent
())
{
tableInfo
=
(
TableInfo
)
one
.
get
();
tableInfo
=
(
TableInfo
)
one
.
get
();
}
}
Integer
modelType
=
tableInfo
.
getModelType
();
Object
values
=
map
.
get
(
tableName
);
Object
values
=
map
.
get
(
tableName
);
if
(
values
instanceof
Map
)
{
if
(
values
instanceof
Map
)
{
//插入数据
//插入数据
insertValue
(
tableInfo
.
getModelName
(),
(
Map
)
values
,
session
,
true
,
false
);
insertValue
(
tableInfo
.
getModelName
(),
(
Map
)
values
,
session
,
true
,
false
,
isDelete
);
}
else
{
}
else
{
//循环插入数据
//循环插入数据
List
valuesList
=
(
List
)
values
;
List
valuesList
=
(
List
)
values
;
for
(
int
i
=
0
;
i
<
valuesList
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
valuesList
.
size
();
i
++)
{
insertValue
(
tableInfo
.
getModelName
(),
(
Map
)
valuesList
.
get
(
i
),
session
,
true
,
false
);
insertValue
(
tableInfo
.
getModelName
(),
(
Map
)
valuesList
.
get
(
i
),
session
,
true
,
false
,
isDelete
);
}
}
}
}
}
}
}
}
try
{
session
.
getTransaction
().
commit
();
session
.
getTransaction
().
commit
();
}
catch
(
StaleStateException
staleStateException
){
if
(
staleStateException
.
getMessage
().
contains
(
"Batch update returned unexpected row count from"
)){
throw
new
ApiException
(
"要操作对象的主键不存在"
);
}
}
finally
{
session
.
close
();
session
.
close
();
}
return
0
;
return
0
;
}
}
...
@@ -296,40 +311,30 @@ public class ModelImpl implements ModelService {
...
@@ -296,40 +311,30 @@ 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
,
boolean
back
,
boolean
saveOrSaveAndUpdate
)
{
public
void
insertValue
(
String
tableName
,
Map
map
,
SessionImpl
session
,
boolean
back
,
boolean
saveOrSaveAndUpdate
,
boolean
isDelete
)
{
EntityPersister
entityPersister
=
session
.
getEntityPersister
(
tableName
,
map
);
EntityPersister
entityPersister
=
session
.
getEntityPersister
(
tableName
,
map
);
//主键类型推断
String
identifierPropertyName
=
entityPersister
.
getIdentifierPropertyName
();
if
(
map
.
containsKey
(
identifierPropertyName
)){
changeValueToTargetType
(
map
,
map
.
get
(
identifierPropertyName
),
entityPersister
.
getIdentifierType
(),
identifierPropertyName
);
}
//类型推断 根据目标值的类型强转目标值的目标类型
Type
[]
propertyTypes
=
entityPersister
.
getPropertyTypes
();
Type
[]
propertyTypes
=
entityPersister
.
getPropertyTypes
();
String
[]
propertyNames
=
entityPersister
.
getEntityPersister
().
getPropertyNames
();
String
[]
propertyNames
=
entityPersister
.
getEntityPersister
().
getPropertyNames
();
Object
[]
propertyValuesToInsert
=
entityPersister
.
getPropertyValuesToInsert
(
map
,
null
,
session
);
Object
[]
propertyValuesToInsert
=
entityPersister
.
getPropertyValuesToInsert
(
map
,
null
,
session
);
for
(
int
i
=
0
;
i
<
propertyValuesToInsert
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
propertyValuesToInsert
.
length
;
i
++)
{
Object
value
=
propertyValuesToInsert
[
i
];
Object
value
=
propertyValuesToInsert
[
i
];
Type
propertyType
=
propertyTypes
[
i
];
Type
propertyType
=
propertyTypes
[
i
];
//先将Type转为java类
//根据目标Type转换
if
(
propertyType
instanceof
TimestampType
)
{
changeValueToTargetType
(
map
,
value
,
propertyType
,
propertyNames
[
i
]);
try
{
if
(
value
instanceof
String
)
{
if
(
StringUtils
.
isNotEmpty
((
String
)
value
))
{
Date
parse
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
).
parse
((
String
)
value
);
map
.
put
(
propertyNames
[
i
],
parse
);
}
}
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
}
}
if
(
propertyType
instanceof
IntegerType
)
{
//然后调用强转方法
int
i1
=
Integer
.
valueOf
(
value
+
""
);
map
.
put
(
propertyNames
[
i
],
i1
);
}
if
(
propertyType
instanceof
StringType
)
{
//然后调用强转方法
map
.
put
(
propertyNames
[
i
],
value
);
}
}
}
HashMap
hashMap
=
new
HashMap
();
HashMap
hashMap
=
new
HashMap
();
hashMap
.
putAll
(
map
);
hashMap
.
putAll
(
map
);
//到这里直接执行删除操作
if
(
isDelete
){
session
.
delete
(
tableName
,
map
);
return
;
}
if
(
saveOrSaveAndUpdate
)
{
if
(
saveOrSaveAndUpdate
)
{
session
.
save
(
tableName
,
map
);
session
.
save
(
tableName
,
map
);
}
else
{
}
else
{
...
@@ -384,9 +389,9 @@ public class ModelImpl implements ModelService {
...
@@ -384,9 +389,9 @@ public class ModelImpl implements ModelService {
}
}
@Override
@Override
public
List
<
Map
<
String
,
Object
>>
complexQuery
(
String
tableName
,
List
<
String
>
columnNames
,
List
<
QueryCondition
>
queryConditions
)
{
public
List
<
Map
<
String
,
Object
>>
complexQuery
(
String
tableName
,
List
<
String
>
columnNames
,
List
<
QueryCondition
>
queryConditions
,
String
groupName
)
{
if
(
Strings
.
isNotEmpty
(
tableName
))
{
if
(
Strings
.
isNotEmpty
(
tableName
))
{
String
query
=
createQuery
(
tableName
,
columnNames
,
queryConditions
,
Strings
.
EMPTY
);
String
query
=
createQuery
(
tableName
,
columnNames
,
queryConditions
,
groupName
);
Session
session
=
sessionUtil
.
getSession
();
Session
session
=
sessionUtil
.
getSession
();
Query
query1
=
session
.
createQuery
(
query
);
Query
query1
=
session
.
createQuery
(
query
);
List
<
Map
<
String
,
Object
>>
list
=
query1
.
list
();
List
<
Map
<
String
,
Object
>>
list
=
query1
.
list
();
...
@@ -397,25 +402,63 @@ public class ModelImpl implements ModelService {
...
@@ -397,25 +402,63 @@ public class ModelImpl implements ModelService {
}
}
@Override
@Override
public
Map
<
Object
,
List
<
Map
<
String
,
Object
>>>
complexQueryWithGroup
(
String
tableName
,
List
<
GroupCondition
>
groupConditions
,
List
<
String
>
columnNames
,
List
<
QueryCondition
>
queryConditions
,
String
groupByColumn
)
{
public
CustomPage
complexQueryWithGroup
(
String
tableName
,
GroupCondition
groupCondition
,
List
<
String
>
columnNames
,
List
<
QueryCondition
>
queryConditions
,
String
groupByColumn
,
Integer
page
,
Integer
size
)
{
Map
<
Object
,
List
<
Map
<
String
,
Object
>>>
result
=
new
HashMap
<>();
if
(
Strings
.
isNotEmpty
(
tableName
))
{
if
(
Strings
.
isNotEmpty
(
tableName
)
&&
Strings
.
isNotEmpty
(
groupByColumn
)
&&
!
groupConditions
.
isEmpty
())
{
List
<
QueryCondition
>
queryConditionList
=
new
ArrayList
<>();
for
(
GroupCondition
groupCondition
:
groupConditions
)
{
if
(
queryConditions
!=
null
)
{
queryConditions
.
add
(
new
QueryCondition
(
queryConditionList
.
addAll
(
queryConditions
);
}
if
(
groupCondition
!=
null
)
{
if
(
StringUtils
.
isNotEmpty
(
groupCondition
.
getValue
()))
{
queryConditionList
.
add
(
new
QueryCondition
(
groupByColumn
,
groupByColumn
,
"like"
,
"like"
,
groupCondition
.
getValue
(),
groupCondition
.
getValue
(),
ConnectionType
.
AND
ConnectionType
.
AND
));
));
String
query
=
createQuery
(
tableName
,
columnNames
,
queryConditions
,
Strings
.
EMPTY
);
}
}
String
query
=
createQuery
(
tableName
,
columnNames
,
queryConditionList
,
Strings
.
EMPTY
);
Session
session
=
sessionUtil
.
getSession
();
Session
session
=
sessionUtil
.
getSession
();
Query
query1
=
session
.
createQuery
(
query
);
Query
query1
=
session
.
createQuery
(
query
);
List
<
Map
<
String
,
Object
>>
list
=
query1
.
list
();
List
list1
=
query1
.
list
();
result
.
put
(
groupCondition
.
getName
(),
list
);
page
=
page
-
1
;
query1
.
setFirstResult
(
page
*
size
);
query1
.
setMaxResults
(
size
);
List
list2
=
query1
.
list
();
session
.
close
();
session
.
close
();
}
return
new
CustomPage
(
list1
.
size
(),
list2
);
return
result
;
}
}
// if (Strings.isNotEmpty(tableName)) {
// }else {
// for (GroupCondition groupCondition : groupConditions) {
// List<QueryCondition> queryConditionList = new ArrayList<>();
// if (queryConditions!=null){
// queryConditionList.addAll(queryConditions);
// }
// if (groupByColumn.isEmpty()){
// throw new ApiException("分类字段不能为空");
// }
// queryConditionList.add(new QueryCondition(
// groupByColumn,
// "like",
// groupCondition.getValue(),
// ConnectionType.AND
// ));
// String query = createQuery(tableName, columnNames, queryConditionList, Strings.EMPTY);
// Session session = sessionUtil.getSession();
// Query query1 = session.createQuery(query);
// List<Map<String, Object>> list = query1.list();
// result.put(groupCondition.getName(), list);
// session.close();
// }
// }
// return result;
// }
return
null
;
return
null
;
}
}
...
@@ -597,17 +640,12 @@ public class ModelImpl implements ModelService {
...
@@ -597,17 +640,12 @@ public class ModelImpl implements ModelService {
throw
new
ApiException
(
"此id已经被删除!"
);
throw
new
ApiException
(
"此id已经被删除!"
);
}
else
{
}
else
{
TableInfo
tableInfo
=
byId
.
get
();
TableInfo
tableInfo
=
byId
.
get
();
Integer
modelType
=
tableInfo
.
getModelType
();
if
(
modelType
.
equals
(
ModelType
.
VIRTUAL
)
||
modelType
.
equals
(
ModelType
.
VIRTUAL
))
{
tableInfoDao
.
deleteById
(
delTableVO
.
getId
());
tableInfoDao
.
deleteById
(
delTableVO
.
getId
());
List
<
ColumnInfo
>
allByDbId
=
columnInfoDao
.
findAllByDbId
(
delTableVO
.
getId
());
List
<
ColumnInfo
>
allByDbId
=
columnInfoDao
.
findAllByDbId
(
delTableVO
.
getId
());
columnInfoDao
.
deleteInBatch
(
allByDbId
);
columnInfoDao
.
deleteInBatch
(
allByDbId
);
jdbcTemplate
.
execute
(
"drop table "
+
tableInfo
.
getModelName
());
jdbcTemplate
.
execute
(
"drop table "
+
tableInfo
.
getModelName
());
return
1
;
return
1
;
}
}
}
return
0
;
}
}
...
@@ -646,4 +684,30 @@ public class ModelImpl implements ModelService {
...
@@ -646,4 +684,30 @@ public class ModelImpl implements ModelService {
}
}
void
changeValueToTargetType
(
Map
map
,
Object
value
,
Type
propertyType
,
String
propertyName
){
if
(
propertyType
instanceof
TimestampType
)
{
try
{
if
(
value
instanceof
String
)
{
if
(
StringUtils
.
isNotEmpty
((
String
)
value
))
{
Date
parse
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
).
parse
((
String
)
value
);
map
.
put
(
propertyName
,
parse
);
}
}
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
}
}
if
(
propertyType
instanceof
IntegerType
)
{
//然后调用强转方法
int
i1
=
Integer
.
valueOf
(
value
+
""
);
map
.
put
(
propertyName
,
i1
);
}
if
(
propertyType
instanceof
StringType
)
{
//然后调用强转方法
map
.
put
(
propertyName
,
value
+
""
);
}
}
}
}
src/main/java/com/tykj/model_layer/service/impl/VersionServiceImpl.java
浏览文件 @
1be24adf
...
@@ -52,7 +52,7 @@ public class VersionServiceImpl implements VersionService {
...
@@ -52,7 +52,7 @@ public class VersionServiceImpl implements VersionService {
version
.
setDbId
(
versionVO
.
getDbId
());
version
.
setDbId
(
versionVO
.
getDbId
());
version
.
setVersionDesc
(
versionVO
.
getVersionDesc
());
version
.
setVersionDesc
(
versionVO
.
getVersionDesc
());
TableInfo
tableInfo
=
tableInfoDao
.
getOne
(
version
.
getDbId
());
TableInfo
tableInfo
=
tableInfoDao
.
getOne
(
version
.
getDbId
());
List
<
Map
<
String
,
Object
>>
maps
=
model
.
complexQuery
(
tableInfo
.
getModelName
(),
null
,
null
);
List
<
Map
<
String
,
Object
>>
maps
=
model
.
complexQuery
(
tableInfo
.
getModelName
(),
null
,
null
,
null
);
List
<
Integer
>
collect
=
new
ArrayList
<>();
List
<
Integer
>
collect
=
new
ArrayList
<>();
for
(
Map
<
String
,
Object
>
map
:
maps
)
{
for
(
Map
<
String
,
Object
>
map
:
maps
)
{
collect
.
add
((
Integer
)
map
.
get
(
"id"
));
collect
.
add
((
Integer
)
map
.
get
(
"id"
));
...
@@ -61,6 +61,7 @@ public class VersionServiceImpl implements VersionService {
...
@@ -61,6 +61,7 @@ public class VersionServiceImpl implements VersionService {
return
versionDao
.
save
(
version
);
return
versionDao
.
save
(
version
);
}
}
@Override
public
List
<
Version
>
findVersionByDbId
(
Integer
dbId
){
public
List
<
Version
>
findVersionByDbId
(
Integer
dbId
){
return
versionDao
.
findAllByDbId
(
dbId
);
return
versionDao
.
findAllByDbId
(
dbId
);
}
}
...
@@ -105,7 +106,7 @@ public class VersionServiceImpl implements VersionService {
...
@@ -105,7 +106,7 @@ public class VersionServiceImpl implements VersionService {
map
.
remove
(
"$type$"
);
map
.
remove
(
"$type$"
);
HashMap
hashMap
=
new
HashMap
();
HashMap
hashMap
=
new
HashMap
();
hashMap
.
putAll
(
map
);
hashMap
.
putAll
(
map
);
model
.
insertValue
(
tableInfo
.
getModelName
(),
hashMap
,(
SessionImpl
)
session
,
false
,
true
);
model
.
insertValue
(
tableInfo
.
getModelName
(),
hashMap
,(
SessionImpl
)
session
,
false
,
true
,
false
);
}
}
System
.
out
.
println
(
"1"
);
System
.
out
.
println
(
"1"
);
session
.
getTransaction
().
commit
();
session
.
getTransaction
().
commit
();
...
...
src/main/java/com/tykj/setting/entity/ConditionSetting.java
浏览文件 @
1be24adf
package
com
.
tykj
.
setting
.
entity
;
package
com
.
tykj
.
setting
.
entity
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.tykj.model_layer.entity.customEnums.ConnectionType
;
import
io.swagger.annotations.ApiModelProperty
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
lombok.NoArgsConstructor
;
import
lombok.experimental.Accessors
;
import
lombok.experimental.Accessors
;
import
javax.persistence.Entity
;
import
javax.persistence.*
;
import
javax.persistence.GeneratedValue
;
import
javax.persistence.GenerationType
;
import
javax.persistence.Id
;
@Accessors
(
chain
=
true
)
@Accessors
(
chain
=
true
)
@AllArgsConstructor
@AllArgsConstructor
...
@@ -33,6 +31,12 @@ public class ConditionSetting {
...
@@ -33,6 +31,12 @@ public class ConditionSetting {
@ApiModelProperty
(
"对象值"
)
@ApiModelProperty
(
"对象值"
)
private
String
value
;
private
String
value
;
@ApiModelProperty
(
value
=
"连接条件"
,
example
=
"or或者and"
)
private
ConnectionType
connectionType
;
@Transient
private
String
columnName
;
@JsonIgnore
@JsonIgnore
private
Integer
screenSettingId
;
private
Integer
screenSettingId
;
}
}
src/main/java/com/tykj/setting/entity/vo/ColumnInfoVo.java
0 → 100644
浏览文件 @
1be24adf
package
com
.
tykj
.
setting
.
entity
.
vo
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
/**
* @author HuangXiahao
* @version V1.0
* @class ColumnInfoVo
* @packageName com.tykj.setting.entity.vo
**/
@AllArgsConstructor
@NoArgsConstructor
@Data
public
class
ColumnInfoVo
{
private
String
name
;
private
String
title
;
}
src/main/java/com/tykj/setting/entity/vo/DisplaySettingVo.java
浏览文件 @
1be24adf
...
@@ -22,4 +22,7 @@ public class DisplaySettingVo {
...
@@ -22,4 +22,7 @@ public class DisplaySettingVo {
@ApiModelProperty
(
"字段信息id集"
)
@ApiModelProperty
(
"字段信息id集"
)
private
List
<
Integer
>
columnIds
;
private
List
<
Integer
>
columnIds
;
@ApiModelProperty
(
"字段信息id集"
)
private
List
<
ColumnInfoVo
>
columnInfoVos
;
}
}
src/main/java/com/tykj/setting/entity/vo/GroupSettingVo.java
浏览文件 @
1be24adf
...
@@ -6,6 +6,7 @@ import lombok.AllArgsConstructor;
...
@@ -6,6 +6,7 @@ import lombok.AllArgsConstructor;
import
lombok.Data
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
lombok.NoArgsConstructor
;
import
javax.persistence.Transient
;
import
java.util.List
;
import
java.util.List
;
...
@@ -26,6 +27,9 @@ public class GroupSettingVo {
...
@@ -26,6 +27,9 @@ public class GroupSettingVo {
@ApiModelProperty
(
"名称"
)
@ApiModelProperty
(
"名称"
)
private
String
name
;
private
String
name
;
@ApiModelProperty
(
"列名"
)
private
String
columnName
;
@ApiModelProperty
(
"分类条件"
)
@ApiModelProperty
(
"分类条件"
)
private
List
<
GroupCondition
>
groupConditions
;
private
List
<
GroupCondition
>
groupConditions
;
...
...
src/main/java/com/tykj/setting/entity/vo/ScreenSettingVo.java
浏览文件 @
1be24adf
...
@@ -26,4 +26,6 @@ public class ScreenSettingVo {
...
@@ -26,4 +26,6 @@ public class ScreenSettingVo {
private
List
<
ConditionSetting
>
conditions
;
private
List
<
ConditionSetting
>
conditions
;
}
}
src/main/java/com/tykj/setting/entity/vo/StatisticsParam.java
浏览文件 @
1be24adf
...
@@ -17,6 +17,6 @@ public class StatisticsParam {
...
@@ -17,6 +17,6 @@ public class StatisticsParam {
private
String
title
;
private
String
title
;
private
List
<
ColumnName
>
columns
;
private
List
<
String
>
columns
;
}
}
src/main/java/com/tykj/setting/repository/ConditionSettingRepository.java
浏览文件 @
1be24adf
...
@@ -2,11 +2,15 @@ package com.tykj.setting.repository;
...
@@ -2,11 +2,15 @@ package com.tykj.setting.repository;
import
com.tykj.setting.entity.ConditionSetting
;
import
com.tykj.setting.entity.ConditionSetting
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.Modifying
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.List
;
import
java.util.List
;
public
interface
ConditionSettingRepository
extends
JpaRepository
<
ConditionSetting
,
Integer
>
{
public
interface
ConditionSettingRepository
extends
JpaRepository
<
ConditionSetting
,
Integer
>
{
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Modifying
void
deleteAllByScreenSettingId
(
Integer
screenSettingId
);
void
deleteAllByScreenSettingId
(
Integer
screenSettingId
);
List
<
ConditionSetting
>
findAllByScreenSettingId
(
Integer
screenSettingId
);
List
<
ConditionSetting
>
findAllByScreenSettingId
(
Integer
screenSettingId
);
...
...
src/main/java/com/tykj/setting/service/DisplaySettingService.java
浏览文件 @
1be24adf
...
@@ -3,7 +3,11 @@ package com.tykj.setting.service;
...
@@ -3,7 +3,11 @@ package com.tykj.setting.service;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.core.type.TypeReference
;
import
com.fasterxml.jackson.core.type.TypeReference
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.tykj.base.result.ApiException
;
import
com.tykj.model_layer.dao.ColumnInfoDao
;
import
com.tykj.model_layer.entity.ColumnInfo
;
import
com.tykj.setting.entity.DisplaySetting
;
import
com.tykj.setting.entity.DisplaySetting
;
import
com.tykj.setting.entity.vo.ColumnInfoVo
;
import
com.tykj.setting.entity.vo.DisplaySettingVo
;
import
com.tykj.setting.entity.vo.DisplaySettingVo
;
import
com.tykj.setting.repository.DisplaySettingRepository
;
import
com.tykj.setting.repository.DisplaySettingRepository
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -19,6 +23,9 @@ public class DisplaySettingService {
...
@@ -19,6 +23,9 @@ public class DisplaySettingService {
@Autowired
@Autowired
private
DisplaySettingRepository
displaySettingRepository
;
private
DisplaySettingRepository
displaySettingRepository
;
@Autowired
ColumnInfoDao
columnInfoDao
;
private
final
Integer
id
=
1
;
private
final
Integer
id
=
1
;
public
void
save
(
DisplaySettingVo
groupSettingVo
){
public
void
save
(
DisplaySettingVo
groupSettingVo
){
...
@@ -43,7 +50,15 @@ public class DisplaySettingService {
...
@@ -43,7 +50,15 @@ public class DisplaySettingService {
}
catch
(
JsonProcessingException
e
)
{
}
catch
(
JsonProcessingException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
return
new
DisplaySettingVo
(
displaySetting
.
getId
(),
displaySetting
.
getDbId
(),
columnIds
);
List
<
ColumnInfoVo
>
columnString
=
new
ArrayList
<>();
for
(
Integer
columnId
:
columnIds
)
{
Optional
<
ColumnInfo
>
byId1
=
columnInfoDao
.
findById
(
columnId
);
if
(!
byId1
.
isPresent
()){
throw
new
ApiException
(
"列ID:"
+
columnId
+
",不存在"
);
}
columnString
.
add
(
new
ColumnInfoVo
(
byId1
.
get
().
getFieldName
(),
byId1
.
get
().
getFieldTitle
()));
}
return
new
DisplaySettingVo
(
displaySetting
.
getId
(),
displaySetting
.
getDbId
(),
columnIds
,
columnString
);
}
else
{
}
else
{
throw
new
RuntimeException
(
"未找到该数据"
);
throw
new
RuntimeException
(
"未找到该数据"
);
}
}
...
...
src/main/java/com/tykj/setting/service/GroupSettingService.java
浏览文件 @
1be24adf
...
@@ -3,16 +3,21 @@ package com.tykj.setting.service;
...
@@ -3,16 +3,21 @@ package com.tykj.setting.service;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.core.type.TypeReference
;
import
com.fasterxml.jackson.core.type.TypeReference
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.tykj.base.result.ApiException
;
import
com.tykj.model_layer.dao.ColumnInfoDao
;
import
com.tykj.model_layer.entity.ColumnInfo
;
import
com.tykj.model_layer.entity.vo.GroupCondition
;
import
com.tykj.model_layer.entity.vo.GroupCondition
;
import
com.tykj.setting.entity.GroupSetting
;
import
com.tykj.setting.entity.GroupSetting
;
import
com.tykj.setting.entity.vo.GroupSettingVo
;
import
com.tykj.setting.entity.vo.GroupSettingVo
;
import
com.tykj.setting.repository.GroupSettingRepository
;
import
com.tykj.setting.repository.GroupSettingRepository
;
import
org.checkerframework.checker.units.qual.A
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.Objects
;
import
java.util.Optional
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
@Service
@Service
...
@@ -21,6 +26,9 @@ public class GroupSettingService {
...
@@ -21,6 +26,9 @@ public class GroupSettingService {
@Autowired
@Autowired
private
GroupSettingRepository
groupSettingRepository
;
private
GroupSettingRepository
groupSettingRepository
;
@Autowired
ColumnInfoDao
columnInfoDao
;
public
void
save
(
GroupSettingVo
groupSettingVo
)
{
public
void
save
(
GroupSettingVo
groupSettingVo
)
{
boolean
newData
=
Objects
.
isNull
(
groupSettingVo
.
getId
());
boolean
newData
=
Objects
.
isNull
(
groupSettingVo
.
getId
());
if
(
newData
)
{
if
(
newData
)
{
...
@@ -42,13 +50,26 @@ public class GroupSettingService {
...
@@ -42,13 +50,26 @@ public class GroupSettingService {
}
}
public
List
<
GroupSettingVo
>
findAll
()
{
public
List
<
GroupSettingVo
>
findAll
()
{
return
groupSettingRepository
.
findAll
().
stream
()
List
<
GroupSettingVo
>
collect
=
groupSettingRepository
.
findAll
().
stream
()
.
map
(
this
::
groupSettingVo
)
.
map
(
this
::
groupSettingVo
)
.
collect
(
Collectors
.
toList
());
.
collect
(
Collectors
.
toList
());
collect
.
forEach
(
item
->{
});
return
collect
;
}
}
public
GroupSettingVo
findById
(
Integer
id
)
{
public
GroupSettingVo
findById
(
Integer
id
)
{
return
groupSettingRepository
.
findById
(
id
).
map
(
this
::
groupSettingVo
).
orElseThrow
(()
->
new
RuntimeException
(
"未找到该id的数据"
));
GroupSettingVo
groupSettingVo
=
groupSettingRepository
.
findById
(
id
)
.
map
(
this
::
groupSettingVo
)
.
orElseThrow
(()
->
new
RuntimeException
(
"未找到该id的数据"
));
Optional
<
ColumnInfo
>
byId
=
columnInfoDao
.
findById
(
groupSettingVo
.
getColumnId
());
if
(!
byId
.
isPresent
()){
throw
new
ApiException
(
"列ID:"
+
groupSettingVo
.
getColumnId
()+
",不存在"
);
}
groupSettingVo
.
setColumnName
(
byId
.
get
().
getFieldName
());
return
groupSettingVo
;
}
}
public
void
deleteById
(
Integer
id
)
{
public
void
deleteById
(
Integer
id
)
{
...
@@ -73,6 +94,7 @@ public class GroupSettingService {
...
@@ -73,6 +94,7 @@ public class GroupSettingService {
}
}
private
GroupSettingVo
groupSettingVo
(
GroupSetting
groupSetting
){
private
GroupSettingVo
groupSettingVo
(
GroupSetting
groupSetting
){
List
<
GroupCondition
>
groupConditions
=
new
ArrayList
<>();
List
<
GroupCondition
>
groupConditions
=
new
ArrayList
<>();
try
{
try
{
groupConditions
=
new
ObjectMapper
().
readValue
(
groupSetting
.
getGroupConditions
(),
new
TypeReference
<
List
<
GroupCondition
>>()
{
groupConditions
=
new
ObjectMapper
().
readValue
(
groupSetting
.
getGroupConditions
(),
new
TypeReference
<
List
<
GroupCondition
>>()
{
...
@@ -80,11 +102,19 @@ public class GroupSettingService {
...
@@ -80,11 +102,19 @@ public class GroupSettingService {
}
catch
(
JsonProcessingException
e
)
{
}
catch
(
JsonProcessingException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
String
columnName
=
""
;
Optional
<
ColumnInfo
>
byId
=
columnInfoDao
.
findById
(
groupSetting
.
getColumnId
());
if
(
byId
.
isPresent
()){
columnName
=
byId
.
get
().
getFieldName
();
}
return
new
GroupSettingVo
(
return
new
GroupSettingVo
(
groupSetting
.
getId
(),
groupSetting
.
getId
(),
groupSetting
.
getModelId
(),
groupSetting
.
getModelId
(),
groupSetting
.
getColumnId
(),
groupSetting
.
getColumnId
(),
groupSetting
.
getName
(),
groupSetting
.
getName
(),
columnName
,
groupConditions
groupConditions
);
);
}
}
...
...
src/main/java/com/tykj/setting/service/ScreenSettingService.java
浏览文件 @
1be24adf
package
com
.
tykj
.
setting
.
service
;
package
com
.
tykj
.
setting
.
service
;
import
com.tykj.base.result.ApiException
;
import
com.tykj.model_layer.dao.ColumnInfoDao
;
import
com.tykj.model_layer.entity.ColumnInfo
;
import
com.tykj.setting.entity.ConditionSetting
;
import
com.tykj.setting.entity.ConditionSetting
;
import
com.tykj.setting.entity.ScreenSetting
;
import
com.tykj.setting.entity.ScreenSetting
;
import
com.tykj.setting.entity.vo.ScreenSettingVo
;
import
com.tykj.setting.entity.vo.ScreenSettingVo
;
...
@@ -26,6 +29,10 @@ public class ScreenSettingService {
...
@@ -26,6 +29,10 @@ public class ScreenSettingService {
@Autowired
@Autowired
private
ConditionSettingRepository
conditionSettingRepository
;
private
ConditionSettingRepository
conditionSettingRepository
;
@Autowired
ColumnInfoDao
columnInfoDao
;
public
void
save
(
ScreenSettingVo
screenSettingVo
){
public
void
save
(
ScreenSettingVo
screenSettingVo
){
boolean
newData
=
Objects
.
isNull
(
screenSettingVo
.
getId
());
boolean
newData
=
Objects
.
isNull
(
screenSettingVo
.
getId
());
if
(
newData
){
if
(
newData
){
...
@@ -66,6 +73,14 @@ public class ScreenSettingService {
...
@@ -66,6 +73,14 @@ public class ScreenSettingService {
if
(
byId
.
isPresent
()){
if
(
byId
.
isPresent
()){
ScreenSetting
screenSetting
=
byId
.
get
();
ScreenSetting
screenSetting
=
byId
.
get
();
List
<
ConditionSetting
>
conditions
=
conditionSettingRepository
.
findAllByScreenSettingId
(
id
);
List
<
ConditionSetting
>
conditions
=
conditionSettingRepository
.
findAllByScreenSettingId
(
id
);
for
(
ConditionSetting
condition
:
conditions
)
{
Optional
<
ColumnInfo
>
byId1
=
columnInfoDao
.
findById
(
condition
.
getColumnId
());
if
(
byId1
.
isPresent
()){
condition
.
setColumnName
(
byId1
.
get
().
getFieldName
());
}
else
{
throw
new
ApiException
(
"列ID:"
+
condition
.
getColumnId
()+
",不存在"
);
}
}
return
new
ScreenSettingVo
(
screenSetting
.
getId
(),
screenSetting
.
getTableInfoId
(),
screenSetting
.
getName
(),
conditions
return
new
ScreenSettingVo
(
screenSetting
.
getId
(),
screenSetting
.
getTableInfoId
(),
screenSetting
.
getName
(),
conditions
);
);
}
else
{
}
else
{
...
@@ -80,6 +95,14 @@ public class ScreenSettingService {
...
@@ -80,6 +95,14 @@ public class ScreenSettingService {
private
ScreenSettingVo
screenSettingVo
(
ScreenSetting
screenSetting
){
private
ScreenSettingVo
screenSettingVo
(
ScreenSetting
screenSetting
){
List
<
ConditionSetting
>
conditions
=
conditionSettingRepository
.
findAllByScreenSettingId
(
screenSetting
.
getId
());
List
<
ConditionSetting
>
conditions
=
conditionSettingRepository
.
findAllByScreenSettingId
(
screenSetting
.
getId
());
for
(
ConditionSetting
condition
:
conditions
)
{
Optional
<
ColumnInfo
>
byId
=
columnInfoDao
.
findById
(
condition
.
getColumnId
());
if
(
byId
.
isPresent
()){
condition
.
setColumnName
(
byId
.
get
().
getFieldName
());
}
else
{
throw
new
ApiException
(
"列ID:"
+
condition
.
getColumnId
()+
",不存在"
);
}
}
return
new
ScreenSettingVo
(
screenSetting
.
getId
(),
screenSetting
.
getTableInfoId
(),
screenSetting
.
getName
(),
conditions
);
return
new
ScreenSettingVo
(
screenSetting
.
getId
(),
screenSetting
.
getTableInfoId
(),
screenSetting
.
getName
(),
conditions
);
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论