Skip to content

Commit 0c1f968

Browse files
Update http.js
1 parent 85144ee commit 0c1f968

1 file changed

Lines changed: 77 additions & 0 deletions

File tree

  • packages/plugins/resource/src/js
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/**
2+
* Copyright (c) 2023 - present TinyEngine Authors.
3+
* Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd.
4+
*
5+
* Use of this source code is governed by an MIT-style license.
6+
*
7+
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
8+
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
9+
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
10+
*
11+
*/
12+
13+
/* metaService: engine.plugins.appmanage.http */
14+
import { getMetaApi, getMergeMeta, META_SERVICE } from '@opentiny/tiny-engine-meta-register'
15+
16+
const baseUrl = '/material-center/api'
17+
18+
// 资源管理 -- 根据分组ID获取资源列表
19+
export const fetchResourceListByGroupId = (resourceGroupId: number) =>
20+
getMetaApi(META_SERVICE.Http).get(`${baseUrl}/resource/find/${resourceGroupId}`)
21+
22+
// 资源管理 -- 获取资源列表含模糊查询
23+
export const fetchResourceList = () => getMetaApi(META_SERVICE.Http).get(`${baseUrl}/resource/like`)
24+
25+
// 资源管理 -- 创建资源
26+
export const createResource = (params: any) =>
27+
getMetaApi(META_SERVICE.Http).post(`${baseUrl}/resource/create`, {
28+
appId: getMetaApi(META_SERVICE.GlobalService).getBaseInfo().id,
29+
platformId: getMergeMeta('engine.config')?.platformId,
30+
...params
31+
})
32+
33+
// 资源管理 -- 批量创建资源
34+
export const batchCreateResource = (params: any) =>
35+
getMetaApi(META_SERVICE.Http).post(
36+
`${baseUrl}/resource/create/batch`,
37+
params.map((item: any) => ({
38+
appId: getMetaApi(META_SERVICE.GlobalService).getBaseInfo().id,
39+
platformId: getMergeMeta('engine.config')?.platformId,
40+
...item
41+
}))
42+
)
43+
44+
// 资源管理 -- 删除资源
45+
export const deleteResource = (id: number) => getMetaApi(META_SERVICE.Http).get(`${baseUrl}/resource/delete/${id}`)
46+
47+
// 资源管理 -- 获取资源详情
48+
export const fetchResourceDetail = (id: number) => getMetaApi(META_SERVICE.Http).get(`${baseUrl}/resource/detail/${id}`)
49+
50+
// 资源管理 -- 查询资源分组列表
51+
export const fetchResourceGroupList = () => getMetaApi(META_SERVICE.Http).get(`${baseUrl}/resource-group/list`)
52+
53+
// 资源管理 -- 根据appId查询资源分组列表
54+
export const fetchResourceGroupByAppId = () =>
55+
getMetaApi(META_SERVICE.Http).get(
56+
`${baseUrl}/resource-group/${getMetaApi(META_SERVICE.GlobalService).getBaseInfo().id}`
57+
)
58+
59+
// 资源管理 -- 创建资源分组
60+
export const createResourceGroup = (params: any) =>
61+
getMetaApi(META_SERVICE.Http).post(`${baseUrl}/resource-group/create`, {
62+
appId: getMetaApi(META_SERVICE.GlobalService).getBaseInfo().id,
63+
platformId: getMergeMeta('engine.config')?.platformId,
64+
...params
65+
})
66+
67+
// 资源管理 -- 修改资源分组信息-包括删除
68+
export const updateResourceGroup = (id: number, params: any) =>
69+
getMetaApi(META_SERVICE.Http).put(`${baseUrl}/resource-group/update/${id}`, params)
70+
71+
// 资源管理 -- 查询资源分组详情
72+
export const fetchResourceGroupDetail = (id: number) =>
73+
getMetaApi(META_SERVICE.Http).get(`${baseUrl}/resource-group/detail/${id}`)
74+
75+
// 资源管理 -- 删除资源分组
76+
export const deleteResourceGroup = (id: number) =>
77+
getMetaApi(META_SERVICE.Http).get(`${baseUrl}/resource-group/delete/${id}`)

0 commit comments

Comments
 (0)