Files
tehran_taj/apps/api/src/modules/accounting-sync/accounting-admin.controller.ts
T

108 lines
2.7 KiB
TypeScript
Raw Normal View History

import { Body, Controller, Delete, Get, HttpCode, Param, Post, Put, Query } from '@nestjs/common';
import { CurrentAdmin, RequirePermission } from '../auth/guards';
import type { AuthenticatedAdmin } from '../auth/jwt.strategy';
import { AccountingAdminService } from './accounting-admin.service';
/**
* «اتصال حسابداری» (D27) — every route behind `config.accounting`. Nothing
* here ever returns a token: the configuration comes back with tokens reduced
* to `tokenSet` / `tokenReadable` flags.
*/
@Controller('admin/accounting')
@RequirePermission('config.accounting')
export class AccountingAdminController {
constructor(private readonly admin: AccountingAdminService) {}
@Get()
overview() {
return this.admin.overview();
}
@Put('config')
save(@Body() body: Record<string, unknown>) {
return this.admin.save(body);
}
@Post('test')
@HttpCode(200)
test(@Body() body: { provider?: string; connection?: Record<string, unknown> }) {
return this.admin.test(body?.provider, body?.connection);
}
@Post('certificate')
@HttpCode(200)
certificate(@Body() body: { baseUrl?: string }) {
return this.admin.certificate(body?.baseUrl);
}
@Get('options')
options(@Query('provider') provider?: string) {
return this.admin.options(provider);
}
@Post('run/:job')
@HttpCode(200)
run(@Param('job') job: string) {
return this.admin.run(job);
}
@Get('outbox')
outbox(@Query() q: Record<string, unknown>) {
return this.admin.outbox(q);
}
@Post('outbox/:id/retry')
@HttpCode(200)
retry(@Param('id') id: string) {
return this.admin.retry(id);
}
@Post('outbox/:id/resolve')
@HttpCode(200)
resolve(@Param('id') id: string, @CurrentAdmin() me: AuthenticatedAdmin, @Body() body: { note?: string }) {
return this.admin.resolve(id, me.id, body?.note);
}
@Get('issues')
issues(@Query() q: Record<string, unknown>) {
return this.admin.issues(q);
}
@Post('issues/:id/resolve')
@HttpCode(200)
resolveIssue(@Param('id') id: string) {
return this.admin.resolveIssue(id);
}
@Get('links')
links(@Query() q: Record<string, unknown>) {
return this.admin.links(q);
}
@Post('links')
@HttpCode(200)
link(@Body() body: Record<string, unknown>) {
return this.admin.manualLink(body);
}
@Delete('links/:id')
unlink(@Param('id') id: string) {
return this.admin.unlink(id);
}
@Get('customers/:id')
customer(@Param('id') id: string) {
return this.admin.customer(id);
}
@Get('products/status')
productsStatus(@Query('ids') ids: string) {
return this.admin.productsStatus(ids);
}
@Get('movement')
movement(@Query() q: Record<string, unknown>) {
return this.admin.movement(q);
}
}