104 lines
2.9 KiB
JavaScript
104 lines
2.9 KiB
JavaScript
import {
|
|
request
|
|
} from "../http";
|
|
// 公共API
|
|
const proName = 'aiShop'
|
|
const apiPath = {
|
|
indexList: "/api/goodsonline/listpage", //上架的软著商品列表 GET
|
|
saveGoods: "/api/goods/save", //新增软著商品 POST
|
|
goodsDetail: "/api/goods/get/{goodsId}", //商品详情 GET
|
|
delGoods: "/api/goods/remove/{ids}", //删除商品 DELETE
|
|
updateGoods: "/api/goods/update/{goodsId}", //修改商品 PUT
|
|
doCheck: "/api/goods/sub-check/{goodsId}", //提交审核 PUT
|
|
onGoods: "/api/goods/publish/{goodsId}", //上架商品 PUT
|
|
offGoods: "/api/goods/no-publish/{goodsId}", //下架商品
|
|
// 0b00884a-f7a2-425f-93e5-599fbaad4bde 软著分类
|
|
// ce3ded65-68ed-4f42-89da-de1b813b8f7e 证件类型
|
|
goodsDics: "/api/data/listbyparentid/{dId}", //商品数据字典
|
|
areaList: "/api/area/listbyparentid/{pId}", //省市区树结构
|
|
}
|
|
class Shop {
|
|
// 通用路径参数替换方法
|
|
static #replacePathParams(path, params) {
|
|
return Object.entries(params).reduce(
|
|
(acc, [key, value]) => acc.replace(`{${key}}`, value),
|
|
path
|
|
)
|
|
}
|
|
|
|
// 通用请求方法
|
|
static requestHandler(endpoint, method, data = null, pathParams = {}) {
|
|
const path = Object.keys(pathParams).length ?
|
|
this.#replacePathParams(endpoint, pathParams) :
|
|
endpoint
|
|
|
|
return request(path, method, data, proName)
|
|
}
|
|
|
|
// 获取上架的软著列表
|
|
static doGetIndexList(data) {
|
|
return this.requestHandler(apiPath.indexList, "GET", data)
|
|
}
|
|
|
|
// 软著类型
|
|
static doGetGoodsDic(id) {
|
|
return this.requestHandler(apiPath.goodsDics, "GET", null, {
|
|
dId: id
|
|
})
|
|
}
|
|
|
|
// 新增软件商品
|
|
static doSaveGoods(data) {
|
|
return this.requestHandler(apiPath.saveGoods, "POST", data)
|
|
}
|
|
|
|
// 商品详情
|
|
static doGetGoodsDetail(id) {
|
|
return this.requestHandler(apiPath.goodsDetail, "GET", null, {
|
|
goodsId: id
|
|
})
|
|
}
|
|
|
|
// 删除商品
|
|
static doDelGoods(id) {
|
|
return this.requestHandler(apiPath.delGoods, "DELETE", null, {
|
|
ids: id
|
|
})
|
|
}
|
|
|
|
// 更新商品
|
|
static doUpdateGoods(id, data) {
|
|
return this.requestHandler(apiPath.updateGoods, "PUT", data, {
|
|
goodsId: id
|
|
})
|
|
}
|
|
|
|
// 提交审核
|
|
static doSubCheck(id) {
|
|
return this.requestHandler(apiPath.doCheck, "PUT", null, {
|
|
goodsId: id
|
|
})
|
|
}
|
|
|
|
// 上架商品
|
|
static doOnGoods(id) {
|
|
return this.requestHandler(apiPath.onGoods, "PUT", null, {
|
|
goodsId: id
|
|
})
|
|
}
|
|
|
|
// 下架商品
|
|
static doOffGoods(id) {
|
|
return this.requestHandler(apiPath.offGoods, "PUT", null, {
|
|
goodsId: id
|
|
})
|
|
}
|
|
//获取地区
|
|
static doGetAreaList(id) {
|
|
return this.requestHandler(apiPath.areaList, "GET", null, {
|
|
pId: id
|
|
})
|
|
}
|
|
}
|
|
|
|
export default Shop; |