Add showPopup, isGoodNews & Update API

This commit is contained in:
naskya 2023-07-08 19:48:20 +00:00
parent cde369d238
commit e1188641a7
6 changed files with 71 additions and 0 deletions

View file

@ -0,0 +1,21 @@
export class AnnouncementPopup1688845537045 {
name = "AnnouncementPopup1688845537045";
async up(queryRunner) {
await queryRunner.query(
`ALTER TABLE "announcement" ADD "showPopup" boolean NOT NULL DEFAULT false`,
);
await queryRunner.query(
`ALTER TABLE "announcement" ADD "isGoodNews" boolean NOT NULL DEFAULT false`,
);
}
async down(queryRunner) {
await queryRunner.query(
`ALTER TABLE "announcement" DROP COLUMN "isGoodNews"`,
);
await queryRunner.query(
`ALTER TABLE "announcement" DROP COLUMN "showPopup"`,
);
}
}

View file

@ -36,6 +36,16 @@ export class Announcement {
})
public imageUrl: string | null;
@Column("boolean", {
default: false,
})
public showPopup: boolean;
@Column("boolean", {
default: false,
})
public isGoodNews: boolean;
constructor(data: Partial<Announcement>) {
if (data == null) return;

View file

@ -47,6 +47,16 @@ export const meta = {
optional: false,
nullable: true,
},
showPopup: {
type: "boolean",
optional: true,
nullable: false,
},
isGoodNews: {
type: "boolean",
optional: true,
nullable: false,
},
},
},
} as const;
@ -57,6 +67,8 @@ export const paramDef = {
title: { type: "string", minLength: 1 },
text: { type: "string", minLength: 1 },
imageUrl: { type: "string", nullable: true, minLength: 1 },
showPopup: { type: "boolean" },
isGoodNews: { type: "boolean" },
},
required: ["title", "text", "imageUrl"],
} as const;
@ -69,6 +81,8 @@ export default define(meta, paramDef, async (ps) => {
title: ps.title,
text: ps.text,
imageUrl: ps.imageUrl,
showPopup: ps.showPopup ?? false,
isGoodNews: ps.isGoodNews ?? false,
}).then((x) => Announcements.findOneByOrFail(x.identifiers[0]));
return Object.assign({}, announcement, {

View file

@ -57,6 +57,16 @@ export const meta = {
optional: false,
nullable: false,
},
showPopup: {
type: "boolean",
optional: true,
nullable: false,
},
isGoodNews: {
type: "boolean",
optional: true,
nullable: false,
},
},
},
},
@ -100,5 +110,7 @@ export default define(meta, paramDef, async (ps) => {
text: announcement.text,
imageUrl: announcement.imageUrl,
reads: reads.get(announcement)!,
showPopup: announcement.showPopup,
isGoodNews: announcement.isGoodNews,
}));
});

View file

@ -24,6 +24,8 @@ export const paramDef = {
title: { type: "string", minLength: 1 },
text: { type: "string", minLength: 1 },
imageUrl: { type: "string", nullable: true, minLength: 1 },
showPopup: { type: "boolean" },
isGoodNews: { type: "boolean" },
},
required: ["id", "title", "text", "imageUrl"],
} as const;
@ -38,5 +40,7 @@ export default define(meta, paramDef, async (ps, me) => {
title: ps.title,
text: ps.text,
imageUrl: ps.imageUrl,
showPopup: ps.showPopup ?? false,
isGoodNews: ps.isGoodNews ?? false,
});
});

View file

@ -56,6 +56,16 @@ export const meta = {
optional: true,
nullable: false,
},
showPopup: {
type: "boolean",
optional: false,
nullable: false,
},
isGoodNews: {
type: "boolean",
optional: false,
nullable: false,
},
},
},
},