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
0c8815ee
Unverified
Commit
0c8815ee
authored
Feb 23, 2019
by
Liang Ding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🔥
删除冗余代码
parent
4c683c6f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
56 deletions
+5
-56
src/main/java/org/b3log/solo/service/ArticleQueryService.java
...main/java/org/b3log/solo/service/ArticleQueryService.java
+5
-56
No files found.
src/main/java/org/b3log/solo/service/ArticleQueryService.java
View file @
0c8815ee
...
@@ -389,21 +389,6 @@ public class ArticleQueryService {
...
@@ -389,21 +389,6 @@ public class ArticleQueryService {
return
article
.
getBoolean
(
Article
.
ARTICLE_HAD_BEEN_PUBLISHED
);
return
article
.
getBoolean
(
Article
.
ARTICLE_HAD_BEEN_PUBLISHED
);
}
}
/**
* Gets all unpublished articles.
*
* @return articles all unpublished articles
* @throws RepositoryException repository exception
*/
public
List
<
JSONObject
>
getUnpublishedArticles
()
throws
RepositoryException
{
final
Map
<
String
,
SortDirection
>
sorts
=
new
HashMap
<>();
sorts
.
put
(
Article
.
ARTICLE_CREATED
,
SortDirection
.
DESCENDING
);
sorts
.
put
(
Article
.
ARTICLE_PUT_TOP
,
SortDirection
.
DESCENDING
);
final
Query
query
=
new
Query
().
setFilter
(
new
PropertyFilter
(
Article
.
ARTICLE_IS_PUBLISHED
,
FilterOperator
.
EQUAL
,
true
));
return
articleRepository
.
getList
(
query
);
}
/**
/**
* Gets the recent articles with the specified fetch size.
* Gets the recent articles with the specified fetch size.
*
*
...
@@ -468,8 +453,7 @@ public class ArticleQueryService {
...
@@ -468,8 +453,7 @@ public class ArticleQueryService {
final
JSONArray
tags
=
new
JSONArray
();
final
JSONArray
tags
=
new
JSONArray
();
final
List
<
JSONObject
>
tagArticleRelations
=
tagArticleRepository
.
getByArticleId
(
articleId
);
final
List
<
JSONObject
>
tagArticleRelations
=
tagArticleRepository
.
getByArticleId
(
articleId
);
for
(
int
i
=
0
;
i
<
tagArticleRelations
.
size
();
i
++)
{
for
(
final
JSONObject
tagArticleRelation
:
tagArticleRelations
)
{
final
JSONObject
tagArticleRelation
=
tagArticleRelations
.
get
(
i
);
final
String
tagId
=
tagArticleRelation
.
getString
(
Tag
.
TAG
+
"_"
+
Keys
.
OBJECT_ID
);
final
String
tagId
=
tagArticleRelation
.
getString
(
Tag
.
TAG
+
"_"
+
Keys
.
OBJECT_ID
);
final
JSONObject
tag
=
tagRepository
.
get
(
tagId
);
final
JSONObject
tag
=
tagRepository
.
get
(
tagId
);
...
@@ -757,7 +741,7 @@ public class ArticleQueryService {
...
@@ -757,7 +741,7 @@ public class ArticleQueryService {
final
int
maxTagCnt
=
displayCnt
>
tagTitles
.
length
?
tagTitles
.
length
:
displayCnt
;
final
int
maxTagCnt
=
displayCnt
>
tagTitles
.
length
?
tagTitles
.
length
:
displayCnt
;
final
String
articleId
=
article
.
getString
(
Keys
.
OBJECT_ID
);
final
String
articleId
=
article
.
getString
(
Keys
.
OBJECT_ID
);
final
List
<
JSONObject
>
articles
=
new
ArrayList
<
JSONObject
>();
final
List
<
JSONObject
>
articles
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
maxTagCnt
;
i
++)
{
// XXX: should average by tag?
for
(
int
i
=
0
;
i
<
maxTagCnt
;
i
++)
{
// XXX: should average by tag?
final
String
tagTitle
=
tagTitles
[
i
];
final
String
tagTitle
=
tagTitles
[
i
];
...
@@ -803,7 +787,7 @@ public class ArticleQueryService {
...
@@ -803,7 +787,7 @@ public class ArticleQueryService {
}
}
final
List
<
Integer
>
randomIntegers
=
CollectionUtils
.
getRandomIntegers
(
0
,
articles
.
size
()
-
1
,
displayCnt
);
final
List
<
Integer
>
randomIntegers
=
CollectionUtils
.
getRandomIntegers
(
0
,
articles
.
size
()
-
1
,
displayCnt
);
final
List
<
JSONObject
>
ret
=
new
ArrayList
<
JSONObject
>();
final
List
<
JSONObject
>
ret
=
new
ArrayList
<>();
for
(
final
int
index
:
randomIntegers
)
{
for
(
final
int
index
:
randomIntegers
)
{
ret
.
add
(
articles
.
get
(
index
));
ret
.
add
(
articles
.
get
(
index
));
...
@@ -817,22 +801,6 @@ public class ArticleQueryService {
...
@@ -817,22 +801,6 @@ public class ArticleQueryService {
}
}
}
}
/**
* Determines an article specified by the given article id is published.
*
* @param articleId the given article id
* @return {@code true} if it is published
* @throws ServiceException service exception
*/
public
boolean
isArticlePublished
(
final
String
articleId
)
throws
ServiceException
{
try
{
return
articleRepository
.
isPublished
(
articleId
);
}
catch
(
final
RepositoryException
e
)
{
LOGGER
.
log
(
Level
.
ERROR
,
"Determines the article publish status failed[articleId="
+
articleId
+
"]"
,
e
);
throw
new
ServiceException
(
e
);
}
}
/**
/**
* Gets the next article(by create date) by the specified article id.
* Gets the next article(by create date) by the specified article id.
* <p>
* <p>
...
@@ -902,25 +870,6 @@ public class ArticleQueryService {
...
@@ -902,25 +870,6 @@ public class ArticleQueryService {
}
}
}
}
/**
* Gets an article by the specified article permalink.
* <p>
* <b>Note</b>: The article content and abstract is raw (no editor type processing).
* </p>
*
* @param articlePermalink the specified article permalink
* @return an article, returns {@code null} if not found
* @throws ServiceException service exception
*/
public
JSONObject
getArticleByPermalink
(
final
String
articlePermalink
)
throws
ServiceException
{
try
{
return
articleRepository
.
getByPermalink
(
articlePermalink
);
}
catch
(
final
RepositoryException
e
)
{
LOGGER
.
log
(
Level
.
ERROR
,
"Gets an article[articlePermalink="
+
articlePermalink
+
"] failed"
,
e
);
throw
new
ServiceException
(
e
);
}
}
/**
/**
* Gets <em>published</em> articles by the specified author id, current page number and page size.
* Gets <em>published</em> articles by the specified author id, current page number and page size.
*
*
...
@@ -1045,7 +994,7 @@ public class ArticleQueryService {
...
@@ -1045,7 +994,7 @@ public class ArticleQueryService {
* @param articles the specified articles
* @param articles the specified articles
* @see #removeUnusedProperties(org.json.JSONObject)
* @see #removeUnusedProperties(org.json.JSONObject)
*/
*/
p
ublic
void
removeUnusedProperties
(
final
List
<
JSONObject
>
articles
)
{
p
rivate
void
removeUnusedProperties
(
final
List
<
JSONObject
>
articles
)
{
for
(
final
JSONObject
article
:
articles
)
{
for
(
final
JSONObject
article
:
articles
)
{
removeUnusedProperties
(
article
);
removeUnusedProperties
(
article
);
}
}
...
@@ -1064,7 +1013,7 @@ public class ArticleQueryService {
...
@@ -1064,7 +1013,7 @@ public class ArticleQueryService {
* @param article the specified article
* @param article the specified article
* @see #removeUnusedProperties(java.util.List)
* @see #removeUnusedProperties(java.util.List)
*/
*/
p
ublic
void
removeUnusedProperties
(
final
JSONObject
article
)
{
p
rivate
void
removeUnusedProperties
(
final
JSONObject
article
)
{
article
.
remove
(
Keys
.
OBJECT_ID
);
article
.
remove
(
Keys
.
OBJECT_ID
);
article
.
remove
(
Article
.
ARTICLE_AUTHOR_ID
);
article
.
remove
(
Article
.
ARTICLE_AUTHOR_ID
);
article
.
remove
(
Article
.
ARTICLE_ABSTRACT
);
article
.
remove
(
Article
.
ARTICLE_ABSTRACT
);
...
...
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