Определяем сервис для получения данных о видео
This commit is contained in:
@@ -11,7 +11,12 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@ComponentScan({ "ks.server.controllers", "ks.server.browser", "ks.server.cinema" })
|
@ComponentScan({
|
||||||
|
"ks.server.controllers",
|
||||||
|
"ks.server.browser",
|
||||||
|
"ks.server.cinema",
|
||||||
|
"ks.server.service"
|
||||||
|
})
|
||||||
@EnableWebMvc
|
@EnableWebMvc
|
||||||
public class SpringConfigMVC implements WebMvcConfigurer {
|
public class SpringConfigMVC implements WebMvcConfigurer {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package ks.server.controllers;
|
package ks.server.controllers;
|
||||||
|
|
||||||
import ks.server.browser.Browser;
|
|
||||||
import ks.server.cinema.Animevost;
|
import ks.server.cinema.Animevost;
|
||||||
|
import ks.server.service.CinemaService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
@@ -19,7 +19,7 @@ import java.util.Map;
|
|||||||
produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
||||||
public class WebController {
|
public class WebController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private Browser browser;
|
private CinemaService cinemaService;
|
||||||
|
|
||||||
private String subpath(String requestUri, String marker) {
|
private String subpath(String requestUri, String marker) {
|
||||||
return requestUri.substring(requestUri.indexOf(marker) + marker.length());
|
return requestUri.substring(requestUri.indexOf(marker) + marker.length());
|
||||||
@@ -32,11 +32,6 @@ public class WebController {
|
|||||||
|
|
||||||
@RequestMapping(path = "/c/animevost/info/**")
|
@RequestMapping(path = "/c/animevost/info/**")
|
||||||
public Animevost animevostInfo(HttpServletRequest request) {
|
public Animevost animevostInfo(HttpServletRequest request) {
|
||||||
final String path = subpath(request.getRequestURI(), "/info/");
|
return cinemaService.getCinema(subpath(request.getRequestURI(), "/info/"));
|
||||||
|
|
||||||
Animevost animevost = new Animevost();
|
|
||||||
animevost.fillInfo(path, browser);
|
|
||||||
|
|
||||||
return animevost;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
19
ks.server/src/main/java/ks/server/service/CinemaService.java
Normal file
19
ks.server/src/main/java/ks/server/service/CinemaService.java
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
package ks.server.service;
|
||||||
|
|
||||||
|
import ks.server.browser.Browser;
|
||||||
|
import ks.server.cinema.Animevost;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.ApplicationContext;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class CinemaService {
|
||||||
|
@Autowired
|
||||||
|
private ApplicationContext applicationContext;
|
||||||
|
|
||||||
|
public Animevost getCinema(String uri) {
|
||||||
|
Animevost animevost = new Animevost();
|
||||||
|
animevost.fillInfo(uri, applicationContext.getBean(Browser.class));
|
||||||
|
return animevost;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user