minapp-fetch
Version:
47 lines (46 loc) • 1.89 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
/*
* @Author: your name
* @Date: 2020-04-16 19:20:44
* @LastEditTime: 2020-04-16 19:53:34
* @LastEditors: Please set LastEditors
* @Description: In User Settings Edit
* @FilePath: /minapp-fetch/src/fetch/content/updateCategory.ts
*/
const utils_1 = require("./utils/utils");
const constants_1 = require("./constants/constants");
const error_1 = require("./constants/error");
function fetchUpdateCategory(contentGroupID, categoryID, params) {
let { BaaS_F, minapp } = utils_1.getBaaSF();
return new Promise((resolve, reject) => {
if (constants_1.PLATFORM_NAME_BAAS.indexOf(minapp) > -1) {
if (minapp === constants_1.PLATFORM_NAME.ZX_CLOUD) {
let MyContentCategory = new BaaS_F.ContentCategory(contentGroupID);
MyContentCategory.update(categoryID, params).then((res) => {
// success
resolve(res);
}, (err) => {
// err
reject(err);
});
}
}
//MongoDB
if (constants_1.PLATFORM_NAME_MONGO_SERVER.indexOf(minapp) > -1) {
throw new Error(`minapp.updateCategory ${error_1.METHOD_NOT_SUPPORT}`);
}
//op 运营后台
if (minapp === constants_1.PLATFORM_NAME.ZX_OP) {
BaaS_F.put(`https://cloud.minapp.com/userve/v2.2/content/${contentGroupID}/category/${categoryID}/`, params).then((res) => {
resolve(res);
}).catch((err) => {
reject(err);
});
}
if (constants_1.PLATFORM_ALL.indexOf(minapp) === -1) {
throw new Error(`minapp.updateCategory ${error_1.METHOD_NOT_SUPPORT}`);
}
});
}
exports.default = fetchUpdateCategory;