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 个修改的文件
包含
219 行增加
和
27 行删除
+219
-27
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
+0
-0
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;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Page
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.*
;
...
...
@@ -117,7 +118,7 @@ public class ModelController {
@ApiOperation
(
value
=
"根据表名表插入数据"
)
@PostMapping
(
"/insertValues"
)
public
ResponseEntity
insertValues
(
@RequestBody
Map
<
String
,
Object
>
map
)
{
int
i
=
modelService
.
putValueByEntityName
(
map
);
int
i
=
modelService
.
putValueByEntityName
(
map
,
false
);
if
(
i
==
0
)
{
return
ResultUtil
.
success
(
""
,
"数据插入成功!"
);
}
...
...
@@ -135,7 +136,7 @@ public class ModelController {
@ApiOperation
(
value
=
"根据表名表插入数据"
)
@PostMapping
(
"/insertValueList"
)
public
ResponseEntity
insertValueList
(
@RequestBody
List
<
Map
<
String
,
Object
>>
mapList
)
{
int
i
=
modelService
.
putValueByEntityNameList
(
mapList
);
int
i
=
modelService
.
putValueByEntityNameList
(
mapList
,
false
);
if
(
i
==
0
)
{
return
ResultUtil
.
success
(
""
,
"数据插入成功!"
);
}
...
...
@@ -167,7 +168,8 @@ public class ModelController {
@ApiOperation
(
"复杂查询"
)
@PostMapping
(
"/complexQuery"
)
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
)
{
return
ResultUtil
.
success
(
list
,
"查询成功!"
);
}
...
...
@@ -181,17 +183,16 @@ public class ModelController {
@ApiOperation
(
"复杂查询(分类)"
)
@PostMapping
(
"/complexQuery/group"
)
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
());
if
(
list
!=
null
)
{
return
ResultUtil
.
success
(
list
,
"查询成功!"
);
CustomPage
customPage
=
modelService
.
complexQueryWithGroup
(
complexQueryVo
.
getTableName
(),
complexQueryVo
.
getGroupCondition
(),
complexQueryVo
.
getColumnNames
(),
complexQueryVo
.
getQueryConditions
(),
complexQueryVo
.
getGroupByColumn
(),
complexQueryVo
.
getPage
(),
complexQueryVo
.
getSize
());
if
(
customPage
.
getContents
()
!=
null
)
{
return
ResultUtil
.
success
(
customPage
,
"查询成功!"
);
}
return
ResultUtil
.
failed
(
null
,
"没有数据!"
);
return
ResultUtil
.
failed
(
HttpStatus
.
INTERNAL_SERVER_ERROR
,
"没有数据!"
);
}
@ApiOperation
(
"编辑操作"
)
@PutMapping
(
"/update"
)
public
ResponseEntity
updateTable
(
@RequestBody
UpdateTableInfoVO
updateTableInfoVO
)
{
int
i
=
modelService
.
updateTable
(
updateTableInfoVO
);
if
(
i
==
1
)
{
return
ResultUtil
.
success
(
""
,
"修改成功!"
);
...
...
@@ -228,5 +229,15 @@ public class ModelController {
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
;
import
com.tykj.base.result.ApiException
;
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.UpdateQuoteVO
;
import
com.tykj.model_layer.service.QuoteService
;
import
com.tykj.model_layer.service.impl.ModelImpl
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiModelProperty
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -11,7 +18,7 @@ import org.springframework.http.ResponseEntity;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.
List
;
import
java.util.
*
;
/**
* @Description TODO
...
...
@@ -26,6 +33,12 @@ public class QuoteController {
@Autowired
private
QuoteService
quoteService
;
@Autowired
ModelImpl
model
;
@Autowired
ColumnInfoDao
columnInfoDao
;
@ApiModelProperty
(
"引用删除"
)
@GetMapping
(
"/delete"
)
public
ResponseEntity
deleteQuote
(
Integer
id
)
{
...
...
@@ -38,11 +51,29 @@ public class QuoteController {
return
ResultUtil
.
success
(
quoteService
.
updateQuote
(
updateQuoteVO
),
"查询成功!"
);
}
@ApiModelProperty
(
"
引用更新
"
)
@ApiModelProperty
(
"
查找所有引用
"
)
@PostMapping
(
"/getAllQuote"
)
public
ResponseEntity
getAllQuote
(
@RequestBody
SearchQuoteVO
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;
import
com.tykj.model_layer.entity.ExcelConfig
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.JpaSpecificationExecutor
;
import
org.springframework.data.jpa.repository.Query
;
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;
import
com.tykj.base.entity.BaseEntity
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
...
...
@@ -16,6 +17,7 @@ import javax.persistence.Table;
* @Date 2021/5/17 15:17
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Entity
@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 {
List
<
String
>
columnNames
;
@ApiModelProperty
(
"分类条件信息"
)
List
<
GroupCondition
>
groupConditions
;
GroupCondition
groupCondition
;
@ApiModelProperty
(
"查询条件"
)
List
<
QueryCondition
>
queryConditions
;
@ApiModelProperty
(
"分类字段"
)
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 {
queryCondition
.
setType
(
"="
);
queryCondition
.
setValue
(
row
.
getCell
(
dataCell
).
getStringCellValue
());
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
){
Object
object
=
list
.
get
(
0
).
get
(
"id"
);
propertyNameAndData
.
put
(
"id"
,
object
);
...
...
@@ -189,7 +189,7 @@ public class ExcelData {
}
}
int
re
=
modelService
.
putValueByEntityNameList
(
saveMapList
);
int
re
=
modelService
.
putValueByEntityNameList
(
saveMapList
,
false
);
if
(
re
==
0
){
successFileNameList
=
successFileNameList
+
"["
+
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 {
* @param map
* @return
*/
int
putValueByEntityName
(
Map
<
String
,
Object
>
map
);
int
putValueByEntityName
(
Map
<
String
,
Object
>
map
,
Boolean
isDelete
);
/**
* 插入一组数据
...
...
@@ -69,7 +69,7 @@ public interface ModelService {
* @param mapList
* @return
*/
int
putValueByEntityNameList
(
List
<
Map
<
String
,
Object
>>
mapList
);
int
putValueByEntityNameList
(
List
<
Map
<
String
,
Object
>>
mapList
,
Boolean
isDelete
);
/**
* 根据表名查询所有
...
...
@@ -88,7 +88,7 @@ public interface ModelService {
* @param queryConditions
* @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 {
* @param queryConditions
* @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 {
*/
TableAndColumnInfoVO
getTableInfoAndColumnInfoByBatch
(
Integer
[]
ids
);
/**
* 执行自定义SQL
* @param sql
* @return
* @throws SQLException
*/
List
<
Map
<
String
,
Object
>>
executeQuery
(
String
sql
)
throws
SQLException
;
}
src/main/java/com/tykj/model_layer/service/impl/ModelImpl.java
浏览文件 @
1be24adf
差异被折叠。
点击展开。
src/main/java/com/tykj/model_layer/service/impl/VersionServiceImpl.java
浏览文件 @
1be24adf
...
...
@@ -52,7 +52,7 @@ public class VersionServiceImpl implements VersionService {
version
.
setDbId
(
versionVO
.
getDbId
());
version
.
setVersionDesc
(
versionVO
.
getVersionDesc
());
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
<>();
for
(
Map
<
String
,
Object
>
map
:
maps
)
{
collect
.
add
((
Integer
)
map
.
get
(
"id"
));
...
...
@@ -61,6 +61,7 @@ public class VersionServiceImpl implements VersionService {
return
versionDao
.
save
(
version
);
}
@Override
public
List
<
Version
>
findVersionByDbId
(
Integer
dbId
){
return
versionDao
.
findAllByDbId
(
dbId
);
}
...
...
@@ -105,7 +106,7 @@ public class VersionServiceImpl implements VersionService {
map
.
remove
(
"$type$"
);
HashMap
hashMap
=
new
HashMap
();
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"
);
session
.
getTransaction
().
commit
();
...
...
src/main/java/com/tykj/setting/entity/ConditionSetting.java
浏览文件 @
1be24adf
package
com
.
tykj
.
setting
.
entity
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.tykj.model_layer.entity.customEnums.ConnectionType
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
lombok.experimental.Accessors
;
import
javax.persistence.Entity
;
import
javax.persistence.GeneratedValue
;
import
javax.persistence.GenerationType
;
import
javax.persistence.Id
;
import
javax.persistence.*
;
@Accessors
(
chain
=
true
)
@AllArgsConstructor
...
...
@@ -33,6 +31,12 @@ public class ConditionSetting {
@ApiModelProperty
(
"对象值"
)
private
String
value
;
@ApiModelProperty
(
value
=
"连接条件"
,
example
=
"or或者and"
)
private
ConnectionType
connectionType
;
@Transient
private
String
columnName
;
@JsonIgnore
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 {
@ApiModelProperty
(
"字段信息id集"
)
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;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
javax.persistence.Transient
;
import
java.util.List
;
...
...
@@ -26,6 +27,9 @@ public class GroupSettingVo {
@ApiModelProperty
(
"名称"
)
private
String
name
;
@ApiModelProperty
(
"列名"
)
private
String
columnName
;
@ApiModelProperty
(
"分类条件"
)
private
List
<
GroupCondition
>
groupConditions
;
...
...
src/main/java/com/tykj/setting/entity/vo/ScreenSettingVo.java
浏览文件 @
1be24adf
...
...
@@ -26,4 +26,6 @@ public class ScreenSettingVo {
private
List
<
ConditionSetting
>
conditions
;
}
src/main/java/com/tykj/setting/entity/vo/StatisticsParam.java
浏览文件 @
1be24adf
...
...
@@ -17,6 +17,6 @@ public class StatisticsParam {
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;
import
com.tykj.setting.entity.ConditionSetting
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.Modifying
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.List
;
public
interface
ConditionSettingRepository
extends
JpaRepository
<
ConditionSetting
,
Integer
>
{
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Modifying
void
deleteAllByScreenSettingId
(
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;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.core.type.TypeReference
;
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.vo.ColumnInfoVo
;
import
com.tykj.setting.entity.vo.DisplaySettingVo
;
import
com.tykj.setting.repository.DisplaySettingRepository
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -19,6 +23,9 @@ public class DisplaySettingService {
@Autowired
private
DisplaySettingRepository
displaySettingRepository
;
@Autowired
ColumnInfoDao
columnInfoDao
;
private
final
Integer
id
=
1
;
public
void
save
(
DisplaySettingVo
groupSettingVo
){
...
...
@@ -43,7 +50,15 @@ public class DisplaySettingService {
}
catch
(
JsonProcessingException
e
)
{
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
{
throw
new
RuntimeException
(
"未找到该数据"
);
}
...
...
src/main/java/com/tykj/setting/service/GroupSettingService.java
浏览文件 @
1be24adf
...
...
@@ -3,16 +3,21 @@ package com.tykj.setting.service;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.core.type.TypeReference
;
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.setting.entity.GroupSetting
;
import
com.tykj.setting.entity.vo.GroupSettingVo
;
import
com.tykj.setting.repository.GroupSettingRepository
;
import
org.checkerframework.checker.units.qual.A
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.Optional
;
import
java.util.stream.Collectors
;
@Service
...
...
@@ -21,6 +26,9 @@ public class GroupSettingService {
@Autowired
private
GroupSettingRepository
groupSettingRepository
;
@Autowired
ColumnInfoDao
columnInfoDao
;
public
void
save
(
GroupSettingVo
groupSettingVo
)
{
boolean
newData
=
Objects
.
isNull
(
groupSettingVo
.
getId
());
if
(
newData
)
{
...
...
@@ -42,13 +50,26 @@ public class GroupSettingService {
}
public
List
<
GroupSettingVo
>
findAll
()
{
return
groupSettingRepository
.
findAll
().
stream
()
List
<
GroupSettingVo
>
collect
=
groupSettingRepository
.
findAll
().
stream
()
.
map
(
this
::
groupSettingVo
)
.
collect
(
Collectors
.
toList
());
collect
.
forEach
(
item
->{
});
return
collect
;
}
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
)
{
...
...
@@ -73,6 +94,7 @@ public class GroupSettingService {
}
private
GroupSettingVo
groupSettingVo
(
GroupSetting
groupSetting
){
List
<
GroupCondition
>
groupConditions
=
new
ArrayList
<>();
try
{
groupConditions
=
new
ObjectMapper
().
readValue
(
groupSetting
.
getGroupConditions
(),
new
TypeReference
<
List
<
GroupCondition
>>()
{
...
...
@@ -80,11 +102,19 @@ public class GroupSettingService {
}
catch
(
JsonProcessingException
e
)
{
e
.
printStackTrace
();
}
String
columnName
=
""
;
Optional
<
ColumnInfo
>
byId
=
columnInfoDao
.
findById
(
groupSetting
.
getColumnId
());
if
(
byId
.
isPresent
()){
columnName
=
byId
.
get
().
getFieldName
();
}
return
new
GroupSettingVo
(
groupSetting
.
getId
(),
groupSetting
.
getModelId
(),
groupSetting
.
getColumnId
(),
groupSetting
.
getName
(),
columnName
,
groupConditions
);
}
...
...
src/main/java/com/tykj/setting/service/ScreenSettingService.java
浏览文件 @
1be24adf
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.ScreenSetting
;
import
com.tykj.setting.entity.vo.ScreenSettingVo
;
...
...
@@ -26,6 +29,10 @@ public class ScreenSettingService {
@Autowired
private
ConditionSettingRepository
conditionSettingRepository
;
@Autowired
ColumnInfoDao
columnInfoDao
;
public
void
save
(
ScreenSettingVo
screenSettingVo
){
boolean
newData
=
Objects
.
isNull
(
screenSettingVo
.
getId
());
if
(
newData
){
...
...
@@ -66,6 +73,14 @@ public class ScreenSettingService {
if
(
byId
.
isPresent
()){
ScreenSetting
screenSetting
=
byId
.
get
();
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
);
}
else
{
...
...
@@ -80,6 +95,14 @@ public class ScreenSettingService {
private
ScreenSettingVo
screenSettingVo
(
ScreenSetting
screenSetting
){
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
);
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论