fix(banner): add nginx uploads proxy and resolve absolute image url for banners
这个提交包含在:
@@ -696,6 +696,18 @@ export class MysqlRepository {
|
||||
};
|
||||
}
|
||||
|
||||
private formatBanner(banner: any): any {
|
||||
if (!banner) return null;
|
||||
let image = banner.image || '';
|
||||
if (image && image.startsWith('/uploads/')) {
|
||||
image = `https://peiww.gynhc.com${image}`;
|
||||
}
|
||||
return {
|
||||
...banner,
|
||||
image,
|
||||
};
|
||||
}
|
||||
|
||||
async getBanners(): Promise<any[]> {
|
||||
const [rows]: any = await pool.query(`
|
||||
SELECT
|
||||
@@ -706,7 +718,7 @@ export class MysqlRepository {
|
||||
WHERE status = 1
|
||||
ORDER BY sort_order ASC, id DESC
|
||||
`);
|
||||
return rows;
|
||||
return (rows || []).map((b: any) => this.formatBanner(b));
|
||||
}
|
||||
|
||||
async getAdminBanners(): Promise<any[]> {
|
||||
@@ -718,7 +730,7 @@ export class MysqlRepository {
|
||||
FROM banners
|
||||
ORDER BY sort_order ASC, id DESC
|
||||
`);
|
||||
return rows;
|
||||
return (rows || []).map((b: any) => this.formatBanner(b));
|
||||
}
|
||||
|
||||
async createBanner(data: {
|
||||
@@ -758,7 +770,7 @@ export class MysqlRepository {
|
||||
FROM banners
|
||||
WHERE id = ?
|
||||
`, [newId]);
|
||||
return rows[0];
|
||||
return this.formatBanner(rows[0]);
|
||||
}
|
||||
|
||||
async updateBanner(id: number | string, data: Partial<{
|
||||
@@ -830,7 +842,7 @@ export class MysqlRepository {
|
||||
FROM banners
|
||||
WHERE id = ?
|
||||
`, [id]);
|
||||
return rows[0] || null;
|
||||
return this.formatBanner(rows[0]) || null;
|
||||
}
|
||||
|
||||
async updateBannerStatus(id: number | string, status: number): Promise<any> {
|
||||
@@ -843,7 +855,7 @@ export class MysqlRepository {
|
||||
FROM banners
|
||||
WHERE id = ?
|
||||
`, [id]);
|
||||
return rows[0] || null;
|
||||
return this.formatBanner(rows[0]) || null;
|
||||
}
|
||||
|
||||
async deleteBanner(id: number | string): Promise<boolean> {
|
||||
|
||||
在新工单中引用
屏蔽一个用户