Skip to content

Commit 94d23b0

Browse files
authored
Merge pull request #17 from snowom/develop
Release 1.4.3
2 parents ea87911 + 51b28ef commit 94d23b0

File tree

105 files changed

+4224
-606
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+4224
-606
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
<img src="https://user-images.githubusercontent.com/70149250/165213835-4fca8d12-7e2a-4e30-a7ab-5a9cd266bbd3.png" height="300"/>
44
</p>
55

6-
Sistema backend em forma de API Restfull do projeto [Posso Ler?](https://github.com/thomazf/PossoLer) <br>
6+
Sistema backend do projeto [Posso Ler?](https://github.com/thomazf/PossoLer) seguindo o padrão de API Restful <br>
77
<br>
8-
<img src="https://img.shields.io/badge/Versão atual-0.3.2 RELEASE-blue.svg"/>
9-
<img src="https://img.shields.io/badge/Data atualização-16/08/2023-green.svg"/>
8+
<img src="https://img.shields.io/badge/Versão atual-1.4.3 RELEASE-blue.svg"/>
9+
<img src="https://img.shields.io/badge/Data atualização-22/02/2024-green.svg"/>
1010
<img src="https://img.shields.io/badge/Tecnologia-Java 14-red.svg"/>
1111
<img src="https://img.shields.io/badge/Tecnologia-Spring Boot 2.7.8-orange.svg"/>
1212
<img src="https://img.shields.io/badge/License-MIT-yellow.svg"/>

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</parent>
1111
<groupId>br.com.possoler.api</groupId>
1212
<artifactId>api_posso_ler</artifactId>
13-
<version>0.3.2-RELEASE</version>
13+
<version>1.4.3-RELEASE</version>
1414
<name>api_posso_ler</name>
1515
<description>API da extensão Posso Ler? em Spring Boot</description>
1616
<properties>
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
package br.com.possoler.api.api_posso_ler.api.cdn.config;
2+
3+
import br.com.possoler.api.api_posso_ler.api.utils.PathConstants;
4+
import org.springframework.beans.factory.annotation.Autowired;
5+
import org.springframework.context.annotation.Bean;
6+
import org.springframework.context.annotation.Configuration;
7+
import org.springframework.core.env.Environment;
8+
9+
import java.util.HashMap;
10+
import java.util.Map;
11+
12+
@Configuration
13+
public class CDNConfigs {
14+
15+
@Autowired
16+
private Environment environment;
17+
18+
@Bean
19+
public String setCDNPath() {
20+
var scope = environment.getProperty("SCOPE");
21+
return (scope == null)
22+
? System.getProperty("user.dir") + PathConstants.FOLDER_POSSOLER_INTEGRATOR + "/CDN/"
23+
: System.getProperty("user.dir") + "\\src\\main\\resources\\static\\CDN\\";
24+
}
25+
26+
@Bean
27+
public Map<String, String> createCDNFilesMap() {
28+
Map<String, String> files = new HashMap<>();
29+
files.put("blockCorePaywall", "[FF]blockCorePaywall.js");
30+
files.put("snackjs", "snackbar.js");
31+
files.put("snackcss", "snackbar.css");
32+
files.put("axioslogo", "img/axiosJS.png");
33+
files.put("mavenlogo", "img/maven.png");
34+
files.put("lomboklogo", "img/lombok.png");
35+
files.put("springlogo", "img/spring.png");
36+
files.put("possolerlogo", "img/128.png");
37+
files.put("respondeailogo", "img/respai.png");
38+
files.put("glidejs", "glide.min.js");
39+
files.put("glidecorecss", "glide.core.min.css");
40+
files.put("glidethemecss", "glide.theme.min.css");
41+
files.put("app_respondeai", "extension/app_responde_ai/app_respondeai.js");
42+
files.put("respondeai", "extension/responde_ai/respondeai.js");
43+
files.put("valorecon", "extension/valor_economico/valor_economico.js");
44+
files.put("exame", "extension/exame/exame.js");
45+
files.put("jota", "extension/jota/jota.js");
46+
files.put("nytimes", "extension/nytimes/nytimes.js");
47+
files.put("elpais", "extension/elpais/elpais.js");
48+
files.put("gauchazh", "extension/gauchazh/gauchazh.js");
49+
files.put("opopular", "extension/opopular/opopular.js");
50+
files.put("diariosm", "extension/diariosm/diariosm.js");
51+
files.put("otempomg", "extension/otempomg/otempomg.js");
52+
files.put("jornaldocomercio", "extension/jornaldocomercio/jornaldocomercio.js");
53+
files.put("opovo", "extension/opovo/opovo.js");
54+
files.put("gaz", "extension/gaz/gaz.js");
55+
files.put("possoler", "extension/possoler/possoler.js");
56+
files.put("att_versao", "extension/att_versao/att_versao.js");
57+
files.put("check_messages", "extension/check_messages/check_messages.js");
58+
files.put("count_content", "extension/count_content/count_content.js");
59+
files.put("save_site_access", "extension/save_site_access/save_site_access.js");
60+
files.put("block_request", "extension/block_request/block_request.js");
61+
62+
return files;
63+
}
64+
}

src/main/java/br/com/possoler/api/api_posso_ler/api/cdn/constants/CDNEnum.java

Lines changed: 0 additions & 25 deletions
This file was deleted.

src/main/java/br/com/possoler/api/api_posso_ler/api/cdn/controller/CDNController.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@
1414
@CrossOrigin(origins = "*")
1515
public class CDNController {
1616

17-
@Autowired
18-
private CDNFileService cdnFileService;
17+
private final CDNFileService cdnFileService;
18+
19+
public CDNController(CDNFileService cdnFileService) {
20+
this.cdnFileService = cdnFileService;
21+
}
1922

2023
@GetMapping("${cdn-api.endpoint.getcdnfile}")
2124
private ResponseEntity<?> getCdnFile(@RequestParam(name = "file") String file) throws IOException {
Lines changed: 17 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package br.com.possoler.api.api_posso_ler.api.cdn.service;
22

3-
import br.com.possoler.api.api_posso_ler.api.cdn.constants.CDNEnum;
4-
import br.com.possoler.api.api_posso_ler.api.utils.PathConstants;
3+
import br.com.possoler.api.api_posso_ler.api.cdn.config.CDNConfigs;
54
import exceptions.NotFoundException;
65
import org.apache.tomcat.util.http.fileupload.IOUtils;
76
import org.springframework.beans.factory.annotation.Autowired;
@@ -11,51 +10,35 @@
1110
import java.io.File;
1211
import java.io.FileInputStream;
1312
import java.io.IOException;
13+
import java.util.HashMap;
14+
import java.util.Map;
1415

1516
@Service
1617
public class CDNFileService {
1718

1819
@Autowired
1920
private HttpServletResponse response;
20-
private final String CDN_PATH = System.getProperty("user.dir") + PathConstants.FOLDER_POSSOLER_INTEGRATOR + "/CDN/";
21-
//private final String CDN_PATH = System.getProperty("user.dir") + "\\src\\main\\resources\\static\\CDN\\";
21+
private final String CDN_PATH;
22+
private final Map<String, String> files;
23+
24+
public CDNFileService(CDNConfigs cdnConfigs) {
25+
CDN_PATH = cdnConfigs.setCDNPath();
26+
files = cdnConfigs.createCDNFilesMap();
27+
}
2228

2329
public void readCdnFile(String fileParamName) throws IOException, NotFoundException {
24-
String filename = getFileName(fileParamName);
25-
File file = new File(CDN_PATH + filename);
30+
String filepath = getFilepath(fileParamName);
31+
File file = new File(CDN_PATH + filepath);
2632
FileInputStream inputStream = new FileInputStream(file);
2733
IOUtils.copy(inputStream, response.getOutputStream());
2834
response.flushBuffer();
2935
}
3036

31-
private String getFileName(String file) {
32-
if(file.equalsIgnoreCase(CDNEnum.BLOCK_CORE_PAYWALL.getFileParamName())) {
33-
return CDNEnum.BLOCK_CORE_PAYWALL.getFilename();
34-
}
35-
if(file.equalsIgnoreCase(CDNEnum.SNACKBAR_JS.getFileParamName())) {
36-
return CDNEnum.SNACKBAR_JS.getFilename();
37-
}
38-
if(file.equalsIgnoreCase(CDNEnum.SNACKBAR_CSS.getFileParamName())) {
39-
return CDNEnum.SNACKBAR_CSS.getFilename();
40-
}
41-
if(file.equalsIgnoreCase(CDNEnum.POSSOLER_LOGO.getFileParamName())) {
42-
return CDNEnum.POSSOLER_LOGO.getFilename();
43-
}
44-
if(file.equalsIgnoreCase(CDNEnum.AXIOS_LOGO.getFileParamName())) {
45-
return CDNEnum.AXIOS_LOGO.getFilename();
46-
}
47-
if(file.equalsIgnoreCase(CDNEnum.MAVEN_LOGO.getFileParamName())) {
48-
return CDNEnum.MAVEN_LOGO.getFilename();
49-
}
50-
if(file.equalsIgnoreCase(CDNEnum.LOMBOK_LOGO.getFileParamName())) {
51-
return CDNEnum.LOMBOK_LOGO.getFilename();
52-
}
53-
if(file.equalsIgnoreCase(CDNEnum.SPRING_LOGO.getFileParamName())) {
54-
return CDNEnum.SPRING_LOGO.getFilename();
55-
}
56-
if(file.equalsIgnoreCase(CDNEnum.RESPONDE_AI_LOGO.getFileParamName())) {
57-
return CDNEnum.RESPONDE_AI_LOGO.getFilename();
37+
private String getFilepath(String fileAlias) {
38+
var filepath = files.get(fileAlias);
39+
if(filepath == null) {
40+
throw new NotFoundException("Arquivo CDN não encontrado");
5841
}
59-
throw new NotFoundException("Arquivo CDN não encontrado");
42+
return filepath;
6043
}
6144
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package br.com.possoler.api.api_posso_ler.api.paywallDOM.config;
2+
3+
import br.com.possoler.api.api_posso_ler.api.utils.PathConstants;
4+
import org.springframework.beans.factory.annotation.Autowired;
5+
import org.springframework.context.annotation.Bean;
6+
import org.springframework.context.annotation.Configuration;
7+
import org.springframework.core.env.Environment;
8+
9+
@Configuration
10+
public class PaywallDOMConfig {
11+
12+
@Autowired
13+
private Environment environment;
14+
15+
@Bean
16+
public String setFilepath() {
17+
var scope = environment.getProperty("SCOPE");
18+
return (scope == null)
19+
? System.getProperty("user.dir") + PathConstants.FOLDER_POSSOLER_INTEGRATOR + "/paywallDOM/configFiles/"
20+
: System.getProperty("user.dir") + "\\src\\main\\resources\\paywallDOM\\configFiles\\";
21+
}
22+
}
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package br.com.possoler.api.api_posso_ler.api.paywallDOM.responde_ai.controller;
22

3-
import br.com.possoler.api.api_posso_ler.api.paywallDOM.responde_ai.model.RespondeAiConfigModel;
4-
import br.com.possoler.api.api_posso_ler.api.paywallDOM.responde_ai.service.RespondeAiPaywallDOMService;
5-
import org.springframework.beans.factory.annotation.Autowired;
3+
import br.com.possoler.api.api_posso_ler.api.paywallDOM.service.PaywallDOMService;
64
import org.springframework.http.ResponseEntity;
75
import org.springframework.web.bind.annotation.CrossOrigin;
86
import org.springframework.web.bind.annotation.GetMapping;
@@ -12,12 +10,16 @@
1210
@CrossOrigin(origins = "*")
1311
public class RespondeAiPaywallDOMController {
1412

15-
@Autowired
16-
RespondeAiPaywallDOMService respondeAiPaywallDOMService;
13+
private final String FILENAME = "respondeai.json";
14+
private final PaywallDOMService paywallDOMService;
15+
16+
public RespondeAiPaywallDOMController(PaywallDOMService paywallDOMService) {
17+
this.paywallDOMService = paywallDOMService;
18+
}
1719

1820
@GetMapping("${paywalldom-api.endpoint.respai}")
19-
public ResponseEntity<RespondeAiConfigModel> getPaywallDOMConfigsRespondeAI() {
20-
RespondeAiConfigModel response = respondeAiPaywallDOMService.getRespondeAiPDConfigs();
21+
public ResponseEntity<?> getPaywallDOMConfigsRespondeAI() {
22+
Object response = paywallDOMService.getConfig(FILENAME);
2123
return ResponseEntity.ok().body(response);
2224
}
2325
}

src/main/java/br/com/possoler/api/api_posso_ler/api/paywallDOM/responde_ai/model/DataCyModel.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ public class DataCyModel {
1818
private List<String> theory_text_content;
1919
private List<String> theory_video_content;
2020
private List<String> exercise_answer_button;
21+
private List<String> video_lesson_div_content;
22+
private List<String> exercise_div_content;
2123
private List<String> exercise_statement;
2224
private List<String> side_menu;
2325
}

src/main/java/br/com/possoler/api/api_posso_ler/api/paywallDOM/responde_ai/service/RespondeAiPaywallDOMService.java

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)