resourceManageApi.js
1.09 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
var globalApi = {}
class Api {
constructor(url) {
this.baseUrl = url;
}
_get(url, data, debug = false) {
if (debug) {
data = Object.assign({}, data, {debug: 'XYZ'})
}
return $.ajax({
url: this.baseUrl + url,
method: 'GET',
contentType: 'appliction/json',
dataType: "json",
data: JSON.stringify(data)
});
}
_post(url, data, debug = false) {
if (debug) {
data = Object.assign({}, data, {debug: 'XYZ'})
}
return $.ajax({
url: this.baseUrl + url,
method: 'POST',
contentType: 'appliction/json',
dataType: "json",
data: JSON.stringify(data)
});
}
}
function initApi() {
class ResourceApi extends Api {
constructor() {
super(contextPath)
}
info(id) {
return this._post('/resource/getResourceInfo', {id})
}
edit(data) {
return this._post('/resource/editResourceContentData', data)
}
editGoodsPool(data) {
return this._post('/resource/batchEditResourceGoodsPool', data)
}
}
globalApi.resource = new ResourceApi();
}
initApi();