mirror of
https://github.com/jiangrui1994/CloudSaver.git
synced 2026-01-11 23:58:46 +08:00
Refactor the backend
This commit is contained in:
@@ -1,41 +1,11 @@
|
||||
import { Request, Response } from "express";
|
||||
import { Cloud115Service } from "../services/Cloud115Service";
|
||||
import { BaseController } from "./BaseController";
|
||||
import { injectable, inject } from "inversify";
|
||||
import { TYPES } from "../core/types";
|
||||
import { BaseCloudController } from "./BaseCloudController";
|
||||
|
||||
@injectable()
|
||||
export class Cloud115Controller extends BaseController {
|
||||
constructor(@inject(TYPES.Cloud115Service) private cloud115Service: Cloud115Service) {
|
||||
super();
|
||||
}
|
||||
|
||||
async getShareInfo(req: Request, res: Response): Promise<void> {
|
||||
await this.handleRequest(req, res, async () => {
|
||||
const { shareCode, receiveCode } = req.query;
|
||||
await this.cloud115Service.setCookie(req);
|
||||
return await this.cloud115Service.getShareInfo(shareCode as string, receiveCode as string);
|
||||
});
|
||||
}
|
||||
|
||||
async getFolderList(req: Request, res: Response): Promise<void> {
|
||||
await this.handleRequest(req, res, async () => {
|
||||
const { parentCid } = req.query;
|
||||
await this.cloud115Service.setCookie(req);
|
||||
return await this.cloud115Service.getFolderList(parentCid as string);
|
||||
});
|
||||
}
|
||||
|
||||
async saveFile(req: Request, res: Response): Promise<void> {
|
||||
await this.handleRequest(req, res, async () => {
|
||||
const { shareCode, receiveCode, fileId, folderId } = req.body;
|
||||
await this.cloud115Service.setCookie(req);
|
||||
return await this.cloud115Service.saveSharedFile({
|
||||
shareCode,
|
||||
receiveCode,
|
||||
fileId,
|
||||
cid: folderId,
|
||||
});
|
||||
});
|
||||
export class Cloud115Controller extends BaseCloudController {
|
||||
constructor(@inject(TYPES.Cloud115Service) cloud115Service: Cloud115Service) {
|
||||
super(cloud115Service);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user