|
@@ -2,6 +2,8 @@ import {IApiProcessor, ICachedData, IMethodParams, IRequest} from "@core/Defined
|
|
|
import {Resp} from "@util/Resp";
|
|
|
import {PrjWeekReport} from "@core-models/PrjWeekReport";
|
|
|
import dayjs from "dayjs";
|
|
|
+import {Oss} from "@util/Oss";
|
|
|
+import {PrjFile} from "@core-models/PrjFile";
|
|
|
|
|
|
interface IData {
|
|
|
/**
|
|
@@ -33,7 +35,13 @@ async function remove(json: IRequest, _params: IMethodParams, _cached_data: ICac
|
|
|
let data = <IData>json.data;
|
|
|
let t = await PrjWeekReport.sequelize!.transaction();
|
|
|
try {
|
|
|
- //TODO: 移除所有该周报的附件
|
|
|
+ let attachments = await PrjFile.findAll({where: {dependent_id: data.id, category_id: 'week_report'}, raw: true});
|
|
|
+
|
|
|
+ let oss = Oss.get_instance('pmr-doc');
|
|
|
+ for (let file of attachments) {
|
|
|
+ await oss.remove_object(oss.bucket, file.id);
|
|
|
+ await PrjFile.destroy({where: {id: file.id}, transaction: t});
|
|
|
+ }
|
|
|
await PrjWeekReport.destroy({where: {id: data.id}, transaction: t});
|
|
|
await t.commit();
|
|
|
} catch (e) {
|