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
118af37e
Commit
118af37e
authored
Feb 06, 2020
by
段启岩
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/fix-issue#12'
parents
8b43006a
1d5e6574
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
9 additions
and
36 deletions
+9
-36
src/main/java/cn/meteor/beyondclouds/modules/question/api/QuestionApi.java
+3
-19
src/main/java/cn/meteor/beyondclouds/modules/question/service/IQuestionService.java
+3
-2
src/main/java/cn/meteor/beyondclouds/modules/question/service/impl/QuestionServiceImpl.java
+2
-3
src/main/java/cn/meteor/beyondclouds/modules/question/util/QuestionUtils.java
+0
-11
src/main/resources/application.yml
+1
-1
No files found.
src/main/java/cn/meteor/beyondclouds/modules/question/api/QuestionApi.java
View file @
118af37e
...
...
@@ -72,15 +72,9 @@ public class QuestionApi {
//设置用户ID(问题发布者ID)
question
.
setUserId
((
String
)
subject
.
getId
());
//祛除重复标签
HashSet
<
String
>
tags
=
QuestionUtils
.
toHashSet
(
questionForm
.
getTagIds
());
//祛除重复话题
HashSet
<
String
>
topicIds
=
QuestionUtils
.
toHashSet
(
questionForm
.
getTopicIds
());
//发布问题
try
{
questionService
.
postQuestion
(
question
,
questionForm
.
getQuestionDetail
(),
tags
,
topicIds
);
questionService
.
postQuestion
(
question
,
questionForm
.
getQuestionDetail
(),
questionForm
.
getTagIds
(),
questionForm
.
getTopicIds
()
);
return
Response
.
success
();
}
catch
(
QuestionServiceException
e
)
{
e
.
printStackTrace
();
...
...
@@ -131,19 +125,9 @@ public class QuestionApi {
//3.设置用户ID
question
.
setUserId
((
String
)
subject
.
getId
());
//4.祛除重复标签
HashSet
<
String
>
tags
=
null
;
if
(!
CollectionUtils
.
isEmpty
(
questionForm
.
getTagIds
()))
{
tags
=
QuestionUtils
.
toHashSet
(
questionForm
.
getTagIds
());
}
//5.祛除重复话题
HashSet
<
String
>
topicIds
=
null
;
if
(!
CollectionUtils
.
isEmpty
(
questionForm
.
getTopicIds
()))
{
topicIds
=
QuestionUtils
.
toHashSet
(
questionForm
.
getTopicIds
());
}
//6.修改问题
//4.修改问题
try
{
questionService
.
updateQuestion
(
question
,
questionForm
.
getQuestionDetail
(),
tags
,
topicIds
);
questionService
.
updateQuestion
(
question
,
questionForm
.
getQuestionDetail
(),
questionForm
.
getTagIds
(),
questionForm
.
getTopicIds
()
);
return
Response
.
success
();
}
catch
(
QuestionServiceException
e
)
{
e
.
printStackTrace
();
...
...
src/main/java/cn/meteor/beyondclouds/modules/question/service/IQuestionService.java
View file @
118af37e
...
...
@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
java.util.HashSet
;
import
java.util.List
;
/**
* <p>
...
...
@@ -28,7 +29,7 @@ public interface IQuestionService extends IService<Question> {
* @param topicIds 话题ID
* @throws QuestionServiceException 问题业务异常
*/
void
postQuestion
(
Question
question
,
String
questionDetail
,
HashSet
<
String
>
tags
,
HashSe
t
<
String
>
topicIds
)
throws
QuestionServiceException
;
void
postQuestion
(
Question
question
,
String
questionDetail
,
List
<
String
>
tags
,
Lis
t
<
String
>
topicIds
)
throws
QuestionServiceException
;
/**
* 删除问题
...
...
@@ -46,7 +47,7 @@ public interface IQuestionService extends IService<Question> {
* @param topicIds 话题ID
* @throws QuestionServiceException 问题业务异常
*/
void
updateQuestion
(
Question
question
,
String
questionDetail
,
HashSet
<
String
>
tags
,
HashSe
t
<
String
>
topicIds
)
throws
QuestionServiceException
;
void
updateQuestion
(
Question
question
,
String
questionDetail
,
List
<
String
>
tags
,
Lis
t
<
String
>
topicIds
)
throws
QuestionServiceException
;
/**
...
...
src/main/java/cn/meteor/beyondclouds/modules/question/service/impl/QuestionServiceImpl.java
View file @
118af37e
...
...
@@ -99,7 +99,7 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
public
void
postQuestion
(
Question
question
,
String
questionDetail
,
HashSet
<
String
>
tagIds
,
HashSe
t
<
String
>
topicIds
)
throws
QuestionServiceException
{
public
void
postQuestion
(
Question
question
,
String
questionDetail
,
List
<
String
>
tagIds
,
Lis
t
<
String
>
topicIds
)
throws
QuestionServiceException
{
//1.检查问题标题是否以?结尾
if
(!
question
.
getQuestionTitle
().
endsWith
(
QUESTION_END_EN
)
&&
!
question
.
getQuestionTitle
().
endsWith
(
QUESTION_END_CN
)){
throw
new
QuestionServiceException
(
QuestionErrorCode
.
QUESTION_END_ERROR
);
...
...
@@ -128,7 +128,6 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
if
(!
CollectionUtils
.
isEmpty
(
topicIds
))
{
// 获取要引用的话题,不正确的话题ID会被自动过滤
List
<
String
>
existsTopicIds
=
topicService
.
listByIds
(
topicIds
).
stream
().
map
(
Topic:
:
getTopicId
).
collect
(
Collectors
.
toList
());
if
(!
CollectionUtils
.
isEmpty
(
existsTopicIds
))
{
List
<
TopicReference
>
topicReferenceList
=
new
ArrayList
<>();
for
(
String
topicId
:
existsTopicIds
)
{
...
...
@@ -203,7 +202,7 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
public
void
updateQuestion
(
Question
question
,
String
questionDetail
,
HashSet
<
String
>
tagIds
,
HashSe
t
<
String
>
topicIds
)
throws
QuestionServiceException
{
public
void
updateQuestion
(
Question
question
,
String
questionDetail
,
List
<
String
>
tagIds
,
Lis
t
<
String
>
topicIds
)
throws
QuestionServiceException
{
//1.判断自己是否发布过此问题
QueryWrapper
<
Question
>
questionQueryWrapper
=
new
QueryWrapper
<>();
questionQueryWrapper
.
eq
(
"question_id"
,
question
.
getQuestionId
())
...
...
src/main/java/cn/meteor/beyondclouds/modules/question/util/QuestionUtils.java
View file @
118af37e
...
...
@@ -25,15 +25,4 @@ public class QuestionUtils {
return
queryWrapper
;
}
/**
* 处理标签
* @param tagIdList 标签
* @return Set
*/
public
static
HashSet
<
String
>
toHashSet
(
List
<
String
>
tagIdList
){
HashSet
<
String
>
tagIds
=
new
HashSet
<>();
tagIds
.
addAll
(
tagIdList
);
return
tagIds
;
}
}
src/main/resources/application.yml
View file @
118af37e
...
...
@@ -3,7 +3,7 @@ spring:
driver-class-name
:
com.mysql.cj.jdbc.Driver
url
:
jdbc:mysql://127.0.0.1:3306/beyond_clouds?useUnicode=true&characterEncoding=UTF-8&useSSL=false&allowPublicKeyRetrieval=true
username
:
root
password
:
2018006709
password
:
197442
swagger
:
enable
:
true
...
...
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