更新
This commit is contained in:
@@ -204,6 +204,15 @@ def create_insurance_rate(rate: schemas.InsuranceRateCreate):
|
||||
"""保険料率を作成"""
|
||||
with get_connection() as conn:
|
||||
with conn.cursor() as cur:
|
||||
# 既存の同キー(rate_year, rate_type, calculation_target, prefecture)が存在しないか確認
|
||||
cur.execute(
|
||||
"SELECT 1 FROM insurance_rates WHERE rate_year = %s AND rate_type = %s AND calculation_target = %s AND prefecture = %s LIMIT 1",
|
||||
(rate.rate_year, rate.rate_type, rate.calculation_target, rate.prefecture)
|
||||
)
|
||||
if cur.fetchone():
|
||||
# 重複があればクライアントに分かりやすく 409 を返す
|
||||
raise HTTPException(status_code=status.HTTP_409_CONFLICT, detail="指定された年度・種類・計算対象・都道府県の保険料率は既に存在します")
|
||||
|
||||
cur.execute(
|
||||
"""
|
||||
INSERT INTO insurance_rates (
|
||||
|
||||
Reference in New Issue
Block a user