Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
guangyuzhang committed Jan 12, 2022
2 parents e3d8869 + 6c3ca23 commit c0116cb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 27 deletions.
1 change: 1 addition & 0 deletions myems-api/README.md
Expand Up @@ -1411,6 +1411,7 @@ Result
| contact | Object | Contact Object |
| cost_center | Object | Cost Center Object |
| description | string | Shopfloor description |
| qrcode | string | QRCode in String |

* GET All Shopfloors
```bash
Expand Down
32 changes: 5 additions & 27 deletions myems-api/core/shopfloor.py
Expand Up @@ -21,18 +21,6 @@ def on_get(req, resp):
cnx = mysql.connector.connect(**config.myems_system_db)
cursor = cnx.cursor(dictionary=True)

query = (" SELECT id, name, uuid "
" FROM tbl_shopfloors ")
cursor.execute(query)
rows_shopfloors = cursor.fetchall()

shopfloor_dict = dict()
if rows_shopfloors is not None and len(rows_shopfloors) > 0:
for row in rows_shopfloors:
shopfloor_dict[row['id']] = {"id": row['id'],
"name": row['name'],
"uuid": row['uuid']}

query = (" SELECT id, name, uuid "
" FROM tbl_contacts ")
cursor.execute(query)
Expand Down Expand Up @@ -77,7 +65,8 @@ def on_get(req, resp):
"is_input_counted": bool(row['is_input_counted']),
"contact": contact,
"cost_center": cost_center,
"description": row['description']}
"description": row['description'],
"qrcode": "shopfloor:" + row['uuid']}
result.append(meta_result)

cursor.close()
Expand Down Expand Up @@ -210,23 +199,11 @@ def on_options(req, resp, id_):
def on_get(req, resp, id_):
if not id_.isdigit() or int(id_) <= 0:
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
description='API.INVALID_METER_ID')
description='API.INVALID_SHOPFLOOR_ID')

cnx = mysql.connector.connect(**config.myems_system_db)
cursor = cnx.cursor(dictionary=True)

query = (" SELECT id, name, uuid "
" FROM tbl_shopfloors ")
cursor.execute(query)
rows_shopfloors = cursor.fetchall()

shopfloor_dict = dict()
if rows_shopfloors is not None and len(rows_shopfloors) > 0:
for row in rows_shopfloors:
shopfloor_dict[row['id']] = {"id": row['id'],
"name": row['name'],
"uuid": row['uuid']}

query = (" SELECT id, name, uuid "
" FROM tbl_contacts ")
cursor.execute(query)
Expand Down Expand Up @@ -273,7 +250,8 @@ def on_get(req, resp, id_):
"is_input_counted": bool(row['is_input_counted']),
"contact": contact,
"cost_center": cost_center,
"description": row['description']}
"description": row['description'],
"qrcode": "shopfloor:" + row['uuid']}

resp.text = json.dumps(meta_result)

Expand Down

0 comments on commit c0116cb

Please sign in to comment.