完善权限系统
This commit is contained in:
@@ -0,0 +1,101 @@
|
||||
import utils.MyUtils as MyUtils
|
||||
from config.minIO import get_temp_url
|
||||
from config.pgDb import pg_pool
|
||||
|
||||
|
||||
def get_ticket_image_list(user_id):
|
||||
with pg_pool.getConn() as conn:
|
||||
with conn.cursor() as cursor:
|
||||
cursor.execute(
|
||||
"""
|
||||
SELECT created_at, file_name, resolution, size, name,
|
||||
moisture_content, cocoon_weight, defective_pupa_count,
|
||||
fresh_shell_weight, sample_count, barcode, oss,
|
||||
net_weight_total, evaluator, reviewer,id ,dead_pupa_count
|
||||
FROM ticket_images
|
||||
WHERE created_by = %s
|
||||
""",
|
||||
(user_id,),
|
||||
)
|
||||
rows = cursor.fetchall()
|
||||
result = []
|
||||
for row in rows:
|
||||
result.append(
|
||||
{
|
||||
"created_at": MyUtils.format_datetime(row[0]),
|
||||
"file_name": row[1],
|
||||
"resolution": row[2],
|
||||
"size": round(row[3] / 1024, 2),
|
||||
"name": row[4],
|
||||
"moisture_content": row[5],
|
||||
"cocoon_weight": row[6],
|
||||
"defective_pupa_count": row[7],
|
||||
"fresh_shell_weight": row[8],
|
||||
"sample_count": row[9],
|
||||
"barcode": row[10],
|
||||
"oss_url": get_temp_url("image-ticket", row[11]),
|
||||
"net_weight_total": row[12],
|
||||
"evaluator": row[13],
|
||||
"reviewer": row[14],
|
||||
"id": row[15],
|
||||
"dead_pupa_count": row[16],
|
||||
}
|
||||
)
|
||||
return result
|
||||
|
||||
|
||||
def insert_ticket_image(
|
||||
created_by,
|
||||
file_name,
|
||||
resolution,
|
||||
size,
|
||||
name,
|
||||
moisture_content,
|
||||
cocoon_weight,
|
||||
defective_pupa_count,
|
||||
dead_pupa_count,
|
||||
fresh_shell_weight,
|
||||
sample_count,
|
||||
barcode,
|
||||
oss,
|
||||
net_weight_total,
|
||||
evaluator,
|
||||
reviewer,
|
||||
):
|
||||
with pg_pool.getConn() as conn:
|
||||
with conn.cursor() as cursor:
|
||||
cursor.execute(
|
||||
"""
|
||||
INSERT INTO ticket_images (
|
||||
created_by, file_name, resolution, size, name,
|
||||
moisture_content, cocoon_weight, defective_pupa_count, dead_pupa_count,
|
||||
fresh_shell_weight, sample_count, barcode, oss,
|
||||
net_weight_total, evaluator, reviewer, created_at
|
||||
)
|
||||
VALUES (%s, %s, %s, %s, %s, %s,
|
||||
%s, %s, %s, %s, %s,
|
||||
%s, %s, %s, %s, %s, NOW())
|
||||
RETURNING id
|
||||
""",
|
||||
(
|
||||
created_by,
|
||||
file_name,
|
||||
resolution,
|
||||
size,
|
||||
name,
|
||||
moisture_content,
|
||||
cocoon_weight,
|
||||
defective_pupa_count,
|
||||
dead_pupa_count,
|
||||
fresh_shell_weight,
|
||||
sample_count,
|
||||
barcode,
|
||||
oss,
|
||||
net_weight_total,
|
||||
evaluator,
|
||||
reviewer,
|
||||
),
|
||||
)
|
||||
new_id = cursor.fetchone()[0]
|
||||
conn.commit()
|
||||
return new_id
|
||||
Reference in New Issue
Block a user