youzanyun-devtool-worker
Version:
- web - ws - proxy
74 lines (73 loc) • 2.69 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const axios_1 = tslib_1.__importDefault(require("axios"));
const pick_1 = tslib_1.__importDefault(require("lodash/pick"));
let getMockDetailCoupons;
class GetMockDetailCoupons {
static getInstance() {
if (!getMockDetailCoupons) {
getMockDetailCoupons = new GetMockDetailCoupons();
}
return getMockDetailCoupons;
}
async run(ctx) {
const { appName, pageNo, pageSize, ids } = ctx.query;
const res = await axios_1.default({
method: "GET",
url: "http://127.0.0.1:31240/api/design-platform/mock-data/list",
params: {
appName,
type: 'coupon',
pageNo,
pageSize,
ids,
}
});
if (res.data && res.data.data && res.data.data.content) {
const data = res.data.data.content || [];
delete res.data.data.content;
res.data.data = data.map((item) => {
const defaultItem = {
"alias": "",
"appoint_type": 1,
"condition": 0,
"discount": 0,
"date_type": 1,
"denominations": 100,
"description": "",
"fixed_term": 0,
"fixed_begin_term": 0,
"formative_context": "无使用门槛",
"group_type": 7,
"is_user_can_take": 1,
"is_sync_weixin": 0,
"is_invalid": 0,
"is_limit": 0,
"is_share": 1,
"is_delete": 0,
"is_forbid_preference": 0,
"id": 0,
"kdt_id": 0,
"preferential_type": 1,
"range_type": "all",
"stock_qty": 999,
"status": 1,
"total_used": 0,
"total_qty": 100,
"title": "测试",
"value_random_to": 0,
"valid_start_time": Date.now(),
"valid_end_time": Date.now() + 7 * 24 * 60 * 60 * 1000,
"max_discount_amount": 0,
};
const customData = pick_1.default(item, Object.keys(defaultItem));
const coupon = Object.assign(defaultItem, customData);
return coupon;
});
}
ctx.body = res.data;
}
}
exports.default = GetMockDetailCoupons;
;