master
Hai Q. Le 1 year ago
parent c4edd5eca2
commit 8888a9b1d3
  1. 38
      src/common/models/file.model.js
  2. 2
      src/common/services/adapters/upload-adapter.js

@ -31,40 +31,20 @@ File.init(
autoIncrement: true, autoIncrement: true,
primaryKey: true primaryKey: true
}, },
url: {
type: DataTypes.STRING(255),
allowNull: false
},
name: { name: {
type: DataTypes.STRING(255), type: DataTypes.STRING(255),
defaultValue: null allowNull: false
}, },
title: { url: {
type: DataTypes.STRING(255), type: DataTypes.STRING(255),
defaultValue: null allowNull: false
},
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
}, },
created_by: { download_count: {
type: DataTypes.JSONB, type: DataTypes.NUMBER,
defaultValue: null // id | name allowNull: true,
defaultValue: 0
} }
}, },
{ {
timestamps: false, timestamps: false,
@ -209,7 +189,7 @@ File.get = async (id) => {
if (!data) { if (!data) {
throw new APIError({ throw new APIError({
status: httpStatus.NOT_FOUND, 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; return data;

@ -79,7 +79,7 @@ const storage = multer.diskStorage({
// : file.originalname; // : file.originalname;
cb( cb(
null, null,
`/${path}/${file.originalname.replace(/\s/g, '')}` `/${path}/${file.originalname.replace(/[\s()]/g, '')}`
); );
} }
}); });

Loading…
Cancel
Save