# 租戶通知特定對象(檔案上傳)
---
- 常數定義
- [推播任務狀態](#推播任務狀態)
- API 清單
- [取得管理列表](#取得管理列表)
- [取得管理明細](#取得管理明細)
- [取得上傳網址](#取得上傳網址)
- [新增推播任務](#新增推播任務)
- [編輯推播任務](#編輯推播任務)
- [刪除推播任務](#刪除推播任務)
---
## 常數定義
### 推播任務狀態
欄位 | 型態 | 說明
---|---|---
status | string | 推播任務狀態, NONE: 未推播, PUSHING: 推播中, PUSHED: 已推播
---
# API 清單
### 取得管理列表
```url
POST /tenant-push-mgmt/task/list
```
* 權限: 租戶管理員(TENANT_ADMIN)
#### Request-取得管理列表
##### Request-取得管理列表-query (查詢條件json)
欄位 | 型態 | 必填 | 長度限制 | 預設 | 說明
---|---|---|---|---|---
startDate | timestamp | Y | | | 查詢起始日
endDate | timestamp | Y | | | 查詢截止日
status | string | | 10 | | 推播任務狀態, 若未填表示查詢全部, 參閱 [推播任務狀態](#推播任務狀態)
keyword | string | | 50 | | 查詢標題或備註關鍵字
##### Request-取得管理列表-pagination (分頁json)
欄位 | 型態 | 必填 | 預設 | 說明
---|---|---|---|---
current | int | | 1 | 當前頁數
pageSize | int | | 10 | 每頁結果數量,-1 為顯示所有
##### Request-取得管理列表-sorter (排序json)
欄位 | 型態 | 必填 | 預設 | 說明
---|---|---|---|---
field | string | | updateTime | 排序欄位,可排序欄位有 title, pushTime, status, updateTime
order | string | | desc | 升序或降序
```javascript
{
"query": {
"startDate": "2023-08-20",
"endDate": "2023-09-01",
"status": null,
"keyword": null
},
"pagination": {
"current": 1,
"total": 1,
"pageSize": 10
},
"sorter": {
"field": "updateTime",
"order": "desc"
}
}
```
#### Response-取得管理列表
欄位 | 型態 | 說明
--- | --- | ---
id | string | 推播任務id
tenantId | string | 租戶 id
title | string | 標題
pushTime | timestamp | 推播時間
status | string | 推播任務狀態, 參閱 [推播任務狀態](#推播任務狀態)
remark | string | 備註
pushedTime | timestamp | 已推播時間
objectKey | string | 推播檔案的objectKey
url | string | 推播檔案可download 的 url, 時效 3600 秒
fileType | string | 推播檔案的檔案類型
fileName | string | 推播檔案的檔名
creator | string | 建立者 account id
updater | string | 更新者 account id
createTime | timestamp | 建立時間
updateTime | timestamp | 更新時間
taskCount | int | 推播檔案的資料筆數
successCount | int | 推播成功的筆數
failCount | int | 推播失敗的筆數
```javascript
{
"httpCode": 200,
"result": {
"data": [
{
"id": "91385431-d6db-4fba-9290-4af31f0d2991",
"tenantId": "5efcfd67-334e-45b3-bf49-7e52f5172891",
"title": "202309家樂福100元電子票券",
"pushTime": 1693531800000,
"status": "NONE",
"remark": "就是100元的電子票券,要搶要快!!",
"creator": "153245f8-bfe0-4e28-b357-9ee48aa0c04c",
"createTime": 1693476930379,
"updateTime": "2023-08-31 18:15:30.379924",
"objectKey": "tenant-push-mgmt/a70a3d2f-7445-41c2-a13c-5660ccd407d3.xlsx",
"url": "http://localhost:3004/v1/AUTH_test/kmuh/tenant-push-mgmt/a70a3d2f-7445-41c2-a13c-5660ccd407d3.xlsx?temp_url_sig=98752f4f2d6d275064f92a95e7a056d958a4afb5&temp_url_expires=1693484236",
"fileType": "xlsx",
"fileName": "H365_v3_匯入_會員訊息推播名單_sample.xlsx",
"taskCount": null,
"successCount": null,
"failCount": null
}
],
"pagination": {
"current": 1,
"pageSize": 10,
"total": 1
},
"sorter": {
"field": "updateTime",
"order": "desc"
},
"total": 1
}
}
```
### 取得管理明細
```url
POST /tenant-push-mgmt/task/info
```
* 權限: 租戶管理員(TENANT_ADMIN)
#### Request-取得管理明細
欄位 | 型態 | 必填 | 長度限制 | 預設 | 說明
---|---|---|---|---|---
id | string | Y | 36 | | 推播任務id
```javascript
{
"id": "91385431-d6db-4fba-9290-4af31f0d2991"
}
```
#### Response-取得管理明細
欄位 | 型態 | 說明
--- | --- | ---
id | string | 推播任務id
tenantId | string | 租戶 id
title | string | 標題
pushTime | timestamp | 推播時間
status | string | 推播任務狀態, 參閱 [推播任務狀態](#推播任務狀態)
remark | string | 備註
pushedTime | timestamp | 已推播時間
objectKey | string | 推播檔案的objectKey
url | string | 推播檔案可download 的 url, 時效 3600 秒
fileType | string | 推播檔案的檔案類型
fileName | string | 推播檔案的檔名
creator | string | 建立者 account id
updater | string | 更新者 account id
createTime | timestamp | 建立時間
updateTime | timestamp | 更新時間
taskCount | int | 推播檔案的資料筆數
successCount | int | 推播成功的筆數
failCount | int | 推播失敗的筆數
```javascript
{
"httpCode": 200,
"result": {
"data": {
"id": "91385431-d6db-4fba-9290-4af31f0d2991",
"tenantId": "5efcfd67-334e-45b3-bf49-7e52f5172891",
"title": "202309家樂福100元電子票券",
"pushTime": 1693531800000,
"status": "NONE",
"remark": "就是100元的電子票券,要搶要快!!",
"creator": "153245f8-bfe0-4e28-b357-9ee48aa0c04c",
"createTime": 1693476930379,
"updateTime": "2023-08-31 18:15:30.379924",
"objectKey": "tenant-push-mgmt/a70a3d2f-7445-41c2-a13c-5660ccd407d3.xlsx",
"url": "http://localhost:3004/v1/AUTH_test/kmuh/tenant-push-mgmt/a70a3d2f-7445-41c2-a13c-5660ccd407d3.xlsx?temp_url_sig=7d8ffe8ee530a69b7b4bbf06addca853689df53c&temp_url_expires=1693484264",
"fileType": "xlsx",
"fileName": "H365_v3_匯入_會員訊息推播名單_sample.xlsx",
"taskCount": null,
"successCount": null,
"failCount": null
}
}
}
```
### 取得上傳網址
```url
POST /tenant-push-mgmt/task/get-upload-url
```
* 權限: 租戶管理員(TENANT_ADMIN)
* 新增/編輯推播任務時用來上傳excel檔前, 要先取得可上傳檔案的網址
* 只允許上傳 .xlsx, .xls 檔案
#### Request-取得上傳網址
欄位 | 型態 | 必填 | 預設 | 說明
---|---|---|---|---
isMultipart | boolean | Y | false | 是否使用分段上傳
isThumbnail | boolean | Y | false | 上傳的是否為縮圖
fileName | String | Y | | 檔名,不包含副檔名,限制最多50字
fileType | String | Y | | 副檔名, 限制最多10字
totalPart | int | **N** (isMultipart=false)<br>**Y** (isMultipart=true) | | 總分塊數量,不可小於2
parts | Array [...part] | **N** (isMultipart=false)<br>**Y** (isMultipart=true) | | part 資訊
##### Request-取得上傳網址-part(Object)
欄位 | 型態 | 必填 | 預設 | 說明
---|---|---|---|---
chunkSize | int | Y | | 該 chunk 的大小, bytes
md5 | string | Y | | 該 part 的 md5
part | int | Y | | part number, 第幾塊 chunk
```javascript
// 單檔
{
"isMultipart": false,
"fileName": "H365_v3_匯入_會員訊息推播名單_sample.xlsx",
"fileType": "xlsx",
"totalPart": null,
"parts": [
],
"isThumbnail": false
}
// 分塊上傳
{
isMultipart: true,
isThumbnail: false,
fileName: giphy (7),
fileType: mp4,
totalPart: 2,
parts: [
{
chunkSize: 5242880,
md5: 5AACA89868CD486D81192221CF9F9415,
part: 1
},
{
chunkSize: 3145728,
md5: 5AACA89868CD486D81192221CF9F9415,
part: 2
}
]
}
```
#### Error-取得上傳網址
httpCode | 錯誤碼 | 說明
--- | --- | ---
422 | SERVICE_ERROR.UPLOAD_FILE_TYPE_NOT_ALLOWED | 上傳的檔案類型不允許
#### Response-取得上傳網址
##### Response-取得上傳網址-data
欄位 | 型態 | 說明
--- | --- | ---
objectKey | string | storage 中的 objectKey, **unique**
uploadId | string | 識別該次上傳的 uploadId
fileName | string | 名稱
fileType | string | 副檔名
url | string | 單檔上傳的時候,才會回傳該 url, 時效 3600 秒
parts | [...part] | multipart上傳各part的url
##### Response-取得上傳網址-part
欄位 | 型態 | 說明
--- | --- | ---
chunkSize | int | 該 chunk 的大小, bytes
md5 | string | 該 part 的 md5
part | int | part number, 第幾塊 chunk
url | string | 可上傳的 url, 時效 3600 秒
```javascript
// 單檔
{
"httpCode": 200,
"result": {
"data": {
"objectKey": "tenant-push-mgmt/c90d1464-97ac-4eed-8fc0-3d711f497672.xlsx",
"uploadId": "1abded54-5ef2-44b2-b5aa-9e99dc418ad3",
"fileName": "H365_v3_匯入_會員訊息推播名單_sample.xlsx",
"fileType": "xlsx",
"url": "http://localhost:3004/v1/AUTH_test/kmuh/tenant-push-mgmt/c90d1464-97ac-4eed-8fc0-3d711f497672.xlsx?temp_url_sig=c1b6a224f40f8cdc370fae4d91f71dbbb27d6e1d&temp_url_expires=1693483919"
}
}
}
// 分塊上傳
{
httpCode: 200,
result: {
data: {
objectKey: tenant-push-mgmt/c90d1464-97ac-4eed-8fc0-3d711f497672.xlsx,
uploadId: 53fde368-43d9-455f-a610-62091fc30be6,
fileName: giphy (7),
fileType: mp4,
parts: [
{
chunkSize: 5242880,
md5: 5AACA89868CD486D81192221CF9F9415,
part: 1,
url: http://swift-storage/tenant-push-mgmt/c90d1464-97ac-4eed-8fc0-3d711f497672.xlsx
},
{
chunkSize: 3145728,
md5: 5AACA89868CD486D81192221CF9F9415,
part: 2,
url: http://swift-storage/tenant-push-mgmt/c90d1464-97ac-4eed-8fc0-3d711f497672.xlsx
}
]
}
}
}
```
### 新增推播任務
```url
POST /tenant-push-mgmt/task/add
```
* 權限: 租戶管理員(TENANT_ADMIN)
#### Request-新增推播任務
欄位 | 型態 | 必填 | 長度限制 | 預設 | 說明
---|---|---|---|---|---
title | string | | 200 | | 標題
pushTime | timestamp | Y | | | 推播時間
remark | string | | 2000 | | 備註
contentObject | json | Y | | | 上傳推播檔案 json
##### Request-新增推播任務-contentObject(json)
欄位 | 型態 | 必填 | 長度限制 | 預設 | 說明
---|---|---|---|---|---
objectKey | string | Y | 500 | | 上傳檔案的objectKey, 先取得檔案的上傳網址並上傳成功,取其 objectKey。
isMultipart | boolean | N | | | 檔案上傳時是否分塊上傳,預設為 false
totalPart | int | **N** (isMultipart=false)<br>**Y** (isMultipart=true) | | | 檔案上傳的總分塊數量,不可小於2
uploadId | string | **N** (isMultipart=false)<br>**Y** (isMultipart=true) | | | 從 /tenant-push-mgmt/task/get-upload-url 取得的 uploadId
```javascript
{
"title": "202309家樂福100元電子票券",
"pushTime": 1693531800000,
"remark": "就是100元的電子票券,要搶要快!!",
"contentObject": {
"objectKey": "tenant-push-mgmt/a70a3d2f-7445-41c2-a13c-5660ccd407d3.xlsx",
"isMultipart": false
}
}
```
#### Error-新增推播任務
httpCode | 錯誤碼 | 說明
--- | --- | ---
400 | API_ERROR.ARGUMENT_ERROR | 輸入參數錯誤, 可參閱 errorDesc
#### Response-新增推播任務
欄位 | 型態 | 說明
--- | --- | ---
id | string | 推播任務id
tenantId | string | 租戶 id
title | string | 標題
pushTime | timestamp | 推播時間
status | string | 推播任務狀態, 參閱 [推播任務狀態](#推播任務狀態)
remark | string | 備註
pushedTime | timestamp | 已推播時間
creator | string | 建立者 account id
updater | string | 更新者 account id
createTime | timestamp | 建立時間
updateTime | timestamp | 更新時間
```javascript
{
"httpCode": 200,
"result": {
"data": {
"id": "91385431-d6db-4fba-9290-4af31f0d2991",
"tenantId": "5efcfd67-334e-45b3-bf49-7e52f5172891",
"title": "202309家樂福100元電子票券",
"pushTime": 1693531800000,
"status": "NONE",
"remark": "就是100元的電子票券,要搶要快!!",
"creator": "153245f8-bfe0-4e28-b357-9ee48aa0c04c",
"createTime": 1693476930379,
"updateTime": "2023-08-31 18:15:30.379924"
}
}
}
```
### 編輯推播任務
```url
POST /tenant-push-mgmt/task/update
```
* 權限: 租戶管理員(TENANT_ADMIN)
#### Request-編輯推播任務
欄位 | 型態 | 必填 | 長度限制 | 預設 | 說明
---|---|---|---|---|---
id | string | Y | 36 | | 推播任務id
title | string | | 200 | | 標題
pushTime | timestamp | Y | | | 推播時間
remark | string | | 2000 | | 備註
contentObject | json | Y | | | 上傳推播檔案 json
##### Request-編輯推播任務-contentObject(json)
欄位 | 型態 | 必填 | 長度限制 | 預設 | 說明
---|---|---|---|---|---
objectKey | string | Y | 500 | | 上傳檔案的objectKey, 先取得檔案的上傳網址並上傳成功,取其 objectKey。
isMultipart | boolean | N | | | 檔案上傳時是否分塊上傳,預設為 false
totalPart | int | **N** (isMultipart=false)<br>**Y** (isMultipart=true) | | | 檔案上傳的總分塊數量,不可小於2
uploadId | string | **N** (isMultipart=false)<br>**Y** (isMultipart=true) | | | 從 /tenant-push-mgmt/task/get-upload-url 取得的 uploadId
```javascript
{
"id": "91385431-d6db-4fba-9290-4af31f0d2991",
"title": "202309家樂福100元電子票券",
"pushTime": 1692617732000,
"remark": "就是100元的電子票券,要搶要快!!",
"contentObject": {
"objectKey": "user-content/dengue/150b53f5-7126-4900-9fb0-87a08b45e06b/5399c12-c5fd-4a2f-8d8a-641e1c63acea.png",
"isMultipart": false
}
}
```
#### Error-編輯推播任務
httpCode | 錯誤碼 | 說明
--- | --- | ---
400 | API_ERROR.ARGUMENT_ERROR | 輸入參數錯誤, 可參閱 errorDesc
400 | API_ERROR.ARGUMENT_ERROR | 資料不存在
403 | API_ERROR.PERMISSION_DENIED | 無此操作權限
#### Response-編輯推播任務
欄位 | 型態 | 說明
--- | --- | ---
id | string | 推播任務id
tenantId | string | 租戶 id
title | string | 標題
pushTime | timestamp | 推播時間
status | string | 推播任務狀態, 參閱 [推播任務狀態](#推播任務狀態)
remark | string | 備註
pushedTime | timestamp | 已推播時間
creator | string | 建立者 account id
updater | string | 更新者 account id
createTime | timestamp | 建立時間
updateTime | timestamp | 更新時間
```javascript
{
"httpCode": 200,
"result": {
"data": {
"id": "91385431-d6db-4fba-9290-4af31f0d2991",
"tenantId": "5efcfd67-334e-45b3-bf49-7e52f5172891",
"title": "202309家樂福100元電子票券",
"pushTime": 1693531800000,
"status": "NONE",
"remark": "就是100元的電子票券,要搶要快!!",
"creator": "153245f8-bfe0-4e28-b357-9ee48aa0c04c",
"createTime": 1693476930379,
"updateTime": "2023-08-31 18:15:30.379924"
}
}
}
```
### 刪除推播任務
```url
POST /tenant-push-mgmt/task/delete
```
* 權限: 租戶管理員(TENANT_ADMIN)
#### Request-刪除推播任務
欄位 | 型態 | 必填 | 長度限制 | 預設 | 說明
---|---|---|---|---|---
id | string | Y | 36 | | 推播任務id
```javascript
{
"id": "91385431-d6db-4fba-9290-4af31f0d2991"
}
```
#### Error-刪除推播任務
httpCode | 錯誤碼 | 說明
--- | --- | ---
400 | API_ERROR.ARGUMENT_ERROR | 輸入參數錯誤, 可參閱 errorDesc
400 | API_ERROR.ARGUMENT_ERROR | 資料不存在
403 | API_ERROR.PERMISSION_DENIED | 無此操作權限
#### Response-刪除推播任務
欄位 | 型態 | 說明
--- | --- | ---
count | int | 成功刪除筆數
```javascript
{
"httpCode": 200,
"result": {
"data": {
"count": 1
}
}
}
```