refactor: 收口业务提供项接口契约
This commit is contained in:
1 parent
844a3bd715
commit
fe7005d4d0
5 files changed
+16
-9
No files matched your search
@@ -11,7 +11,7 @@ Page({
|
|||||||
template: getTemplate("personal"),
|
template: getTemplate("personal"),
|
||||||
},
|
},
|
||||||
onLoad(query) {
|
onLoad(query) {
|
||||||
Promise.all([request("/public/services"), request("/public/brand")])
|
Promise.all([request("/public/offerings"), request("/public/brand")])
|
||||||
.then(([services, brand]) => {
|
.then(([services, brand]) => {
|
||||||
const list = Array.isArray(services) ? services : [];
|
const list = Array.isArray(services) ? services : [];
|
||||||
const service =
|
const service =
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ Page({
|
|||||||
},
|
},
|
||||||
load() {
|
load() {
|
||||||
this.setData({ loading: true, error: "" });
|
this.setData({ loading: true, error: "" });
|
||||||
Promise.all([request("/public/brand"), request("/public/services")])
|
Promise.all([request("/public/brand"), request("/public/offerings")])
|
||||||
.then(([brand, services]) => {
|
.then(([brand, services]) => {
|
||||||
getApp().globalData.brand = brand;
|
getApp().globalData.brand = brand;
|
||||||
wx.setNavigationBarTitle({ title: brand.name || "个人品牌" });
|
wx.setNavigationBarTitle({ title: brand.name || "个人品牌" });
|
||||||
|
|||||||
@@ -9,12 +9,12 @@ Page({
|
|||||||
this.setData({ loading: true, error: "" });
|
this.setData({ loading: true, error: "" });
|
||||||
Promise.all([
|
Promise.all([
|
||||||
request("/public/offerings"),
|
request("/public/offerings"),
|
||||||
request("/public/services"),
|
request("/public/offerings"),
|
||||||
request("/public/brand"),
|
request("/public/brand"),
|
||||||
])
|
])
|
||||||
.then(([offerings, services, brand]) => {
|
.then(([offerings, services, brand]) => {
|
||||||
const labels = getTemplate(brand.templateKey);
|
const labels = getTemplate(brand.templateKey);
|
||||||
const source = offerings.length ? offerings : services;
|
const source = offerings;
|
||||||
const mapped = source.map((item) => ({
|
const mapped = source.map((item) => ({
|
||||||
...item,
|
...item,
|
||||||
coverUrl:
|
coverUrl:
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ export interface ServiceUpdate {
|
|||||||
categoryKey?: string;
|
categoryKey?: string;
|
||||||
config?: Record<string, unknown>;
|
config?: Record<string, unknown>;
|
||||||
}
|
}
|
||||||
|
export type OfferingUpdate = ServiceUpdate;
|
||||||
export interface TrustContent {
|
export interface TrustContent {
|
||||||
id: string;
|
id: string;
|
||||||
type: string;
|
type: string;
|
||||||
@@ -271,7 +272,7 @@ export class ApiClient {
|
|||||||
return this.request("/public/brand");
|
return this.request("/public/brand");
|
||||||
}
|
}
|
||||||
listServices(): Promise<PublicService[]> {
|
listServices(): Promise<PublicService[]> {
|
||||||
return this.request("/public/services");
|
return this.request("/public/offerings");
|
||||||
}
|
}
|
||||||
getPublicWorkspace(): Promise<PublicWorkspace> {
|
getPublicWorkspace(): Promise<PublicWorkspace> {
|
||||||
return this.request("/public/workspace");
|
return this.request("/public/workspace");
|
||||||
@@ -440,18 +441,23 @@ export class ApiClient {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
updateAdminService(id: string, body: ServiceUpdate): Promise<PublicService> {
|
updateAdminService(id: string, body: ServiceUpdate): Promise<PublicService> {
|
||||||
return this.request(`/admin/config/services/${encodeURIComponent(id)}`, {
|
const { categoryKey, ...rest } = body;
|
||||||
|
return this.request(`/admin/workspace/offerings/${encodeURIComponent(id)}`, {
|
||||||
method: "PATCH",
|
method: "PATCH",
|
||||||
body,
|
body: { ...rest, ...(categoryKey ? { kind: categoryKey } : {}) },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
listAdminServices(): Promise<PublicService[]> {
|
listAdminServices(): Promise<PublicService[]> {
|
||||||
return this.request("/admin/config/services");
|
return this.request("/admin/workspace/offerings");
|
||||||
}
|
}
|
||||||
createAdminService(
|
createAdminService(
|
||||||
body: ServiceUpdate & { name: string; description: string },
|
body: ServiceUpdate & { name: string; description: string },
|
||||||
): Promise<PublicService> {
|
): Promise<PublicService> {
|
||||||
return this.request("/admin/config/services", { method: "POST", body });
|
const { categoryKey, bookingEnabled: _bookingEnabled, ...rest } = body;
|
||||||
|
return this.request("/admin/workspace/offerings", {
|
||||||
|
method: "POST",
|
||||||
|
body: { ...rest, kind: categoryKey ?? "service" },
|
||||||
|
});
|
||||||
}
|
}
|
||||||
listAdminTrustContent(): Promise<TrustContent[]> {
|
listAdminTrustContent(): Promise<TrustContent[]> {
|
||||||
return this.request("/admin/config/trust-content");
|
return this.request("/admin/config/trust-content");
|
||||||
|
|||||||
@@ -38,3 +38,4 @@ export interface PublicService {
|
|||||||
categoryKey?: string;
|
categoryKey?: string;
|
||||||
config?: Record<string, unknown> | null;
|
config?: Record<string, unknown> | null;
|
||||||
}
|
}
|
||||||
|
export type PublicOffering = PublicService;
|
||||||
Reference in new issue
Block a user