@jiexiaoyin/wecom-api 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +228 -0
- package/config.example.json +7 -0
- package/config.js +76 -0
- package/docs/approval-templates.example.json +11 -0
- package/docs/nginx-mirror.md +193 -0
- package/openclaw.plugin.json +15 -0
- package/package.json +34 -0
- package/plugin.cjs +172 -0
- package/plugin.ts +136 -0
- package/skills/wecom-api/SKILL.md +40 -0
- package/skills/wecom-api/index.js +288 -0
- package/skills/wecom-api/openclaw.plugin.json +10 -0
- package/src/callback-helper.js +198 -0
- package/src/config.cjs +286 -0
- package/src/core/permission.js +479 -0
- package/src/crypto.js +130 -0
- package/src/index.js +199 -0
- package/src/modules/addressbook/index.js +413 -0
- package/src/modules/addressbook_cache/index.js +365 -0
- package/src/modules/advanced/index.js +159 -0
- package/src/modules/app/index.js +102 -0
- package/src/modules/approval/index.js +146 -0
- package/src/modules/auth/index.js +103 -0
- package/src/modules/callback/index.js +1180 -0
- package/src/modules/chain/index.js +193 -0
- package/src/modules/checkin/index.js +142 -0
- package/src/modules/checkin_rules/index.js +251 -0
- package/src/modules/contact/index.js +481 -0
- package/src/modules/contact_stats/index.js +349 -0
- package/src/modules/custom/index.js +140 -0
- package/src/modules/customer/index.js +51 -0
- package/src/modules/disk/index.js +245 -0
- package/src/modules/document/index.js +282 -0
- package/src/modules/hr/index.js +93 -0
- package/src/modules/intelligence/index.js +346 -0
- package/src/modules/kf/index.js +74 -0
- package/src/modules/live/index.js +122 -0
- package/src/modules/media/index.js +183 -0
- package/src/modules/meeting/index.js +665 -0
- package/src/modules/message/index.js +402 -0
- package/src/modules/messenger/index.js +208 -0
- package/src/modules/moments/index.js +161 -0
- package/src/modules/msgaudit/index.js +24 -0
- package/src/modules/notify/index.js +81 -0
- package/src/modules/oceanengine/index.js +199 -0
- package/src/modules/openchat/index.js +197 -0
- package/src/modules/phone/index.js +45 -0
- package/src/modules/room/index.js +178 -0
- package/src/modules/schedule/index.js +246 -0
- package/src/modules/school/index.js +199 -0
- package/src/modules/security/index.js +223 -0
- package/src/modules/sensitive/index.js +170 -0
- package/src/modules/thirdparty/index.js +145 -0
- package/src/sdk/index.js +269 -0
- package/src/utils/callback-helper.js +198 -0
- package/test/callback-crypto.test.js +55 -0
- package/test/crypto.test.js +85 -0
- package/test/permission.test.js +115 -0
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 上下游管理模块
|
|
3
|
+
* API 章节:六 - 上下游
|
|
4
|
+
* 包含:基础接口、上下游通讯录管理、上下游规则、回调事件
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const WeComSDK = require('../../sdk');
|
|
8
|
+
|
|
9
|
+
class Chain extends WeComSDK {
|
|
10
|
+
constructor(config) {
|
|
11
|
+
super(config);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// ========== 基础接口 ==========
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* 获取应用共享信息
|
|
18
|
+
* @param {string} agentId 应用 ID
|
|
19
|
+
*/
|
|
20
|
+
async getCorpSharedInfo(agentId) {
|
|
21
|
+
return this.post('/thirdparty/get_corp_shared_info', { agentid: agentId });
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* 获取下级/下游企业的 access_token
|
|
26
|
+
* @param {string} corpId 下级企业 ID
|
|
27
|
+
*/
|
|
28
|
+
async getSubCorpToken(corpId) {
|
|
29
|
+
return this.post('/thirdparty/get_sub_corp_token', { corpid: corpId });
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* 获取下级/下游企业小程序 session
|
|
34
|
+
* @param {string} userId 用户 ID
|
|
35
|
+
* @param {string} sessionKey 小程序 session key
|
|
36
|
+
* @param {number} type 类型
|
|
37
|
+
*/
|
|
38
|
+
async getSubCorpMiniProgramSession(userId, sessionKey, type = 1) {
|
|
39
|
+
return this.post('/thirdparty/get_sub_corp_mini_program_session', {
|
|
40
|
+
userid: userId,
|
|
41
|
+
session_key: sessionKey,
|
|
42
|
+
type
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* 获取上下游关联客户信息(已添加客户)
|
|
48
|
+
* @param {string} userId 成员 ID
|
|
49
|
+
* @param {string} externalUserId 外部客户 ID
|
|
50
|
+
*/
|
|
51
|
+
async getChainCustomerInfo(userId, externalUserId) {
|
|
52
|
+
return this.post('/externalchain/get_customer_info', {
|
|
53
|
+
userid: userId,
|
|
54
|
+
external_userid: externalUserId
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* 获取上下游关联客户信息(未添加客户)
|
|
60
|
+
* @param {string} chainId 上下游 ID
|
|
61
|
+
* @param {string} userId 成员 ID
|
|
62
|
+
*/
|
|
63
|
+
async getChainPendingCustomerInfo(chainId, userId) {
|
|
64
|
+
return this.post('/externalchain/get_pending_customer_info', {
|
|
65
|
+
chain_id: chainId,
|
|
66
|
+
userid: userId
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// ========== 上下游通讯录管理 ==========
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* 获取上下游信息
|
|
74
|
+
* @param {string} chainId 上下游 ID
|
|
75
|
+
*/
|
|
76
|
+
async getChainInfo(chainId) {
|
|
77
|
+
return this.post('/externalchain/get_chain_info', { chain_id: chainId });
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* 批量导入上下游联系人
|
|
82
|
+
* @param {string} chainId 上下游 ID
|
|
83
|
+
* @param {number} importType 导入类型: 1-成员 2-客户
|
|
84
|
+
* @param {string} mediaId 文件 ID
|
|
85
|
+
*/
|
|
86
|
+
async importChainContacts(chainId, importType, mediaId) {
|
|
87
|
+
return this.post('/externalchain/import_contacts', {
|
|
88
|
+
chain_id: chainId,
|
|
89
|
+
import_type: importType,
|
|
90
|
+
media_id: mediaId
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* 获取异步任务结果
|
|
96
|
+
* @param {string} jobId 任务 ID
|
|
97
|
+
*/
|
|
98
|
+
async getChainJobResult(jobId) {
|
|
99
|
+
return this.post('/externalchain/get_job_result', { jobid: jobId });
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* 移除企业
|
|
104
|
+
* @param {string} chainId 上下游 ID
|
|
105
|
+
* @param {string} corpId 企业 ID
|
|
106
|
+
*/
|
|
107
|
+
async removeChainCorp(chainId, corpId) {
|
|
108
|
+
return this.post('/externalchain/remove_corp', {
|
|
109
|
+
chain_id: chainId,
|
|
110
|
+
corpid: corpId
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* 查询成员自定义 ID
|
|
116
|
+
* @param {string} customId 成员自定义 ID
|
|
117
|
+
*/
|
|
118
|
+
async getMemberCustomIdInfo(customId) {
|
|
119
|
+
return this.post('/externalchain/get_member_custom_id', { custom_id: customId });
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* 获取下级企业加入的上下游
|
|
124
|
+
* @param {string} corpId 下级企业 ID
|
|
125
|
+
*/
|
|
126
|
+
async getSubCorpChains(corpId) {
|
|
127
|
+
return this.post('/externalchain/get_sub_corp_chains', { corpid: corpId });
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// ========== 上下游规则管理 ==========
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* 获取对接规则 ID 列表
|
|
134
|
+
* @param {string} chainId 上下游 ID
|
|
135
|
+
* @param {number} offset 偏移量
|
|
136
|
+
* @param {number} size 每页数量
|
|
137
|
+
*/
|
|
138
|
+
async getChainRuleIds(chainId, offset = 0, size = 100) {
|
|
139
|
+
return this.post('/externalchain/get_rule_id_list', {
|
|
140
|
+
chain_id: chainId,
|
|
141
|
+
offset,
|
|
142
|
+
limit: size
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* 删除对接规则
|
|
148
|
+
* @param {string} chainId 上下游 ID
|
|
149
|
+
* @param {string} ruleId 规则 ID
|
|
150
|
+
*/
|
|
151
|
+
async deleteChainRule(chainId, ruleId) {
|
|
152
|
+
return this.post('/externalchain/delete_rule', {
|
|
153
|
+
chain_id: chainId,
|
|
154
|
+
rule_id: ruleId
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* 获取对接规则详情
|
|
160
|
+
* @param {string} chainId 上下游 ID
|
|
161
|
+
* @param {string} ruleId 规则 ID
|
|
162
|
+
*/
|
|
163
|
+
async getChainRuleDetail(chainId, ruleId) {
|
|
164
|
+
return this.post('/externalchain/get_rule_detail', {
|
|
165
|
+
chain_id: chainId,
|
|
166
|
+
rule_id: ruleId
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* 新增对接规则
|
|
172
|
+
* @param {object} rule 规则配置
|
|
173
|
+
*/
|
|
174
|
+
async createChainRule(rule) {
|
|
175
|
+
return this.post('/externalchain/add_rule', rule);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* 更新对接规则
|
|
180
|
+
* @param {string} chainId 上下游 ID
|
|
181
|
+
* @param {string} ruleId 规则 ID
|
|
182
|
+
* @param {object} rule 规则配置
|
|
183
|
+
*/
|
|
184
|
+
async updateChainRule(chainId, ruleId, rule) {
|
|
185
|
+
return this.post('/externalchain/update_rule', {
|
|
186
|
+
chain_id: chainId,
|
|
187
|
+
rule_id: ruleId,
|
|
188
|
+
...rule
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
module.exports = Chain;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 打卡考勤模块
|
|
3
|
+
* API 章节:二十一
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const WeComSDK = require('../../sdk');
|
|
7
|
+
|
|
8
|
+
class CheckIn extends WeComSDK {
|
|
9
|
+
constructor(config) {
|
|
10
|
+
super(config);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* 获取企业所有打卡规则
|
|
15
|
+
*/
|
|
16
|
+
async getCorpRules() {
|
|
17
|
+
return this.post('/checkin/getcorpcheckintypes', {});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* 获取员工打卡规则
|
|
22
|
+
* @param {string} userId 成员 userid
|
|
23
|
+
* @param {number} dateTime 查询日期时间戳
|
|
24
|
+
*/
|
|
25
|
+
async getUserRules(userId, dateTime) {
|
|
26
|
+
return this.post('/checkin/getcheckinrule', { userid: userId, datetime: dateTime });
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* 获取打卡记录数据
|
|
31
|
+
* @param {number} startTime 开始时间戳
|
|
32
|
+
* @param {number} endTime 结束时间戳
|
|
33
|
+
* @param {string[]} userIds 成员 userid 列表
|
|
34
|
+
* @param {number} type 打卡类型: 1-上下班 2-外出 3-全部
|
|
35
|
+
*/
|
|
36
|
+
async getRecords(startTime, endTime, userIds, type = 1) {
|
|
37
|
+
return this.post('/checkin/getcheckindata', {
|
|
38
|
+
starttime: startTime,
|
|
39
|
+
endtime: endTime,
|
|
40
|
+
userid: userIds,
|
|
41
|
+
type
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* 获取打卡日报数据
|
|
47
|
+
* @param {number} startTime 开始时间戳
|
|
48
|
+
* @param {number} endTime 结束时间戳
|
|
49
|
+
* @param {string[]} userIds 成员 userid 列表
|
|
50
|
+
*/
|
|
51
|
+
async getDailyReport(startTime, endTime, userIds) {
|
|
52
|
+
return this.post('/checkin/getcheckin_daydata', {
|
|
53
|
+
starttime: startTime,
|
|
54
|
+
endtime: endTime,
|
|
55
|
+
userid: userIds
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* 获取打卡月报数据
|
|
61
|
+
* @param {number} startTime 开始时间戳
|
|
62
|
+
* @param {number} endTime 结束时间戳
|
|
63
|
+
* @param {string[]} userIds 成员 userid 列表
|
|
64
|
+
*/
|
|
65
|
+
async getMonthlyReport(startTime, endTime, userIds) {
|
|
66
|
+
return this.post('/checkin/getcheckin_monthdata', {
|
|
67
|
+
starttime: startTime,
|
|
68
|
+
endtime: endTime,
|
|
69
|
+
userid: userIds
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* 获取打卡人员排班信息
|
|
75
|
+
* @param {number} startTime 开始时间戳
|
|
76
|
+
* @param {number} endTime 结束时间戳
|
|
77
|
+
* @param {string[]} userIds 成员 userid 列表
|
|
78
|
+
*/
|
|
79
|
+
async getSchedule(startTime, endTime, userIds) {
|
|
80
|
+
return this.post('/checkin/getcheckinschedulist', {
|
|
81
|
+
starttime: startTime,
|
|
82
|
+
endtime: endTime,
|
|
83
|
+
userid: userIds
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* 为打卡人员排班
|
|
89
|
+
* @param {string} userId 成员 userid
|
|
90
|
+
* @param {number} scheduleTime 排班日期时间戳
|
|
91
|
+
* @param {object} schedule 班次信息
|
|
92
|
+
*/
|
|
93
|
+
async addSchedule(userId, scheduleTime, schedule) {
|
|
94
|
+
return this.post('/checkin/addcheckinschedulist', {
|
|
95
|
+
userid: userId,
|
|
96
|
+
schedule_time: scheduleTime,
|
|
97
|
+
schedule
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* 为打卡人员补卡
|
|
103
|
+
* @param {string} userId 成员 userid
|
|
104
|
+
* @param {number} checkinTime 补卡时间戳
|
|
105
|
+
* @param {string} notes 备注
|
|
106
|
+
*/
|
|
107
|
+
async addCheckinRecord(userId, checkinTime, notes = '') {
|
|
108
|
+
return this.post('/checkin/addcheckinrecord', {
|
|
109
|
+
userid: userId,
|
|
110
|
+
checkin_time: checkinTime,
|
|
111
|
+
notes
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* 获取设备打卡数据
|
|
117
|
+
* @param {number} startTime 开始时间戳
|
|
118
|
+
* @param {number} endTime 结束时间戳
|
|
119
|
+
* @param {string} deviceId 设备ID
|
|
120
|
+
*/
|
|
121
|
+
async getDeviceData(startTime, endTime, deviceId) {
|
|
122
|
+
return this.post('/checkin/get_device_checkin_data', {
|
|
123
|
+
starttime: startTime,
|
|
124
|
+
endtime: endTime,
|
|
125
|
+
device_id: deviceId
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* 录入打卡人员人脸信息
|
|
131
|
+
* @param {string} userId 成员 userid
|
|
132
|
+
* @param {string} faceData 人脸数据 (base64)
|
|
133
|
+
*/
|
|
134
|
+
async addFace(userId, faceData) {
|
|
135
|
+
return this.post('/checkin/add_face', {
|
|
136
|
+
userid: userId,
|
|
137
|
+
face_data: faceData
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
module.exports = CheckIn;
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 打卡规则管理模块
|
|
3
|
+
* API 章节:二十一 - 打卡(规则管理)
|
|
4
|
+
* 包含:管理打卡规则、设备打卡数据
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const WeComSDK = require('../../sdk');
|
|
8
|
+
|
|
9
|
+
class CheckInRules extends WeComSDK {
|
|
10
|
+
constructor(config) {
|
|
11
|
+
super(config);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// ========== 打卡规则管理 ==========
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* 获取企业所有打卡规则
|
|
18
|
+
* @param {number} offset 偏移量
|
|
19
|
+
* @param {number} size 每页数量
|
|
20
|
+
*/
|
|
21
|
+
async getCheckInRules(offset = 0, size = 100) {
|
|
22
|
+
return this.post('/checkin/get_rule', { offset, limit: size });
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* 获取打卡规则详情
|
|
27
|
+
* @param {string} groupId 打卡组 ID
|
|
28
|
+
*/
|
|
29
|
+
async getCheckInRuleDetail(groupId) {
|
|
30
|
+
return this.post('/checkin/get_rule_detail', { group_id: groupId });
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* 创建打卡规则
|
|
35
|
+
* @param {object} rule 打卡规则配置
|
|
36
|
+
*/
|
|
37
|
+
async createCheckInRule(rule) {
|
|
38
|
+
return this.post('/checkin/add_rule', rule);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* 更新打卡规则
|
|
43
|
+
* @param {string} groupId 打卡组 ID
|
|
44
|
+
* @param {object} rule 打卡规则配置
|
|
45
|
+
*/
|
|
46
|
+
async updateCheckInRule(groupId, rule) {
|
|
47
|
+
return this.post('/checkin/update_rule', {
|
|
48
|
+
group_id: groupId,
|
|
49
|
+
...rule
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* 删除打卡规则
|
|
55
|
+
* @param {string} groupId 打卡组 ID
|
|
56
|
+
*/
|
|
57
|
+
async deleteCheckInRule(groupId) {
|
|
58
|
+
return this.post('/checkin/del_rule', { group_id: groupId });
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* 拷贝打卡规则
|
|
63
|
+
* @param {string} sourceGroupId 源打卡组 ID
|
|
64
|
+
* @param {string} newGroupName 新打卡组名称
|
|
65
|
+
*/
|
|
66
|
+
async copyCheckInRule(sourceGroupId, newGroupName) {
|
|
67
|
+
return this.post('/checkin/copy_rule', {
|
|
68
|
+
source_group_id: sourceGroupId,
|
|
69
|
+
new_group_name: newGroupName
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// ========== 打卡人员管理 ==========
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* 获取打卡规则成员
|
|
77
|
+
* @param {string} groupId 打卡组 ID
|
|
78
|
+
*/
|
|
79
|
+
async getCheckInRuleUsers(groupId) {
|
|
80
|
+
return this.post('/checkin/get_rule_user', { group_id: groupId });
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* 添加入打卡规则成员
|
|
85
|
+
* @param {string} groupId 打卡组 ID
|
|
86
|
+
* @param {string[]} userIds 成员 ID 列表
|
|
87
|
+
* @param {number[]} departmentIds 部门 ID 列表
|
|
88
|
+
*/
|
|
89
|
+
async addCheckInRuleUsers(groupId, userIds = [], departmentIds = []) {
|
|
90
|
+
return this.post('/checkin/add_rule_user', {
|
|
91
|
+
group_id: groupId,
|
|
92
|
+
users: userIds,
|
|
93
|
+
departments: departmentIds
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* 删除打卡规则成员
|
|
99
|
+
* @param {string} groupId 打卡组 ID
|
|
100
|
+
* @param {string[]} userIds 成员 ID 列表
|
|
101
|
+
* @param {number[]} departmentIds 部门 ID 列表
|
|
102
|
+
*/
|
|
103
|
+
async removeCheckInRuleUsers(groupId, userIds = [], departmentIds = []) {
|
|
104
|
+
return this.post('/checkin/del_rule_user', {
|
|
105
|
+
group_id: groupId,
|
|
106
|
+
users: userIds,
|
|
107
|
+
departments: departmentIds
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// ========== 打卡地点管理 ==========
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* 获取打卡地点列表
|
|
115
|
+
* @param {string} groupId 打卡组 ID
|
|
116
|
+
*/
|
|
117
|
+
async getCheckInLocations(groupId) {
|
|
118
|
+
return this.post('/checkin/get_location_list', { group_id: groupId });
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* 添加打卡地点
|
|
123
|
+
* @param {string} groupId 打卡组 ID
|
|
124
|
+
* @param {object} location 地点配置
|
|
125
|
+
*/
|
|
126
|
+
async addCheckInLocation(groupId, location) {
|
|
127
|
+
return this.post('/checkin/add_location', {
|
|
128
|
+
group_id: groupId,
|
|
129
|
+
...location
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* 删除打卡地点
|
|
135
|
+
* @param {string} groupId 打卡组 ID
|
|
136
|
+
* @param {string} locationId 地点 ID
|
|
137
|
+
*/
|
|
138
|
+
async deleteCheckInLocation(groupId, locationId) {
|
|
139
|
+
return this.post('/checkin/del_location', {
|
|
140
|
+
group_id: groupId,
|
|
141
|
+
location_id: locationId
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// ========== 设备打卡数据 ==========
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* 获取设备打卡数据
|
|
149
|
+
* @param {string} deviceId 设备 ID
|
|
150
|
+
* @param {number} startTime 开始时间戳
|
|
151
|
+
* @param {number} endTime 结束时间戳
|
|
152
|
+
*/
|
|
153
|
+
async getDeviceCheckInData(deviceId, startTime, endTime) {
|
|
154
|
+
return this.post('/checkin/get_device_data', {
|
|
155
|
+
device_id: deviceId,
|
|
156
|
+
start_time: startTime,
|
|
157
|
+
end_time: endTime
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* 获取设备列表
|
|
163
|
+
* @param {number} offset 偏移量
|
|
164
|
+
* @param {number} size 每页数量
|
|
165
|
+
*/
|
|
166
|
+
async getDeviceList(offset = 0, size = 100) {
|
|
167
|
+
return this.post('/checkin/get_device_list', { offset, limit: size });
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// ========== 打卡提醒设置 ==========
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* 设置打卡提醒
|
|
174
|
+
* @param {string} groupId 打卡组 ID
|
|
175
|
+
* @param {number} remindTime 提醒时间(秒)
|
|
176
|
+
* @param {string} remindLocation 提醒地点
|
|
177
|
+
*/
|
|
178
|
+
async setCheckInReminder(groupId, remindTime, remidLocation = '') {
|
|
179
|
+
return this.post('/checkin/set_remind', {
|
|
180
|
+
group_id: groupId,
|
|
181
|
+
remind_time: remindTime,
|
|
182
|
+
remind_location: remidLocation
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// ========== 排班管理 ==========
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* 获取打卡人员排班信息
|
|
190
|
+
* @param {number} startTime 开始时间戳
|
|
191
|
+
* @param {number} endTime 结束时间戳
|
|
192
|
+
* @param {string} userId 成员 ID(可选)
|
|
193
|
+
* @param {number} departmentId 部门 ID(可选)
|
|
194
|
+
*/
|
|
195
|
+
async getCheckInSchedule(startTime, endTime, userId = '', departmentId = '') {
|
|
196
|
+
return this.post('/checkin/get_schedulelist', {
|
|
197
|
+
starttime: startTime,
|
|
198
|
+
endtime: endTime,
|
|
199
|
+
userid: userId,
|
|
200
|
+
department_id: departmentId
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* 为打卡人员排班
|
|
206
|
+
* @param {string} userId 成员 ID
|
|
207
|
+
* @param {number} scheduleDate 排班日期时间戳
|
|
208
|
+
* @param {string} dayType 日期类型: workdays-工作日, holidays-节假日
|
|
209
|
+
* @param {string} timeSection 时段配置
|
|
210
|
+
*/
|
|
211
|
+
async setCheckInSchedule(userId, scheduleDate, dayType = 'workdays', timeSection = '') {
|
|
212
|
+
return this.post('/checkin/add_schedulelist', {
|
|
213
|
+
userid: userId,
|
|
214
|
+
schedule_date: scheduleDate,
|
|
215
|
+
day_type: dayType,
|
|
216
|
+
time_section: timeSection
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* 清除打卡人员排班
|
|
222
|
+
* @param {number} startTime 开始时间戳
|
|
223
|
+
* @param {number} endTime 结束时间戳
|
|
224
|
+
* @param {string[]} userIds 成员 ID 列表
|
|
225
|
+
*/
|
|
226
|
+
async clearCheckInSchedule(startTime, endTime, userIds) {
|
|
227
|
+
return this.post('/checkin/del_schedulelist', {
|
|
228
|
+
starttime: startTime,
|
|
229
|
+
endtime: endTime,
|
|
230
|
+
useridlist: userIds
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// ========== 补卡管理 ==========
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* 为打卡人员补卡
|
|
238
|
+
* @param {string} userId 成员 ID
|
|
239
|
+
* @param {number} time 补卡时间戳
|
|
240
|
+
* @param {string} notes 备注
|
|
241
|
+
*/
|
|
242
|
+
async addCheckInRecord(userId, time, notes = '') {
|
|
243
|
+
return this.post('/checkin/add_checkin_record', {
|
|
244
|
+
userid: userId,
|
|
245
|
+
time,
|
|
246
|
+
notes
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
module.exports = CheckInRules;
|