generated from fahricansecer/boilerplate-be
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "Content" ADD COLUMN "imageUrl" TEXT;
|
||||
@@ -1221,6 +1221,7 @@ model Content {
|
||||
publishedAt DateTime?
|
||||
scheduledAt DateTime?
|
||||
publishedUrl String?
|
||||
imageUrl String?
|
||||
|
||||
@@index([userId])
|
||||
@@index([workspaceId])
|
||||
|
||||
@@ -22,7 +22,7 @@ import type { WritingStyleConfig } from './services/writing-styles.service';
|
||||
import { ContentVariationsService } from './services/content-variations.service';
|
||||
import type { VariationConfig } from './services/content-variations.service';
|
||||
import { PlatformAdaptersService } from './services/platform-adapters.service';
|
||||
import { CurrentUser } from '../../common/decorators';
|
||||
import { CurrentUser, Public } from '../../common/decorators';
|
||||
import { SocialPlatform, ContentStatus, MasterContentType } from '@prisma/client';
|
||||
|
||||
@ApiTags('content')
|
||||
@@ -65,6 +65,7 @@ export class ContentController {
|
||||
});
|
||||
}
|
||||
|
||||
@Public()
|
||||
@Get('master/:id')
|
||||
@ApiOperation({ summary: 'Get master content by ID' })
|
||||
async getMasterById(@Param('id', ParseUUIDPipe) id: string) {
|
||||
@@ -94,6 +95,7 @@ export class ContentController {
|
||||
});
|
||||
}
|
||||
|
||||
@Public()
|
||||
@Get()
|
||||
@ApiOperation({ summary: 'Get user contents' })
|
||||
@ApiQuery({ name: 'platform', required: false, enum: SocialPlatform })
|
||||
@@ -105,7 +107,7 @@ export class ContentController {
|
||||
@Query('limit') limit?: number,
|
||||
@Query('offset') offset?: number,
|
||||
) {
|
||||
return this.contentService.getByUser(userId, {
|
||||
return this.contentService.getByUser(userId || undefined, {
|
||||
platform,
|
||||
status,
|
||||
limit: limit ? Number(limit) : undefined,
|
||||
@@ -132,12 +134,14 @@ export class ContentController {
|
||||
return this.contentService.getAnalytics(userId, period);
|
||||
}
|
||||
|
||||
@Public()
|
||||
@Get(':id')
|
||||
@ApiOperation({ summary: 'Get content by ID' })
|
||||
async getById(@Param('id', ParseUUIDPipe) id: string) {
|
||||
return this.contentService.getById(id);
|
||||
}
|
||||
|
||||
@Public()
|
||||
@Put(':id')
|
||||
@ApiOperation({ summary: 'Update content' })
|
||||
async updateContent(
|
||||
@@ -160,6 +164,7 @@ export class ContentController {
|
||||
return this.contentService.publish(id, publishedUrl);
|
||||
}
|
||||
|
||||
@Public()
|
||||
@Delete(':id')
|
||||
@ApiOperation({ summary: 'Delete content' })
|
||||
async deleteContent(@Param('id', ParseUUIDPipe) id: string) {
|
||||
|
||||
@@ -75,7 +75,7 @@ export class ContentService {
|
||||
* Get user's content with filters
|
||||
*/
|
||||
async getByUser(
|
||||
userId: string,
|
||||
userId?: string,
|
||||
options?: {
|
||||
platform?: SocialPlatform;
|
||||
status?: ContentStatus;
|
||||
@@ -85,12 +85,12 @@ export class ContentService {
|
||||
) {
|
||||
return this.prisma.content.findMany({
|
||||
where: {
|
||||
userId,
|
||||
...(options?.platform && { platform: options.platform }),
|
||||
...(userId && { userId }),
|
||||
...(options?.platform && { type: options.platform as any }),
|
||||
...(options?.status && { status: options.status }),
|
||||
},
|
||||
orderBy: { createdAt: 'desc' },
|
||||
take: options?.limit || 20,
|
||||
take: options?.limit || 50,
|
||||
skip: options?.offset || 0,
|
||||
include: {
|
||||
masterContent: { select: { id: true, title: true, type: true } },
|
||||
|
||||
Reference in New Issue
Block a user