.
This commit is contained in:
parent
133bcec868
commit
ef3a9c3576
@ -63,8 +63,8 @@ export class UploadProfileLogoUseCase
|
|||||||
return this._saveProfile(profile);
|
return this._saveProfile(profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async _deleteOldLogo(filename) {
|
private async _deleteOldLogo(logo: ProfileLogotype) {
|
||||||
const logo_path = `${this._defaults.dealer_logos_upload_path}/${filename}`;
|
const logo_path = logo.relativePath();
|
||||||
await fs.rm(logo_path);
|
await fs.rm(logo_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,14 +88,14 @@ export class UploadProfileLogoUseCase
|
|||||||
|
|
||||||
private async _getProfileDealer(userId: UniqueID) {
|
private async _getProfileDealer(userId: UniqueID) {
|
||||||
const transaction = this._adapter.startTransaction();
|
const transaction = this._adapter.startTransaction();
|
||||||
const dealerRepoBuilder = this._getProfileRepository();
|
const profileRepoBuilder = this._getProfileRepository();
|
||||||
|
|
||||||
let profile: Profile | null = null;
|
let profile: Profile | null = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await transaction.complete(async (t) => {
|
await transaction.complete(async (t) => {
|
||||||
const dealerRepo = dealerRepoBuilder({ transaction: t });
|
const profileRepo = profileRepoBuilder({ transaction: t });
|
||||||
profile = await dealerRepo.getByUserId(userId);
|
profile = await profileRepo.getByUserId(userId);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!profile) {
|
if (!profile) {
|
||||||
|
|||||||
@ -2,7 +2,6 @@ import { config } from "@/config";
|
|||||||
import { IValueObjectOptions, Result, ValueObject } from "@shared/contexts";
|
import { IValueObjectOptions, Result, ValueObject } from "@shared/contexts";
|
||||||
import fs from "fs/promises";
|
import fs from "fs/promises";
|
||||||
import mime from "mime-types";
|
import mime from "mime-types";
|
||||||
import path from "path";
|
|
||||||
|
|
||||||
export interface IProfileLogotypeOptions extends IValueObjectOptions {}
|
export interface IProfileLogotypeOptions extends IValueObjectOptions {}
|
||||||
|
|
||||||
@ -38,12 +37,8 @@ export class ProfileLogotype extends ValueObject<string> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public relativePath() {
|
public relativePath() {
|
||||||
// `${context.defaults.dealer_logos_upload_path}/${profile.logo}`
|
|
||||||
return this.filename
|
return this.filename
|
||||||
? path.format({
|
? `${config.defaults.dealer_logos_upload_path}/${this.filename}`
|
||||||
base: config.defaults.dealer_logos_upload_path,
|
|
||||||
name: this.filename,
|
|
||||||
})
|
|
||||||
: config.defaults.dealer_logo_placeholder;
|
: config.defaults.dealer_logo_placeholder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user