feat: update the announcement update process
This commit is contained in:
@@ -24,4 +24,3 @@ export const connectionSource = new DataSource({
|
|||||||
migrationsTableName: "typeorm_migrations",
|
migrationsTableName: "typeorm_migrations",
|
||||||
migrationsRun: false,
|
migrationsRun: false,
|
||||||
});
|
});
|
||||||
console.log(join(process.cwd(), PATH, "modules/**/*.entity{.ts,.js}"));
|
|
||||||
|
|||||||
@@ -1,26 +1,5 @@
|
|||||||
import { IsDate, IsOptional, IsString, IsUUID } from "class-validator";
|
import { PartialType } from "@nestjs/swagger";
|
||||||
|
|
||||||
export class UpdateAnnouncementDto {
|
import { CreateAnnouncementDto } from "./create-announcement.dto";
|
||||||
@IsOptional()
|
|
||||||
@IsString()
|
|
||||||
title?: string;
|
|
||||||
|
|
||||||
@IsOptional()
|
export class UpdateAnnouncementDto extends PartialType(CreateAnnouncementDto) {}
|
||||||
@IsString()
|
|
||||||
content?: string;
|
|
||||||
|
|
||||||
@IsOptional()
|
|
||||||
@IsDate()
|
|
||||||
publishAt?: Date;
|
|
||||||
|
|
||||||
@IsOptional()
|
|
||||||
@IsUUID()
|
|
||||||
serviceId?: string;
|
|
||||||
|
|
||||||
@IsOptional()
|
|
||||||
@IsUUID(undefined, { each: true })
|
|
||||||
userIds?: string[];
|
|
||||||
|
|
||||||
@IsOptional()
|
|
||||||
isImportant?: boolean;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ export class AnnouncementService {
|
|||||||
const announcement = this.announcementRepository.create({ ...createAnnouncementDto });
|
const announcement = this.announcementRepository.create({ ...createAnnouncementDto });
|
||||||
|
|
||||||
if (!announcement.publishAt) {
|
if (!announcement.publishAt) {
|
||||||
announcement.publishAt = new Date();
|
announcement.publishAt = dayjs().toDate();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dayjs(announcement.publishAt).isBefore(dayjs().subtract(1, "day")))
|
if (dayjs(announcement.publishAt).isBefore(dayjs().subtract(1, "day")))
|
||||||
|
|||||||
Reference in New Issue
Block a user