# API討論區 ### 排程功能 #### ` POST /api2/getBatchCode` #### **Request** ##### 根據不同的job_name夾帶不同的參數 | job_name | 描述 | | --- | -------- | | estate_batch_upload_monthly_report |批次上傳物件報表 | estate_batch_close_rent | 取消物件刊登招租廣告 | estate_batch_open_rent | 刊登招租廣告| | estate_import_monthly_statement | 物件匯入每月對帳單 | community_export |匯出社區 | estate_export | 匯出物件 | contract_export | 匯出合約 | repair_export | 匯出修繕單 | repair_export | 匯出修繕單 | estate_batch_edit_bigLandlord | 批次編輯大房東物件權限(新增修改刪除) | estate_batch_edit_agent | 批次編輯經理人物件or合約(新增修改) 1. 批次上傳物件報表 ```json { "job_name":"estate_batch_upload_monthly_report" "estatesIds":[], "publicUrl":"", "date": "", "total":123, "searchOptions":{ // ex. country : 1,.... }, } ``` 2. 批次物件刊登招租廣告/批次取消物件刊登招租廣告/匯出物件 ```json { "job_name": "estate_batch_open_rent" //estate_batch_close_rent //estate_export "estatesIds":[], "total":123, "searchOptions":{ // ex. country : 1,.... }, } ``` 3. 匯出社區 ```json { "job_name": "community_export" "communityIds":[], "total":123, "searchOptions":{ // ex. country : 1,.... }, } ``` 4. 匯出合約 ```json { "job_name": "contract_export" "contractIds":[], "total":123, "searchOptions":{ // ex. country : 1,.... }, } ``` 5. 匯出修繕單 ```json { "job_name": "repair_export" "repairIds":[], "total":123, "searchOptions":{ // ex. country : 1,.... }, } ``` 6.7. 批次編輯大房東權限,批次編輯經理人物件合約 ```json { "job_name": "estate_batch_edit_agent" "action" : "estate" /// estate or contract //// 當使用個別編輯時使用下列格式 //// "data":[ editId : [ 'id' : editId, 'editUserId' : editUserId, ], editId : [ ... ] ], //// 當使用批次編輯時使用下列格式 //// "total":123, "searchOptions":{ // ex. country : 1,.... }, "editUserId" : editUserId, } ``` ```json { "job_name": "estate_batch_edit_bigLandlord" "action" : "estate" // always estate //// 當使用個別編輯時使用下列格式 //// "data":[ editId : [ 'id' : editId, //物件的ID 'editUserId' : editUserId, //使用者的ID 'capabilities' : [ 'show_estate' : 0, 'show_contract' : 0, ... (沒寫上來就不會進行修改,新增的情況請傳空陣列) ], ], editId : [ ... ] ], //// 當使用批次編輯時使用下列格式 //// "total":123, "searchOptions":{ // ex. country : 1,.... }, "editUserId" : editUserId, "capabilitiesReplace" : [ 'show_estate' : 0, 'show_contract' : 0, ... (沒寫上來就不會進行修改,新增的情況會預設為0) ], } ``` #### 參數列表 | 參數名稱 | 類型 | 必填 | 描述 | ------------- | --------------- | ------------------ | ----------------- | job_name | String | 是 | 上述資料 | | total | number | when Ids is string | 物件數量(後端驗證用) | | searchOptions | Array | when Ids is string | 搜尋條件 | | estatesIds | Array\\\ String | 是 | 要上傳的多個物件Id,如果是全選會帶'all'並帶query給後端告知哪些物件 | | communityIds | 同上 | 同上 | 同上 | | constarctIds | 同上 | 同上 | 同上 | | repairIds | 同上 | 同上 | 同上 | | publicUrl | String | 是 | 上傳的pdfUrl | | date | String | 是 | 年月(YYYYmm) | #### **Response** ```json //success { "success": true, "data": { "batch_code": "xxxxxxxxxxxxxxx" } } //fail { "success": "false", } ``` --- 接著batch_code後會再打這支取得目前狀態與資料 ### 取得目前狀態 #### ` GET /api2/getBatchStatus` ` 錯誤訊息由前端顯示與判定` #### **Response** ```json //未完成狀態 { "batch_code": "6552e15d743264.42384055", "process": 50, "success": false } // 完成狀態 { "code": 200 //200,500,400,403,.... "success": true, "data":{ "batch_code": "6552e15d743264.42384055", "url": '........xls'.. //如果是donwload會帶 "file_name":'xxxxxx',//donwload會夾帶 "process": 100 "failed_estates_amount":199 //部分成功與全部失敗會回傳的訊息 } } ``` | code | 描述 | | -------- |-------- | |200 |回應成功,命令完整執行(全部成功&部分成功) | |204 |回應成功,但沒有符合編輯需求的內容(全部失敗)| |400 |客戶端傳送資料格式錯誤 | |403 |客戶端使用者沒有操作權限 | |500 |伺服器端資料執行發生錯誤或資料正確性驗證失敗 |