Skip to content

Commit a747978

Browse files
committed
feat: #9 Paging Example and Return Parameter Adjustment
1 parent 1260fd1 commit a747978

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

routers/files.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const tinify = require("tinify");
77
const { Op } = require("sequelize");
88
const { v4: uuidv4 } = require("uuid");
99
const { detectFileType } = require("../utils/detectFileType");
10-
const File = require("../models/files");
10+
const Files = require("../models/files");
1111
const JSZip = require("jszip");
1212
const {
1313
imageMimeTypes,
@@ -86,7 +86,7 @@ router.post("/files", async (ctx) => {
8686
const fileUrl = `${process.env.PUBLIC_NETWORK_DOMAIN}/files/${fileId}/preview`;
8787
const thumbUrl = shouldGenerateThumb ? `${fileUrl}?type=thumb` : null;
8888

89-
await File.create({
89+
await Files.create({
9090
id: fileId,
9191
filename: path.basename(realFilePath),
9292
filesize: (await fsp.stat(realFilePath)).size,
@@ -164,7 +164,7 @@ router.get("/files", async (ctx) => {
164164
};
165165
}
166166

167-
const { rows, count } = await File.findAndCountAll({
167+
const { rows, count } = await Files.findAndCountAll({
168168
where: {
169169
is_delete: false,
170170
is_public: true,
@@ -203,7 +203,7 @@ router.get("/files/:id", async (ctx) => {
203203
const { id } = ctx.params;
204204

205205
try {
206-
const file = await File.findOne({
206+
const file = await Files.findOne({
207207
where: {
208208
id,
209209
is_delete: false,
@@ -254,7 +254,7 @@ router.get("/files/:id/preview", async (ctx) => {
254254
const { type } = ctx.query; // 获取查询参数 'type',可以是 'thumb' 或 'original'
255255

256256
try {
257-
const file = await File.findOne({
257+
const file = await Files.findOne({
258258
where: {
259259
id,
260260
is_delete: false,
@@ -317,7 +317,7 @@ router.get("/files/:id/export", async (ctx) => {
317317
const { id } = ctx.params;
318318

319319
try {
320-
const file = await File.findOne({
320+
const file = await Files.findOne({
321321
where: {
322322
id: id,
323323
is_delete: false,
@@ -375,7 +375,7 @@ router.get("/files/export", async (ctx) => {
375375
}
376376

377377
try {
378-
const files = await File.findAll({
378+
const files = await Files.findAll({
379379
where: {
380380
id: { [Op.in]: fileIds },
381381
is_delete: false,

0 commit comments

Comments
 (0)