@@ 1540-1572 (lines=33) @@ | ||
1537 | ||
1538 | resp.status = falcon.HTTP_200 |
|
1539 | ||
1540 | @staticmethod |
|
1541 | @user_logger |
|
1542 | def on_delete(req, resp, id_): |
|
1543 | admin_control(req) |
|
1544 | if not id_.isdigit() or int(id_) <= 0: |
|
1545 | raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST', |
|
1546 | description='API.INVALID_EMAIL_MESSAGE_ID') |
|
1547 | ||
1548 | cnx = mysql.connector.connect(**config.myems_user_db) |
|
1549 | cursor = cnx.cursor() |
|
1550 | ||
1551 | cursor.execute(" SELECT id " |
|
1552 | " FROM tbl_email_messages " |
|
1553 | " WHERE id = %s ", (id_,)) |
|
1554 | row = cursor.fetchone() |
|
1555 | ||
1556 | if row is None: |
|
1557 | if cursor: |
|
1558 | cursor.close() |
|
1559 | if cnx: |
|
1560 | cnx.close() |
|
1561 | raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND', |
|
1562 | description='API.EMAIL_MESSAGE_NOT_FOUND') |
|
1563 | ||
1564 | cursor.execute(" DELETE FROM tbl_email_messages WHERE id = %s ", (id_,)) |
|
1565 | cnx.commit() |
|
1566 | ||
1567 | if cursor: |
|
1568 | cursor.close() |
|
1569 | if cnx: |
|
1570 | cnx.close() |
|
1571 | ||
1572 | resp.status = falcon.HTTP_204 |
|
1573 | ||
1574 | ||
1575 | class NewUserCollection: |
@@ 480-512 (lines=33) @@ | ||
477 | ||
478 | resp.status = falcon.HTTP_200 |
|
479 | ||
480 | @staticmethod |
|
481 | @user_logger |
|
482 | def on_delete(req, resp, id_): |
|
483 | admin_control(req) |
|
484 | if not id_.isdigit() or int(id_) <= 0: |
|
485 | raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST', |
|
486 | description='API.INVALID_WECHAT_MESSAGE_ID') |
|
487 | ||
488 | cnx = mysql.connector.connect(**config.myems_fdd_db) |
|
489 | cursor = cnx.cursor() |
|
490 | ||
491 | cursor.execute(" SELECT id " |
|
492 | " FROM tbl_wechat_messages_outbox " |
|
493 | " WHERE id = %s ", (id_,)) |
|
494 | row = cursor.fetchone() |
|
495 | ||
496 | if row is None: |
|
497 | if cursor: |
|
498 | cursor.close() |
|
499 | if cnx: |
|
500 | cnx.close() |
|
501 | raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND', |
|
502 | description='API.WECHAT_MESSAGE_NOT_FOUND') |
|
503 | ||
504 | cursor.execute(" DELETE FROM tbl_wechat_messages_outbox WHERE id = %s ", (id_,)) |
|
505 | cnx.commit() |
|
506 | ||
507 | if cursor: |
|
508 | cursor.close() |
|
509 | if cnx: |
|
510 | cnx.close() |
|
511 | ||
512 | resp.status = falcon.HTTP_204 |
|
513 |
@@ 462-494 (lines=33) @@ | ||
459 | ||
460 | resp.status = falcon.HTTP_200 |
|
461 | ||
462 | @staticmethod |
|
463 | @user_logger |
|
464 | def on_delete(req, resp, id_): |
|
465 | admin_control(req) |
|
466 | if not id_.isdigit() or int(id_) <= 0: |
|
467 | raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST', |
|
468 | description='API.INVALID_EMAIL_MESSAGE_ID') |
|
469 | ||
470 | cnx = mysql.connector.connect(**config.myems_fdd_db) |
|
471 | cursor = cnx.cursor() |
|
472 | ||
473 | cursor.execute(" SELECT id " |
|
474 | " FROM tbl_email_messages " |
|
475 | " WHERE id = %s ", (id_,)) |
|
476 | row = cursor.fetchone() |
|
477 | ||
478 | if row is None: |
|
479 | if cursor: |
|
480 | cursor.close() |
|
481 | if cnx: |
|
482 | cnx.close() |
|
483 | raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND', |
|
484 | description='API.EMAIL_MESSAGE_NOT_FOUND') |
|
485 | ||
486 | cursor.execute(" DELETE FROM tbl_email_messages WHERE id = %s ", (id_,)) |
|
487 | cnx.commit() |
|
488 | ||
489 | if cursor: |
|
490 | cursor.close() |
|
491 | if cnx: |
|
492 | cnx.close() |
|
493 | ||
494 | resp.status = falcon.HTTP_204 |
|
495 |
@@ 431-461 (lines=31) @@ | ||
428 | ||
429 | resp.status = falcon.HTTP_200 |
|
430 | ||
431 | @staticmethod |
|
432 | @user_logger |
|
433 | def on_delete(req, resp, id_): |
|
434 | admin_control(req) |
|
435 | if not id_.isdigit() or int(id_) <= 0: |
|
436 | raise falcon.HTTPError(status=falcon.HTTP_400, title='API.BAD_REQUEST', |
|
437 | description='API.INVALID_TEXT_MESSAGE_ID') |
|
438 | ||
439 | cnx = mysql.connector.connect(**config.myems_fdd_db) |
|
440 | cursor = cnx.cursor() |
|
441 | ||
442 | cursor.execute(" SELECT id FROM tbl_text_messages_outbox WHERE id = %s ", (id_,)) |
|
443 | row = cursor.fetchone() |
|
444 | ||
445 | if row is None: |
|
446 | if cursor: |
|
447 | cursor.close() |
|
448 | if cnx: |
|
449 | cnx.close() |
|
450 | raise falcon.HTTPError(status=falcon.HTTP_404, title='API.NOT_FOUND', |
|
451 | description='API.TEXT_MESSAGE_NOT_FOUND') |
|
452 | ||
453 | cursor.execute(" DELETE FROM tbl_text_messages_outbox WHERE id = %s ", (id_,)) |
|
454 | cnx.commit() |
|
455 | ||
456 | if cursor: |
|
457 | cursor.close() |
|
458 | if cnx: |
|
459 | cnx.close() |
|
460 | ||
461 | resp.status = falcon.HTTP_204 |
|
462 |