0

Определяем сервис для получения данных о видео

This commit is contained in:
2019-01-07 18:27:59 +03:00
parent 92ac92c000
commit 78b95eb2cb
3 changed files with 28 additions and 9 deletions

View File

@@ -11,7 +11,12 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import java.util.List;
@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
public class SpringConfigMVC implements WebMvcConfigurer {
@Override

View File

@@ -1,7 +1,7 @@
package ks.server.controllers;
import ks.server.browser.Browser;
import ks.server.cinema.Animevost;
import ks.server.service.CinemaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -19,7 +19,7 @@ import java.util.Map;
produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class WebController {
@Autowired
private Browser browser;
private CinemaService cinemaService;
private String subpath(String requestUri, String marker) {
return requestUri.substring(requestUri.indexOf(marker) + marker.length());
@@ -32,11 +32,6 @@ public class WebController {
@RequestMapping(path = "/c/animevost/info/**")
public Animevost animevostInfo(HttpServletRequest request) {
final String path = subpath(request.getRequestURI(), "/info/");
Animevost animevost = new Animevost();
animevost.fillInfo(path, browser);
return animevost;
return cinemaService.getCinema(subpath(request.getRequestURI(), "/info/"));
}
}

View 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;
}
}