实现后端webResource CRUD
This commit is contained in:
@@ -10,6 +10,9 @@ import { AdminRoleController } from './controller/admin-role.controller';
|
||||
import { AdminPermissionController } from './controller/admin-permission.controller';
|
||||
import { AdminRolePermissionController } from './controller/admin-role-permission.controller';
|
||||
import { AdminUserRoleController } from './controller/admin-user-role.controller';
|
||||
import { AdminWebResourceController } from './controller/web/admin-web-resource.controller';
|
||||
import { AdminWebBlogController } from './controller/web/admin-web-blog.controller';
|
||||
import { ResourceModule } from 'src/resource/resource.module';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
@@ -18,6 +21,7 @@ import { AdminUserRoleController } from './controller/admin-user-role.controller
|
||||
]),
|
||||
UserModule,
|
||||
RoleModule,
|
||||
ResourceModule,
|
||||
],
|
||||
controllers: [
|
||||
AdminController,
|
||||
@@ -26,6 +30,8 @@ import { AdminUserRoleController } from './controller/admin-user-role.controller
|
||||
AdminPermissionController,
|
||||
AdminRolePermissionController,
|
||||
AdminUserRoleController,
|
||||
AdminWebResourceController,
|
||||
AdminWebBlogController,
|
||||
],
|
||||
providers: [
|
||||
AdminUserService,
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
import { Controller } from "@nestjs/common";
|
||||
|
||||
@Controller('/admin/web/blog')
|
||||
export class AdminWebBlogController {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
import { Body, Controller, Delete, Get, Param, Post, Put } from "@nestjs/common";
|
||||
import { CreateResourceDto } from "src/admin/dto/admin-web/create-resource.dto";
|
||||
import { ResourceService } from "src/resource/resource.service";
|
||||
|
||||
@Controller('/admin/web/resource')
|
||||
export class AdminWebResourceController {
|
||||
|
||||
constructor(
|
||||
private readonly resourceService: ResourceService,
|
||||
) { }
|
||||
|
||||
@Get()
|
||||
async list() {
|
||||
return this.resourceService.findAll();
|
||||
}
|
||||
|
||||
@Post()
|
||||
async create(@Body() data: CreateResourceDto) {
|
||||
return this.resourceService.create(data);
|
||||
}
|
||||
|
||||
@Put(':id')
|
||||
async update(
|
||||
@Param('id') id: string,
|
||||
@Body() data: CreateResourceDto
|
||||
) {
|
||||
return this.resourceService.update(id, data);
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
async delete(@Param('id') id: string) {
|
||||
return this.resourceService.delete(id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
import { Type } from "class-transformer";
|
||||
import { IsString, ValidateNested } from "class-validator";
|
||||
|
||||
class ResourceTagDto {
|
||||
@IsString()
|
||||
name: string;
|
||||
|
||||
@IsString()
|
||||
type: string;
|
||||
}
|
||||
|
||||
export class CreateResourceDto {
|
||||
@IsString()
|
||||
title: string;
|
||||
|
||||
@IsString()
|
||||
description: string;
|
||||
|
||||
@IsString()
|
||||
imageUrl: string;
|
||||
|
||||
@IsString()
|
||||
link: string;
|
||||
|
||||
@ValidateNested({ each: true })
|
||||
@Type(() => ResourceTagDto)
|
||||
tags: ResourceTagDto[];
|
||||
}
|
||||
Reference in New Issue
Block a user