Skip to content
Snippets Groups Projects
Verified Commit c06193e6 authored by Eunhak Lee's avatar Eunhak Lee
Browse files

chore: 부품 유형 별 기본 이미지 설정

parent 838b78c4
Branches
No related tags found
No related merge requests found
Pipeline #10861 passed
...@@ -61,11 +61,11 @@ def create_new_one(_dict, part_type, _cursor): ...@@ -61,11 +61,11 @@ def create_new_one(_dict, part_type, _cursor):
columns = ", ".join([f'"{key}"' for key, _ in _obj]) columns = ", ".join([f'"{key}"' for key, _ in _obj])
values = [value for _, value in _obj] values = [value for _, value in _obj]
sql = """WITH rows AS (INSERT INTO parts (name, type) VALUES (%s, %s) ON CONFLICT (name) DO UPDATE SET name = excluded.name RETURNING id) sql = """WITH rows AS (INSERT INTO parts (name, type, image_url) VALUES (%s, %s, %s) ON CONFLICT (name) DO UPDATE SET name = excluded.name RETURNING id)
INSERT INTO part_info_{type} (part_id, {columns}) INSERT INTO part_info_{type} (part_id, {columns})
(SELECT rows.id, {value_entries} FROM rows) (SELECT rows.id, {value_entries} FROM rows)
RETURNING part_id;""".format(type=_part_type_enum, columns=columns, value_entries=", ".join(["%s"] * len(values))) RETURNING part_id;""".format(type=_part_type_enum, columns=columns, value_entries=", ".join(["%s"] * len(values)))
_cursor.execute(sql, (name, _part_type_enum, *values)) _cursor.execute(sql, (name, _part_type_enum, "/static/img/placeholder/{}.png".format(part_type.lower()), *values))
data = _cursor.fetchall() data = _cursor.fetchall()
if data: if data:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment