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
35360880
Commit
35360880
authored
Jun 15, 2021
by
刘基明
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
话题相关
parent
07d7c66a
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
142 additions
and
14 deletions
+142
-14
ThemeDTO.java
...src/main/java/com/tanpu/community/api/beans/ThemeDTO.java
+4
-0
TopicDTO.java
...src/main/java/com/tanpu/community/api/beans/TopicDTO.java
+6
-0
ThemeController.java
.../java/com/tanpu/community/controller/ThemeController.java
+37
-0
TopicController.java
.../java/com/tanpu/community/controller/TopicController.java
+50
-8
ThemeManager.java
...c/main/java/com/tanpu/community/manager/ThemeManager.java
+11
-0
TopicManager.java
...c/main/java/com/tanpu/community/manager/TopicManager.java
+18
-2
ThemeService.java
...c/main/java/com/tanpu/community/service/ThemeService.java
+12
-0
TopicService.java
...c/main/java/com/tanpu/community/service/TopicService.java
+4
-4
No files found.
community-api/src/main/java/com/tanpu/community/api/beans/ThemeDTO.java
0 → 100644
View file @
35360880
package
com
.
tanpu
.
community
.
api
.
beans
;
public
class
ThemeDTO
{
}
community-api/src/main/java/com/tanpu/community/api/beans/TopicDTO.java
View file @
35360880
...
@@ -44,6 +44,12 @@ public class TopicDTO implements Serializable {
...
@@ -44,6 +44,12 @@ public class TopicDTO implements Serializable {
@ApiModelProperty
(
value
=
"点赞量"
)
@ApiModelProperty
(
value
=
"点赞量"
)
private
Long
likeAmount
;
private
Long
likeAmount
;
@ApiModelProperty
(
value
=
"总用户数"
)
private
Long
UserAmount
;
@ApiModelProperty
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
return
"TopicEntity{"
+
return
"TopicEntity{"
+
...
...
community-service/src/main/java/com/tanpu/community/controller/ThemeController.java
0 → 100644
View file @
35360880
package
com
.
tanpu
.
community
.
controller
;
import
com.tanpu.community.api.beans.ThemeDTO
;
import
com.tanpu.community.dao.entity.community.ThemeEntity
;
import
com.tanpu.community.manager.ThemeManager
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.List
;
@RestController
@Slf4j
@RequestMapping
(
value
=
"/api/theme"
)
public
class
ThemeController
{
@Autowired
private
ThemeManager
themeManager
;
@RequestMapping
(
value
=
"/add"
)
public
void
insertTheme
(
@RequestBody
ThemeDTO
themeDTO
){
}
public
List
<
ThemeEntity
>
selectList
(){
return
null
;
}
public
String
commetOnTheme
(
String
themeId
,
String
commet
){
String
user
=
"liujm"
;
return
"success"
;
}
}
community-service/src/main/java/com/tanpu/community/controller/TopicController.java
View file @
35360880
...
@@ -6,6 +6,7 @@ import com.tanpu.community.api.beans.TopicDTO;
...
@@ -6,6 +6,7 @@ import com.tanpu.community.api.beans.TopicDTO;
import
com.tanpu.community.controller.convert.TopicConverter
;
import
com.tanpu.community.controller.convert.TopicConverter
;
import
com.tanpu.community.dao.entity.community.TopicEntity
;
import
com.tanpu.community.dao.entity.community.TopicEntity
;
import
com.tanpu.community.manager.TopicManager
;
import
com.tanpu.community.manager.TopicManager
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.Value
;
import
lombok.Value
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
...
@@ -15,6 +16,7 @@ import org.springframework.web.bind.MissingServletRequestParameterException;
...
@@ -15,6 +16,7 @@ import org.springframework.web.bind.MissingServletRequestParameterException;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.List
;
import
java.util.List
;
import
java.util.stream.Collectors
;
@RestController
@RestController
@Slf4j
@Slf4j
...
@@ -25,42 +27,82 @@ public class TopicController {
...
@@ -25,42 +27,82 @@ public class TopicController {
private
TopicManager
topicManager
;
private
TopicManager
topicManager
;
@PostMapping
(
value
=
"/queryTopicList"
)
@PostMapping
(
value
=
"/queryTopicList"
)
@ApiOperation
(
"查询所有的主题
列表
"
)
@ApiOperation
(
"查询所有的主题
详情
"
)
@ResponseBody
@ResponseBody
public
List
<
TopicDTO
>
getAllTopList
(
@RequestBody
String
content
){
public
List
<
TopicDTO
>
getAllTop
ic
List
(
@RequestBody
String
content
){
JSONObject
params
=
JSONObject
.
parseObject
(
content
);
JSONObject
params
=
JSONObject
.
parseObject
(
content
);
List
<
TopicEntity
>
allTopic
=
topicManager
.
getAllTopic
();
List
<
TopicEntity
>
allTopic
=
topicManager
.
getAllTopic
();
List
<
TopicDTO
>
topicDTOS
=
TopicConverter
.
convertToDTOs
(
allTopic
);
List
<
TopicDTO
>
topicDTOS
=
TopicConverter
.
convertToDTOs
(
allTopic
);
//获取浏览数据:浏览、发帖、回帖
return
topicDTOS
;
return
topicDTOS
;
}
}
@PostMapping
(
value
=
"/queryTopicList"
)
@ApiOperation
(
"查询所有的主题名称列表"
)
@ResponseBody
public
List
<
String
>
getTopicNameList
(
@RequestBody
String
content
){
JSONObject
params
=
JSONObject
.
parseObject
(
content
);
List
<
TopicEntity
>
allTopic
=
topicManager
.
getAllTopic
();
List
<
String
>
topictitiles
=
allTopic
.
stream
().
map
(
TopicEntity:
:
getTopicTitle
).
collect
(
Collectors
.
toList
());
//获取浏览数据:浏览、发帖、回帖
return
topictitiles
;
}
@PostMapping
(
value
=
"/insertTopic"
)
@PostMapping
(
value
=
"/insertTopic"
)
@ApiOperation
(
"新增主题主题"
)
@ResponseBody
@ResponseBody
public
String
addTopic
(
@RequestBody
String
topicTitle
){
public
String
addTopic
(
@RequestParam
String
topicTitle
){
topicManager
.
insertTopic
(
topicTitle
);
//TODO:获取登录用户信息
String
userId
=
"liujm"
;
topicManager
.
insertTopic
(
topicTitle
,
userId
);
return
"success"
;
}
@ApiOperation
(
"单个话题数据总览"
)
@PostMapping
(
"/selectOne"
)
@ResponseBody
public
String
selectOne
(
@RequestParam
String
topicId
)
throws
MissingServletRequestParameterException
{
if
(
StringUtils
.
isEmpty
(
topicId
)){
throw
new
MissingServletRequestParameterException
(
"topicId"
,
"String"
);
}
TopicDTO
topicDTO
=
topicManager
.
getDetail
(
topicId
);
return
"success"
;
return
"success"
;
}
}
@PostMapping
(
value
=
"/setTop"
)
@PostMapping
(
value
=
"/setTop"
)
@ApiOperation
(
"顶置/取消顶置主题"
)
@ResponseBody
@ResponseBody
public
String
setTopTopic
(
@Request
Body
String
topicId
,
@RequestBody
boolean
setTop
)
throws
MissingServletRequestParameterException
{
public
String
setTopTopic
(
@Request
Param
String
topicId
,
@RequestParam
boolean
setTop
)
throws
MissingServletRequestParameterException
{
if
(
StringUtils
.
isEmpty
(
topicId
)){
if
(
StringUtils
.
isEmpty
(
topicId
)){
throw
new
MissingServletRequestParameterException
(
"topicId"
,
"
Lo
ng"
);
throw
new
MissingServletRequestParameterException
(
"topicId"
,
"
Stri
ng"
);
}
}
topicManager
.
setTopTopic
(
topicId
,
setTop
);
topicManager
.
setTopTopic
(
topicId
,
setTop
);
return
"success"
;
return
"success"
;
}
}
@PostMapping
(
value
=
"/setConceal"
)
@PostMapping
(
value
=
"/setConceal"
)
@ApiOperation
(
"隐藏/显示主题"
)
@ResponseBody
@ResponseBody
public
String
setConceal
(
@Request
Body
String
topicId
,
@RequestBody
boolean
setConceal
)
throws
MissingServletRequestParameterException
{
public
String
setConceal
(
@Request
Param
String
topicId
,
@RequestParam
boolean
setConceal
)
throws
MissingServletRequestParameterException
{
if
(
StringUtils
.
isEmpty
(
topicId
)){
if
(
StringUtils
.
isEmpty
(
topicId
)){
throw
new
MissingServletRequestParameterException
(
"topicId"
,
"
Lo
ng"
);
throw
new
MissingServletRequestParameterException
(
"topicId"
,
"
Stri
ng"
);
}
}
topicManager
.
setTopicConceal
(
topicId
,
setConceal
);
topicManager
.
setTopicConceal
(
topicId
,
setConceal
);
return
"success"
;
return
"success"
;
}
}
@PostMapping
(
value
=
"/modifyViewNum"
)
@ApiOperation
(
"主题浏览数调整"
)
@ResponseBody
public
String
modifyViewNum
(
@RequestParam
String
topicId
,
@RequestParam
Long
modifyMount
)
throws
MissingServletRequestParameterException
{
if
(
StringUtils
.
isEmpty
(
topicId
)){
throw
new
MissingServletRequestParameterException
(
"topicId"
,
"String"
);
}
//修改浏览量
return
"success"
;
}
...
...
community-service/src/main/java/com/tanpu/community/manager/ThemeManager.java
0 → 100644
View file @
35360880
package
com
.
tanpu
.
community
.
manager
;
import
com.tanpu.community.service.ThemeService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
@Service
public
class
ThemeManager
{
@Autowired
private
ThemeService
themeService
;
}
community-service/src/main/java/com/tanpu/community/manager/TopicManager.java
View file @
35360880
package
com
.
tanpu
.
community
.
manager
;
package
com
.
tanpu
.
community
.
manager
;
import
com.tanpu.common.exception.BizException
;
import
com.tanpu.common.exception.BizException
;
import
com.tanpu.community.api.beans.TopicDTO
;
import
com.tanpu.community.controller.convert.TopicConverter
;
import
com.tanpu.community.dao.entity.community.TopicEntity
;
import
com.tanpu.community.dao.entity.community.TopicEntity
;
import
com.tanpu.community.service.TopicService
;
import
com.tanpu.community.service.TopicService
;
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.time.LocalDateTime
;
import
java.util.List
;
import
java.util.List
;
@Service
@Service
...
@@ -14,10 +17,16 @@ public class TopicManager {
...
@@ -14,10 +17,16 @@ public class TopicManager {
@Autowired
@Autowired
private
TopicService
topicService
;
private
TopicService
topicService
;
public
void
insertTopic
(
String
topicTitle
){
public
void
insertTopic
(
String
topicTitle
,
String
userId
){
TopicEntity
topicEntity
=
new
TopicEntity
();
TopicEntity
topicEntity
=
new
TopicEntity
();
topicEntity
.
setCreateBy
(
userId
);
topicEntity
.
setUpdateBy
(
userId
);
topicEntity
.
setTopicTitle
(
topicTitle
);
topicEntity
.
setTopicTitle
(
topicTitle
);
topicEntity
.
setCreateTime
(
LocalDateTime
.
now
());
topicEntity
.
setUpdateTime
(
LocalDateTime
.
now
());
topicEntity
.
setIsTop
(
0
);
topicEntity
.
setIsConceal
(
0
);
topicService
.
addTopic
(
topicEntity
);
}
}
...
@@ -51,4 +60,11 @@ public class TopicManager {
...
@@ -51,4 +60,11 @@ public class TopicManager {
topicService
.
updateTopicNotConceal
(
topicId
);
topicService
.
updateTopicNotConceal
(
topicId
);
}
}
}
}
public
TopicDTO
getDetail
(
String
topicId
)
{
TopicEntity
topicEntity
=
topicService
.
queryById
(
topicId
);
TopicDTO
topicDTO
=
TopicConverter
.
convertToDTO
(
topicEntity
);
//TODO:添加实时数据
return
topicDTO
;
}
}
}
community-service/src/main/java/com/tanpu/community/service/ThemeService.java
0 → 100644
View file @
35360880
package
com
.
tanpu
.
community
.
service
;
import
com.tanpu.community.dao.mapper.community.ThemeMapper
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
@Service
public
class
ThemeService
{
@Autowired
private
ThemeMapper
themeMapper
;
}
community-service/src/main/java/com/tanpu/community/service/TopicService.java
View file @
35360880
...
@@ -31,28 +31,28 @@ public class TopicService {
...
@@ -31,28 +31,28 @@ public class TopicService {
public
void
updateTopicToTop
(
String
topicId
){
public
void
updateTopicToTop
(
String
topicId
){
UpdateWrapper
<
TopicEntity
>
updateWrapper
=
new
UpdateWrapper
<>();
UpdateWrapper
<
TopicEntity
>
updateWrapper
=
new
UpdateWrapper
<>();
updateWrapper
.
eq
(
"id"
,
topicId
);
updateWrapper
.
eq
(
"id"
,
topicId
);
updateWrapper
.
set
(
"is
Top"
,
true
);
updateWrapper
.
set
(
"is
_top"
,
1
);
topicMapper
.
update
(
null
,
updateWrapper
);
topicMapper
.
update
(
null
,
updateWrapper
);
}
}
public
void
updateTopicNotTop
(
String
topicId
){
public
void
updateTopicNotTop
(
String
topicId
){
UpdateWrapper
<
TopicEntity
>
updateWrapper
=
new
UpdateWrapper
<>();
UpdateWrapper
<
TopicEntity
>
updateWrapper
=
new
UpdateWrapper
<>();
updateWrapper
.
eq
(
"id"
,
topicId
);
updateWrapper
.
eq
(
"id"
,
topicId
);
updateWrapper
.
set
(
"is
Top"
,
false
);
updateWrapper
.
set
(
"is
_top"
,
0
);
topicMapper
.
update
(
null
,
updateWrapper
);
topicMapper
.
update
(
null
,
updateWrapper
);
}
}
public
void
updateTopicToConceal
(
String
topicId
){
public
void
updateTopicToConceal
(
String
topicId
){
UpdateWrapper
<
TopicEntity
>
updateWrapper
=
new
UpdateWrapper
<>();
UpdateWrapper
<
TopicEntity
>
updateWrapper
=
new
UpdateWrapper
<>();
updateWrapper
.
eq
(
"id"
,
topicId
);
updateWrapper
.
eq
(
"id"
,
topicId
);
updateWrapper
.
set
(
"is
Conceal"
,
true
);
updateWrapper
.
set
(
"is
_conceal"
,
1
);
topicMapper
.
update
(
null
,
updateWrapper
);
topicMapper
.
update
(
null
,
updateWrapper
);
}
}
public
void
updateTopicNotConceal
(
String
topicId
){
public
void
updateTopicNotConceal
(
String
topicId
){
UpdateWrapper
<
TopicEntity
>
updateWrapper
=
new
UpdateWrapper
<>();
UpdateWrapper
<
TopicEntity
>
updateWrapper
=
new
UpdateWrapper
<>();
updateWrapper
.
eq
(
"id"
,
topicId
);
updateWrapper
.
eq
(
"id"
,
topicId
);
updateWrapper
.
set
(
"is
Conceal"
,
false
);
updateWrapper
.
set
(
"is
_conceal"
,
0
);
topicMapper
.
update
(
null
,
updateWrapper
);
topicMapper
.
update
(
null
,
updateWrapper
);
}
}
...
...
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