track.js
3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
"use strict";
const Controller = require("egg").Controller;
class TrackController extends Controller {
async create() {
const { ctx } = this;
// console.log('ctx.request.body: ', ctx.request.body);
// 定义创建项目接口的请求参数规则
const createRule = {
info: {
type: "array",
itemType: "object",
required: false,
rule: {
exta: "string?",
// id: 'number',
accountName: "string?",
userName: "string?",
accountType: "number?",
accountLevel: "number?",
userType: "number?",
merchantId: "number?",
merchantName: "string?",
admin: "boolean?",
merchantModel: "number?",
sapCode: { type: "string", required: false },
status: "number?",
staffAvatar: { type: "string", required: false },
isMerchantStaffAdmin: { type: "boolean", required: false },
token: "string?",
event: "string?",
pageUrl: "string?",
pageName: "string?",
intoTime: "string?",
leaveTime: "string?",
},
},
// merchant_name: 'number?',
// account_level: 'string?',
// merchant_id: 'number?',
// time_on_page: 'dateTime?',
// query_parameters: 'string?',
// channel_name: 'string?',
// choose_specialist: 'string?',
// welcome_message_code: 'string?',
// qr_code_link: 'string?',
// channel_id: 'number?',
// how_to_specify: 'string?',
// customer_information: 'string?',
// send_group_message: 'string?',
// welcome_message_market: 'string?',
// sop_name: 'string?',
// marketing_time: 'dateTime?',
// marketing_people: 'string?',
// update_crowd: 'string?',
// marketing_content: 'string?',
// marketing_channels: 'string?',
// follow_employees: 'string?',
// part_times: 'number?',
// select_group_account: 'string?',
// select_customer: 'string?',
// bulk_content: 'string?',
// send_time: 'dateTime?',
// group_name_group: 'string?',
// choose_owner_group: 'string?',
// bulk_content_group: 'string?',
// send_time_group: 'dateTime?',
// exta: 'string?',
// page_url: 'string?',
};
try {
// ctx.validate(createRule, ctx.request.body);
const result = await ctx.service.trackService.create(ctx.request.body);
ctx.body = result;
} catch (error) {
ctx.body = {
code: error.code,
message: error.message,
};
}
}
// 查询列表
async list() {
// todo 分页 page pageSize
// const page = ctx.query.page || 1;
//
// 分页
const { ctx } = this;
const result = await ctx.service.trackService.list(ctx.request.body);
ctx.body = result;
}
async pageList() {
const { ctx } = this;
const result = await ctx.service.trackService.pageList(ctx.request.body);
ctx.body = result;
}
}
module.exports = TrackController;