-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5eb9423
commit fd7b3c1
Showing
7 changed files
with
366 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
src/main/java/com/search/docsearch/entity/vo/GoogleSearchParams.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* Copyright (c) 2024 openEuler Community | ||
EasySoftware is licensed under the Mulan PSL v2. | ||
You can use this software according to the terms and conditions of the Mulan PSL v2. | ||
You may obtain a copy of Mulan PSL v2 at: | ||
http://license.coscl.org.cn/MulanPSL2 | ||
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, | ||
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, | ||
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. | ||
See the Mulan PSL v2 for more details. | ||
*/ | ||
package com.search.docsearch.entity.vo; | ||
|
||
|
||
import jakarta.validation.constraints.NotBlank; | ||
import jakarta.validation.constraints.Pattern; | ||
import jakarta.validation.constraints.Size; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
|
||
@Getter | ||
@Setter | ||
public class GoogleSearchParams { | ||
|
||
/** | ||
* The keyword to search for. | ||
*/ | ||
@NotBlank(message = "keyword can not be null") | ||
@Pattern(regexp = "^[\\u4E00-\\u9FA5A-Za-z0-9.()$\\-_ ]+$", message = "Include only letters, digits, and special characters(_-()$.), Contain 1 to 100 characters.") | ||
@Size(max = 100) | ||
private String keyWord; | ||
/** | ||
* The starting index for the search results to return. | ||
*/ | ||
@NotBlank(message = "start can not be null") | ||
@Pattern(regexp = "\\d+", message = "start Must be numeric") | ||
@Size(max = 100) | ||
private String start; | ||
/** | ||
* The number of search results to return per page. | ||
*/ | ||
@Pattern(regexp = "\\d+", message = "num Must be numeric") | ||
@Size(max = 10) | ||
private String num; | ||
/** | ||
* The language restriction for the search. | ||
*/ | ||
private String lr; | ||
public String buildUrl(String url, String api, String cx) { | ||
String urlString = url + "?key=" + api + "&q=" + keyWord + "&cx=" + cx | ||
+ "&start=" + start + "&num=" + num + "&lr=" + lr; | ||
return urlString; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/main/java/com/search/docsearch/properties/GoogleSearchProperties.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* Copyright (c) 2024 openEuler Community | ||
EasySoftware is licensed under the Mulan PSL v2. | ||
You can use this software according to the terms and conditions of the Mulan PSL v2. | ||
You may obtain a copy of Mulan PSL v2 at: | ||
http://license.coscl.org.cn/MulanPSL2 | ||
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, | ||
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, | ||
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. | ||
See the Mulan PSL v2 for more details. | ||
*/ | ||
package com.search.docsearch.properties; | ||
|
||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
import org.springframework.stereotype.Component; | ||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
@Component | ||
@Getter | ||
@Setter | ||
@ConfigurationProperties(prefix = "google-search") | ||
public class GoogleSearchProperties { | ||
/** | ||
* The Google Search API key. | ||
*/ | ||
private String key; | ||
/** | ||
* The ID of the Google Custom Search Engine (cx). | ||
*/ | ||
private String cx; | ||
/** | ||
* The URL template for the Google Search API. | ||
*/ | ||
private String url; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.