Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
midjourney-proxy
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
徐少华
midjourney-proxy
Commits
c1d9795c
Commit
c1d9795c
authored
Sep 12, 2018
by
songxiang
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
http://192.168.89.173/rays/pcloud-common-parent.git
parents
a798b4d5
373fae58
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
13 deletions
+20
-13
SolrUtils.java
...src/main/java/com/pcloud/common/utils/solr/SolrUtils.java
+20
-13
No files found.
pcloud-common/src/main/java/com/pcloud/common/utils/solr/SolrUtils.java
View file @
c1d9795c
...
@@ -35,17 +35,17 @@ public class SolrUtils {
...
@@ -35,17 +35,17 @@ public class SolrUtils {
private
static
final
SimpleDateFormat
UTC_FULL_DATE_FORMAT
=
new
SimpleDateFormat
(
"yyyy-MM-dd'T'HH:mm:ss'Z'"
);
private
static
final
SimpleDateFormat
UTC_FULL_DATE_FORMAT
=
new
SimpleDateFormat
(
"yyyy-MM-dd'T'HH:mm:ss'Z'"
);
private
static
CloudSolrClient
solrClient
;
private
static
String
defaultCollection
;
private
static
String
defaultCollection
;
private
static
CloudSolrClient
solrClient
;
/**
/**
* 新增或修改索引(id主键存在时为更新)
* 新增或修改索引(id主键存在时为更新)
* @param solrDto solr索引DTO
* @param solrDto solr索引DTO
* @return 是否成功
* @return 是否成功
*/
*/
public
static
Boolean
add
(
SolrDto
solrDto
)
{
public
static
Boolean
add
(
SolrDto
solrDto
)
{
return
add
(
solrClient
.
getDefaultCollection
(),
solrDto
);
return
add
(
getDefaultCollection
(),
solrDto
);
}
}
/**
/**
...
@@ -71,7 +71,7 @@ public class SolrUtils {
...
@@ -71,7 +71,7 @@ public class SolrUtils {
* @return 是否成功
* @return 是否成功
*/
*/
public
static
Boolean
add
(
List
<
SolrDto
>
list
)
{
public
static
Boolean
add
(
List
<
SolrDto
>
list
)
{
return
add
(
solrClient
.
getDefaultCollection
(),
list
);
return
add
(
getDefaultCollection
(),
list
);
}
}
/**
/**
...
@@ -97,7 +97,7 @@ public class SolrUtils {
...
@@ -97,7 +97,7 @@ public class SolrUtils {
* @return 是否成功
* @return 是否成功
*/
*/
public
static
Boolean
deleteById
(
String
id
)
{
public
static
Boolean
deleteById
(
String
id
)
{
return
deleteById
(
solrClient
.
getDefaultCollection
(),
id
);
return
deleteById
(
getDefaultCollection
(),
id
);
}
}
/**
/**
...
@@ -123,7 +123,7 @@ public class SolrUtils {
...
@@ -123,7 +123,7 @@ public class SolrUtils {
* @return 是否成功
* @return 是否成功
*/
*/
public
static
Boolean
deleteByQuery
(
String
query
)
{
public
static
Boolean
deleteByQuery
(
String
query
)
{
return
deleteByQuery
(
solrClient
.
getDefaultCollection
(),
query
);
return
deleteByQuery
(
getDefaultCollection
(),
query
);
}
}
/**
/**
...
@@ -149,7 +149,7 @@ public class SolrUtils {
...
@@ -149,7 +149,7 @@ public class SolrUtils {
* @return SolrDto
* @return SolrDto
*/
*/
public
static
SolrDto
getById
(
String
id
)
{
public
static
SolrDto
getById
(
String
id
)
{
return
getById
(
solrClient
.
getDefaultCollection
(),
id
);
return
getById
(
getDefaultCollection
(),
id
);
}
}
/**
/**
...
@@ -178,7 +178,7 @@ public class SolrUtils {
...
@@ -178,7 +178,7 @@ public class SolrUtils {
* @return SolrDto Map
* @return SolrDto Map
*/
*/
public
static
Map
<
String
,
SolrDto
>
getById
(
List
<
String
>
ids
)
{
public
static
Map
<
String
,
SolrDto
>
getById
(
List
<
String
>
ids
)
{
return
getById
(
solrClient
.
getDefaultCollection
(),
ids
);
return
getById
(
getDefaultCollection
(),
ids
);
}
}
/**
/**
...
@@ -214,7 +214,7 @@ public class SolrUtils {
...
@@ -214,7 +214,7 @@ public class SolrUtils {
* @return SolrResult
* @return SolrResult
*/
*/
public
static
SolrResult
search
(
SolrQueryParam
param
)
{
public
static
SolrResult
search
(
SolrQueryParam
param
)
{
return
search
(
solrClient
.
getDefaultCollection
(),
param
);
return
search
(
getDefaultCollection
(),
param
);
}
}
/**
/**
...
@@ -368,14 +368,21 @@ public class SolrUtils {
...
@@ -368,14 +368,21 @@ public class SolrUtils {
return
UTC_FULL_DATE_FORMAT
.
format
(
calendar
.
getTime
());
return
UTC_FULL_DATE_FORMAT
.
format
(
calendar
.
getTime
());
}
}
@Autowired
/**
public
void
setSolrClient
(
SolrClient
solrClient
)
{
* 获取默认集合
SolrUtils
.
solrClient
=
(
CloudSolrClient
)
solrClient
;
*/
SolrUtils
.
solrClient
.
setDefaultCollection
(
defaultCollection
);
private
static
String
getDefaultCollection
()
{
return
null
==
solrClient
.
getDefaultCollection
()
?
defaultCollection
:
solrClient
.
getDefaultCollection
();
}
}
@Value
(
"${solr.default.collection}"
)
@Value
(
"${solr.default.collection}"
)
public
void
setDefaultCollection
(
String
defaultCollection
)
{
public
void
setDefaultCollection
(
String
defaultCollection
)
{
SolrUtils
.
defaultCollection
=
defaultCollection
;
SolrUtils
.
defaultCollection
=
defaultCollection
;
}
}
@Autowired
public
void
setSolrClient
(
SolrClient
solrClient
)
{
SolrUtils
.
solrClient
=
(
CloudSolrClient
)
solrClient
;
SolrUtils
.
solrClient
.
setDefaultCollection
(
defaultCollection
);
}
}
}
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