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
010b039d
Unverified
Commit
010b039d
authored
Jan 08, 2020
by
Liang Ding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
✨
#17
parent
6f395e3e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
65 additions
and
66 deletions
+65
-66
src/main/java/org/b3log/solo/service/ArticleMgmtService.java
src/main/java/org/b3log/solo/service/ArticleMgmtService.java
+30
-31
src/main/java/org/b3log/solo/service/StatisticMgmtService.java
...ain/java/org/b3log/solo/service/StatisticMgmtService.java
+35
-35
No files found.
src/main/java/org/b3log/solo/service/ArticleMgmtService.java
View file @
010b039d
...
@@ -52,7 +52,7 @@ import static org.b3log.solo.model.Article.*;
...
@@ -52,7 +52,7 @@ import static org.b3log.solo.model.Article.*;
* Article management service.
* Article management service.
*
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.3.4.
0, Nov 7, 2019
* @version 1.3.4.
1, Jan 8, 2020
* @since 0.3.5
* @since 0.3.5
*/
*/
@Service
@Service
...
@@ -649,36 +649,35 @@ public class ArticleMgmtService {
...
@@ -649,36 +649,35 @@ public class ArticleMgmtService {
* @throws ServiceException service exception
* @throws ServiceException service exception
*/
*/
public
void
incViewCount
(
final
String
articleId
)
throws
ServiceException
{
public
void
incViewCount
(
final
String
articleId
)
throws
ServiceException
{
JSONObject
article
;
// JSONObject article;
//
try
{
// try {
article
=
articleRepository
.
get
(
articleId
);
// article = articleRepository.get(articleId);
//
if
(
null
==
article
)
{
// if (null == article) {
return
;
// return;
}
// }
}
catch
(
final
RepositoryException
e
)
{
// } catch (final RepositoryException e) {
LOGGER
.
log
(
Level
.
ERROR
,
"Gets article [id="
+
articleId
+
"] failed"
,
e
);
// LOGGER.log(Level.ERROR, "Gets article [id=" + articleId + "] failed", e);
//
return
;
// return;
}
// }
//
final
Transaction
transaction
=
articleRepository
.
beginTransaction
();
// final Transaction transaction = articleRepository.beginTransaction();
// try {
try
{
// article.put(Article.ARTICLE_VIEW_COUNT, article.getInt(Article.ARTICLE_VIEW_COUNT) + 1);
article
.
put
(
Article
.
ARTICLE_VIEW_COUNT
,
article
.
getInt
(
Article
.
ARTICLE_VIEW_COUNT
)
+
1
);
// articleRepository.update(articleId, article, ARTICLE_VIEW_COUNT);
articleRepository
.
update
(
articleId
,
article
,
ARTICLE_VIEW_COUNT
);
//
// transaction.commit();
transaction
.
commit
();
// } catch (final Exception e) {
}
catch
(
final
Exception
e
)
{
// if (transaction.isActive()) {
if
(
transaction
.
isActive
())
{
// transaction.rollback();
transaction
.
rollback
();
// }
}
//
// LOGGER.log(Level.WARN, "Updates article view count failed");
LOGGER
.
log
(
Level
.
WARN
,
"Updates article view count failed"
);
//
// throw new ServiceException(e);
throw
new
ServiceException
(
e
);
// }
}
}
}
/**
/**
...
...
src/main/java/org/b3log/solo/service/StatisticMgmtService.java
View file @
010b039d
...
@@ -48,7 +48,7 @@ import java.util.concurrent.ConcurrentHashMap;
...
@@ -48,7 +48,7 @@ import java.util.concurrent.ConcurrentHashMap;
* Statistic management service.
* Statistic management service.
*
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 2.0.1.
4, Nov 19, 2019
* @version 2.0.1.
5, Jan 8, 2020
* @since 0.5.0
* @since 0.5.0
*/
*/
@Service
@Service
...
@@ -211,40 +211,40 @@ public class StatisticMgmtService {
...
@@ -211,40 +211,40 @@ public class StatisticMgmtService {
* @throws ServiceException service exception
* @throws ServiceException service exception
*/
*/
public
void
incBlogViewCount
(
final
RequestContext
context
,
final
Response
response
)
throws
ServiceException
{
public
void
incBlogViewCount
(
final
RequestContext
context
,
final
Response
response
)
throws
ServiceException
{
if
(
Solos
.
isBot
(
context
.
getRequest
()))
{
//
if (Solos.isBot(context.getRequest())) {
return
;
//
return;
}
//
}
//
if
(
hasBeenServed
(
context
,
response
))
{
//
if (hasBeenServed(context, response)) {
return
;
//
return;
}
//
}
//
final
Transaction
transaction
=
optionRepository
.
beginTransaction
();
//
final Transaction transaction = optionRepository.beginTransaction();
JSONObject
statistic
;
//
JSONObject statistic;
try
{
//
try {
statistic
=
optionRepository
.
get
(
Option
.
ID_C_STATISTIC_BLOG_VIEW_COUNT
);
//
statistic = optionRepository.get(Option.ID_C_STATISTIC_BLOG_VIEW_COUNT);
if
(
null
==
statistic
)
{
//
if (null == statistic) {
return
;
//
return;
}
//
}
//
LOGGER
.
log
(
Level
.
TRACE
,
"Before inc blog view count is [{0}]"
,
statistic
);
//
LOGGER.log(Level.TRACE, "Before inc blog view count is [{0}]", statistic);
//
statistic
.
put
(
Option
.
OPTION_VALUE
,
statistic
.
optInt
(
Option
.
OPTION_VALUE
)
+
1
);
//
statistic.put(Option.OPTION_VALUE, statistic.optInt(Option.OPTION_VALUE) + 1);
//
updateStatistic
(
Option
.
ID_C_STATISTIC_BLOG_VIEW_COUNT
,
statistic
);
//
updateStatistic(Option.ID_C_STATISTIC_BLOG_VIEW_COUNT, statistic);
//
transaction
.
commit
();
//
transaction.commit();
}
catch
(
final
RepositoryException
e
)
{
//
} catch (final RepositoryException e) {
if
(
transaction
.
isActive
())
{
//
if (transaction.isActive()) {
transaction
.
rollback
();
//
transaction.rollback();
}
//
}
//
LOGGER
.
log
(
Level
.
ERROR
,
"Updates blog view count failed"
,
e
);
//
LOGGER.log(Level.ERROR, "Updates blog view count failed", e);
//
return
;
//
return;
}
//
}
//
LOGGER
.
log
(
Level
.
TRACE
,
"Inced blog view count[statistic={0}]"
,
statistic
);
//
LOGGER.log(Level.TRACE, "Inced blog view count[statistic={0}]", statistic);
}
}
/**
/**
...
...
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