Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
M
Micro_Services
Project
Project
Details
Activity
Releases
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
ali.saeed
Micro_Services
Commits
2ad6a1d6
Commit
2ad6a1d6
authored
Apr 24, 2024
by
Ali Saeed
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init rest controller for invoices service
parent
dc8f7a5e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
166 additions
and
1 deletion
+166
-1
Invoice.java
...ing-service/src/main/java/org/example/models/Invoice.java
+68
-0
User.java
invoicing-service/src/main/java/org/example/models/User.java
+46
-0
InvoiceResource.java
.../src/main/java/org/example/resources/InvoiceResource.java
+51
-0
UserResource.java
...ice/src/main/java/org/example/resources/UserResource.java
+1
-1
No files found.
invoicing-service/src/main/java/org/example/models/Invoice.java
0 → 100644
View file @
2ad6a1d6
package
org
.
example
.
models
;
public
class
Invoice
{
private
String
invoiceID
;
private
String
userID
;
private
String
description
;
private
boolean
status
;
private
double
value
;
public
Invoice
(
String
invoiceID
,
String
userID
,
String
description
,
boolean
status
,
double
value
)
{
this
.
invoiceID
=
invoiceID
;
this
.
userID
=
userID
;
this
.
description
=
description
;
this
.
status
=
status
;
this
.
value
=
value
;
}
public
String
getInvoiceID
()
{
return
invoiceID
;
}
public
void
setInvoiceID
(
String
invoiceID
)
{
this
.
invoiceID
=
invoiceID
;
}
public
String
getUserID
()
{
return
userID
;
}
public
void
setUserID
(
String
userID
)
{
this
.
userID
=
userID
;
}
public
String
getDescription
()
{
return
description
;
}
public
void
setDescription
(
String
description
)
{
this
.
description
=
description
;
}
public
boolean
isStatus
()
{
return
status
;
}
public
void
setStatus
(
boolean
status
)
{
this
.
status
=
status
;
}
public
double
getValue
()
{
return
value
;
}
public
void
setValue
(
double
value
)
{
this
.
value
=
value
;
}
@Override
public
String
toString
()
{
return
"Invoice{"
+
"invoiceID='"
+
invoiceID
+
'\''
+
", userID='"
+
userID
+
'\''
+
", description='"
+
description
+
'\''
+
", status="
+
status
+
", value="
+
value
+
'}'
;
}
}
invoicing-service/src/main/java/org/example/models/User.java
0 → 100644
View file @
2ad6a1d6
package
org
.
example
.
models
;
public
class
User
{
private
String
userId
;
private
String
name
;
private
double
balance
;
public
User
(
String
userId
,
String
name
,
double
balance
)
{
this
.
userId
=
userId
;
this
.
name
=
name
;
this
.
balance
=
balance
;
}
public
String
getUserId
()
{
return
userId
;
}
public
void
setUserId
(
String
userId
)
{
this
.
userId
=
userId
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
double
getBalance
()
{
return
balance
;
}
public
void
setBalance
(
double
balance
)
{
this
.
balance
=
balance
;
}
@Override
public
String
toString
()
{
return
"User{"
+
"userId='"
+
userId
+
'\''
+
", name='"
+
name
+
'\''
+
", balance="
+
balance
+
'}'
;
}
}
invoicing-service/src/main/java/org/example/resources/InvoiceResource.java
0 → 100644
View file @
2ad6a1d6
package
org
.
example
.
resources
;
import
org.example.models.Invoice
;
import
org.example.models.User
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
@RestController
@RequestMapping
(
"/invoices"
)
public
class
InvoiceResource
{
@RequestMapping
(
"/{userId}"
)
public
List
<
Invoice
>
getUnPaidInvoicesForSpecificUser
(
@PathVariable
(
"userId"
)
String
userId
){
Invoice
inv1
=
new
Invoice
(
"1"
,
"1"
,
"ssssssd"
,
false
,
55.0
);
Invoice
inv2
=
new
Invoice
(
"2"
,
"1"
,
"dddddddddd"
,
false
,
545.0
);
ArrayList
<
Invoice
>
inv
=
new
ArrayList
<
Invoice
>();
inv
.
add
(
inv1
);
inv
.
add
(
inv2
);
return
inv
;
}
@RequestMapping
(
"/{invoiceId}"
)
public
boolean
updateInvoiceStatus
(
@PathVariable
(
"invoiceId"
)
String
invoiceId
){
Invoice
invoice
=
new
Invoice
(
"2"
,
"1"
,
"dddddddddd"
,
false
,
545.0
);
invoice
.
setStatus
(
true
);
return
true
;
}
@RequestMapping
()
public
List
<
Invoice
>
getUnPaidInvoices
(){
Invoice
invoice1
=
new
Invoice
(
"2"
,
"1"
,
"dddddddddd"
,
false
,
545.0
);
Invoice
invoice2
=
new
Invoice
(
"3"
,
"2"
,
"dddddddddd"
,
false
,
545.0
);
ArrayList
<
Invoice
>
inv
=
new
ArrayList
<
Invoice
>();
inv
.
add
(
invoice1
);
inv
.
add
(
invoice2
);
return
inv
;
}
@RequestMapping
()
public
List
<
Invoice
>
getPaidInvoices
(){
Invoice
invoice1
=
new
Invoice
(
"2"
,
"1"
,
"dddddddddd"
,
true
,
545.0
);
Invoice
invoice2
=
new
Invoice
(
"3"
,
"2"
,
"dddddddddd"
,
true
,
545.0
);
ArrayList
<
Invoice
>
inv
=
new
ArrayList
<
Invoice
>();
inv
.
add
(
invoice1
);
inv
.
add
(
invoice2
);
return
inv
;
}
}
users-service/src/main/java/org/example/resources/UserResource.java
View file @
2ad6a1d6
...
@@ -16,7 +16,7 @@ public class UserResource {
...
@@ -16,7 +16,7 @@ public class UserResource {
@RequestMapping
(
"/{userId}"
)
@RequestMapping
(
"/{userId}"
)
public
List
<
Invoice
>
getUnPaidInvoices
(
@PathVariable
(
"userId"
)
String
userId
){
public
List
<
Invoice
>
getUnPaidInvoices
(
@PathVariable
(
"userId"
)
String
userId
){
Invoice
inv1
=
new
Invoice
(
"1"
,
"1"
,
"ssssssd"
,
tru
e
,
55.0
);
Invoice
inv1
=
new
Invoice
(
"1"
,
"1"
,
"ssssssd"
,
fals
e
,
55.0
);
Invoice
inv2
=
new
Invoice
(
"2"
,
"1"
,
"dddddddddd"
,
false
,
545.0
);
Invoice
inv2
=
new
Invoice
(
"2"
,
"1"
,
"dddddddddd"
,
false
,
545.0
);
System
.
out
.
println
(
userId
);
System
.
out
.
println
(
userId
);
...
...
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