Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
javab_20230617
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
Patryk Czarnik
javab_20230617
Commits
3fdf0a54
Commit
3fdf0a54
authored
Jul 16, 2023
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
extract interface
parent
ce321722
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
3 deletions
+16
-3
PobieranieWalut.java
...rc/main/java/com/example/demo/waluty/PobieranieWalut.java
+8
-0
PobieranieXML.java
.../src/main/java/com/example/demo/waluty/PobieranieXML.java
+2
-1
WalutyController.java
...c/main/java/com/example/demo/waluty/WalutyController.java
+5
-1
WalutyRest.java
...ing/src/main/java/com/example/demo/waluty/WalutyRest.java
+1
-1
No files found.
PC25-Spring/src/main/java/com/example/demo/waluty/PobieranieWalut.java
0 → 100644
View file @
3fdf0a54
package
com
.
example
.
demo
.
waluty
;
public
interface
PobieranieWalut
{
TabelaWalut
pobierzTabele
(
String
data
);
}
\ No newline at end of file
PC25-Spring/src/main/java/com/example/demo/waluty/PobieranieXML.java
View file @
3fdf0a54
...
@@ -26,8 +26,9 @@ import org.xml.sax.SAXException;
...
@@ -26,8 +26,9 @@ import org.xml.sax.SAXException;
* 2) ten obiekt będzie dostępny dla innych jako "komponent" ("bean") i będzie go wstrzykiwać
* 2) ten obiekt będzie dostępny dla innych jako "komponent" ("bean") i będzie go wstrzykiwać
*/
*/
@Service
@Service
public
class
PobieranieXML
{
public
class
PobieranieXML
implements
PobieranieWalut
{
@Override
public
TabelaWalut
pobierzTabele
(
String
data
)
{
public
TabelaWalut
pobierzTabele
(
String
data
)
{
String
adres
=
"https://api.nbp.pl/api/exchangerates/tables/a"
;
String
adres
=
"https://api.nbp.pl/api/exchangerates/tables/a"
;
if
(
data
!=
null
)
{
if
(
data
!=
null
)
{
...
...
PC25-Spring/src/main/java/com/example/demo/waluty/WalutyController.java
View file @
3fdf0a54
...
@@ -17,10 +17,14 @@ public class WalutyController {
...
@@ -17,10 +17,14 @@ public class WalutyController {
* Wstrzykiwać można obiekty, które są typu:
* Wstrzykiwać można obiekty, które są typu:
* - komponent (bean) istniejący w tej samej aplikacji (tak jest tutaj)
* - komponent (bean) istniejący w tej samej aplikacji (tak jest tutaj)
* - klasa o specjalnym znaczeniu, którą Spring "zna", np. ServletContext
* - klasa o specjalnym znaczeniu, którą Spring "zna", np. ServletContext
*
* W miejscu użycia zmienna może być typu interfejsowego,
* a Spring wstawi "jakąś implementację" tego interfejsu,
* jeśli taka implementacja jest dostępna wśród komponentów (beanów).
*/
*/
@Autowired
@Autowired
private
Pobieranie
XML
pobieracz
;
private
Pobieranie
Walut
pobieracz
;
@GetMapping
(
"/waluty"
)
@GetMapping
(
"/waluty"
)
public
String
wyswietlWaluty
(
String
data
,
Model
model
)
{
public
String
wyswietlWaluty
(
String
data
,
Model
model
)
{
...
...
PC25-Spring/src/main/java/com/example/demo/waluty/WalutyRest.java
View file @
3fdf0a54
...
@@ -10,7 +10,7 @@ import org.springframework.web.bind.annotation.RestController;
...
@@ -10,7 +10,7 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping
(
"/waluty.rest"
)
@RequestMapping
(
"/waluty.rest"
)
public
class
WalutyRest
{
public
class
WalutyRest
{
@Autowired
@Autowired
private
Pobieranie
XML
pobieracz
;
private
Pobieranie
Walut
pobieracz
;
@GetMapping
@GetMapping
public
TabelaWalut
wyswietlWaluty
()
{
public
TabelaWalut
wyswietlWaluty
()
{
...
...
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