fix: connect remaining sms pages to real backend

This commit is contained in:
hectorzhao
2026-07-02 19:30:04 +08:00
parent 06562e42dd
commit 131f344ac4
50 changed files with 2074 additions and 6400 deletions
+17 -2
View File
@@ -1,6 +1,6 @@
import { Body, Controller, Get, Param, Post } from '@nestjs/common';
import { Body, Controller, Delete, Get, Param, Post, Put } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { CreateTenantDto, TenantsService } from './tenants.service';
import { CreateTenantDto, TenantsService, UpdateTenantDto } from './tenants.service';
@ApiTags('tenants')
@Controller('admin/tenants')
@@ -21,4 +21,19 @@ export class TenantsController {
create(@Body() body: CreateTenantDto) {
return this.tenants.create(body);
}
@Put(':id')
update(@Param('id') id: string, @Body() body: UpdateTenantDto) {
return this.tenants.update(id, body);
}
@Post(':id/status')
changeStatus(@Param('id') id: string, @Body() body: { status: string }) {
return this.tenants.changeStatus(id, body.status);
}
@Delete(':id')
delete(@Param('id') id: string) {
return this.tenants.delete(id);
}
}
+28
View File
@@ -7,6 +7,12 @@ export interface CreateTenantDto {
status?: string;
}
export interface UpdateTenantDto {
name?: string;
code?: string;
status?: string;
}
@Injectable()
export class TenantsService {
constructor(private readonly prisma: PrismaService) {}
@@ -31,4 +37,26 @@ export class TenantsService {
},
});
}
update(id: string, data: UpdateTenantDto) {
return this.prisma.tenant.update({
where: { id },
data: {
name: data.name,
code: data.code,
status: data.status,
},
});
}
changeStatus(id: string, status: string) {
return this.prisma.tenant.update({
where: { id },
data: { status },
});
}
delete(id: string) {
return this.changeStatus(id, 'deleted');
}
}