generated from lucien/api-template
modified docker structure
This commit is contained in:
parent
e2d8d04c04
commit
8f11c56d1a
5 changed files with 37 additions and 4 deletions
5
client/company/Dockerfile
Normal file
5
client/company/Dockerfile
Normal file
|
@ -0,0 +1,5 @@
|
|||
FROM python:alpine
|
||||
WORKDIR /app
|
||||
COPY . .
|
||||
CMD ["python", "-u", "main.py"]
|
||||
|
42
client/company/main.py
Normal file
42
client/company/main.py
Normal file
|
@ -0,0 +1,42 @@
|
|||
import requests
|
||||
|
||||
HOST = "http://localhost:3000/"
|
||||
|
||||
"""Affichage des actions mises en vente par une entreprise
|
||||
input :
|
||||
- idComp : Identifiant de l'entreprise
|
||||
"""
|
||||
def getShares(idComp):
|
||||
url = HOST + 'api/companies/'+idComp+'/shares'
|
||||
r = requests.get(url)
|
||||
return r.json()
|
||||
|
||||
"""Création d'une action par une entreprise
|
||||
input :
|
||||
- idComp : identifiant de l'entreprise
|
||||
- price : prix de l'action sur le marché
|
||||
"""
|
||||
def emmitShare(idComp, price):
|
||||
url = HOST + 'api/shares/emmit'
|
||||
obj={'id':idComp,'price':price}
|
||||
r = requests.post(url, json=obj)
|
||||
return r.json()
|
||||
|
||||
"""Affichage des informations d'une enteprise
|
||||
input :
|
||||
- idComp : identifiant de l'entreprise
|
||||
"""
|
||||
def getCompany(idComp):
|
||||
url = HOST + 'api/companies/'+idComp
|
||||
r=requests.get(url)
|
||||
return r.json()
|
||||
|
||||
"""Affichage les enteprises """
|
||||
def getCompanies():
|
||||
url = HOST + 'api/companies/'
|
||||
r=requests.get(url)
|
||||
return r.json()
|
||||
|
||||
if __name__ == "__main__":
|
||||
pass
|
||||
|
33
client/docker-compose.yml
Normal file
33
client/docker-compose.yml
Normal file
|
@ -0,0 +1,33 @@
|
|||
services:
|
||||
companies:
|
||||
build: ./company
|
||||
container_name: companies
|
||||
restart: always
|
||||
networks:
|
||||
- bourse
|
||||
|
||||
shareholder1:
|
||||
build: ./shareholder
|
||||
container_name: shareholder1
|
||||
restart: always
|
||||
networks:
|
||||
- bourse
|
||||
|
||||
shareholder2:
|
||||
build: ./shareholder
|
||||
container_name: shareholder2
|
||||
restart: always
|
||||
networks:
|
||||
- bourse
|
||||
|
||||
shareholder3:
|
||||
build: ./shareholder
|
||||
container_name: shareholder3
|
||||
restart: always
|
||||
networks:
|
||||
- bourse
|
||||
|
||||
networks:
|
||||
bourse:
|
||||
driver: bridge
|
||||
|
5
client/shareholder/Dockerfile
Normal file
5
client/shareholder/Dockerfile
Normal file
|
@ -0,0 +1,5 @@
|
|||
FROM python:alpine
|
||||
WORKDIR /app
|
||||
COPY . .
|
||||
CMD ["python", "-u", "main.py"]
|
||||
|
57
client/shareholder/main.py
Normal file
57
client/shareholder/main.py
Normal file
|
@ -0,0 +1,57 @@
|
|||
import requests
|
||||
|
||||
HOST = "http://localhost:3000/"
|
||||
|
||||
"""Achat d'une action par un actionnaire à une entreprise
|
||||
input :
|
||||
- idBuyer : identifiant de l'actionnaire
|
||||
- idShare : identifiant de l'action
|
||||
"""
|
||||
def buyShare(idBuyer, idShare):
|
||||
url = HOST + 'api/shares/buy'
|
||||
obj={'id':idBuyer,'share_id':idShare}
|
||||
r = requests.post(url, json=obj)
|
||||
return r.json()
|
||||
|
||||
"""Affichage les actions possédées par un actionnaire
|
||||
input :
|
||||
- idBuyer : identifiant de l'actionnaire
|
||||
"""
|
||||
def getSharesOf(idBuyer):
|
||||
url = HOST + 'api/shareholders/'+idBuyer+'/shares'
|
||||
r = requests.get(url)
|
||||
return r.json()
|
||||
|
||||
"""Affichage les informations d'une actions
|
||||
input :
|
||||
- idShare : identifiant de l'action
|
||||
"""
|
||||
def getShare(idShare):
|
||||
url = HOST + 'api/shares/'+idShare
|
||||
r = requests.get(url)
|
||||
return r.json()
|
||||
|
||||
"""Affichage les actions en circulation sur le marché (possédées ou en vente) """
|
||||
def getAllShares():
|
||||
url = HOST + 'api/shares'
|
||||
r = requests.get(url)
|
||||
return r.json()
|
||||
|
||||
"""Affichage les informations sur un actionnaire
|
||||
input :
|
||||
- idBuyer : identifiant de l'actionnaire
|
||||
"""
|
||||
def getInfoBuyer(idBuyer):
|
||||
url = HOST + 'api/shareholders/'+idBuyer
|
||||
r=requests.get(url)
|
||||
return r.json()
|
||||
|
||||
"""Affichage tous les actionnaires """
|
||||
def getAllBuyers():
|
||||
url = HOST + 'api/shareholders/'
|
||||
r=requests.get(url)
|
||||
return r.json()
|
||||
|
||||
if __name__ == "__main__":
|
||||
pass
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue