update
This commit is contained in:
parent
164fad0a3e
commit
c902c4ccd8
63
main.py
63
main.py
@ -39,7 +39,7 @@ async def require_admin(request: Request):
|
||||
return payload
|
||||
|
||||
|
||||
app = FastAPI(title='文艺汇演评分系统', description='乌鲁木齐群众文化艺术展评')
|
||||
app = FastAPI()
|
||||
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
@ -102,6 +102,28 @@ def init_db():
|
||||
('admin_001', 'admin', 'admin123', datetime.now()),
|
||||
)
|
||||
|
||||
cursor.execute("SELECT COUNT(*) FROM settings WHERE key = 'main_title'")
|
||||
if cursor.fetchone()[0] == 0:
|
||||
cursor.execute(
|
||||
"INSERT INTO settings (key, value) VALUES ('main_title', '文化艺术展评'), ('sub_title', '文艺汇演')"
|
||||
)
|
||||
|
||||
cursor.execute('SELECT COUNT(*) FROM batches')
|
||||
if cursor.fetchone()[0] == 0:
|
||||
batches_data = []
|
||||
cursor.executemany(
|
||||
'INSERT INTO batches (name, created_at) VALUES (?, ?)',
|
||||
batches_data,
|
||||
)
|
||||
|
||||
cursor.execute('SELECT COUNT(*) FROM judges')
|
||||
if cursor.fetchone()[0] == 0:
|
||||
judges_data = []
|
||||
cursor.executemany(
|
||||
'INSERT INTO judges (id, name, order_num, created_at) VALUES (?, ?, ?, ?)',
|
||||
judges_data,
|
||||
)
|
||||
|
||||
cursor.execute("SELECT COUNT(*) FROM settings WHERE key = 'award_first'")
|
||||
if cursor.fetchone()[0] == 0:
|
||||
cursor.execute(
|
||||
@ -114,37 +136,6 @@ def init_db():
|
||||
"INSERT INTO settings (key, value) VALUES ('award_first_name', '一等奖'), ('award_second_name', '二等奖'), ('award_third_name', '三等奖')"
|
||||
)
|
||||
|
||||
cursor.execute("SELECT COUNT(*) FROM settings WHERE key = 'main_title'")
|
||||
if cursor.fetchone()[0] == 0:
|
||||
cursor.execute(
|
||||
"INSERT INTO settings (key, value) VALUES ('main_title', '乌鲁木齐群众文化艺术展评'), ('sub_title', '“建农杯”文艺汇演')"
|
||||
)
|
||||
|
||||
cursor.execute('SELECT COUNT(*) FROM batches')
|
||||
if cursor.fetchone()[0] == 0:
|
||||
cursor.execute(
|
||||
'INSERT INTO batches (name, created_at) VALUES (?, ?)',
|
||||
('第一批次', datetime.now()),
|
||||
)
|
||||
cursor.execute(
|
||||
'INSERT INTO batches (name, created_at) VALUES (?, ?)',
|
||||
('第二批次', datetime.now()),
|
||||
)
|
||||
|
||||
cursor.execute('SELECT COUNT(*) FROM judges')
|
||||
if cursor.fetchone()[0] == 0:
|
||||
judges_data = [
|
||||
('P.01', '王飞翔', 1, datetime.now()),
|
||||
('P.02', '冯建农', 2, datetime.now()),
|
||||
('P.03', '张宁', 3, datetime.now()),
|
||||
('P.04', '沈澜涛', 4, datetime.now()),
|
||||
('P.05', '龚楠', 5, datetime.now()),
|
||||
]
|
||||
cursor.executemany(
|
||||
'INSERT INTO judges (id, name, order_num, created_at) VALUES (?, ?, ?, ?)',
|
||||
judges_data,
|
||||
)
|
||||
|
||||
|
||||
init_db()
|
||||
|
||||
@ -303,8 +294,8 @@ async def get_title_settings():
|
||||
)
|
||||
titles = {row['key']: row['value'] for row in cursor.fetchall()}
|
||||
return {
|
||||
'main_title': titles.get('main_title', '乌鲁木齐群众文化艺术展评'),
|
||||
'sub_title': titles.get('sub_title', '“建农杯”文艺汇演'),
|
||||
'main_title': titles.get('main_title', ''),
|
||||
'sub_title': titles.get('sub_title', ''),
|
||||
}
|
||||
|
||||
|
||||
@ -1769,7 +1760,7 @@ HTML_TEMPLATE = """
|
||||
|
||||
async function renderAdminScoringTable() {
|
||||
if(!judgesData.length || !programsData.length){
|
||||
document.getElementById('adminScoringContainer').innerHTML = '<div style="text-align:center;padding:40px;">加载中...</div>';
|
||||
document.getElementById('adminScoringContainer').innerHTML = '<div style="text-align:center;padding:40px;">缺少评委或节目数据</div>';
|
||||
return;
|
||||
}
|
||||
const snList = programsData.map(p => p.sn);
|
||||
@ -2053,6 +2044,7 @@ HTML_TEMPLATE = """
|
||||
const category = document.getElementById('programCategory').value;
|
||||
const batch_id = parseInt(document.getElementById('programBatchId').value);
|
||||
if(!sn||!name){ showToast('请填写节目编号和名称'); return; }
|
||||
if(!batch_id){ showToast('请先添加批次'); return; }
|
||||
let res;
|
||||
if(editingProgramSn){
|
||||
res = await fetch(`/api/programs/${editingProgramSn}`, {
|
||||
@ -2097,6 +2089,7 @@ HTML_TEMPLATE = """
|
||||
const file = document.getElementById('importFile').files[0];
|
||||
if(!file){ showToast('请选择Excel文件'); return; }
|
||||
const batch_id = document.getElementById('importBatchId').value;
|
||||
if(!batch_id){ showToast('请先添加批次'); return; }
|
||||
const formData = new FormData();
|
||||
formData.append('file', file);
|
||||
const res = await fetch(`/api/programs/import?batch_id=${batch_id}`, {
|
||||
|
||||
BIN
score_system.db
BIN
score_system.db
Binary file not shown.
Loading…
Reference in New Issue
Block a user