Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
D
dataDeclaration
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
黄夏豪
dataDeclaration
Commits
d5029e7e
提交
d5029e7e
authored
5月 21, 2021
作者:
黄承天
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[设置模块]字段改动
上级
ddff351d
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
93 行增加
和
28 行删除
+93
-28
GroupSettingController.java
...a/com/tykj/setting/controller/GroupSettingController.java
+5
-5
GroupSetting.java
src/main/java/com/tykj/setting/entity/GroupSetting.java
+4
-9
GroupSettingVo.java
src/main/java/com/tykj/setting/entity/vo/GroupSettingVo.java
+32
-0
GroupSettingService.java
...in/java/com/tykj/setting/service/GroupSettingService.java
+52
-14
没有找到文件。
src/main/java/com/tykj/setting/controller/GroupSettingController.java
浏览文件 @
d5029e7e
package
com
.
tykj
.
setting
.
controller
;
import
com.tykj.base.result.ResultUtil
;
import
com.tykj.setting.entity.
GroupSetting
;
import
com.tykj.setting.entity.
vo.GroupSettingVo
;
import
com.tykj.setting.service.GroupSettingService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
...
...
@@ -19,15 +19,15 @@ public class GroupSettingController {
@PostMapping
@ApiOperation
(
"新增分类设置"
)
public
ResponseEntity
save
(
@RequestBody
GroupSetting
groupSetting
){
groupSettingService
.
save
(
groupSetting
);
public
ResponseEntity
save
(
@RequestBody
GroupSetting
Vo
groupSettingVo
){
groupSettingService
.
save
(
groupSetting
Vo
);
return
ResultUtil
.
success
(
""
,
"保存成功"
);
}
@PutMapping
@ApiOperation
(
"更新分类设置"
)
public
ResponseEntity
update
(
@RequestBody
GroupSetting
groupSetting
){
groupSettingService
.
update
(
groupSetting
);
public
ResponseEntity
update
(
@RequestBody
GroupSetting
Vo
groupSettingVo
){
groupSettingService
.
update
(
groupSetting
Vo
);
return
ResultUtil
.
success
(
""
,
"更新成功"
);
}
...
...
src/main/java/com/tykj/setting/entity/GroupSetting.java
浏览文件 @
d5029e7e
package
com
.
tykj
.
setting
.
entity
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
javax.persistence.Entity
;
import
javax.persistence.GeneratedValue
;
import
javax.persistence.GenerationType
;
import
javax.persistence.Id
;
import
javax.persistence.*
;
@AllArgsConstructor
@NoArgsConstructor
...
...
@@ -18,16 +14,15 @@ public class GroupSetting {
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
@ApiModelProperty
(
"主键"
)
private
Integer
id
;
@ApiModelProperty
(
"模型ID"
)
private
Integer
modelId
;
@ApiModelProperty
(
"字段ID"
)
private
Integer
columnId
;
@ApiModelProperty
(
"名称"
)
private
String
name
;
@Column
(
columnDefinition
=
"text"
)
private
String
groupConditions
;
}
src/main/java/com/tykj/setting/entity/vo/GroupSettingVo.java
0 → 100644
浏览文件 @
d5029e7e
package
com
.
tykj
.
setting
.
entity
.
vo
;
import
com.tykj.model_layer.entity.vo.GroupCondition
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.util.List
;
@AllArgsConstructor
@NoArgsConstructor
@Data
public
class
GroupSettingVo
{
@ApiModelProperty
(
"主键"
)
private
Integer
id
;
@ApiModelProperty
(
"模型ID"
)
private
Integer
modelId
;
@ApiModelProperty
(
"字段ID"
)
private
Integer
columnId
;
@ApiModelProperty
(
"名称"
)
private
String
name
;
@ApiModelProperty
(
"分类条件"
)
private
List
<
GroupCondition
>
groupConditions
;
}
src/main/java/com/tykj/setting/service/GroupSettingService.java
浏览文件 @
d5029e7e
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.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.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
public
class
GroupSettingService
{
...
...
@@ -15,35 +21,34 @@ public class GroupSettingService {
@Autowired
private
GroupSettingRepository
groupSettingRepository
;
public
void
save
(
GroupSetting
groupSetting
)
{
boolean
newData
=
Objects
.
isNull
(
groupSetting
.
getId
());
public
void
save
(
GroupSetting
Vo
groupSettingVo
)
{
boolean
newData
=
Objects
.
isNull
(
groupSetting
Vo
.
getId
());
if
(
newData
)
{
GroupSetting
groupSetting
=
groupSetting
(
groupSettingVo
);
groupSettingRepository
.
save
(
groupSetting
);
}
else
{
throw
new
RuntimeException
(
"新增数据不可附带id"
);
}
}
public
void
update
(
GroupSetting
groupSetting
)
{
boolean
exist
=
Objects
.
nonNull
(
groupSetting
.
getId
())
&&
groupSettingRepository
.
existsById
(
groupSetting
.
getId
());
public
void
update
(
GroupSetting
Vo
groupSettingVo
)
{
boolean
exist
=
Objects
.
nonNull
(
groupSetting
Vo
.
getId
())
&&
groupSettingRepository
.
existsById
(
groupSettingVo
.
getId
());
if
(
exist
)
{
GroupSetting
groupSetting
=
groupSetting
(
groupSettingVo
);
groupSettingRepository
.
save
(
groupSetting
);
}
else
{
throw
new
RuntimeException
(
"未找到该id的数据"
);
}
}
public
List
<
GroupSetting
>
findAll
()
{
return
groupSettingRepository
.
findAll
();
public
List
<
GroupSettingVo
>
findAll
()
{
return
groupSettingRepository
.
findAll
().
stream
()
.
map
(
this
::
groupSettingVo
)
.
collect
(
Collectors
.
toList
());
}
public
GroupSetting
findById
(
Integer
id
)
{
Optional
<
GroupSetting
>
byId
=
groupSettingRepository
.
findById
(
id
);
if
(
byId
.
isPresent
())
{
return
byId
.
get
();
}
else
{
throw
new
RuntimeException
(
"未找到该id的数据"
);
}
public
GroupSettingVo
findById
(
Integer
id
)
{
return
groupSettingRepository
.
findById
(
id
).
map
(
this
::
groupSettingVo
).
orElseThrow
(()
->
new
RuntimeException
(
"未找到该id的数据"
));
}
public
void
deleteById
(
Integer
id
)
{
...
...
@@ -51,4 +56,37 @@ public class GroupSettingService {
}
private
GroupSetting
groupSetting
(
GroupSettingVo
groupSettingVo
){
String
groupConditions
=
"[]"
;
try
{
groupConditions
=
new
ObjectMapper
().
writeValueAsString
(
groupSettingVo
.
getGroupConditions
());
}
catch
(
JsonProcessingException
e
)
{
e
.
printStackTrace
();
}
return
new
GroupSetting
(
groupSettingVo
.
getId
(),
groupSettingVo
.
getModelId
(),
groupSettingVo
.
getColumnId
(),
groupSettingVo
.
getName
(),
groupConditions
);
}
private
GroupSettingVo
groupSettingVo
(
GroupSetting
groupSetting
){
List
<
GroupCondition
>
groupConditions
=
new
ArrayList
<>();
try
{
groupConditions
=
new
ObjectMapper
().
readValue
(
groupSetting
.
getGroupConditions
(),
new
TypeReference
<
List
<
GroupCondition
>>()
{
});
}
catch
(
JsonProcessingException
e
)
{
e
.
printStackTrace
();
}
return
new
GroupSettingVo
(
groupSetting
.
getId
(),
groupSetting
.
getModelId
(),
groupSetting
.
getColumnId
(),
groupSetting
.
getName
(),
groupConditions
);
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论