Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
solo-1
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
solo-1
Commits
4ff35443
Unverified
Commit
4ff35443
authored
Apr 18, 2019
by
Liang Ding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🔥
#12764 删除评论接口
parent
13653c4c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
3 additions
and
146 deletions
+3
-146
src/main/java/org/b3log/solo/SoloServletListener.java
src/main/java/org/b3log/solo/SoloServletListener.java
+1
-3
src/main/java/org/b3log/solo/processor/console/CommentConsole.java
...java/org/b3log/solo/processor/console/CommentConsole.java
+1
-87
src/test/java/org/b3log/solo/service/CommentMgmtServiceTestCase.java
...va/org/b3log/solo/service/CommentMgmtServiceTestCase.java
+1
-56
No files found.
src/main/java/org/b3log/solo/SoloServletListener.java
View file @
4ff35443
...
@@ -58,7 +58,7 @@ import javax.servlet.http.HttpSessionEvent;
...
@@ -58,7 +58,7 @@ import javax.servlet.http.HttpSessionEvent;
*
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="http://vanessa.b3log.org">Vanessa</a>
* @author <a href="http://vanessa.b3log.org">Vanessa</a>
* @version 1.11.0.1
4, Mar 31
, 2019
* @version 1.11.0.1
5, Apr 18
, 2019
* @since 0.3.1
* @since 0.3.1
*/
*/
public
final
class
SoloServletListener
extends
AbstractServletListener
{
public
final
class
SoloServletListener
extends
AbstractServletListener
{
...
@@ -361,11 +361,9 @@ public final class SoloServletListener extends AbstractServletListener {
...
@@ -361,11 +361,9 @@ public final class SoloServletListener extends AbstractServletListener {
DispatcherServlet
.
get
(
"/console/categories/{page}/{pageSize}/{windowSize}"
,
categoryConsole:
:
getCategories
);
DispatcherServlet
.
get
(
"/console/categories/{page}/{pageSize}/{windowSize}"
,
categoryConsole:
:
getCategories
);
final
CommentConsole
commentConsole
=
beanManager
.
getReference
(
CommentConsole
.
class
);
final
CommentConsole
commentConsole
=
beanManager
.
getReference
(
CommentConsole
.
class
);
DispatcherServlet
.
delete
(
"/console/page/comment/{id}"
,
commentConsole:
:
removePageComment
);
DispatcherServlet
.
delete
(
"/console/article/comment/{id}"
,
commentConsole:
:
removeArticleComment
);
DispatcherServlet
.
delete
(
"/console/article/comment/{id}"
,
commentConsole:
:
removeArticleComment
);
DispatcherServlet
.
get
(
"/console/comments/{page}/{pageSize}/{windowSize}"
,
commentConsole:
:
getComments
);
DispatcherServlet
.
get
(
"/console/comments/{page}/{pageSize}/{windowSize}"
,
commentConsole:
:
getComments
);
DispatcherServlet
.
get
(
"/console/comments/article/{id}"
,
commentConsole:
:
getArticleComments
);
DispatcherServlet
.
get
(
"/console/comments/article/{id}"
,
commentConsole:
:
getArticleComments
);
DispatcherServlet
.
get
(
"/console/comments/page/{id}"
,
commentConsole:
:
getPageComments
);
final
LinkConsole
linkConsole
=
beanManager
.
getReference
(
LinkConsole
.
class
);
final
LinkConsole
linkConsole
=
beanManager
.
getReference
(
LinkConsole
.
class
);
DispatcherServlet
.
delete
(
"/console/link/{id}"
,
linkConsole:
:
removeLink
);
DispatcherServlet
.
delete
(
"/console/link/{id}"
,
linkConsole:
:
removeLink
);
...
...
src/main/java/org/b3log/solo/processor/console/CommentConsole.java
View file @
4ff35443
...
@@ -39,7 +39,7 @@ import java.util.List;
...
@@ -39,7 +39,7 @@ import java.util.List;
* Comment console request processing.
* Comment console request processing.
*
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.
0.0.5, Dec 11, 2018
* @version 1.
1.0.0, Apr 18, 2019
* @since 0.4.0
* @since 0.4.0
*/
*/
@RequestProcessor
@RequestProcessor
...
@@ -69,48 +69,6 @@ public class CommentConsole {
...
@@ -69,48 +69,6 @@ public class CommentConsole {
@Inject
@Inject
private
LangPropsService
langPropsService
;
private
LangPropsService
langPropsService
;
/**
* Removes a comment of an article by the specified request.
* <p>
* Renders the response with a json object, for example,
* <pre>
* {
* "sc": boolean,
* "msg": ""
* }
* </pre>
* </p>
*
* @param context the specified request context
*/
public
void
removePageComment
(
final
RequestContext
context
)
{
final
JsonRenderer
renderer
=
new
JsonRenderer
();
context
.
setRenderer
(
renderer
);
final
JSONObject
ret
=
new
JSONObject
();
renderer
.
setJSONObject
(
ret
);
try
{
final
String
commentId
=
context
.
pathVar
(
"id"
);
final
JSONObject
currentUser
=
Solos
.
getCurrentUser
(
context
.
getRequest
(),
context
.
getResponse
());
if
(!
commentQueryService
.
canAccessComment
(
commentId
,
currentUser
))
{
ret
.
put
(
Keys
.
STATUS_CODE
,
false
);
ret
.
put
(
Keys
.
MSG
,
langPropsService
.
get
(
"forbiddenLabel"
));
return
;
}
commentMgmtService
.
removePageComment
(
commentId
);
ret
.
put
(
Keys
.
STATUS_CODE
,
true
);
ret
.
put
(
Keys
.
MSG
,
langPropsService
.
get
(
"removeSuccLabel"
));
}
catch
(
final
Exception
e
)
{
LOGGER
.
log
(
Level
.
ERROR
,
e
.
getMessage
(),
e
);
ret
.
put
(
Keys
.
STATUS_CODE
,
false
);
ret
.
put
(
Keys
.
MSG
,
langPropsService
.
get
(
"removeFailLabel"
));
}
}
/**
/**
* Removes a comment of an article by the specified request.
* Removes a comment of an article by the specified request.
* <p>
* <p>
...
@@ -251,48 +209,4 @@ public class CommentConsole {
...
@@ -251,48 +209,4 @@ public class CommentConsole {
jsonObject
.
put
(
Keys
.
MSG
,
langPropsService
.
get
(
"getFailLabel"
));
jsonObject
.
put
(
Keys
.
MSG
,
langPropsService
.
get
(
"getFailLabel"
));
}
}
}
}
/**
* Gets comments of a page specified by the article id for administrator.
* <p>
* Renders the response with a json object, for example,
* <pre>
* {
* "sc": boolean,
* "comments": [{
* "oId": "",
* "commentName": "",
* "thumbnailUrl": "",
* "commentURL": "",
* "commentContent": "",
* "commentTime": long,
* "commentSharpURL": "",
* "isReply": boolean
* }, ....]
* }
* </pre>
* </p>
*
* @param context the specified request context
*/
public
void
getPageComments
(
final
RequestContext
context
)
{
final
JsonRenderer
renderer
=
new
JsonRenderer
();
context
.
setRenderer
(
renderer
);
final
JSONObject
ret
=
new
JSONObject
();
renderer
.
setJSONObject
(
ret
);
try
{
final
String
pageId
=
context
.
pathVar
(
"id"
);
final
List
<
JSONObject
>
comments
=
commentQueryService
.
getComments
(
pageId
);
ret
.
put
(
Comment
.
COMMENTS
,
comments
);
ret
.
put
(
Keys
.
STATUS_CODE
,
true
);
}
catch
(
final
Exception
e
)
{
LOGGER
.
log
(
Level
.
ERROR
,
e
.
getMessage
(),
e
);
final
JSONObject
jsonObject
=
new
JSONObject
().
put
(
Keys
.
STATUS_CODE
,
false
);
renderer
.
setJSONObject
(
jsonObject
);
jsonObject
.
put
(
Keys
.
MSG
,
langPropsService
.
get
(
"getFailLabel"
));
}
}
}
}
src/test/java/org/b3log/solo/service/CommentMgmtServiceTestCase.java
View file @
4ff35443
...
@@ -18,12 +18,10 @@
...
@@ -18,12 +18,10 @@
package
org
.
b3log
.
solo
.
service
;
package
org
.
b3log
.
solo
.
service
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.util.Requests
;
import
org.b3log.solo.AbstractTestCase
;
import
org.b3log.solo.AbstractTestCase
;
import
org.b3log.solo.model.Comment
;
import
org.b3log.solo.model.Comment
;
import
org.b3log.solo.model.Page
;
import
org.b3log.solo.model.Page
;
import
org.b3log.solo.util.Solos
;
import
org.b3log.solo.util.Solos
;
import
org.json.JSONArray
;
import
org.json.JSONObject
;
import
org.json.JSONObject
;
import
org.testng.Assert
;
import
org.testng.Assert
;
import
org.testng.annotations.Test
;
import
org.testng.annotations.Test
;
...
@@ -34,7 +32,7 @@ import java.util.List;
...
@@ -34,7 +32,7 @@ import java.util.List;
* {@link CommentMgmtService} test case.
* {@link CommentMgmtService} test case.
*
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.
3, Sep 16, 2018
* @version 1.0.0.
4, Apr 18, 2019
*/
*/
@Test
(
suiteName
=
"service"
)
@Test
(
suiteName
=
"service"
)
public
class
CommentMgmtServiceTestCase
extends
AbstractTestCase
{
public
class
CommentMgmtServiceTestCase
extends
AbstractTestCase
{
...
@@ -91,59 +89,6 @@ public class CommentMgmtServiceTestCase extends AbstractTestCase {
...
@@ -91,59 +89,6 @@ public class CommentMgmtServiceTestCase extends AbstractTestCase {
Assert
.
assertEquals
(
result
.
getJSONArray
(
Comment
.
COMMENTS
).
length
(),
2
);
Assert
.
assertEquals
(
result
.
getJSONArray
(
Comment
.
COMMENTS
).
length
(),
2
);
}
}
/**
* Add Page Comment.
*
* @throws Exception exception
*/
@Test
(
dependsOnMethods
=
"addArticleComment"
)
public
void
addPageComment
()
throws
Exception
{
addPage
();
final
PageQueryService
pageQueryService
=
getPageQueryService
();
final
JSONObject
paginationRequest
=
Solos
.
buildPaginationRequest
(
"1/10/20"
);
JSONObject
result
=
pageQueryService
.
getPages
(
paginationRequest
);
Assert
.
assertNotNull
(
result
);
Assert
.
assertEquals
(
result
.
getJSONArray
(
Page
.
PAGES
).
length
(),
1
);
final
JSONArray
pages
=
result
.
getJSONArray
(
Page
.
PAGES
);
final
CommentQueryService
commentQueryService
=
getCommentQueryService
();
result
=
commentQueryService
.
getComments
(
paginationRequest
);
Assert
.
assertNotNull
(
result
);
Assert
.
assertEquals
(
result
.
getJSONArray
(
Comment
.
COMMENTS
).
length
(),
2
);
// 2 article comments
final
CommentMgmtService
commentMgmtService
=
getCommentMgmtService
();
final
JSONObject
requestJSONObject
=
new
JSONObject
();
final
String
pageId
=
pages
.
getJSONObject
(
0
).
getString
(
Keys
.
OBJECT_ID
);
requestJSONObject
.
put
(
Keys
.
OBJECT_ID
,
pageId
);
requestJSONObject
.
put
(
Comment
.
COMMENT_NAME
,
"Solo"
);
requestJSONObject
.
put
(
Comment
.
COMMENT_URL
,
"comment URL"
);
requestJSONObject
.
put
(
Comment
.
COMMENT_CONTENT
,
"comment content"
);
final
JSONObject
addResult
=
commentMgmtService
.
addPageComment
(
requestJSONObject
);
Assert
.
assertNotNull
(
addResult
);
Assert
.
assertNotNull
(
addResult
.
getString
(
Keys
.
OBJECT_ID
));
Assert
.
assertNotNull
(
addResult
.
getString
(
Comment
.
COMMENT_T_DATE
));
Assert
.
assertNotNull
(
addResult
.
getString
(
Comment
.
COMMENT_THUMBNAIL_URL
));
Assert
.
assertNotNull
(
addResult
.
getString
(
Comment
.
COMMENT_SHARP_URL
));
result
=
commentQueryService
.
getComments
(
paginationRequest
);
Assert
.
assertNotNull
(
result
);
Assert
.
assertEquals
(
result
.
getJSONArray
(
Comment
.
COMMENTS
).
length
(),
3
);
// 2 article comments + 1 page comment
final
List
<
JSONObject
>
pageComments
=
commentQueryService
.
getComments
(
pageId
);
Assert
.
assertNotNull
(
pageComments
);
Assert
.
assertEquals
(
pageComments
.
size
(),
1
);
}
/**
/**
* Adds a page.
* Adds a page.
*
*
...
...
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