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
13653c4c
Unverified
Commit
13653c4c
authored
Apr 18, 2019
by
Liang Ding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🔥
#12764 移除页面发布评论接口
parent
7f555a70
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
292 deletions
+12
-292
src/main/java/org/b3log/solo/model/Page.java
src/main/java/org/b3log/solo/model/Page.java
+3
-1
src/main/java/org/b3log/solo/processor/CommentProcessor.java
src/main/java/org/b3log/solo/processor/CommentProcessor.java
+5
-99
src/main/java/org/b3log/solo/service/CommentMgmtService.java
src/main/java/org/b3log/solo/service/CommentMgmtService.java
+4
-192
No files found.
src/main/java/org/b3log/solo/model/Page.java
View file @
13653c4c
...
...
@@ -21,7 +21,7 @@ package org.b3log.solo.model;
* This class defines all page model relevant keys.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.1.0.
1, Feb 6
, 2019
* @version 1.1.0.
2, Apr 18
, 2019
* @since 0.3.1
*/
public
final
class
Page
{
...
...
@@ -82,6 +82,8 @@ public final class Page {
* A normal customized page.
* </ul>
* </p>
* <p>
* "page" 类型已经废除 https://github.com/b3log/solo/issues/12764
*/
public
static
final
String
PAGE_TYPE
=
"pageType"
;
...
...
src/main/java/org/b3log/solo/processor/CommentProcessor.java
View file @
13653c4c
...
...
@@ -29,12 +29,14 @@ import org.b3log.latke.servlet.RequestContext;
import
org.b3log.latke.servlet.annotation.RequestProcessing
;
import
org.b3log.latke.servlet.annotation.RequestProcessor
;
import
org.b3log.latke.servlet.renderer.JsonRenderer
;
import
org.b3log.solo.model.*
;
import
org.b3log.solo.model.Article
;
import
org.b3log.solo.model.Comment
;
import
org.b3log.solo.model.Common
;
import
org.b3log.solo.model.Option
;
import
org.b3log.solo.service.CommentMgmtService
;
import
org.b3log.solo.service.OptionQueryService
;
import
org.b3log.solo.service.UserMgmtService
;
import
org.b3log.solo.service.UserQueryService
;
import
org.b3log.solo.util.Emotions
;
import
org.b3log.solo.util.Skins
;
import
org.b3log.solo.util.Solos
;
import
org.json.JSONObject
;
...
...
@@ -48,7 +50,7 @@ import java.util.Map;
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="https://hacpai.com/member/armstrong">ArmstrongCN</a>
* @version 1.
3.3.7, Mar 17
, 2019
* @version 1.
4.0.0, Apr 18
, 2019
* @since 0.3.1
*/
@RequestProcessor
...
...
@@ -89,102 +91,6 @@ public class CommentProcessor {
@Inject
private
OptionQueryService
optionQueryService
;
/**
* Adds a comment to a page.
*
* <p>
* Request json:
* <pre>
* {
* "captcha": "",
* "oId": pageId,
* "commentName": "",
* "commentURL": "",
* "commentContent": "",
* "commentOriginalCommentId": "" // optional, if exists this key, the comment is an reply
* }
* </pre>
* </p>
* <p>
* Renders the response with a json object, for example,
* <pre>
* {
* "oId": generatedCommentId,
* "sc": "COMMENT_PAGE_SUCC"
* "commentDate": "", // yyyy/MM/dd HH:mm:ss
* "commentSharpURL": "",
* "commentThumbnailURL": "",
* "commentOriginalCommentName": "" // if exists this key, the comment is an reply
* }
* </pre>
* </p>
*
* @param context the specified context
*/
@RequestProcessing
(
value
=
"/page/comments"
,
method
=
HttpMethod
.
POST
)
public
void
addPageComment
(
final
RequestContext
context
)
{
final
JSONObject
requestJSONObject
=
context
.
requestJSON
();
requestJSONObject
.
put
(
Common
.
TYPE
,
Page
.
PAGE
);
fillCommenter
(
requestJSONObject
,
context
);
final
JSONObject
jsonObject
=
commentMgmtService
.
checkAddCommentRequest
(
requestJSONObject
);
final
JsonRenderer
renderer
=
new
JsonRenderer
();
context
.
setRenderer
(
renderer
);
renderer
.
setJSONObject
(
jsonObject
);
if
(!
jsonObject
.
optBoolean
(
Keys
.
STATUS_CODE
))
{
LOGGER
.
log
(
Level
.
WARN
,
"Can't add comment[msg={0}]"
,
jsonObject
.
optString
(
Keys
.
MSG
));
return
;
}
if
(!
Solos
.
isLoggedIn
(
context
))
{
jsonObject
.
put
(
Keys
.
STATUS_CODE
,
false
);
jsonObject
.
put
(
Keys
.
MSG
,
"Need login"
);
return
;
}
try
{
final
JSONObject
addResult
=
commentMgmtService
.
addPageComment
(
requestJSONObject
);
final
Map
<
String
,
Object
>
dataModel
=
new
HashMap
<>();
dataModel
.
put
(
Comment
.
COMMENT
,
addResult
);
final
JSONObject
page
=
addResult
.
optJSONObject
(
Page
.
PAGE
);
page
.
put
(
Common
.
COMMENTABLE
,
addResult
.
opt
(
Common
.
COMMENTABLE
));
page
.
put
(
Common
.
PERMALINK
,
addResult
.
opt
(
Common
.
PERMALINK
));
dataModel
.
put
(
Article
.
ARTICLE
,
page
);
// 添加评论优化 https://github.com/b3log/solo/issues/12246
try
{
final
String
skinDirName
=
(
String
)
context
.
attr
(
Keys
.
TEMAPLTE_DIR_NAME
);
final
Template
template
=
Skins
.
getSkinTemplate
(
context
,
"common-comment.ftl"
);
final
JSONObject
preference
=
optionQueryService
.
getPreference
();
Skins
.
fillLangs
(
preference
.
optString
(
Option
.
ID_C_LOCALE_STRING
),
skinDirName
,
dataModel
);
Keys
.
fillServer
(
dataModel
);
final
StringWriter
stringWriter
=
new
StringWriter
();
template
.
process
(
dataModel
,
stringWriter
);
stringWriter
.
close
();
String
cmtTpl
=
stringWriter
.
toString
();
cmtTpl
=
Emotions
.
convert
(
cmtTpl
);
addResult
.
put
(
"cmtTpl"
,
cmtTpl
);
}
catch
(
final
Exception
e
)
{
// 1.9.0 向后兼容
}
addResult
.
put
(
Keys
.
STATUS_CODE
,
true
);
renderer
.
setJSONObject
(
addResult
);
}
catch
(
final
Exception
e
)
{
LOGGER
.
log
(
Level
.
ERROR
,
"Can not add comment on page"
,
e
);
jsonObject
.
put
(
Keys
.
STATUS_CODE
,
false
);
jsonObject
.
put
(
Keys
.
MSG
,
langPropsService
.
get
(
"addFailLabel"
));
}
}
/**
* Adds a comment to an article.
*
...
...
src/main/java/org/b3log/solo/service/CommentMgmtService.java
View file @
13653c4c
This diff is collapsed.
Click to expand it.
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