Skip to content

Commit c6d6aae

Browse files
authored
Merge pull request #12 from souovan/python-flask
Updating README and adding some endpoints
2 parents 6881dbc + 859b1c2 commit c6d6aae

File tree

2 files changed

+165
-2
lines changed

2 files changed

+165
-2
lines changed

python-flask/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,14 @@
11
Aplicação feita no framework Python Flask com base na documentação do meu [TCC](https://github.com/souovan/TCC)
2+
3+
# Para executar a aplicação
4+
5+
Navege até essa pasta e execute:
6+
7+
```sh
8+
python3 -m venv venv
9+
source venv/bin/activate
10+
11+
pip install -r requirements.txt
12+
13+
flask run
14+
```

python-flask/src/app.py

Lines changed: 152 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ class provider(db.Model):
161161
razao_social = db.Column(db.String(), nullable=False)
162162
telefone = db.Column(db.String(), nullable=False)
163163
celular = db.Column(db.String(), nullable=False)
164-
cnpj = db.Column(db.String(), nullable=False)
165164
email = db.Column(db.String(), nullable=False)
166165
endereco = db.Column(db.String(), nullable=False)
167166
complemento = db.Column(db.String(), nullable=False)
@@ -292,7 +291,7 @@ def test():
292291
'test': 'test1'
293292
}, 200
294293

295-
@app.route('/users', methods=['GET'])
294+
@app.route('/usuarios', methods=['GET'])
296295
def all_users():
297296
all_user = user.query.all()
298297
output = []
@@ -305,3 +304,154 @@ def all_users():
305304
output.append(current_user)
306305
return jsonify(output), 200
307306

307+
@app.route('/agendamentos', methods=['GET'])
308+
def all_scheduling():
309+
all_scheduling = scheduling.query.all()
310+
output = []
311+
for agendamento in all_scheduling:
312+
current_scheduling = {}
313+
current_scheduling['id_agendamento'] = agendamento.id_agendamento
314+
current_scheduling['fk_id_usuario'] = agendamento.fk_id_usuario
315+
current_scheduling['fk_id_vendedor'] = agendamento.fk_id_vendedor
316+
current_scheduling['data_agendamento'] = agendamento.data_agendamento
317+
output.append(current_scheduling)
318+
return jsonify(output), 200
319+
320+
@app.route('/clientes', methods=['GET'])
321+
def all_clients():
322+
all_clients = client.query.all()
323+
output = []
324+
for clientes in all_clients:
325+
current_clients = {}
326+
current_clients['id_cliente'] = clientes.id_cliente
327+
current_clients['fk_nome_categoria_cliente'] = clientes.fk_nome_categoria_cliente
328+
current_clients['nome'] = clientes.nome
329+
current_clients['razao_social'] = clientes.razao_social
330+
current_clients['cpf'] = clientes.cpf
331+
current_clients['cnpj'] = clientes.cnpj
332+
current_clients['endereco'] = clientes.endereco
333+
current_clients['numero_endereco'] = clientes.numero_endereco
334+
current_clients['complemento'] = clientes.complemento
335+
current_clients['bairro'] = clientes.bairro
336+
current_clients['cidade'] = clientes.cidade
337+
current_clients['uf'] = clientes.uf
338+
current_clients['cep'] = clientes.cep
339+
current_clients['celular'] = clientes.celular
340+
current_clients['email'] = clientes.email
341+
current_clients['observacao'] = clientes.observacao
342+
343+
output.append(current_clients)
344+
return jsonify(output), 200
345+
346+
@app.route('/compras', methods=['GET'])
347+
def all_purchase():
348+
all_purchases = purchase.query.all()
349+
output = []
350+
for compras in all_purchases:
351+
current_purchase = {}
352+
current_purchase['id_compra'] = compras.id_compra
353+
current_purchase['fk_id_cotacao_compra'] = compras.fk_id_cotacao_compra
354+
current_purchase['fk_id_condicao_pagamento'] = compras.fk_id_condicao_pagamento
355+
output.append(current_purchase)
356+
return jsonify(output), 200
357+
358+
@app.route('/estoque', methods=['GET'])
359+
def all_inventory():
360+
all_inventory = inventory.query.all()
361+
output = []
362+
for estoques in all_inventory:
363+
current_inventory = {}
364+
current_inventory['id_estoque'] = estoques.id_estoque
365+
current_inventory['fk_id_produto'] = estoques.fk_id_produto
366+
current_inventory['quantidade_produto'] = estoques.quantidade_produto
367+
output.append(current_inventory)
368+
return jsonify(output), 200
369+
370+
@app.route('/fornecedores', methods=['GET'])
371+
def all_providers():
372+
all_providers = provider.query.all()
373+
output = []
374+
for fornecedores in all_providers:
375+
current_providers = {}
376+
current_providers['id_fornecedor'] = fornecedores.id_fornecedor
377+
current_providers['fk_id_categoria_fornecedor'] = fornecedores.fk_id_categoria_fornecedor
378+
current_providers['razao_social'] = fornecedores.razao_social
379+
current_providers['telefone'] = fornecedores.telefone
380+
current_providers['celular'] = fornecedores.celular
381+
current_providers['email'] = fornecedores.email
382+
current_providers['endereco'] = fornecedores.endereco
383+
current_providers['complemento'] = fornecedores.complemento
384+
current_providers['bairro'] = fornecedores.bairro
385+
current_providers['cidade'] = fornecedores.cidade
386+
current_providers['uf'] = fornecedores.uf
387+
current_providers['cep'] = fornecedores.cep
388+
current_providers['observacao'] = fornecedores.observacao
389+
output.append(current_providers)
390+
return jsonify(output), 200
391+
392+
@app.route('/orcamentos', methods=['GET'])
393+
def all_budgets():
394+
all_budgets = budget.query.all()
395+
output = []
396+
for orcamentos in all_budgets:
397+
current_budgets = {}
398+
current_budgets['id_item_orcamento'] = orcamentos.id_item_orcamento
399+
current_budgets['fk_id_cotacao_compra'] = orcamentos.fk_id_cotacao_compra
400+
current_budgets['fk_id_produto'] = orcamentos.fk_id_produto
401+
output.append(current_budgets)
402+
return jsonify(output), 200
403+
404+
@app.route('/produtos', methods=['GET'])
405+
def all_products():
406+
all_products = product.query.all()
407+
output = []
408+
for products in all_products:
409+
current_products = {}
410+
current_products['id_produto'] = products.id_produto
411+
current_products['fk_id_categoria_produto'] = products.fk_id_categoria_produto
412+
current_products['codigo_barra'] = products.codigo_barra
413+
current_products['nome_produto'] = products.nome_produto
414+
current_products['preco_custo'] = products.preco_custo
415+
current_products['preco_venda'] = products.preco_venda
416+
current_products['fk_quantidade_produto'] = products.fk_quantidade_produto
417+
output.append(current_products)
418+
return jsonify(output), 200
419+
420+
@app.route('/titulos_a_pagar', methods=['GET'])
421+
def all_title_to_pay():
422+
all_title_to_pay = title_to_pay.query.all()
423+
output = []
424+
for titles_to_pay in all_title_to_pay:
425+
current_title_to_pay = {}
426+
current_title_to_pay['fk_id_compra'] = titles_to_pay.fk_id_compra
427+
current_title_to_pay['data_documento'] = titles_to_pay.data_documento
428+
current_title_to_pay['data_vencimento'] = titles_to_pay.data_vencimento
429+
current_title_to_pay['valor_titulo'] = titles_to_pay.valor_titulo
430+
current_title_to_pay['desconto'] = titles_to_pay.desconto
431+
output.append(current_title_to_pay)
432+
return jsonify(output), 200
433+
434+
@app.route('/vendas', methods=['GET'])
435+
def all_sales():
436+
all_sales = sale.query.all()
437+
output = []
438+
for sales in all_sales:
439+
current_sales = {}
440+
current_sales['id_venda'] = sales.id_venda
441+
current_sales['fk_id_orcamento'] = sales.fk_id_orcamento
442+
current_sales['fk_id_condicao_pagamento'] = sales.fk_id_condicao_pagamento
443+
output.append(current_sales)
444+
return jsonify(output), 200
445+
446+
@app.route('/vendedores', methods=['GET'])
447+
def all_sellers():
448+
all_sellers = seller.query.all()
449+
output = []
450+
for sellers in all_sellers:
451+
current_sellers = {}
452+
current_sellers['id_vendedor'] = sellers.id_vendedor
453+
current_sellers['nome_vendedor'] = sellers.nome_vendedor
454+
current_sellers['login'] = sellers.login
455+
current_sellers['senha'] = sellers.senha
456+
output.append(current_sellers)
457+
return jsonify(output), 200

0 commit comments

Comments
 (0)