Initial commit
This commit is contained in:
55
services/documents.py
Normal file
55
services/documents.py
Normal file
@@ -0,0 +1,55 @@
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
def update_comment_1c(conn, doc_id, comment):
|
||||
cursor = conn.cursor()
|
||||
now = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||
cursor.execute(
|
||||
"""
|
||||
UPDATE documents_1c
|
||||
SET comment = ?, updated_at = ?
|
||||
WHERE id = ?
|
||||
""",
|
||||
(comment.strip(), now, doc_id),
|
||||
)
|
||||
conn.commit()
|
||||
return cursor.rowcount > 0
|
||||
|
||||
|
||||
def update_comment_sbis(conn, doc_id, comment):
|
||||
cursor = conn.cursor()
|
||||
now = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||
cursor.execute(
|
||||
"""
|
||||
UPDATE documents_sbis
|
||||
SET comment = ?, updated_at = ?
|
||||
WHERE id = ?
|
||||
""",
|
||||
(comment.strip(), now, doc_id),
|
||||
)
|
||||
conn.commit()
|
||||
return cursor.rowcount > 0
|
||||
|
||||
|
||||
def get_distinct_states_1c(conn):
|
||||
rows = conn.execute(
|
||||
"""
|
||||
SELECT DISTINCT state
|
||||
FROM documents_1c
|
||||
WHERE state IS NOT NULL AND TRIM(state) != ''
|
||||
ORDER BY state COLLATE NOCASE
|
||||
"""
|
||||
).fetchall()
|
||||
return [r[0] for r in rows]
|
||||
|
||||
|
||||
def get_distinct_states_sbis(conn):
|
||||
rows = conn.execute(
|
||||
"""
|
||||
SELECT DISTINCT state
|
||||
FROM documents_sbis
|
||||
WHERE state IS NOT NULL AND TRIM(state) != ''
|
||||
ORDER BY state COLLATE NOCASE
|
||||
"""
|
||||
).fetchall()
|
||||
return [r[0] for r in rows]
|
||||
Reference in New Issue
Block a user