diff --git a/src/common/models/file.model.js b/src/common/models/file.model.js index 770c512..2e928b0 100644 --- a/src/common/models/file.model.js +++ b/src/common/models/file.model.js @@ -31,40 +31,20 @@ File.init( autoIncrement: true, primaryKey: true }, - url: { - type: DataTypes.STRING(255), - allowNull: false - }, name: { type: DataTypes.STRING(255), - defaultValue: null + allowNull: false }, - title: { + url: { type: DataTypes.STRING(255), - defaultValue: null - }, - payload: { - type: DataTypes.JSONB, - defaultValue: null // id | code | name - }, - - // manager - is_active: { - type: DataTypes.BOOLEAN, - defaultValue: true - }, - created_at: { - type: DataTypes.DATE, - defaultValue: DataTypes.NOW - }, - updated_at: { - type: DataTypes.DATE, - defaultValue: DataTypes.NOW + allowNull: false }, - created_by: { - type: DataTypes.JSONB, - defaultValue: null // id | name + download_count: { + type: DataTypes.NUMBER, + allowNull: true, + defaultValue: 0 } + }, { timestamps: false, @@ -209,7 +189,7 @@ File.get = async (id) => { if (!data) { throw new APIError({ status: httpStatus.NOT_FOUND, - message: 'Không tìm thấy địa chỉ tỉnh/thành!' + message: 'Không tìm thấy địa chỉ file!' }); } return data; diff --git a/src/common/services/adapters/upload-adapter.js b/src/common/services/adapters/upload-adapter.js index 4a04c27..3a41e5b 100644 --- a/src/common/services/adapters/upload-adapter.js +++ b/src/common/services/adapters/upload-adapter.js @@ -79,7 +79,7 @@ const storage = multer.diskStorage({ // : file.originalname; cb( null, - `/${path}/${file.originalname.replace(/\s/g, '')}` + `/${path}/${file.originalname.replace(/[\s()]/g, '')}` ); } });