backup: 完成 HR_position_ 表格前綴重命名與欄位對照表整理
變更內容: - 所有資料表加上 HR_position_ 前綴 - 整理完整欄位顯示名稱與 ID 對照表 - 模組化 JS 檔案 (admin.js, ai.js, csv.js 等) - 專案結構優化 (docs/, scripts/, tests/ 等) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -32,8 +32,8 @@ cors_origins = os.getenv('CORS_ORIGINS', 'http://localhost:5000,http://127.0.0.1
|
||||
CORS(app, origins=cors_origins)
|
||||
|
||||
# 模擬資料庫
|
||||
positions_db = {}
|
||||
jobs_db = {}
|
||||
HR_position_positions_db = {}
|
||||
HR_position_jobs_db = {}
|
||||
|
||||
# 預設崗位資料
|
||||
default_positions = {
|
||||
@@ -76,7 +76,7 @@ default_positions = {
|
||||
"updatedAt": "2024-01-01T00:00:00"
|
||||
}
|
||||
}
|
||||
positions_db.update(default_positions)
|
||||
HR_position_positions_db.update(default_positions)
|
||||
|
||||
# 預設職務資料
|
||||
default_jobs = {
|
||||
@@ -98,7 +98,7 @@ default_jobs = {
|
||||
"updatedAt": "2024-01-01T00:00:00"
|
||||
}
|
||||
}
|
||||
jobs_db.update(default_jobs)
|
||||
HR_position_jobs_db.update(default_jobs)
|
||||
|
||||
# ==================== 靜態頁面 ====================
|
||||
|
||||
@@ -118,7 +118,7 @@ def get_positions():
|
||||
size = request.args.get('size', 20, type=int)
|
||||
search = request.args.get('search', '', type=str)
|
||||
|
||||
filtered = list(positions_db.values())
|
||||
filtered = list(HR_position_positions_db.values())
|
||||
if search:
|
||||
filtered = [p for p in filtered
|
||||
if search.lower() in p['basicInfo'].get('positionCode', '').lower()
|
||||
@@ -142,9 +142,9 @@ def get_positions():
|
||||
|
||||
@app.route('/api/positions/<position_id>', methods=['GET'])
|
||||
def get_position(position_id):
|
||||
if position_id not in positions_db:
|
||||
if position_id not in HR_position_positions_db:
|
||||
return jsonify({'success': False, 'error': '找不到該崗位資料'}), 404
|
||||
return jsonify({'success': True, 'data': positions_db[position_id]})
|
||||
return jsonify({'success': True, 'data': HR_position_positions_db[position_id]})
|
||||
|
||||
@app.route('/api/positions', methods=['POST'])
|
||||
def create_position():
|
||||
@@ -160,7 +160,7 @@ def create_position():
|
||||
return jsonify({'success': False, 'error': '崗位名稱為必填欄位'}), 400
|
||||
|
||||
position_code = basic_info['positionCode']
|
||||
if position_code in positions_db:
|
||||
if position_code in HR_position_positions_db:
|
||||
return jsonify({'success': False, 'error': f'崗位編號 {position_code} 已存在'}), 409
|
||||
|
||||
now = datetime.now().isoformat()
|
||||
@@ -171,7 +171,7 @@ def create_position():
|
||||
'createdAt': now,
|
||||
'updatedAt': now
|
||||
}
|
||||
positions_db[position_code] = new_position
|
||||
HR_position_positions_db[position_code] = new_position
|
||||
return jsonify({'success': True, 'message': '崗位資料新增成功', 'data': new_position}), 201
|
||||
except Exception as e:
|
||||
return jsonify({'success': False, 'error': f'新增失敗: {str(e)}'}), 500
|
||||
|
||||
Reference in New Issue
Block a user