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
fc1465a5
Commit
fc1465a5
authored
Feb 11, 2020
by
胡明森
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
发布话题不可重复
parent
d76b5876
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
4 deletions
+16
-4
src/main/java/cn/meteor/beyondclouds/modules/topic/api/TopicApi.java
+5
-0
src/main/java/cn/meteor/beyondclouds/modules/topic/service/ITopicService.java
+1
-1
src/main/java/cn/meteor/beyondclouds/modules/topic/service/impl/TopicServiceImpl.java
+10
-3
No files found.
src/main/java/cn/meteor/beyondclouds/modules/topic/api/TopicApi.java
View file @
fc1465a5
...
@@ -42,8 +42,13 @@ public class TopicApi {
...
@@ -42,8 +42,13 @@ public class TopicApi {
@PostMapping
(
"/topic"
)
@PostMapping
(
"/topic"
)
public
Response
createTopic
(
@RequestBody
@Valid
CreateTopicForm
createTopicForm
,
@CurrentSubject
Subject
subject
)
{
public
Response
createTopic
(
@RequestBody
@Valid
CreateTopicForm
createTopicForm
,
@CurrentSubject
Subject
subject
)
{
try
{
TopicDetail
topic
=
topicService
.
createTopic
(
String
.
valueOf
(
subject
.
getId
()),
createTopicForm
.
getTopicName
());
TopicDetail
topic
=
topicService
.
createTopic
(
String
.
valueOf
(
subject
.
getId
()),
createTopicForm
.
getTopicName
());
return
Response
.
success
(
topic
);
return
Response
.
success
(
topic
);
}
catch
(
TopicServiceException
e
)
{
e
.
printStackTrace
();
return
Response
.
error
(
e
);
}
}
}
...
...
src/main/java/cn/meteor/beyondclouds/modules/topic/service/ITopicService.java
View file @
fc1465a5
...
@@ -25,7 +25,7 @@ public interface ITopicService extends IService<Topic> {
...
@@ -25,7 +25,7 @@ public interface ITopicService extends IService<Topic> {
* @param topicName
* @param topicName
* @return TopicDetail
* @return TopicDetail
*/
*/
TopicDetail
createTopic
(
String
userId
,
String
topicName
);
TopicDetail
createTopic
(
String
userId
,
String
topicName
)
throws
TopicServiceException
;
/**
/**
* 检索话题
* 检索话题
...
...
src/main/java/cn/meteor/beyondclouds/modules/topic/service/impl/TopicServiceImpl.java
View file @
fc1465a5
...
@@ -53,15 +53,22 @@ public class TopicServiceImpl extends ServiceImpl<TopicMapper, Topic> implements
...
@@ -53,15 +53,22 @@ public class TopicServiceImpl extends ServiceImpl<TopicMapper, Topic> implements
}
}
@Override
@Override
public
TopicDetail
createTopic
(
String
userId
,
String
topicName
)
{
public
TopicDetail
createTopic
(
String
userId
,
String
topicName
)
throws
TopicServiceException
{
//1. 创建话题
//1. 检测是否存在该话题
QueryWrapper
<
Topic
>
topicQueryWrapper
=
new
QueryWrapper
<>();
topicQueryWrapper
.
eq
(
"topic_name"
,
topicName
);
if
(
getOne
(
topicQueryWrapper
)
!=
null
)
{
throw
new
TopicServiceException
(
TopicErrorCode
.
TOPIC_EXISTS
);
}
//2. 创建话题
Topic
topic
=
new
Topic
();
Topic
topic
=
new
Topic
();
topic
.
setUserId
(
userId
);
topic
.
setUserId
(
userId
);
topic
.
setTopicName
(
topicName
);
topic
.
setTopicName
(
topicName
);
save
(
topic
);
save
(
topic
);
//
2
. 返回话题的id与话题名称
//
3
. 返回话题的id与话题名称
TopicDetail
topicDetail
=
new
TopicDetail
();
TopicDetail
topicDetail
=
new
TopicDetail
();
BeanUtils
.
copyProperties
(
topic
,
topicDetail
);
BeanUtils
.
copyProperties
(
topic
,
topicDetail
);
return
topicDetail
;
return
topicDetail
;
...
...
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