Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
beyond-clouds
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
4
Issues
4
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
段启岩
beyond-clouds
Commits
fc57e42f
Commit
fc57e42f
authored
Feb 12, 2020
by
胡明森
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
通过话题id与话题name获取话题详情
parent
08a40aa6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
8 deletions
+28
-8
src/main/java/cn/meteor/beyondclouds/modules/topic/api/TopicApi.java
+7
-3
src/main/java/cn/meteor/beyondclouds/modules/topic/service/ITopicService.java
+4
-2
src/main/java/cn/meteor/beyondclouds/modules/topic/service/impl/TopicServiceImpl.java
+17
-3
No files found.
src/main/java/cn/meteor/beyondclouds/modules/topic/api/TopicApi.java
View file @
fc57e42f
...
...
@@ -83,10 +83,14 @@ public class TopicApi {
@Anonymous
@ApiOperation
(
"话题详情"
)
@GetMapping
(
"/topic/{topicId}"
)
public
Response
getTopic
(
@PathVariable
(
"topicId"
)
String
topicId
)
{
@GetMapping
(
"/topic/{topicBy}"
)
public
Response
getTopic
(
@PathVariable
(
"topicBy"
)
String
topicBy
,
String
by
)
{
if
(
by
==
null
)
{
by
=
"id"
;
}
try
{
Topic
topic
=
topicService
.
getTopic
(
topic
Id
);
Topic
topic
=
topicService
.
getTopic
(
topic
By
,
by
);
return
Response
.
success
(
topic
);
}
catch
(
TopicServiceException
e
)
{
e
.
printStackTrace
();
...
...
src/main/java/cn/meteor/beyondclouds/modules/topic/service/ITopicService.java
View file @
fc57e42f
...
...
@@ -46,10 +46,12 @@ public interface ITopicService extends IService<Topic> {
/**
* 话题详情
* @param topicId
* @param topicBy
* @param by
* @return
* @throws TopicServiceException
*/
Topic
getTopic
(
String
topic
Id
)
throws
TopicServiceException
;
Topic
getTopic
(
String
topic
By
,
String
by
)
throws
TopicServiceException
;
/**
* 我关注的话题
...
...
src/main/java/cn/meteor/beyondclouds/modules/topic/service/impl/TopicServiceImpl.java
View file @
fc57e42f
...
...
@@ -99,10 +99,24 @@ public class TopicServiceImpl extends ServiceImpl<TopicMapper, Topic> implements
@Override
public
Topic
getTopic
(
String
topic
Id
)
throws
TopicServiceException
{
public
Topic
getTopic
(
String
topic
By
,
String
by
)
throws
TopicServiceException
{
//1. 获取话题
Topic
topic
=
getById
(
topicId
);
//1. 判断by为话题id,还是话题名称
Topic
topic
;
if
(
"id"
.
equals
(
by
))
{
// 通过话题id获取话题
topic
=
getById
(
topicBy
);
}
else
{
// 通过话题name获取话题
QueryWrapper
<
Topic
>
topicQueryWrapper
=
new
QueryWrapper
<>();
topicQueryWrapper
.
eq
(
"topic_name"
,
topicBy
);
topic
=
getOne
(
topicQueryWrapper
);
}
//2. 找不到该话题,抛出业务异常
if
(
topic
==
null
)
{
...
...
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