75 lines
1.7 KiB
JavaScript
Vendored
75 lines
1.7 KiB
JavaScript
Vendored
/**
|
|
* 取得媒體
|
|
*
|
|
* 參數:
|
|
* category_id: 分類ID
|
|
* last_fetched_media_id: 最後一個取得的媒體media
|
|
* limit: 取得的數量
|
|
*
|
|
* Response:
|
|
* medias: 媒體資訊
|
|
*/
|
|
export const get = (categoryId, lastFetchedMediaId = null, limit = null, data = {}) => {
|
|
data = Object.assign({
|
|
category_id: categoryId,
|
|
last_fetched_media_id: lastFetchedMediaId,
|
|
limit: limit
|
|
}, data)
|
|
return axios.get(app.admin.ajax.resource.mediaFile.get, {params: data});
|
|
}
|
|
/**
|
|
* 更新媒體描述
|
|
*
|
|
* 參數:
|
|
* id: 媒體ID
|
|
* description: 描述
|
|
*
|
|
* Response:
|
|
* message: 訊息
|
|
*/
|
|
export const update = (id, description = '', data = {}) => {
|
|
data = Object.assign({
|
|
description: description
|
|
}, data);
|
|
return axios.put(app.admin.ajax.resource.mediaFile.update.replace(':id', id), data);
|
|
}
|
|
/**
|
|
* 刪除媒體
|
|
*
|
|
* 參數:
|
|
* id: 媒體ID
|
|
*
|
|
* Success Response:
|
|
* id: 媒體ID
|
|
* message: 訊息
|
|
*
|
|
* Error Response:
|
|
* message: 訊息
|
|
*/
|
|
export const destroy = (id, data = {}) => {
|
|
return axios.delete(app.admin.ajax.resource.mediaFile.destroy.replace(':id', id), data);
|
|
}
|
|
/**
|
|
* 更新媒體的分類
|
|
*
|
|
* 參數:
|
|
* category_id: 分類ID
|
|
* media_ids: 媒體的ID字串(使用逗號分隔)
|
|
*
|
|
* Success Response:
|
|
* mediaIds: 被移動的媒體ID
|
|
* categoryId: 被移動至的分類ID
|
|
* categorySources: 被移動的媒體的舊分類ID與數量
|
|
* message: 訊息
|
|
*
|
|
* Error Response:
|
|
* message: 訊息
|
|
*/
|
|
export const updateCategory = (mediaIds, categoryId, data = {}) => {
|
|
data = Object.assign({
|
|
media_ids: mediaIds,
|
|
category_id: categoryId
|
|
}, data)
|
|
return axios.put(app.admin.ajax.resource.mediaFile.updateCategory, data);
|
|
}
|