Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in
Toggle navigation
T
tanpu-community
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
探普后端
tanpu-community
Commits
8c40abcc
Commit
8c40abcc
authored
Jul 16, 2021
by
刘基明
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
热点数据
parent
a98e8975
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
21 deletions
+46
-21
ThemeController.java
.../java/com/tanpu/community/controller/ThemeController.java
+0
-3
ThemeManager.java
...c/main/java/com/tanpu/community/manager/ThemeManager.java
+15
-9
ThemeAttachmentService.java
...a/com/tanpu/community/service/ThemeAttachmentService.java
+11
-3
ConvertUtil.java
...e/src/main/java/com/tanpu/community/util/ConvertUtil.java
+20
-6
No files found.
community-service/src/main/java/com/tanpu/community/controller/ThemeController.java
View file @
8c40abcc
...
...
@@ -35,9 +35,6 @@ public class ThemeController {
@ResponseBody
public
CommonResp
<
CreateThemeResp
>
publishTheme
(
@Validated
@RequestBody
CreateThemeReq
req
)
{
String
userId
=
userHolder
.
getUserId
();
if
(
StringUtils
.
isEmpty
(
userId
)){
throw
new
BizException
(
"用户为空"
);
}
return
CommonResp
.
success
(
themeManager
.
publishTheme
(
req
,
userId
));
}
...
...
community-service/src/main/java/com/tanpu/community/manager/ThemeManager.java
View file @
8c40abcc
...
...
@@ -73,18 +73,24 @@ public class ThemeManager {
BeanUtils
.
copyProperties
(
req
,
themeEntity
);
themeEntity
.
setAuthorId
(
userId
);
themeEntity
.
setContent
(
JsonUtil
.
toJson
(
req
.
getContent
()));
//保存附件表
List
<
ThemeAttachmentEntity
>
themeAttachments
=
ConvertUtil
.
themeReqToAttachmentList
(
req
,
themeEntity
.
getThemeId
());
if
(
StringUtils
.
isEmpty
(
req
.
getEditThemeId
()))
{
//新建
themeService
.
insertTheme
(
themeEntity
);
themeAttachmentService
.
insertList
(
themeAttachments
);
}
else
{
//修改
themeService
.
update
(
themeEntity
,
req
.
getEditThemeId
());
themeEntity
.
setThemeId
(
req
.
getEditThemeId
());
themeAttachmentService
.
deleteByThemeId
(
req
.
getEditThemeId
());
themeAttachmentService
.
insertList
(
themeAttachments
);
}
//保存附件表
List
<
ThemeAttachmentEntity
>
themeAttachments
=
ConvertUtil
.
themeReqToAttachmentList
(
req
,
themeEntity
.
getThemeId
());
themeAttachmentService
.
insertList
(
themeAttachments
);
return
CreateThemeResp
.
builder
().
themeId
(
themeEntity
.
getThemeId
()).
build
();
}
...
...
@@ -311,14 +317,14 @@ public class ThemeManager {
String
formerThemeId
=
themeQo
.
getFormerThemeId
();
if
(
StringUtils
.
isNotEmpty
(
formerThemeId
))
{
ThemeQo
formerTheme
=
ConvertUtil
.
themeEntityToQo2
(
themeService
.
queryByThemeId
(
formerThemeId
));
if
(
formerTheme
==
null
)
{
throw
new
BizException
(
"转发主题Id错误,id:"
+
formerThemeId
);
if
(
formerTheme
!=
null
)
{
//单个查询详情
productService
.
getAttachDetail
(
formerTheme
);
FormerThemeQo
f
=
ConvertUtil
.
themeQo2FormerThemeQo
(
formerTheme
);
themeQo
.
setFormerTheme
(
f
);
}
//单个查询详情
productService
.
getAttachDetail
(
formerTheme
);
FormerThemeQo
f
=
ConvertUtil
.
themeQo2FormerThemeQo
(
formerTheme
);
themeQo
.
setFormerTheme
(
f
);
}
}
...
...
community-service/src/main/java/com/tanpu/community/service/ThemeAttachmentService.java
View file @
8c40abcc
package
com
.
tanpu
.
community
.
service
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper
;
import
com.tanpu.community.api.enums.DeleteTagEnum
;
import
com.tanpu.community.dao.entity.community.ThemeAttachmentEntity
;
import
com.tanpu.community.dao.mapper.community.ThemeAttachmentMapper
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.annotation.Resource
;
import
java.util.List
;
...
...
@@ -17,14 +18,21 @@ public class ThemeAttachmentService {
public
List
<
ThemeAttachmentEntity
>
selectByThemeId
(
String
themeId
){
return
themeAttachmentMapper
.
selectList
(
new
LambdaQueryWrapper
<
ThemeAttachmentEntity
>()
.
eq
(
ThemeAttachmentEntity:
:
getThemeId
,
themeId
));
.
eq
(
ThemeAttachmentEntity:
:
getThemeId
,
themeId
)
.
eq
(
ThemeAttachmentEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
));
}
@Transactional
public
void
insertList
(
List
<
ThemeAttachmentEntity
>
themeAttachments
)
{
for
(
ThemeAttachmentEntity
themeAttachment
:
themeAttachments
)
{
themeAttachmentMapper
.
insert
(
themeAttachment
);
}
return
;
}
public
int
deleteByThemeId
(
String
themeId
)
{
ThemeAttachmentEntity
target
=
ThemeAttachmentEntity
.
builder
().
deleteTag
(
DeleteTagEnum
.
DELETED
.
getCode
()).
build
();
LambdaUpdateWrapper
<
ThemeAttachmentEntity
>
update
=
new
LambdaUpdateWrapper
<
ThemeAttachmentEntity
>().
eq
(
ThemeAttachmentEntity:
:
getThemeId
,
themeId
);
return
themeAttachmentMapper
.
update
(
target
,
update
);
}
}
community-service/src/main/java/com/tanpu/community/util/ConvertUtil.java
View file @
8c40abcc
...
...
@@ -166,12 +166,26 @@ public class ConvertUtil {
.
themeId
(
themeId
)
.
build
());
}
}
else
{
list
.
add
(
ThemeAttachmentEntity
.
builder
()
.
attachType
(
Integer
.
valueOf
(
content
.
getType
()))
.
attachId
(
content
.
getValue
())
.
themeId
(
themeId
)
.
build
());
}
else
if
((
content
.
getType
().
equals
(
RelTypeEnum
.
SINGLE_IMG
.
type
)))
{
if
(
StringUtils
.
isEmpty
(
content
.
getValue
())){
list
.
add
(
ThemeAttachmentEntity
.
builder
()
.
attachType
(
Integer
.
valueOf
(
content
.
getType
()))
.
attachId
(
content
.
getValue
())
.
themeId
(
themeId
)
.
build
());
}
else
{
List
<
ImagesDTO
>
imgList
=
content
.
getImgList
();
for
(
ImagesDTO
imagesDTO
:
imgList
)
{
list
.
add
(
ThemeAttachmentEntity
.
builder
()
.
attachType
(
Integer
.
valueOf
(
RelTypeEnum
.
SINGLE_IMG
.
type
))
.
attachId
(
imagesDTO
.
getRelId
())
.
themeId
(
themeId
)
.
build
());
}
}
}
else
{
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment