| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- import BaseController from '../../base';
- import { AdminRoute } from '../../../decorator/router_register';
- import { PageGetDto } from '../../../dto/comm';
- import { CreateBotDto, DeleteBotDto, UpdateBotDto } from '../../../dto/admin/tg/bot';
- export default class TgbotController extends BaseController {
- @AdminRoute('/tg/tgboot/test', 'get')
- async test() {
- this.res({
- data: await this.service.admin.tg.tgbot.tgTest(),
- });
- }
- /**
- * list
- */
- @AdminRoute('/tg/bot/list', 'get')
- async list() {
- this.res({
- data: await this.service.admin.tg.tgbot.list(),
- });
- }
- /**
- * page
- */
- @AdminRoute('/tg/bot/page', 'get')
- async page() {
- const dto = await this.ctx.validate<PageGetDto>(PageGetDto, this.getQuery());
- this.res({
- data: {
- list: await this.service.admin.tg.tgbot.page(dto.current - 1, dto.pageSize),
- pagination: {
- page: dto.current,
- size: dto.pageSize,
- total: await this.service.admin.tg.tgbot.count(),
- },
- },
- });
- }
- @AdminRoute('/tg/bot/add', 'post')
- async add() {
- const dto = await this.ctx.validate<CreateBotDto>(CreateBotDto);
- this.res({
- data: await this.service.admin.tg.tgbot.add(dto),
- });
- }
- @AdminRoute('/tg/bot/update', 'post')
- async update() {
- const dto = await this.ctx.validate<UpdateBotDto>(UpdateBotDto);
- await this.service.admin.tg.tgbot.update(dto);
- this.res({});
- }
- @AdminRoute('/tg/bot/delete', 'post')
- async delete() {
- const dto = await this.ctx.validate<DeleteBotDto>(DeleteBotDto);
- this.res({
- data: await this.service.admin.tg.tgbot.delete(dto.id),
- });
- }
- }
|